]> pd.if.org Git - zpackage/blob - libtomcrypt/src/modes/cbc/cbc_setiv.c
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / modes / cbc / cbc_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 cbc_setiv.c
13    CBC implementation, set IV, Tom St Denis
14 */
15
16
17 #ifdef LTC_CBC_MODE
18
19 /**
20    Set an initialization vector
21    @param IV   The initialization vector
22    @param len  The length of the vector (in octets)
23    @param cbc  The CBC state
24    @return CRYPT_OK if successful
25 */
26 int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc)
27 {
28    LTC_ARGCHK(IV  != NULL);
29    LTC_ARGCHK(cbc != NULL);
30    if (len != (unsigned long)cbc->blocklen) {
31       return CRYPT_INVALID_ARG;
32    }
33    XMEMCPY(cbc->IV, IV, len);
34    return CRYPT_OK;
35 }
36
37 #endif
38
39
40 /* ref:         $Format:%D$ */
41 /* git commit:  $Format:%H$ */
42 /* commit time: $Format:%ai$ */