1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
13 CTR implementation, set IV, Tom St Denis
19 Set an initialization vector
20 @param IV The initialization vector
21 @param len The length of the vector (in octets)
22 @param ctr The CTR state
23 @return CRYPT_OK if successful
25 int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr)
29 LTC_ARGCHK(IV != NULL);
30 LTC_ARGCHK(ctr != NULL);
33 if ((err = cipher_is_valid(ctr->cipher)) != CRYPT_OK) {
37 if (len != (unsigned long)ctr->blocklen) {
38 return CRYPT_INVALID_ARG;
42 XMEMCPY(ctr->ctr, IV, len);
44 /* force next block */
46 return cipher_descriptor[ctr->cipher].ecb_encrypt(IV, ctr->pad, &ctr->key);
52 /* ref: $Format:%D$ */
53 /* git commit: $Format:%H$ */
54 /* commit time: $Format:%ai$ */