Mercurial > dropbear
comparison libtomcrypt/src/encauth/gcm/gcm_mult_h.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 | |
12 /** | |
13 @file gcm_mult_h.c | |
14 GCM implementation, do the GF mult, by Tom St Denis | |
15 */ | |
16 #include "tomcrypt.h" | |
17 | |
18 #if defined(GCM_MODE) | |
19 /** | |
20 GCM multiply by H | |
21 @param gcm The GCM state which holds the H value | |
22 @param I The value to multiply H by | |
23 */ | |
24 void gcm_mult_h(gcm_state *gcm, unsigned char *I) | |
25 { | |
26 unsigned char T[16]; | |
27 #ifdef GCM_TABLES | |
28 int x, y; | |
29 #ifdef GCM_TABLES_SSE2 | |
30 asm("movdqa (%0),%%xmm0"::"r"(&gcm->PC[0][I[0]][0])); | |
31 for (x = 1; x < 16; x++) { | |
32 asm("pxor (%0),%%xmm0"::"r"(&gcm->PC[x][I[x]][0])); | |
33 } | |
34 asm("movdqa %%xmm0,(%0)"::"r"(&T)); | |
35 #else | |
36 XMEMCPY(T, &gcm->PC[0][I[0]][0], 16); | |
37 for (x = 1; x < 16; x++) { | |
38 #ifdef LTC_FAST | |
39 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { | |
40 *((LTC_FAST_TYPE *)(T + y)) ^= *((LTC_FAST_TYPE *)(&gcm->PC[x][I[x]][y])); | |
41 } | |
42 #else | |
43 for (y = 0; y < 16; y++) { | |
44 T[y] ^= gcm->PC[x][I[x]][y]; | |
45 } | |
46 #endif /* LTC_FAST */ | |
47 } | |
48 #endif /* GCM_TABLES_SSE2 */ | |
49 #else | |
50 gcm_gf_mult(gcm->H, I, T); | |
51 #endif | |
52 XMEMCPY(I, T, 16); | |
53 } | |
54 #endif | |
55 | |
56 /* $Source: /cvs/libtom/libtomcrypt/src/encauth/gcm/gcm_mult_h.c,v $ */ | |
57 /* $Revision: 1.4 $ */ | |
58 /* $Date: 2006/08/23 20:40:23 $ */ |