Mercurial > dropbear
comparison libtomcrypt/src/modes/cfb/cfb_setiv.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
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_setiv.c | 12 @file cfb_setiv.c |
15 CFB implementation, set IV, Tom St Denis | 13 CFB implementation, set IV, Tom St Denis |
16 */ | 14 */ |
17 | 15 |
18 #ifdef LTC_CFB_MODE | 16 #ifdef LTC_CFB_MODE |
19 | 17 |
20 /** | 18 /** |
21 Set an initial vector | 19 Set an initialization vector |
22 @param IV The initial vector | 20 @param IV The initialization vector |
23 @param len The length of the vector (in octets) | 21 @param len The length of the vector (in octets) |
24 @param cfb The CFB state | 22 @param cfb The CFB state |
25 @return CRYPT_OK if successful | 23 @return CRYPT_OK if successful |
26 */ | 24 */ |
27 int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb) | 25 int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb) |
28 { | 26 { |
29 int err; | 27 int err; |
30 | 28 |
31 LTC_ARGCHK(IV != NULL); | 29 LTC_ARGCHK(IV != NULL); |
32 LTC_ARGCHK(cfb != NULL); | 30 LTC_ARGCHK(cfb != NULL); |
33 | 31 |
34 if ((err = cipher_is_valid(cfb->cipher)) != CRYPT_OK) { | 32 if ((err = cipher_is_valid(cfb->cipher)) != CRYPT_OK) { |
35 return err; | 33 return err; |
36 } | 34 } |
37 | 35 |
38 if (len != (unsigned long)cfb->blocklen) { | 36 if (len != (unsigned long)cfb->blocklen) { |
39 return CRYPT_INVALID_ARG; | 37 return CRYPT_INVALID_ARG; |
40 } | 38 } |
41 | 39 |
42 /* force next block */ | 40 /* force next block */ |
43 cfb->padlen = 0; | 41 cfb->padlen = 0; |
44 return cipher_descriptor[cfb->cipher].ecb_encrypt(IV, cfb->IV, &cfb->key); | 42 return cipher_descriptor[cfb->cipher].ecb_encrypt(IV, cfb->IV, &cfb->key); |
45 } | 43 } |
46 | 44 |
47 #endif | 45 #endif |
48 | 46 |
49 | 47 |
50 /* $Source$ */ | 48 /* ref: $Format:%D$ */ |
51 /* $Revision$ */ | 49 /* git commit: $Format:%H$ */ |
52 /* $Date$ */ | 50 /* commit time: $Format:%ai$ */ |