Path: blob/master/libs/tomcrypt/src/modes/ofb/ofb_getiv.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 ofb_getiv.c12OFB implementation, get IV, Tom St Denis13*/1415#ifdef LTC_OFB_MODE1617/**18Get the current initialization vector19@param IV [out] The destination of the initialization vector20@param len [in/out] The max size and resulting size of the initialization vector21@param ofb The OFB state22@return CRYPT_OK if successful23*/24int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb)25{26LTC_ARGCHK(IV != NULL);27LTC_ARGCHK(len != NULL);28LTC_ARGCHK(ofb != NULL);29if ((unsigned long)ofb->blocklen > *len) {30*len = ofb->blocklen;31return CRYPT_BUFFER_OVERFLOW;32}33XMEMCPY(IV, ofb->IV, ofb->blocklen);34*len = ofb->blocklen;3536return CRYPT_OK;37}3839#endif404142