
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-aes-cmac
Advanced tools
A pure Node.js implementation of the AES-CMAC algorithm (NIST 800-38B / RFC 4493).
A pure Node.js implementation of the AES-CMAC algorithm per NIST Special Publication 800-38B and (RFC 4493). This algorithm creates a cryptographic message authentication code (CMAC) from a given message using the AES cipher with 128, 192, and 256 bit keys.
At work we had a need to run AES-CMAC from Node.js. A coworker created an implementation which uses a C++ addon which wrapped Crypto++, but unfortunately the module was only known to build correctly on Ubuntu. OS X support was added through some further hacking, but Windows support was extremely difficult.
Searching the web yielded no alternatives, so I started this project with a goal to create an AES-CMAC implementation to share with the Node.js community which would be easy to use on OS X, Windows, and Linux.
Currently the project only uses the built-in cryptographic functions provided by Node.js and avoids using C/C++ addons. This was a conscious trade-off favoring simplicity over raw performance.
npm install node-aes-cmac
The module exposes a single method: aesCmac(key, message[, options])
key - (string | Buffer) the cryptographic key to use for the operation.
Must be 128, 192, or 256 bits in length.message - (string | Buffer) the message.options - (object optional) a set of extra options to pass into the method:
returnAsBuffer - (boolean) set to true to get the returned CMAC as a Buffer
instead of a string. Defaults to false.The method normally returns the CMAC as a lowercase hexadecimal string.
It can also return a Buffer if the returnAsBuffer option is set to true.
var aesCmac = require('node-aes-cmac').aesCmac;
// Simple example.
var key = 'k3Men*p/2.3j4abB';
var message = 'this|is|a|test|message';
var cmac = aesCmac(key, message);
// cmac will be: '0125c538f8be7c4eea370f992a4ffdcb'
// Example with buffers.
var bufferKey = new Buffer('6b334d656e2a702f322e336a34616242', 'hex');
var bufferMessage = new Buffer('this|is|a|test|message');
var options = {returnAsBuffer: true};
cmac = aesCmac(bufferKey, bufferMessage, options);
// cmac will be a Buffer containing:
// <01 25 c5 38 f8 be 7c 4e ea 37 0f 99 2a 4f fd cb>
This code is provided under an MIT license. See the LICENSE file for full details.
FAQs
A pure Node.js implementation of the AES-CMAC algorithm (NIST 800-38B / RFC 4493).
The npm package node-aes-cmac receives a total of 2,041 weekly downloads. As such, node-aes-cmac popularity was classified as popular.
We found that node-aes-cmac demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.