Embedded systems coursework 2.
Fork of Crypto_light by
Diff: cipher/RC4.cpp
- Revision:
- 8:a090264e9b2d
- Parent:
- 7:2dbbdfb08123
--- a/cipher/RC4.cpp Sat Sep 14 18:21:32 2013 +0000 +++ b/cipher/RC4.cpp Sat Sep 14 20:54:59 2013 +0000 @@ -1,7 +1,7 @@ #include "RC4.h" RC4::RC4(uint8_t *key, uint8_t keyLength): -Cipher(), +StreamCipher(), s(), i(0), j(0) @@ -18,7 +18,7 @@ } } -uint8_t RC4::encyptByte(uint8_t in) +uint8_t RC4::encryptByte(uint8_t in) { ++i; j += s[i]; @@ -26,21 +26,10 @@ s[i] = s[j]; s[j] = tmp; uint8_t c = s[(s[i]+s[j])%256]; - return in^c; -} - -void RC4::encrypt(uint8_t *out, uint8_t *in, uint32_t length) -{ - for(uint32_t l = 0; l < length; ++l) - out[l] = encyptByte(in[l]); + return in^c; } -void RC4::decrypt(uint8_t *out, uint8_t *in, uint32_t length) +uint8_t RC4::decryptByte(uint8_t in) { - encrypt(out, in, length); + return encryptByte(in); } - -uint32_t RC4::getBlockSize() const -{ - return 1; -}