TAY
Fork of Crypto_light by
cipher/BlockCipher.h@16:d387221543a5, 2018-03-23 (annotated)
- Committer:
- ahaliassos
- Date:
- Fri Mar 23 22:05:23 2018 +0000
- Revision:
- 16:d387221543a5
- Parent:
- 8:a090264e9b2d
commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
feb11 | 8:a090264e9b2d | 1 | #ifndef BLOCK_CIPHER_H |
feb11 | 8:a090264e9b2d | 2 | #define BLOCK_CIPHER_H |
feb11 | 8:a090264e9b2d | 3 | |
feb11 | 8:a090264e9b2d | 4 | #include "Cipher.h" |
feb11 | 8:a090264e9b2d | 5 | |
feb11 | 8:a090264e9b2d | 6 | enum BLOCK_CIPHER_MODE |
feb11 | 8:a090264e9b2d | 7 | { |
feb11 | 8:a090264e9b2d | 8 | ECB_MODE, |
feb11 | 8:a090264e9b2d | 9 | CBC_MODE |
feb11 | 8:a090264e9b2d | 10 | }; |
feb11 | 8:a090264e9b2d | 11 | |
feb11 | 8:a090264e9b2d | 12 | class BlockCipher : public Cipher |
feb11 | 8:a090264e9b2d | 13 | { |
feb11 | 8:a090264e9b2d | 14 | public : |
feb11 | 8:a090264e9b2d | 15 | |
feb11 | 8:a090264e9b2d | 16 | BlockCipher(uint32_t bs, BLOCK_CIPHER_MODE m, uint8_t *iv = 0); |
feb11 | 8:a090264e9b2d | 17 | virtual ~BlockCipher(); |
feb11 | 8:a090264e9b2d | 18 | |
feb11 | 8:a090264e9b2d | 19 | virtual CIPHER_TYPE getType() const; |
feb11 | 8:a090264e9b2d | 20 | uint32_t getBlockSize() const; |
feb11 | 8:a090264e9b2d | 21 | |
feb11 | 8:a090264e9b2d | 22 | virtual void encrypt(uint8_t *out, uint8_t *in, uint32_t length); |
feb11 | 8:a090264e9b2d | 23 | virtual void decrypt(uint8_t *out, uint8_t *in, uint32_t length); |
feb11 | 8:a090264e9b2d | 24 | |
feb11 | 8:a090264e9b2d | 25 | protected : |
feb11 | 8:a090264e9b2d | 26 | |
feb11 | 8:a090264e9b2d | 27 | virtual void encryptBlock(uint8_t *out, uint8_t *in) = 0; |
feb11 | 8:a090264e9b2d | 28 | virtual void decryptBlock(uint8_t *out, uint8_t *in) = 0; |
feb11 | 8:a090264e9b2d | 29 | |
feb11 | 8:a090264e9b2d | 30 | private : |
feb11 | 8:a090264e9b2d | 31 | |
feb11 | 8:a090264e9b2d | 32 | uint32_t blockSize; |
feb11 | 8:a090264e9b2d | 33 | BLOCK_CIPHER_MODE mode; |
feb11 | 8:a090264e9b2d | 34 | uint8_t *IV; |
feb11 | 8:a090264e9b2d | 35 | }; |
feb11 | 8:a090264e9b2d | 36 | |
feb11 | 8:a090264e9b2d | 37 | #endif |