]> pd.if.org Git - zpackage/blob - libtomcrypt/src/modes/f8/f8_setiv.c
8f45a3f440b0aa69ec2b9bc4404d28b8860aff41
[zpackage] / libtomcrypt / src / modes / f8 / f8_setiv.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9 #include "tomcrypt.h"
10
11 /**
12    @file f8_setiv.c
13    F8 implementation, set IV, Tom St Denis
14 */
15
16 #ifdef LTC_F8_MODE
17
18 /**
19    Set an initialization vector
20    @param IV   The initialization vector
21    @param len  The length of the vector (in octets)
22    @param f8   The F8 state
23    @return CRYPT_OK if successful
24 */
25 int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8)
26 {
27    int err;
28
29    LTC_ARGCHK(IV != NULL);
30    LTC_ARGCHK(f8 != NULL);
31
32    if ((err = cipher_is_valid(f8->cipher)) != CRYPT_OK) {
33        return err;
34    }
35
36    if (len != (unsigned long)f8->blocklen) {
37       return CRYPT_INVALID_ARG;
38    }
39
40    /* force next block */
41    f8->padlen = 0;
42    return cipher_descriptor[f8->cipher].ecb_encrypt(IV, f8->IV, &f8->key);
43 }
44
45 #endif
46
47
48 /* ref:         $Format:%D$ */
49 /* git commit:  $Format:%H$ */
50 /* commit time: $Format:%ai$ */