Fork of François Berder Crypto, fixed AES CBC and small rework
Dependents: AES_example shaun_larada Smartage
Fork of Crypto by
cipher/StreamCipher.cpp@8:a090264e9b2d, 2013-09-14 (annotated)
- Committer:
- feb11
- Date:
- Sat Sep 14 20:54:59 2013 +0000
- Revision:
- 8:a090264e9b2d
refactored public API for ciphers & added TDES
Who changed what in which revision?
User | Revision | Line number | New 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 | } |