Skip to content

jfamousket/aes-cmac-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 ⚡️

Releases

No releases published

Packages

No packages published