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 CBC implementation, start chain, Tom St Denis
19 Initialize a CBC context
20 @param cipher The index of the cipher desired
21 @param IV The initialization vector
22 @param key The secret key
23 @param keylen The length of the secret key (octets)
24 @param num_rounds Number of rounds in the cipher desired (0 for default)
25 @param cbc The CBC state to initialize
26 @return CRYPT_OK if successful
28 int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,
29 int keylen, int num_rounds, symmetric_CBC *cbc)
33 LTC_ARGCHK(IV != NULL);
34 LTC_ARGCHK(key != NULL);
35 LTC_ARGCHK(cbc != NULL);
38 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
43 if ((err = cipher_descriptor[cipher].setup(key, keylen, num_rounds, &cbc->key)) != CRYPT_OK) {
48 cbc->blocklen = cipher_descriptor[cipher].block_length;
50 for (x = 0; x < cbc->blocklen; x++) {
58 /* ref: $Format:%D$ */
59 /* git commit: $Format:%H$ */
60 /* commit time: $Format:%ai$ */