This library implements some hash and cryptographic algorithms.

Dependents:   ES_CW2_Starter_JIN EMBEDDED_CW2 EMBEDDED_CW2_Final Spinnybois ... more

Fork of Crypto by Francois Berder

Committer:
estott
Date:
Fri Mar 09 10:10:16 2018 +0000
Revision:
15:634f9c4cbab1
Parent:
8:a090264e9b2d
Reduced flash footprint by removing __forceinline directive in SHA2_32.c

Who changed what in which revision?

UserRevisionLine numberNew 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