1 // SPDX-License-Identifier: BSD-2-Clause
2 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3  *
4  * LibTomCrypt is a library that provides various cryptographic
5  * algorithms in a highly modular and flexible manner.
6  *
7  * The library is free for all purposes without any express
8  * guarantee it works.
9  */
10 #include "tomcrypt_private.h"
11 
12 /**
13    @file lrw_getiv.c
14    LRW_MODE implementation, Retrieve the current IV, Tom St Denis
15 */
16 
17 #ifdef LTC_LRW_MODE
18 
19 /**
20   Get the IV for LRW
21   @param IV      [out] The IV, must be 16 octets
22   @param len     Length ... must be at least 16 :-)
23   @param lrw     The LRW state to read
24   @return CRYPT_OK if successful
25 */
lrw_getiv(unsigned char * IV,unsigned long * len,const symmetric_LRW * lrw)26 int lrw_getiv(unsigned char *IV, unsigned long *len, const symmetric_LRW *lrw)
27 {
28    LTC_ARGCHK(IV != NULL);
29    LTC_ARGCHK(len != NULL);
30    LTC_ARGCHK(lrw != NULL);
31    if (*len < 16) {
32        *len = 16;
33        return CRYPT_BUFFER_OVERFLOW;
34    }
35 
36    XMEMCPY(IV, lrw->IV, 16);
37    *len = 16;
38    return CRYPT_OK;
39 }
40 
41 #endif
42 /* ref:         $Format:%D$ */
43 /* git commit:  $Format:%H$ */
44 /* commit time: $Format:%ai$ */
45