Closed Bug 1924059 Opened 2 years ago Closed 1 year ago

crypto.subtle.importKey("raw") for ECDH with non-zero usages must throw but not

Categories

(Core :: DOM: Web Crypto, defect, P5)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: saschanaz, Unassigned)

References

Details

(Keywords: parity-chrome)

const key = new Uint8Array([4, 35, 209, 246, 236, 32, 242, 225, 146, 218, 48, 63, 72, 104, 228, 161, 193, 65, 195, 81, 149, 134, 133, 68, 69, 16, 211, 88, 204, 8, 160, 53, 142, 102, 139, 23, 16, 123, 236, 44, 109, 179, 50, 18, 54, 152, 103, 77, 203, 76, 207, 122, 233, 197, 216, 199, 191, 6, 247, 26, 251, 127, 247, 229, 180]);
await crypto.subtle.importKey('raw', key, {name:"ECDH", namedCurve:"P-256"}, true, ['deriveBits']);

This should throw SyntaxError per the spec:

If format is "raw":

  1. If the namedCurve member of normalizedAlgorithm is not a named curve, then throw a DataError.
  2. If usages is not the empty list, then throw a SyntaxError.

Gecko does not and the resulting CryptoKey also has non-zero usages attribute.

Thanks, the attached patch does solve this problem, even though the bug itself is talking about a separate problem. I'll close this when the patch lands.

See Also: → 1919532

I would put a better name, thanks!

Severity: -- → S4
Priority: -- → P5

Hi,
https://bugzilla.mozilla.org/show_bug.cgi?id=1919532 was closed. Could I close this bug as well?

Flags: needinfo?(krosylight)

Yes 👍

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(krosylight)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.