Fork of François Berder Crypto, fixed AES CBC and small rework

Dependents:   AES_example shaun_larada Smartage

Fork of Crypto by Francois Berder

cipher/AES.h

Committer:
feb11
Date:
2013-09-14
Revision:
7:2dbbdfb08123
Parent:
AES.h@ 0:7a1237bd2d13
Child:
8:a090264e9b2d

File content as of revision 7:2dbbdfb08123:

#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