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

Dependents:   AES_example shaun_larada Smartage

Fork of Crypto by Francois Berder

Committer:
Geremia
Date:
Wed Jan 28 17:55:13 2015 +0000
Revision:
16:4399e2e6260b
Parent:
8:a090264e9b2d
AES: bugfixed CBC, added PCBC (i could add CFB and OFB if needed), added public setIV(), moved keyExpansion() to public, in and out buffers can be the same

Who changed what in which revision?

UserRevisionLine numberNew contents of line
feb11 8:a090264e9b2d 1 #include "StreamCipher.h"
feb11 8:a090264e9b2d 2
feb11 8:a090264e9b2d 3
feb11 8:a090264e9b2d 4 StreamCipher::StreamCipher()
feb11 8:a090264e9b2d 5 {
feb11 8:a090264e9b2d 6 }
feb11 8:a090264e9b2d 7
feb11 8:a090264e9b2d 8 CIPHER_TYPE StreamCipher::getType() const
feb11 8:a090264e9b2d 9 {
feb11 8:a090264e9b2d 10 return STREAM_CIPHER;
feb11 8:a090264e9b2d 11 }
feb11 8:a090264e9b2d 12
feb11 8:a090264e9b2d 13 void StreamCipher::encrypt(uint8_t *out, uint8_t *in, uint32_t length)
feb11 8:a090264e9b2d 14 {
feb11 8:a090264e9b2d 15 for(uint32_t i = 0; i < length; ++i)
feb11 8:a090264e9b2d 16 out[i] = encryptByte(in[i]);
feb11 8:a090264e9b2d 17 }
feb11 8:a090264e9b2d 18
feb11 8:a090264e9b2d 19 void StreamCipher::decrypt(uint8_t *out, uint8_t *in, uint32_t length)
feb11 8:a090264e9b2d 20 {
feb11 8:a090264e9b2d 21 for(uint32_t i = 0; i < length; ++i)
feb11 8:a090264e9b2d 22 out[i] = decryptByte(in[i]);
feb11 8:a090264e9b2d 23 }