1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6    @file lrw_getiv.c
7    LRW_MODE implementation, Retrieve the current IV, Tom St Denis
8 */
9 
10 #ifdef LTC_LRW_MODE
11 
12 /**
13   Get the IV for LRW
14   @param IV      [out] The IV, must be 16 octets
15   @param len     Length ... must be at least 16 :-)
16   @param lrw     The LRW state to read
17   @return CRYPT_OK if successful
18 */
lrw_getiv(unsigned char * IV,unsigned long * len,const symmetric_LRW * lrw)19 int lrw_getiv(unsigned char *IV, unsigned long *len, const symmetric_LRW *lrw)
20 {
21    LTC_ARGCHK(IV != NULL);
22    LTC_ARGCHK(len != NULL);
23    LTC_ARGCHK(lrw != NULL);
24    if (*len < 16) {
25        *len = 16;
26        return CRYPT_BUFFER_OVERFLOW;
27    }
28 
29    XMEMCPY(IV, lrw->IV, 16);
30    *len = 16;
31    return CRYPT_OK;
32 }
33 
34 #endif
35