Mercurial > dropbear
comparison eax_done.c @ 0:d7da3b1e1540 libtomcrypt
put back the 0.95 makefile which was inadvertently merged over
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 31 May 2004 18:21:40 +0000 |
parents | |
children | 5d99163f7e32 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d7da3b1e1540 |
---|---|
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.org | |
10 */ | |
11 | |
12 /* EAX Implementation by Tom St Denis */ | |
13 #include "mycrypt.h" | |
14 | |
15 #ifdef EAX_MODE | |
16 | |
17 int eax_done(eax_state *eax, unsigned char *tag, unsigned long *taglen) | |
18 { | |
19 int err; | |
20 unsigned char headermac[MAXBLOCKSIZE], ctmac[MAXBLOCKSIZE]; | |
21 unsigned long x, len; | |
22 | |
23 _ARGCHK(eax != NULL); | |
24 _ARGCHK(tag != NULL); | |
25 _ARGCHK(taglen != NULL); | |
26 | |
27 /* finish ctomac */ | |
28 len = sizeof(ctmac); | |
29 if ((err = omac_done(&eax->ctomac, ctmac, &len)) != CRYPT_OK) { | |
30 return err; | |
31 } | |
32 | |
33 /* finish headeromac */ | |
34 | |
35 /* note we specifically don't reset len so the two lens are minimal */ | |
36 | |
37 if ((err = omac_done(&eax->headeromac, headermac, &len)) != CRYPT_OK) { | |
38 return err; | |
39 } | |
40 | |
41 /* compute N xor H xor C */ | |
42 for (x = 0; x < len && x < *taglen; x++) { | |
43 tag[x] = eax->N[x] ^ headermac[x] ^ ctmac[x]; | |
44 } | |
45 *taglen = x; | |
46 | |
47 #ifdef CLEAN_STACK | |
48 zeromem(ctmac, sizeof(ctmac)); | |
49 zeromem(headermac, sizeof(headermac)); | |
50 zeromem(eax, sizeof(*eax)); | |
51 #endif | |
52 | |
53 return CRYPT_OK; | |
54 } | |
55 | |
56 #endif |