Support GMAC and multiple AAD chunks for AEAD
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
What is the problem this feature will solve?
Node.js only allows a single call to setAAD() for AEAD algorithms. AAD that consists of multiple chunks must be concatenated in memory before it can be passed to setAAD(), which is highly inefficient.
GMAC is a MAC algorithm based on AES-GCM that consumes the entire input data as AAD and leaves the plaintext/ciphertext empty. The AES-GCM authentication tag is the MAC produced by GMAC. Implementing GMAC on top of Node.js again requires concatenating all input data in memory before calling setAAD().
What is the feature you are proposing to solve the problem?
Extend the API to allow appending multiple chunks of AAD. This is common practice and supported by various cryptographic libraries, including OpenSSL.
We should consider carefully if such an extension should be a separate WritableStream or if a simpler API makes more sense.
What alternatives have you considered?
Concatenating all data in memory before passing it to setAAD().
My primary use case for multiple calls to setAAD() is GMAC, so a separate GMAC API (similar to the existing HMAC API) would also be sufficient for my purposes. However, it would leave a gap between AES-GCM and GMAC for those rare use cases that have multiple chunks of AAD and a non-empty plaintext/ciphertext.
On a side note, I preliminarily decided against adding streaming support for AAD in https://github.com/wintercg/proposal-webcrypto-streams, see this section of the explainer. However, that is mostly due to the API constraints of the Web Crypto API.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Node.js's crypto API and the existing setAAD() behavior, then compare the proposed options with the OpenSSL support mentioned in the issue. The work is done when a decided API supports multiple AAD chunks and the GMAC use case without requiring callers to concatenate all input in memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100