1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 3 #include "tomcrypt_private.h" 4 5 /** 6 @file cbc_setiv.c 7 CBC implementation, set IV, Tom St Denis 8 */ 9 10 11 #ifdef LTC_CBC_MODE 12 13 /** 14 Set an initialization vector 15 @param IV The initialization vector 16 @param len The length of the vector (in octets) 17 @param cbc The CBC state 18 @return CRYPT_OK if successful 19 */ cbc_setiv(const unsigned char * IV,unsigned long len,symmetric_CBC * cbc)20int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc) 21 { 22 LTC_ARGCHK(IV != NULL); 23 LTC_ARGCHK(cbc != NULL); 24 if (len != (unsigned long)cbc->blocklen) { 25 return CRYPT_INVALID_ARG; 26 } 27 XMEMCPY(cbc->IV, IV, len); 28 return CRYPT_OK; 29 } 30 31 #endif 32 33