aboutsummaryrefslogtreecommitdiff
path: root/aes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'aes.cpp')
-rw-r--r--aes.cpp33
1 files changed, 0 insertions, 33 deletions
diff --git a/aes.cpp b/aes.cpp
index 7048b17..29fc7fc 100644
--- a/aes.cpp
+++ b/aes.cpp
@@ -145,13 +145,11 @@ namespace AES{
addRoundKey(state,keysched);
for(int round=0;round<numrounds-1;round++){
- //cout<<"round["<<setw(2)<<setfill(' ')<<round+1<<"].start "; printstate(state);
subBytes(state);
shiftRows(state);
mixColumns(state);
addRoundKey(state,keysched+16*(round+1));
}
- //cout<<"round["<<setw(2)<<setfill(' ')<<numrounds<<"].start "; printstate(state);
subBytes(state);
shiftRows(state);
addRoundKey(state,keysched+16*numrounds);
@@ -162,13 +160,11 @@ namespace AES{
addRoundKey(state,keysched+16*numrounds);
for(int round=numrounds-2;round>=0;round--){
- //cout<<"round["<<setw(2)<<setfill(' ')<<round+1<<"].start "; printstate(state);
invShiftRows(state);
invSubBytes(state);
addRoundKey(state,keysched+16*(round+1));
invMixColumns(state);
}
- //cout<<"round["<<setw(2)<<setfill(' ')<<numrounds<<"].start "; printstate(state);
invShiftRows(state);
invSubBytes(state);
addRoundKey(state,keysched);
@@ -256,33 +252,4 @@ namespace AES{
return decryptCBC(data,key,10+2*increment);
}
- void test(){
- #if 0
- // Test encryption
- initTables();
- const int numrounds=10;
- uint8_t keysched[16*(numrounds+1)];
- uint8_t plaintext[16]={0x32,0x43,0xf6,0xa8,0x88,0x5a,0x30,0x8d,0x31,0x31,0x98,0xa2,0xe0,0x37,0x07,0x34};
- const int keylen=4;
- uint8_t key[4*keylen]={0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0x4f,0x3c};
- keyExpand(keysched,key,keylen,numrounds);
- uint8_t dest[16];
- encryptBlock(dest,keysched,plaintext,numrounds);
- printstate(dest);
- #endif
- #if 1
- // Test decryption
- initTables();
- const int numrounds=14;
- uint8_t keysched[16*(numrounds+1)];
- uint8_t plaintext[16]={0x8e,0xa2,0xb7,0xca,0x51,0x67,0x45,0xbf,0xea,0xfc,0x49,0x90,0x4b,0x49,0x60,0x89};
- const int keylen=8;
- uint8_t key[4*keylen]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f};
- keyExpand(keysched,key,keylen,numrounds);
- uint8_t dest[16];
- decryptBlock(dest,keysched,plaintext,numrounds);
- printstate(dest);
- #endif
- }
-
}