tomcrypt/src/modes/ofb/ofb_setiv.c

53 lines
1.1 KiB
C
Raw Normal View History

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.
*
2007-07-20 17:48:02 +00:00
* Tom St Denis, tomstdenis@gmail.com, http://libtom.org
2004-05-31 02:36:47 +00:00
*/
2004-12-30 23:55:53 +00:00
#include "tomcrypt.h"
2004-05-31 02:36:47 +00:00
2004-12-30 23:55:53 +00:00
/**
@file ofb_setiv.c
OFB implementation, set IV, Tom St Denis
*/
2004-05-31 02:36:47 +00:00
2006-08-30 23:30:00 +00:00
#ifdef LTC_OFB_MODE
2004-05-31 02:36:47 +00:00
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 ofb The OFB state
@return CRYPT_OK if successful
*/
2004-05-31 02:36:47 +00:00
int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb)
{
int err;
2004-12-30 23:55:53 +00:00
LTC_ARGCHK(IV != NULL);
LTC_ARGCHK(ofb != NULL);
2004-05-31 02:36:47 +00:00
if ((err = cipher_is_valid(ofb->cipher)) != CRYPT_OK) {
return err;
}
if (len != (unsigned long)ofb->blocklen) {
return CRYPT_INVALID_ARG;
}
/* force next block */
ofb->padlen = 0;
2005-11-18 05:15:37 +00:00
return cipher_descriptor[ofb->cipher].ecb_encrypt(IV, ofb->IV, &ofb->key);
2004-05-31 02:36:47 +00:00
}
#endif
2005-06-09 00:08:13 +00:00
/* $Source$ */
/* $Revision$ */
/* $Date$ */