Closed Bug 1994770 Opened 10 months ago Closed 8 months ago

crypto.subtle.deriveKey ignores key length if DH alg is X25519 and derived key alg is AES-*

Categories

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

Firefox 144
defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: sageptr, Assigned: anna.weine)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Steps to reproduce:

  1. Generate or import two X25519 keys (private and public)
  2. Use crypto.subtle.deriveKey with parameters: ({ name: "X25519", public: publicKey }, privateKey, { name: "AES-GCM", length: 128 }, true, ["encrypt", "decrypt"])

Actual results:

Derived key will have length 256 bits, despite 128 were passed as argument. The length value of third argument is totally ignored.

Expected results:

The function should respect length and return 128 bit key.

Note: if using ECDH keys, the length works correctly. Also, deriveBits isn't affected to, it works with X25519 keys normally. The bug only happens when DH algorithm is X25519 and the function deriveKey is used, not deriveBits.

Here is CodePen showcase of the given bug: https://codepen.io/SagePtr/pen/xbZPLXp?editors=0011

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Web Crypto' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Web Crypto
Product: Firefox → Core
Assignee: nobody → anna.weine

The severity field is not set for this bug.
:keeler, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(dkeeler)

(In reply to BugBot [:suhaib / :marco/ :calixte] from comment #3)

The severity field is not set for this bug.
:keeler, could you have a look please?

For more information, please visit BugBot documentation.

Anna, what do you think?

Flags: needinfo?(dkeeler) → needinfo?(anna.weine)
Severity: -- → S4
Flags: needinfo?(anna.weine)
Priority: -- → P3

The bug is almost resolved as we have a working patch. The patch still would benefit from a bit of improvement, so I will take care of it as soon as I am back

Status: UNCONFIRMED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
QA Whiteboard: [qa-triage-done-c149/b148]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: