comparison libtomcrypt/src/modes/cfb/cfb_start.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
3 * LibTomCrypt is a library that provides various cryptographic 3 * LibTomCrypt is a library that provides various cryptographic
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 *
9 * Tom St Denis, [email protected], http://libtom.org
10 */ 8 */
11 #include "tomcrypt.h" 9 #include "tomcrypt.h"
12 10
13 /** 11 /**
14 @file cfb_start.c 12 @file cfb_start.c
19 #ifdef LTC_CFB_MODE 17 #ifdef LTC_CFB_MODE
20 18
21 /** 19 /**
22 Initialize a CFB context 20 Initialize a CFB context
23 @param cipher The index of the cipher desired 21 @param cipher The index of the cipher desired
24 @param IV The initial vector 22 @param IV The initialization vector
25 @param key The secret key 23 @param key The secret key
26 @param keylen The length of the secret key (octets) 24 @param keylen The length of the secret key (octets)
27 @param num_rounds Number of rounds in the cipher desired (0 for default) 25 @param num_rounds Number of rounds in the cipher desired (0 for default)
28 @param cfb The CFB state to initialize 26 @param cfb The CFB state to initialize
29 @return CRYPT_OK if successful 27 @return CRYPT_OK if successful
30 */ 28 */
31 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, 29 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
32 int keylen, int num_rounds, symmetric_CFB *cfb) 30 int keylen, int num_rounds, symmetric_CFB *cfb)
33 { 31 {
34 int x, err; 32 int x, err;
35 33
36 LTC_ARGCHK(IV != NULL); 34 LTC_ARGCHK(IV != NULL);
38 LTC_ARGCHK(cfb != NULL); 36 LTC_ARGCHK(cfb != NULL);
39 37
40 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) { 38 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
41 return err; 39 return err;
42 } 40 }
43 41
44 42
45 /* copy data */ 43 /* copy data */
46 cfb->cipher = cipher; 44 cfb->cipher = cipher;
47 cfb->blocklen = cipher_descriptor[cipher].block_length; 45 cfb->blocklen = cipher_descriptor[cipher].block_length;
48 for (x = 0; x < cfb->blocklen; x++) 46 for (x = 0; x < cfb->blocklen; x++)
58 return cipher_descriptor[cfb->cipher].ecb_encrypt(cfb->IV, cfb->IV, &cfb->key); 56 return cipher_descriptor[cfb->cipher].ecb_encrypt(cfb->IV, cfb->IV, &cfb->key);
59 } 57 }
60 58
61 #endif 59 #endif
62 60
63 /* $Source$ */ 61 /* ref: $Format:%D$ */
64 /* $Revision$ */ 62 /* git commit: $Format:%H$ */
65 /* $Date$ */ 63 /* commit time: $Format:%ai$ */