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 F9 Support, start an F9 state
18 /** Initialize F9-MAC state
19 @param f9 [out] f9 state to initialize
20 @param cipher Index of cipher to use
21 @param key [in] Secret key
22 @param keylen Length of secret key in octets
23 Return CRYPT_OK on success
25 int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen)
29 LTC_ARGCHK(f9 != NULL);
30 LTC_ARGCHK(key != NULL);
32 /* schedule the key */
33 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
38 if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
39 return CRYPT_INVALID_ARG;
43 if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, &f9->key)) != CRYPT_OK) {
47 /* make the second key */
48 for (x = 0; (unsigned)x < keylen; x++) {
49 f9->akey[x] = key[x] ^ 0xAA;
53 zeromem(f9->IV, cipher_descriptor[cipher].block_length);
54 zeromem(f9->ACC, cipher_descriptor[cipher].block_length);
55 f9->blocksize = cipher_descriptor[cipher].block_length;
65 /* ref: $Format:%D$ */
66 /* git commit: $Format:%H$ */
67 /* commit time: $Format:%ai$ */