annotate src/mac/f9/f9_memory.c @ 390:d8e44bef7917 libtomcrypt-dropbear

Replace // with /* */
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 04:28:09 +0000
parents d5faf4814ddb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
380
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 *
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 * LibTomCrypt is a library that provides various cryptographic
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * algorithms in a highly modular and flexible manner.
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 *
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 * The library is free for all purposes without any express
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 * guarantee it works.
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 *
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * Tom St Denis, [email protected], http://libtomcrypt.com
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 #include "tomcrypt.h"
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 /**
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 @file f9_process.c
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 f9 Support, Process a block through F9-MAC
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 #ifdef LTC_F9_MODE
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 /** f9-MAC a block of memory
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 @param cipher Index of cipher to use
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 @param key [in] Secret key
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 @param keylen Length of key in octets
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 @param in [in] Message to MAC
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 @param inlen Length of input in octets
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 @param out [out] Destination for the MAC tag
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 @param outlen [in/out] Output size and final tag size
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 Return CRYPT_OK on success.
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 int f9_memory(int cipher,
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 const unsigned char *key, unsigned long keylen,
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 const unsigned char *in, unsigned long inlen,
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 unsigned char *out, unsigned long *outlen)
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 f9_state *f9;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 int err;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 /* is the cipher valid? */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 return err;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 /* Use accelerator if found */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 if (cipher_descriptor[cipher].f9_memory != NULL) {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 return cipher_descriptor[cipher].f9_memory(key, keylen, in, inlen, out, outlen);
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 f9 = XCALLOC(1, sizeof(*f9));
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 if (f9 == NULL) {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 return CRYPT_MEM;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 if ((err = f9_init(f9, cipher, key, keylen)) != CRYPT_OK) {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 goto done;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57 if ((err = f9_process(f9, in, inlen)) != CRYPT_OK) {
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 goto done;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 err = f9_done(f9, out, outlen);
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 done:
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63 XFREE(f9);
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 return err;
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 }
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 #endif
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 /* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_memory.c,v $ */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70 /* $Revision: 1.4 $ */
d5faf4814ddb Update to LibTomCrypt 1.16
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 /* $Date: 2006/11/21 23:02:42 $ */