tomcrypt/src/modes/ofb/ofb_getiv.c

47 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_getiv.c
OFB implementation, get 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
/**
Get the current initial vector
@param IV [out] The destination of the initial vector
@param len [in/out] The max size and resulting size of the initial vector
@param ofb The OFB state
@return CRYPT_OK if successful
*/
2004-05-31 02:36:47 +00:00
int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb)
{
2004-12-30 23:55:53 +00:00
LTC_ARGCHK(IV != NULL);
LTC_ARGCHK(len != NULL);
LTC_ARGCHK(ofb != NULL);
2004-05-31 02:36:47 +00:00
if ((unsigned long)ofb->blocklen > *len) {
2006-06-18 01:37:50 +00:00
*len = ofb->blocklen;
2004-05-31 02:36:47 +00:00
return CRYPT_BUFFER_OVERFLOW;
}
2004-06-20 02:41:49 +00:00
XMEMCPY(IV, ofb->IV, ofb->blocklen);
2004-05-31 02:36:47 +00:00
*len = ofb->blocklen;
return CRYPT_OK;
}
#endif
2005-06-09 00:08:13 +00:00
/* $Source$ */
/* $Revision$ */
/* $Date$ */