2013년 11월 30일 토요일

About AES

AES (Advanced Encryption Standard) is a subset of the Rijndael encryption algorithm (limited to a block size of 128 bit). AES was announced by National Institute of Standards and Technology (NIST) as U.S. standard FIPS PUB 197 (FIPS 197) on November 26, 2001 after a 5-year standardization process in which fifteen competing designs were presented and evaluated before Rijndael was selected as the most suitable (see Advanced Encryption Standard process for more details). It became effective as a standard May 26, 2002. As of 2009, AES is one of the most popular algorithms used in symmetric key cryptography.
For our implementation we use the optimizations for 8-Bit CPUs presented in http://gladman.plushost.co.uk/oldsite/cryptography_technology/rijndael/aes.spec.v316.pdf.
You may be also interested in the Wikipedia article on AES.

Implementation files

AES in C

The C implementation consists of multiple files:
As you can see, the AES implementation is split up in many small pieces, which allows you to reduce the required flash size.

AES in ASM

Interface

Items

The interface to our AES implementation consits of the following items:

Example

#include 
#include "aes.h"

...
/* a sample key, key must be located in RAM */
uint8_t key[]  = { 0x01, 0x23, 0x45, 0x67,
                   0x89, 0xAB, 0xCD, OxEF,
                   0x01, 0x23, 0x45, 0x67,
                   0x89, 0xAB, 0xCD, OxEF };
/* sample data, you can encrypt what you want but keep in mind that only 128 bits (not less not more) get encrypted*/
uint8_t data[] = { 0x01, 0x02, 0x03, 0x04,
                   0x05, 0x06, 0x07, 0x08,
                   0x09, 0x0A, 0x0B, 0x0C,
                   0x0D, 0x0E, 0x0F, 0x00 };
aes128_ctx_t ctx; /* the context where the round keys are stored */
aes128_init(key, &ctx); /* generating the round keys from the 128 bit key */
aes128_enc(data, &ctx); /* encrypting the data block */

...

aes128_dec(data, &ctx); /* decrypting the data block */

...

Component weight (flash size)

C implementation

size (bytes)componentreq. for encryptionreq. for decryptionreq. for 128 bitreq. for 192 bitreq. for 256 bit
652aes_enc.oxoxxx
834aes_dec.ooxxxx
256aes_sbox.oxoxxx
256aes_invsbox.ooxxxx
486aes_keyschedule.oxxxxx
26gf256mul.oxxxxx
8aes128_enc.oxoxxx
8aes128_dec.ooxxxx
8aes192_enc.oxooxo
8aes192_dec.ooxoxo
8aes256_enc.oxooox
8aes256_dec.ooxoox

ASM implementation

size (bytes)componentreq. for encryptionreq. for decryption
550aes_enc-asm.oxo
770aes_dec-asm.oox (alt. aes_dec-asm_faster.o)
1280aes_dec-asm_faster.oox (alt. aes_dec-asm.o )
256aes_sbox-asm.oxo
256aes_invsbox-asm.oox
238aes_keyschedule-asm.oxx

Component speed

C implementation

functionclock cycles
init (128 bit)4632
init (192 bit)5082
init (256 bit)6161
enc (128 bit)21279
enc (192 bit)25724
enc (256 bit)30174
dec (128 bit)39340
dec (192 bit)47799
dec (256 bit)56253

ASM implementation

functionclock cycles
init (128 bit)2039
init (192 bit)2267
init (256 bit)2852
enc (128 bit)2555
enc (192 bit)3039
enc (256 bit)3521
dec (128 bit)6764
dec (192 bit)8164
dec (256 bit)9562

fast decryption

functionclock cycles
dec (128 bit)3193
dec (192 bit)3819
dec (256 bit)4443

댓글 없음:

댓글 쓰기