From d9c9ad2ffcb64bbb0e886bcde9151e075d81707a Mon Sep 17 00:00:00 2001 From: kokke Date: Mon, 15 Dec 2014 21:18:10 +0100 Subject: Update aes_cbc.c --- aes_cbc.c | 85 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) 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