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.com
15
F9 Support, start an F9 state
20
/** Initialize F9-MAC state
21
@param f9 [out] f9 state to initialize
22
@param cipher Index of cipher to use
23
@param key [in] Secret key
24
@param keylen Length of secret key in octets
25
Return CRYPT_OK on success
27
int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen)
31
LTC_ARGCHK(f9 != NULL);
32
LTC_ARGCHK(key != NULL);
34
/* schedule the key */
35
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
40
if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
41
return CRYPT_INVALID_ARG;
45
if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, &f9->key)) != CRYPT_OK) {
49
/* make the second key */
50
for (x = 0; (unsigned)x < keylen; x++) {
51
f9->akey[x] = key[x] ^ 0xAA;
55
zeromem(f9->IV, cipher_descriptor[cipher].block_length);
56
zeromem(f9->ACC, cipher_descriptor[cipher].block_length);
57
f9->blocksize = cipher_descriptor[cipher].block_length;
67
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_init.c,v $ */
68
/* $Revision: 1.4 $ */
69
/* $Date: 2006/11/08 22:54:18 $ */