AES-128 in PASM
ericball
Posts: 774
Attached is a functioning AES-128 implementation in PASM (with just enough SPIN to set the pointer to the SBox & InvSBox lookup tables).
1. I have tested it (successfully) against the FIPS-197 example using GEAR V09_10_26. (Note: this is the Data and Key in the file, output in istate.)
2. It is not a complete driver, it just encrypts & decrypts data loaded with the PASM and leaves that data in the COG. Adding data movement (along with the steps needed to support multi-block modes) is left to the implementor.
ObEx licensed, although I'll wait for some feedback before adding it to ObEx.
Performance: Key Expansion ~4.4K cycles, Cipher ~16.1K cycles/block, Inverse Cipher ~18K cycles/block.
1. I have tested it (successfully) against the FIPS-197 example using GEAR V09_10_26. (Note: this is the Data and Key in the file, output in istate.)
2. It is not a complete driver, it just encrypts & decrypts data loaded with the PASM and leaves that data in the COG. Adding data movement (along with the steps needed to support multi-block modes) is left to the implementor.
ObEx licensed, although I'll wait for some feedback before adding it to ObEx.
Performance: Key Expansion ~4.4K cycles, Cipher ~16.1K cycles/block, Inverse Cipher ~18K cycles/block.
Comments
Note: it is possible to modify the code to support AES-192 and AES-256 (or non-AES Rijndael, i.e. different block sizes) but care must be taken. In particular, KeyExpand assumes Nk is divisible by 4 (not true for AES-192).
I don't know what the Key Expansion is, but I would assume that for AES-256 it would take longer than 4.4Kcycles.
Do you have any demos available. What would be really neat is an app that took a file off the SDcard and encrypted it and wrote it back. Then we could verify the coding on another computer.
Thanks for your hard work,
Doug
Each block is 128 bits or 16 bytes. 80M * 8 / 16.1K = 77.6Kbyte/s encrypt, 69.4Kbyte/s decrypt.
* AES-128 should be secure enough for almost any possible use. The real issue is keeping the key (and the initalization vector) secret.
I mistook the blocks to be 128Bytes instead of 128bits, hence my calculation is way off.
Thanks,
Doug
I've been inspired (by this and other things) recently to look at AES and have put together a more fully featured AES object with 128/192/256 bit key support and CBC mode as well as ECB. Eric's code has been one of the inspirations (but I'm also doing java versions for other systems and getting close to an Elliptic Curve Cryptography object for the Prop).
Its just "AES" in the ObEx, and comes with test code to generate test-vectors (that for me all agree with the official NIST results).