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
9
* Tom St Denis, tomstdenis@iahu.ca, http://libtomcrypt.org
15
int ctr_start(int cipher, const unsigned char *count, const unsigned char *key, int keylen,
16
int num_rounds, symmetric_CTR *ctr)
20
_ARGCHK(count != NULL);
25
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
30
if ((err = cipher_descriptor[cipher].setup(key, keylen, num_rounds, &ctr->key)) != CRYPT_OK) {
35
ctr->blocklen = cipher_descriptor[cipher].block_length;
39
for (x = 0; x < ctr->blocklen; x++) {
40
ctr->ctr[x] = count[x];
42
cipher_descriptor[ctr->cipher].ecb_encrypt(ctr->ctr, ctr->pad, &ctr->key);