TAY

Fork of Crypto_light by Edward Stott

Revision:
8:a090264e9b2d
Parent:
7:2dbbdfb08123
diff -r 2dbbdfb08123 -r a090264e9b2d cipher/AES.cpp
--- a/cipher/AES.cpp	Sat Sep 14 18:21:32 2013 +0000
+++ b/cipher/AES.cpp	Sat Sep 14 20:54:59 2013 +0000
@@ -52,6 +52,32 @@
 };
 
 AES::AES(const AES_TYPE t, uint8_t *key):
+BlockCipher(16,ECB_MODE),
+state()
+{
+    switch(t)
+    {
+        case AES_128:
+            nr = 10;
+            nk = 4;
+        break;
+        
+        case AES_192:
+            nr = 12;
+            nk = 6;
+        break;
+        
+        case AES_256:
+            nr = 14;
+            nk = 8;
+        break;
+    }
+    
+    keyExpansion(key);
+}
+
+AES::AES(const AES_TYPE t, uint8_t *key, uint8_t *iv):
+BlockCipher(16,CBC_MODE, iv),
 state()
 {
     switch(t)
@@ -275,20 +301,3 @@
     
     memcpy(out, state, 16);
 }
-
-void AES::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-    for(uint32_t i = 0; i < length; i+=16)
-        encryptBlock(&out[i], &in[i]);
-}
-
-void AES::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
-{
-    for(uint32_t i = 0; i < length; i+=16)
-        decryptBlock(&out[i], &in[i]);
-}
-
-uint32_t AES::getBlockSize() const
-{
-    return 16;
-}