This library implements some hash and cryptographic algorithms.
Dependents: ES_CW2_Starter_JIN EMBEDDED_CW2 EMBEDDED_CW2_Final Spinnybois ... more
Fork of Crypto by
Diff: cipher/AES.h
- Revision:
- 7:2dbbdfb08123
- Parent:
- 0:7a1237bd2d13
- Child:
- 8:a090264e9b2d
diff -r 19aa835f2bbb -r 2dbbdfb08123 cipher/AES.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cipher/AES.h Sat Sep 14 18:21:32 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