Path: blob/master/libs/tomcrypt/src/modes/cbc/cbc_setiv.c
5972 views
/* LibTomCrypt, modular cryptographic library -- Tom St Denis1*2* LibTomCrypt is a library that provides various cryptographic3* algorithms in a highly modular and flexible manner.4*5* The library is free for all purposes without any express6* guarantee it works.7*/8#include "tomcrypt.h"910/**11@file cbc_setiv.c12CBC implementation, set IV, Tom St Denis13*/141516#ifdef LTC_CBC_MODE1718/**19Set an initialization vector20@param IV The initialization vector21@param len The length of the vector (in octets)22@param cbc The CBC state23@return CRYPT_OK if successful24*/25int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc)26{27LTC_ARGCHK(IV != NULL);28LTC_ARGCHK(cbc != NULL);29if (len != (unsigned long)cbc->blocklen) {30return CRYPT_INVALID_ARG;31}32XMEMCPY(cbc->IV, IV, len);33return CRYPT_OK;34}3536#endif373839