Mercurial > dropbear
comparison cbc_decrypt.c @ 15:6362d3854bb4 libtomcrypt-orig
0.96 release of LibTomCrypt
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 15 Jun 2004 14:07:21 +0000 |
parents | 7faae8f46238 |
children |
comparison
equal
deleted
inserted
replaced
3:7faae8f46238 | 15:6362d3854bb4 |
---|---|
23 | 23 |
24 /* decrypt the block from ct into tmp */ | 24 /* decrypt the block from ct into tmp */ |
25 if ((err = cipher_is_valid(cbc->cipher)) != CRYPT_OK) { | 25 if ((err = cipher_is_valid(cbc->cipher)) != CRYPT_OK) { |
26 return err; | 26 return err; |
27 } | 27 } |
28 cipher_descriptor[cbc->cipher].ecb_decrypt(ct, tmp, &cbc->key); | 28 _ARGCHK(cipher_descriptor[cbc->cipher].ecb_decrypt != NULL); |
29 | 29 |
30 /* is blocklen valid? */ | 30 /* is blocklen valid? */ |
31 if (cbc->blocklen < 0 || cbc->blocklen > (int)sizeof(cbc->IV)) { | 31 if (cbc->blocklen < 0 || cbc->blocklen > (int)sizeof(cbc->IV)) { |
32 return CRYPT_INVALID_ARG; | 32 return CRYPT_INVALID_ARG; |
33 } | 33 } |
34 | 34 |
35 /* xor IV against the plaintext of the previous step */ | 35 /* decrypt and xor IV against the plaintext of the previous step */ |
36 cipher_descriptor[cbc->cipher].ecb_decrypt(ct, tmp, &cbc->key); | |
36 for (x = 0; x < cbc->blocklen; x++) { | 37 for (x = 0; x < cbc->blocklen; x++) { |
37 /* copy CT in case ct == pt */ | 38 /* copy CT in case ct == pt */ |
38 tmp2[x] = ct[x]; | 39 tmp2[x] = ct[x]; |
39 | 40 |
40 /* actually decrypt the byte */ | 41 /* actually decrypt the byte */ |