comparison libtomcrypt/src/modes/ecb/ecb_encrypt.c @ 398:59c7938af2bd

merge of '1250b8af44b62d8f4fe0f8d9fc7e7a1cc34e7e1c' and '7f8670ac3bb975f40967f3979d09d2199b7e90c8'
author Matt Johnston <matt@ucc.asn.au>
date Sat, 03 Feb 2007 08:20:30 +0000
parents 0cbe8f6dbf9e
children f849a5ca2efc
comparison
equal deleted inserted replaced
396:e7c1a77d2921 398:59c7938af2bd
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_encrypt.c 14 @file ecb_encrypt.c
15 ECB implementation, encrypt a block, Tom St Denis 15 ECB implementation, encrypt a block, Tom St Denis
16 */ 16 */
17 17
18 #ifdef ECB 18 #ifdef LTC_ECB_MODE
19 19
20 /** 20 /**
21 ECB encrypt 21 ECB encrypt
22 @param pt Plaintext 22 @param pt Plaintext
23 @param ct [out] Ciphertext 23 @param ct [out] Ciphertext
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_encrypt != NULL) { 42 if (cipher_descriptor[ecb->cipher].accel_ecb_encrypt != NULL) {
43 cipher_descriptor[ecb->cipher].accel_ecb_encrypt(pt, ct, len / cipher_descriptor[ecb->cipher].block_length, &ecb->key); 43 return cipher_descriptor[ecb->cipher].accel_ecb_encrypt(pt, ct, 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_encrypt(pt, ct, &ecb->key); 46 if ((err = cipher_descriptor[ecb->cipher].ecb_encrypt(pt, ct, &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_encrypt.c,v $ */ 59 /* $Source: /cvs/libtom/libtomcrypt/src/modes/ecb/ecb_encrypt.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 $ */