Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/modes/ofb/ofb_setiv.c
5972 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
#include "tomcrypt.h"
10
11
/**
12
@file ofb_setiv.c
13
OFB implementation, set IV, Tom St Denis
14
*/
15
16
#ifdef LTC_OFB_MODE
17
18
/**
19
Set an initialization vector
20
@param IV The initialization vector
21
@param len The length of the vector (in octets)
22
@param ofb The OFB state
23
@return CRYPT_OK if successful
24
*/
25
int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb)
26
{
27
int err;
28
29
LTC_ARGCHK(IV != NULL);
30
LTC_ARGCHK(ofb != NULL);
31
32
if ((err = cipher_is_valid(ofb->cipher)) != CRYPT_OK) {
33
return err;
34
}
35
36
if (len != (unsigned long)ofb->blocklen) {
37
return CRYPT_INVALID_ARG;
38
}
39
40
/* force next block */
41
ofb->padlen = 0;
42
return cipher_descriptor[ofb->cipher].ecb_encrypt(IV, ofb->IV, &ofb->key);
43
}
44
45
#endif
46
47