Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

aes-cmac-js

jfamousket1.1kMIT1.0.2TypeScript support: included

AES CMAC implementation in pure js

aes, cmac, encrypt, decrypt, block, cipher

readme

AES-CMAC-JS

AES-CMAC implementation in pure javascript using sjcl. See RFC Spec.

For validation, this library contains passing test vectors taken from the RFC spec, see tests/test.ts.

Example

// pass your key here
const cmac = new AesCmac("0x2b7e151628aed2a6abf7158809cf4f3c");

// encrypt 0x000... using your key
const encrypted = cmac.encrypt(
  sjcl.codec.hex.toBits("0x00000000000000000000000000000000")
);
// expected output
const expected = sjcl.codec.hex.toBits("0x7df76b0c1ab899b33e42f047b91b546f");

// should be true
console.log(sjcl.bitArray.equal(t_0, aes_0));

Testing

You can easily fork and try out a live version of the code StackBlitz ⚡️