npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-aes-cmac

v0.1.1

Published

A pure Node.js implementation of the AES-CMAC algorithm (NIST 800-38B / RFC 4493).

Downloads

5,029

Readme

node-aes-cmac

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.

Why?

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.

Installation

npm install node-aes-cmac

Usage

The module exposes a single method: aesCmac(key, message[, options])

Arguments

  • 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.

Return Value

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.

Example

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>

License

This code is provided under an MIT license. See the LICENSE file for full details.