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 cfb_getiv.c 14 CFB implementation, get IV, Tom St Denis 15 */ 16 17 #ifdef LTC_CFB_MODE 18 19 /** 20 Get the current initialization vector 21 @param IV [out] The destination of the initialization vector 22 @param len [in/out] The max size and resulting size of the initialization vector 23 @param cfb The CFB state 24 @return CRYPT_OK if successful 25 */ cfb_getiv(unsigned char * IV,unsigned long * len,const symmetric_CFB * cfb)26int cfb_getiv(unsigned char *IV, unsigned long *len, const symmetric_CFB *cfb) 27 { 28 LTC_ARGCHK(IV != NULL); 29 LTC_ARGCHK(len != NULL); 30 LTC_ARGCHK(cfb != NULL); 31 if ((unsigned long)cfb->blocklen > *len) { 32 *len = cfb->blocklen; 33 return CRYPT_BUFFER_OVERFLOW; 34 } 35 XMEMCPY(IV, cfb->IV, cfb->blocklen); 36 *len = cfb->blocklen; 37 38 return CRYPT_OK; 39 } 40 41 #endif 42 43 /* ref: $Format:%D$ */ 44 /* git commit: $Format:%H$ */ 45 /* commit time: $Format:%ai$ */ 46