Mercurial > dropbear
comparison libtomcrypt/src/mac/f9/f9_memory_multi.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 #include <stdarg.h> | |
13 | |
14 /** | |
15 @file f9_memory_multi.c | |
16 f9 support, process multiple blocks of memory, Tom St Denis | |
17 */ | |
18 | |
19 #ifdef LTC_F9_MODE | |
20 | |
21 /** | |
22 f9 multiple blocks of memory | |
23 @param cipher The index of the desired cipher | |
24 @param key The secret key | |
25 @param keylen The length of the secret key (octets) | |
26 @param out [out] The destination of the authentication tag | |
27 @param outlen [in/out] The max size and resulting size of the authentication tag (octets) | |
28 @param in The data to send through f9 | |
29 @param inlen The length of the data to send through f9 (octets) | |
30 @param ... tuples of (data,len) pairs to f9, terminated with a (NULL,x) (x=don't care) | |
31 @return CRYPT_OK if successful | |
32 */ | |
33 int f9_memory_multi(int cipher, | |
34 const unsigned char *key, unsigned long keylen, | |
35 unsigned char *out, unsigned long *outlen, | |
36 const unsigned char *in, unsigned long inlen, ...) | |
37 { | |
38 int err; | |
39 f9_state *f9; | |
40 va_list args; | |
41 const unsigned char *curptr; | |
42 unsigned long curlen; | |
43 | |
44 LTC_ARGCHK(key != NULL); | |
45 LTC_ARGCHK(in != NULL); | |
46 LTC_ARGCHK(out != NULL); | |
47 LTC_ARGCHK(outlen != NULL); | |
48 | |
49 /* allocate ram for f9 state */ | |
50 f9 = XMALLOC(sizeof(f9_state)); | |
51 if (f9 == NULL) { | |
52 return CRYPT_MEM; | |
53 } | |
54 | |
55 /* f9 process the message */ | |
56 if ((err = f9_init(f9, cipher, key, keylen)) != CRYPT_OK) { | |
57 goto LBL_ERR; | |
58 } | |
59 va_start(args, inlen); | |
60 curptr = in; | |
61 curlen = inlen; | |
62 for (;;) { | |
63 /* process buf */ | |
64 if ((err = f9_process(f9, curptr, curlen)) != CRYPT_OK) { | |
65 goto LBL_ERR; | |
66 } | |
67 /* step to next */ | |
68 curptr = va_arg(args, const unsigned char*); | |
69 if (curptr == NULL) { | |
70 break; | |
71 } | |
72 curlen = va_arg(args, unsigned long); | |
73 } | |
74 if ((err = f9_done(f9, out, outlen)) != CRYPT_OK) { | |
75 goto LBL_ERR; | |
76 } | |
77 LBL_ERR: | |
78 #ifdef LTC_CLEAN_STACK | |
79 zeromem(f9, sizeof(f9_state)); | |
80 #endif | |
81 XFREE(f9); | |
82 va_end(args); | |
83 return err; | |
84 } | |
85 | |
86 #endif | |
87 | |
88 /* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_memory_multi.c,v $ */ | |
89 /* $Revision: 1.2 $ */ | |
90 /* $Date: 2006/11/08 21:50:13 $ */ |