]> pd.if.org Git - zpackage/blob - libtomcrypt/src/modes/f8/f8_getiv.c
a5885c95eef20ab89f149dc63f5158e90622ba5a
[zpackage] / libtomcrypt / src / modes / f8 / f8_getiv.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 ofb_getiv.c
13    F8 implementation, get IV, Tom St Denis
14 */
15
16 #ifdef LTC_F8_MODE
17
18 /**
19    Get the current initialization vector
20    @param IV   [out] The destination of the initialization vector
21    @param len  [in/out]  The max size and resulting size of the initialization vector
22    @param f8   The F8 state
23    @return CRYPT_OK if successful
24 */
25 int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8)
26 {
27    LTC_ARGCHK(IV  != NULL);
28    LTC_ARGCHK(len != NULL);
29    LTC_ARGCHK(f8  != NULL);
30    if ((unsigned long)f8->blocklen > *len) {
31       *len = f8->blocklen;
32       return CRYPT_BUFFER_OVERFLOW;
33    }
34    XMEMCPY(IV, f8->IV, f8->blocklen);
35    *len = f8->blocklen;
36
37    return CRYPT_OK;
38 }
39
40 #endif
41
42 /* ref:         $Format:%D$ */
43 /* git commit:  $Format:%H$ */
44 /* commit time: $Format:%ai$ */