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@gmail.com, http://libtomcrypt.org
15
CTR implementation, start chain, Tom St Denis
22
Initialize a CTR context
23
@param cipher The index of the cipher desired
24
@param IV The initial vector
25
@param key The secret key
26
@param keylen The length of the secret key (octets)
27
@param num_rounds Number of rounds in the cipher desired (0 for default)
28
@param ctr_mode The counter mode (CTR_COUNTER_LITTLE_ENDIAN or CTR_COUNTER_BIG_ENDIAN)
29
@param ctr The CTR state to initialize
30
@return CRYPT_OK if successful
32
int ctr_start( int cipher,
33
const unsigned char *IV,
34
const unsigned char *key, int keylen,
35
int num_rounds, int ctr_mode,
40
LTC_ARGCHK(IV != NULL);
41
LTC_ARGCHK(key != NULL);
42
LTC_ARGCHK(ctr != NULL);
45
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
50
if ((err = cipher_descriptor[cipher].setup(key, keylen, num_rounds, &ctr->key)) != CRYPT_OK) {
55
ctr->blocklen = cipher_descriptor[cipher].block_length;
59
for (x = 0; x < ctr->blocklen; x++) {
62
cipher_descriptor[ctr->cipher].ecb_encrypt(ctr->ctr, ctr->pad, &ctr->key);
68
/* $Source: /cvs/libtom/libtomcrypt/src/modes/ctr/ctr_start.c,v $ */
69
/* $Revision: 1.6 $ */
70
/* $Date: 2005/05/05 14:35:59 $ */