TAY
Fork of Crypto_light by
cipher/TDES.cpp@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 | #include "TDES.h" |
feb11 | 8:a090264e9b2d | 2 | |
feb11 | 8:a090264e9b2d | 3 | TDES::TDES(uint8_t *key1, uint8_t *key2, uint8_t *key3): |
feb11 | 8:a090264e9b2d | 4 | BlockCipher(8,ECB_MODE), |
feb11 | 8:a090264e9b2d | 5 | a(key1), |
feb11 | 8:a090264e9b2d | 6 | b(key2), |
feb11 | 8:a090264e9b2d | 7 | c(key3) |
feb11 | 8:a090264e9b2d | 8 | { |
feb11 | 8:a090264e9b2d | 9 | |
feb11 | 8:a090264e9b2d | 10 | } |
feb11 | 8:a090264e9b2d | 11 | |
feb11 | 8:a090264e9b2d | 12 | TDES::TDES(uint8_t *key1, uint8_t *key2, uint8_t *key3, uint8_t *iv): |
feb11 | 8:a090264e9b2d | 13 | BlockCipher(8,CBC_MODE,iv), |
feb11 | 8:a090264e9b2d | 14 | a(key1), |
feb11 | 8:a090264e9b2d | 15 | b(key2), |
feb11 | 8:a090264e9b2d | 16 | c(key3) |
feb11 | 8:a090264e9b2d | 17 | { |
feb11 | 8:a090264e9b2d | 18 | |
feb11 | 8:a090264e9b2d | 19 | } |
feb11 | 8:a090264e9b2d | 20 | |
feb11 | 8:a090264e9b2d | 21 | void TDES::encryptBlock(uint8_t *out, uint8_t *in) |
feb11 | 8:a090264e9b2d | 22 | { |
feb11 | 8:a090264e9b2d | 23 | uint8_t tmp[8], tmp2[8]; |
feb11 | 8:a090264e9b2d | 24 | a.encryptBlock(tmp,in); |
feb11 | 8:a090264e9b2d | 25 | b.decryptBlock(tmp2,tmp); |
feb11 | 8:a090264e9b2d | 26 | c.encryptBlock(out, tmp2); |
feb11 | 8:a090264e9b2d | 27 | } |
feb11 | 8:a090264e9b2d | 28 | |
feb11 | 8:a090264e9b2d | 29 | void TDES::decryptBlock(uint8_t *out, uint8_t *in) |
feb11 | 8:a090264e9b2d | 30 | { |
feb11 | 8:a090264e9b2d | 31 | uint8_t tmp[8], tmp2[8]; |
feb11 | 8:a090264e9b2d | 32 | c.decryptBlock(tmp, in); |
feb11 | 8:a090264e9b2d | 33 | b.encryptBlock(tmp2, tmp); |
feb11 | 8:a090264e9b2d | 34 | a.decryptBlock(out, tmp2); |
feb11 | 8:a090264e9b2d | 35 | } |