Skip to content

crypto: add a generic MAC API - #65553

Draft
panva wants to merge 1 commit into
nodejs:mainfrom
panva:crypto-provider-macs
Draft

crypto: add a generic MAC API#65553
panva wants to merge 1 commit into
nodejs:mainfrom
panva:crypto-provider-macs

Conversation

@panva

@panva panva commented Aug 25, 2026

Copy link
Copy Markdown
Member

Add getMacs() and createMac() to node:crypto as a layer on top of OpenSSL EVP_MAC. Support incremental and streaming operations with provider parameter validation and configurable output sizes.

> require('crypto').getMacs()
[
  'blake2bmac', 'blake2smac',
  'cmac',       'gmac',
  'hmac',       'kmac-128',
  'kmac-256',   'kmac128',
  'kmac256',    'poly1305',
  'siphash'
]

TODO

  • docs
  • benchmark, especially createMac() vs. createHmac() (new vs. old)

Refs: #32433
Refs: #48314
Refs: #32448
Refs: #32477

Add getMacs() and createMac() to node:crypto as a layer on top of
OpenSSL EVP_MAC. Support incremental and streaming operations with
provider parameter validation and configurable output sizes.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/gyp
  • @nodejs/performance
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 25, 2026
Comment thread src/crypto/crypto_mac.cc
CHECK_NOT_NULL(cache);
if (!algorithm_cache.IsEmpty()) {
Isolate* isolate = env->isolate();
Local<Context> context = isolate->GetCurrentContext();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Local<Context> context = isolate->GetCurrentContext();
Local<Context> context = env->context();

@jasnell jasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants