Skip to content

feat(cryptography): accept AES-GCM associated data and empty HKDF input - #10628

Merged
matthiasgeihs merged 10 commits into
mainfrom
feat/cryptography-aad-empty-hkdf
Oct 1, 2026
Merged

matthiasgeihs merged 10 commits into
mainfrom
feat/cryptography-aad-empty-hkdf

Conversation

@matthiasgeihs

Copy link
Copy Markdown
Contributor

Explanation

@metamask/cryptography can cover the Noise primitives in the MFA wallet SDK except for two gaps:

  • AES-GCM encrypt and decrypt never passed associated data through to WebCrypto. Noise authenticates the handshake hash on every message, so ciphertext produced without that data does not interoperate.
  • HKDF rejected a zero-length input even when unsafeInputKeyingMaterial was set. Noise Split derives the two transport keys with HKDF(chaining_key, zerolen).

additionalData is now an option on both AES-GCM calls. An empty HKDF input is accepted when unsafeInputKeyingMaterial is set; without that flag the call still throws. AES-GCM associated data is covered by NIST GCM test case 4. The empty-input HKDF vector matches Node's hkdfSync.

References

  • Related to MetaMask/mfa-wallet-sdk, which uses Noise_KK with these two operations.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Made with Cursor

Noise authenticates every handshake message with associated data, and Split derives the transport keys from an empty HKDF input.

Co-authored-by: Cursor <cursoragent@cursor.com>
@matthiasgeihs
matthiasgeihs requested a review from a team as a code owner September 30, 2026 15:33
matthiasgeihs and others added 2 commits September 30, 2026 17:33
Co-authored-by: Cursor <cursoragent@cursor.com>
…-empty-hkdf

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	packages/cryptography/CHANGELOG.md
Comment thread packages/cryptography/src/aes-gcm.test.ts Outdated
Comment thread packages/cryptography/src/aes-gcm.test.ts Outdated
Comment thread packages/cryptography/src/hkdf.ts
Comment thread packages/cryptography/src/hkdf.ts Outdated
Comment thread packages/cryptography/src/aes-gcm.ts Outdated
Comment thread packages/cryptography/src/aes-gcm.test.ts
… decrypt

Co-authored-by: Cursor <cursoragent@cursor.com>
@matthiasgeihs
matthiasgeihs added this pull request to the merge queue Oct 1, 2026
Merged via the queue into main with commit f3eaa26 Oct 1, 2026
45 checks passed
@matthiasgeihs
matthiasgeihs deleted the feat/cryptography-aad-empty-hkdf branch October 1, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants