Embedded systems coursework 2.

Fork of Crypto_light by Edward Stott

Revision:
0:7a1237bd2d13
diff -r 000000000000 -r 7a1237bd2d13 AES.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AES.h	Sat Sep 07 23:47:28 2013 +0000
@@ -0,0 +1,47 @@
+#ifndef AES_H
+#define AES_H
+
+#include "Cipher.h"
+
+enum AES_TYPE
+{
+    AES_128 = 4,
+    AES_192 = 6,
+    AES_256 = 8
+};
+
+class AES : public Cipher
+{
+    public :
+    
+        AES(const AES_TYPE type, uint8_t *key);
+        
+        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);
+        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);
+        virtual uint32_t getBlockSize() const;
+        
+    private :
+    
+        void encryptBlock(uint8_t *out, uint8_t *in);
+        void decryptBlock(uint8_t *out, uint8_t *in);
+        
+        void keyExpansion(uint8_t *key);
+        uint32_t rotWord(uint32_t w);
+        uint32_t invRotWord(uint32_t w);        
+        uint32_t subWord(uint32_t w);
+        void subBytes();
+        void invSubBytes();
+        void shiftRows();
+        void invShiftRows();
+        void mul(uint8_t *r);
+        void invMul(uint8_t *r);
+        void mixColumns();
+        void invMixColumns();
+        void addRoundKey(int round);
+
+        uint8_t state[16];
+        uint32_t w[60];
+        uint8_t nr,nk;
+};
+
+#endif