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 cbc_setiv.c 14 CBC implementation, set IV, Tom St Denis 15 */ 16 17 18 #ifdef LTC_CBC_MODE 19 20 /** 21 Set an initialization vector 22 @param IV The initialization vector 23 @param len The length of the vector (in octets) 24 @param cbc The CBC state 25 @return CRYPT_OK if successful 26 */ cbc_setiv(const unsigned char * IV,unsigned long len,symmetric_CBC * cbc)27int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc) 28 { 29 LTC_ARGCHK(IV != NULL); 30 LTC_ARGCHK(cbc != NULL); 31 if (len != (unsigned long)cbc->blocklen) { 32 return CRYPT_INVALID_ARG; 33 } 34 XMEMCPY(cbc->IV, IV, len); 35 return CRYPT_OK; 36 } 37 38 #endif 39 40 41 /* ref: $Format:%D$ */ 42 /* git commit: $Format:%H$ */ 43 /* commit time: $Format:%ai$ */ 44