comparison libtomcrypt/src/mac/f9/f9_init.c @ 382:0cbe8f6dbf9e

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f) to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:41:05 +0000
parents
children f849a5ca2efc
comparison
equal deleted inserted replaced
379:b66a00272a90 382:0cbe8f6dbf9e
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2 *
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
5 *
6 * The library is free for all purposes without any express
7 * guarantee it works.
8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.com
10 */
11 #include "tomcrypt.h"
12
13 /**
14 @file f9_init.c
15 F9 Support, start an F9 state
16 */
17
18 #ifdef LTC_F9_MODE
19
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
26 */
27 int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen)
28 {
29 int x, err;
30
31 LTC_ARGCHK(f9 != NULL);
32 LTC_ARGCHK(key != NULL);
33
34 /* schedule the key */
35 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
36 return err;
37 }
38
39 #ifdef LTC_FAST
40 if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
41 return CRYPT_INVALID_ARG;
42 }
43 #endif
44
45 if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, &f9->key)) != CRYPT_OK) {
46 goto done;
47 }
48
49 /* make the second key */
50 for (x = 0; (unsigned)x < keylen; x++) {
51 f9->akey[x] = key[x] ^ 0xAA;
52 }
53
54 /* setup struct */
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;
58 f9->cipher = cipher;
59 f9->buflen = 0;
60 f9->keylen = keylen;
61 done:
62 return err;
63 }
64
65 #endif
66
67 /* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_init.c,v $ */
68 /* $Revision: 1.4 $ */
69 /* $Date: 2006/11/08 22:54:18 $ */
70