1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6    @file cfb_getiv.c
7    CFB implementation, get IV, Tom St Denis
8 */
9 
10 #ifdef LTC_CFB_MODE
11 
12 /**
13    Get the current initialization vector
14    @param IV   [out] The destination of the initialization vector
15    @param len  [in/out]  The max size and resulting size of the initialization vector
16    @param cfb  The CFB state
17    @return CRYPT_OK if successful
18 */
cfb_getiv(unsigned char * IV,unsigned long * len,const symmetric_CFB * cfb)19 int cfb_getiv(unsigned char *IV, unsigned long *len, const symmetric_CFB *cfb)
20 {
21    LTC_ARGCHK(IV  != NULL);
22    LTC_ARGCHK(len != NULL);
23    LTC_ARGCHK(cfb != NULL);
24    if ((unsigned long)cfb->blocklen > *len) {
25       *len = cfb->blocklen;
26       return CRYPT_BUFFER_OVERFLOW;
27    }
28    XMEMCPY(IV, cfb->IV, cfb->blocklen);
29    *len = cfb->blocklen;
30 
31    return CRYPT_OK;
32 }
33 
34 #endif
35