diff --git a/aes_cbc.c b/aes_cbc.c index 59df8aa..21c8430 100644 --- a/aes_cbc.c +++ b/aes_cbc.c @@ -1,6 +1,6 @@ /* -This is an implementation of the AES128 algorithm, specifically ECB mode. +This is an implementation of the AES128 algorithm, specifically ECB and CBC mode. The implementation is verified against the test vectors in: National Institute of Standards and Technology Special Publication 800-38A 2001 ED @@ -46,7 +46,7 @@ NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) // The number of 32 bit words in a key. #define Nk 4 // Key length in bytes [128 bit] -#define keyln 16 +#define KEYLEN 16 // The number of rounds in AES Cipher. #define Nr 10 @@ -57,13 +57,6 @@ NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0) #define MULTIPLY_AS_A_FUNCTION 0 #endif -#ifndef CBC - #define CBC 1 -#endif - -#ifndef ECB - #define ECB 0 -#endif /*****************************************************************************/ /* Private variables: */ @@ -439,10 +432,10 @@ static void InvCipher(void) AddRoundKey(0); } -static void BufferCopy(uint8_t* output, uint8_t* input) +static void BlockCopy(uint8_t* output, uint8_t* input) { uint8_t i; - for (i=0;i<16;++i) + for (i=0;i