Closed Bug 1919532 Opened 1 year ago Closed 1 year ago

EC algorithms import operation throws DataError exception on invalid usages

Categories

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

Firefox 130
defect

Tracking

()

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: u738353, Assigned: anna.weine)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0

Steps to reproduce:

1- Load the following script in the console

var jwkKey = {
kty: "EC",
crv: "P-521",
x: "AVb0efjfHiCn_8BM5CDD4VSuJRmWvuQvA0uE1Bt0PzTkXzEbgTqc3sjNpZu7vTHUYLMpJSHnwbci5WZ8A9svrnU_",
y: "AVAXNs_iRzlDINjkr8L9ObWpMxBhuB4iQSgrnheJGCK1t54FL0WXtZZD_Tk3nFG9USXE9IvD8CXOPNNpUyhsyzj7",
d: "APQIdYNoupMPMPdq4FT-XNLOf9osn3am1DbPddZsRAv-YzHHwXKhJHgZPIJRSHvJEmP6UCF_hf9jb1nNVG46tIO0"
};

// Create a new ECDH key with valid usages
window.crypto.subtle.importKey("jwk", jwkKey, { "name": "ECDH", "namedCurve": "P-521"}, true, ["sign"])
    .then((importedKey) => {
        console.log("Key import succeed !!!");
    }, (err) => {
        console.log("FAIL: The 'import' operation threw an unexpected error: " + err.toString());
    });

Actual results:

The following message appears in the console:

"FAIL: The 'import' operation threw an unexpected error: DataError: Data provided to an operation does not meet requirements"

Expected results:

It should throw a SyntaxError exception instead.

According to the last spec draft [1], which matches the last published [2] version, the JWK import should perform the following step:

  1. If the "d" field is present and if usages contains an entry which is not "deriveKey" or "deriveBits" then throw a SyntaxError.

[1] https://w3c.github.io/webcrypto/#ecdh-operations
[2] https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations

Added a script for an easier bug triage.

Attached a test case for a better triage.

(please move if there is a better component for this bug)

Component: Untriaged → DOM: Web Crypto
Product: Firefox → Core
Severity: -- → S4
Priority: -- → P5
Assignee: nobody → anna.weine
Attachment #9425620 - Attachment description: WIP: Bug 1919532 - RSA/EC algorithms import operation throws DataError exception on invalid usages → Bug 1919532 - RSA/EC algorithms import operation throws DataError instead on SyntaxError exception on invalid usages
Attachment #9425620 - Attachment description: Bug 1919532 - RSA/EC algorithms import operation throws DataError instead on SyntaxError exception on invalid usages → WIP: Bug 1919532 - WebCrypto operations to throw SyntaxError exception on invalid usages
Attachment #9425620 - Attachment description: WIP: Bug 1919532 - WebCrypto operations to throw SyntaxError exception on invalid usages → Bug 1919532 - WebCrypto operations to throw SyntaxError exception on invalid usages
Attachment #9425620 - Attachment description: Bug 1919532 - WebCrypto operations to throw SyntaxError exception on invalid usages → Bug 1919532 - WebCrypto operations to throw SyntaxError exception on invalid usages/Update publicKey usage for ECDH to empty set
Pushed by nkulatova@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d8f0ba47e216 WebCrypto operations to throw SyntaxError exception on invalid usages/Update publicKey usage for ECDH to empty set r=jfernandez,keeler
Pushed by nkulatova@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e27b2cb9f605 WebCrypto operations to throw SyntaxError exception on invalid usages/Update publicKey usage for ECDH to empty set r=jfernandez,keeler
Pushed by nkulatova@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6632f5bcf069 WebCrypto operations to throw SyntaxError exception on invalid usages/Update publicKey usage for ECDH to empty set r=jfernandez,keeler
Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch
QA Whiteboard: [qa-133b-p2]
Duplicate of this bug: 1919539
Flags: needinfo?(anna.weine)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: