2004-05-31 02:36:47 +00:00
|
|
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
|
|
|
*
|
|
|
|
* LibTomCrypt is a library that provides various cryptographic
|
|
|
|
* algorithms in a highly modular and flexible manner.
|
|
|
|
*
|
|
|
|
* The library is free for all purposes without any express
|
|
|
|
* guarantee it works.
|
|
|
|
*
|
2005-04-17 11:37:13 +00:00
|
|
|
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
|
2004-05-31 02:36:47 +00:00
|
|
|
*/
|
2004-12-30 23:55:53 +00:00
|
|
|
#include "tomcrypt.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
@file cbc_setiv.c
|
|
|
|
CBC implementation, set IV, Tom St Denis
|
|
|
|
*/
|
2004-05-31 02:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CBC
|
|
|
|
|
2004-12-30 23:55:53 +00:00
|
|
|
/**
|
|
|
|
Set an initial vector
|
|
|
|
@param IV The initial vector
|
|
|
|
@param len The length of the vector (in octets)
|
|
|
|
@param cbc The CBC state
|
|
|
|
@return CRYPT_OK if successful
|
|
|
|
*/
|
2004-05-31 02:36:47 +00:00
|
|
|
int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc)
|
|
|
|
{
|
2004-12-30 23:55:53 +00:00
|
|
|
LTC_ARGCHK(IV != NULL);
|
|
|
|
LTC_ARGCHK(cbc != NULL);
|
2004-05-31 02:36:47 +00:00
|
|
|
if (len != (unsigned long)cbc->blocklen) {
|
|
|
|
return CRYPT_INVALID_ARG;
|
|
|
|
}
|
2004-06-20 02:41:49 +00:00
|
|
|
XMEMCPY(cbc->IV, IV, len);
|
2004-05-31 02:36:47 +00:00
|
|
|
return CRYPT_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|