Path: blob/master/libs/tomcrypt/src/modes/ofb/ofb_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 ofb_setiv.c12OFB implementation, set IV, Tom St Denis13*/1415#ifdef LTC_OFB_MODE1617/**18Set an initialization vector19@param IV The initialization vector20@param len The length of the vector (in octets)21@param ofb The OFB state22@return CRYPT_OK if successful23*/24int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb)25{26int err;2728LTC_ARGCHK(IV != NULL);29LTC_ARGCHK(ofb != NULL);3031if ((err = cipher_is_valid(ofb->cipher)) != CRYPT_OK) {32return err;33}3435if (len != (unsigned long)ofb->blocklen) {36return CRYPT_INVALID_ARG;37}3839/* force next block */40ofb->padlen = 0;41return cipher_descriptor[ofb->cipher].ecb_encrypt(IV, ofb->IV, &ofb->key);42}4344#endif454647