comparison src/modes/ecb/ecb_decrypt.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16

Update to LibTomCrypt 1.16
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:22:00 +0000
parents 59400faa4b44
children
comparison
equal deleted inserted replaced
280:59400faa4b44 380:d5faf4814ddb
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.org 9 * Tom St Denis, [email protected], http://libtomcrypt.com
10 */ 10 */
11 #include "tomcrypt.h" 11 #include "tomcrypt.h"
12 12
13 /** 13 /**
14 @file ecb_decrypt.c 14 @file ecb_decrypt.c
15 ECB implementation, decrypt a block, Tom St Denis 15 ECB implementation, decrypt a block, Tom St Denis
16 */ 16 */
17 17
18 #ifdef ECB 18 #ifdef LTC_ECB_MODE
19 19
20 /** 20 /**
21 ECB decrypt 21 ECB decrypt
22 @param ct Ciphertext 22 @param ct Ciphertext
23 @param pt [out] Plaintext 23 @param pt [out] Plaintext
38 return CRYPT_INVALID_ARG; 38 return CRYPT_INVALID_ARG;
39 } 39 }
40 40
41 /* check for accel */ 41 /* check for accel */
42 if (cipher_descriptor[ecb->cipher].accel_ecb_decrypt != NULL) { 42 if (cipher_descriptor[ecb->cipher].accel_ecb_decrypt != NULL) {
43 cipher_descriptor[ecb->cipher].accel_ecb_decrypt(ct, pt, len / cipher_descriptor[ecb->cipher].block_length, &ecb->key); 43 return cipher_descriptor[ecb->cipher].accel_ecb_decrypt(ct, pt, len / cipher_descriptor[ecb->cipher].block_length, &ecb->key);
44 } else { 44 } else {
45 while (len) { 45 while (len) {
46 cipher_descriptor[ecb->cipher].ecb_decrypt(ct, pt, &ecb->key); 46 if ((err = cipher_descriptor[ecb->cipher].ecb_decrypt(ct, pt, &ecb->key)) != CRYPT_OK) {
47 return err;
48 }
47 pt += cipher_descriptor[ecb->cipher].block_length; 49 pt += cipher_descriptor[ecb->cipher].block_length;
48 ct += cipher_descriptor[ecb->cipher].block_length; 50 ct += cipher_descriptor[ecb->cipher].block_length;
49 len -= cipher_descriptor[ecb->cipher].block_length; 51 len -= cipher_descriptor[ecb->cipher].block_length;
50 } 52 }
51 } 53 }
53 } 55 }
54 56
55 #endif 57 #endif
56 58
57 /* $Source: /cvs/libtom/libtomcrypt/src/modes/ecb/ecb_decrypt.c,v $ */ 59 /* $Source: /cvs/libtom/libtomcrypt/src/modes/ecb/ecb_decrypt.c,v $ */
58 /* $Revision: 1.5 $ */ 60 /* $Revision: 1.9 $ */
59 /* $Date: 2005/05/05 14:35:59 $ */ 61 /* $Date: 2006/06/29 01:51:34 $ */