1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6    @file ofb_getiv.c
7    OFB implementation, get IV, Tom St Denis
8 */
9 
10 #ifdef LTC_OFB_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 ofb  The OFB state
17    @return CRYPT_OK if successful
18 */
ofb_getiv(unsigned char * IV,unsigned long * len,const symmetric_OFB * ofb)19 int ofb_getiv(unsigned char *IV, unsigned long *len, const symmetric_OFB *ofb)
20 {
21    LTC_ARGCHK(IV  != NULL);
22    LTC_ARGCHK(len != NULL);
23    LTC_ARGCHK(ofb != NULL);
24    if ((unsigned long)ofb->blocklen > *len) {
25       *len = ofb->blocklen;
26       return CRYPT_BUFFER_OVERFLOW;
27    }
28    XMEMCPY(IV, ofb->IV, ofb->blocklen);
29    *len = ofb->blocklen;
30 
31    return CRYPT_OK;
32 }
33 
34 #endif
35