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 CFB implementation, start chain, Tom St Denis
20 Initialize a CFB context
21 @param cipher The index of the cipher desired
22 @param IV The initialization vector
23 @param key The secret key
24 @param keylen The length of the secret key (octets)
25 @param num_rounds Number of rounds in the cipher desired (0 for default)
26 @param cfb The CFB state to initialize
27 @return CRYPT_OK if successful
29 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
30 int keylen, int num_rounds, symmetric_CFB *cfb)
34 LTC_ARGCHK(IV != NULL);
35 LTC_ARGCHK(key != NULL);
36 LTC_ARGCHK(cfb != NULL);
38 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
45 cfb->blocklen = cipher_descriptor[cipher].block_length;
46 for (x = 0; x < cfb->blocklen; x++)
50 if ((err = cipher_descriptor[cipher].setup(key, keylen, num_rounds, &cfb->key)) != CRYPT_OK) {
56 return cipher_descriptor[cfb->cipher].ecb_encrypt(cfb->IV, cfb->IV, &cfb->key);
61 /* ref: $Format:%D$ */
62 /* git commit: $Format:%H$ */
63 /* commit time: $Format:%ai$ */