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/BlockCipher.h

Committer:
Geremia
Date:
2015-01-28
Revision:
16:4399e2e6260b
Parent:
15:6093fc19aad6

File content as of revision 16:4399e2e6260b:

#ifndef BLOCK_CIPHER_H
#define BLOCK_CIPHER_H

#include "Cipher.h"

enum BLOCK_CIPHER_MODE
{
    ECB_MODE,
    CBC_MODE,
    PCBC_MODE
};

class BlockCipher : public Cipher
{
    public :
    
        BlockCipher(uint32_t bs, BLOCK_CIPHER_MODE m, uint8_t *iv = 0);
        virtual ~BlockCipher();
        
        virtual CIPHER_TYPE getType() const;        
        uint32_t getBlockSize() const;
        void setIV(uint8_t *iv);

        virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length);        
        virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length);        

    protected :
    
        virtual void encryptBlock(uint8_t *out, uint8_t *in) = 0;
        virtual void decryptBlock(uint8_t *out, uint8_t *in) = 0;

    private :
    
        uint32_t blockSize;
        BLOCK_CIPHER_MODE mode;
        uint8_t *IV;
        uint8_t *tmpIV;
        uint8_t *tmpdatain;
        uint8_t *tmpdata;
};

#endif