Run this on a PICO. See previous post to explain a CMAC.
The CMAC is working as a module. AEScmac.js
testAEScmac.js uses the module to run the NIST test values.
There are two tests.
Test one expects one long array as input.
Test two allows 16 byte blocks in different locations to be pointed to as input.
In test two if there is a partial block at the end, remember to pad the block. (see the test code for the 320 bit example. Test one inserts the padding.
The output of testAEScmac.js
AEScmac from one large array
keys
2b,7e,15,16,28,ae,d2,a6,ab,f7,15,88,9,cf,4f,3c,
fb,ee,d6,18,35,71,33,66,7c,85,e0,8f,72,36,a8,de,
f7,dd,ac,30,6a,e2,66,cc,f9,b,c1,1e,e4,6d,51,3b,
Example 1 null message
bb,1d,69,29,e9,59,37,28,7f,a3,7d,12,9b,75,67,46,
Valid
Example 2 , 128 bit message
7,a,16,b4,6b,4d,41,44,f7,9b,dd,9d,d0,4a,28,7c,
Valid
example 3, 320 bit message
df,a6,67,47,de,9a,e6,30,30,ca,32,61,14,97,c8,27,
Valid
example 4, 512 bit message
51,f0,be,bf,7e,3b,9d,92,fc,49,74,17,79,36,3c,fe,
Valid
AEScmac from Uint8Arrays
keys
2b,7e,15,16,28,ae,d2,a6,ab,f7,15,88,9,cf,4f,3c,
fb,ee,d6,18,35,71,33,66,7c,85,e0,8f,72,36,a8,de,
f7,dd,ac,30,6a,e2,66,cc,f9,b,c1,1e,e4,6d,51,3b,
Example 1 null message
bb,1d,69,29,e9,59,37,28,7f,a3,7d,12,9b,75,67,46,
Valid
Example 2 , 128 bit message
7,a,16,b4,6b,4d,41,44,f7,9b,dd,9d,d0,4a,28,7c,
Valid
example 3, 320 bit message
df,a6,67,47,de,9a,e6,30,30,ca,32,61,14,97,c8,27,
Valid
example 4, 512 bit message
51,f0,be,bf,7e,3b,9d,92,fc,49,74,17,79,36,3c,fe,
Valid
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Run this on a PICO. See previous post to explain a CMAC.
The CMAC is working as a module. AEScmac.js
testAEScmac.js uses the module to run the NIST test values.
There are two tests.
Test one expects one long array as input.
Test two allows 16 byte blocks in different locations to be pointed to as input.
In test two if there is a partial block at the end, remember to pad the block. (see the test code for the 320 bit example. Test one inserts the padding.
The output of testAEScmac.js
2 Attachments