Mercurial > dropbear
comparison src/encauth/gcm/gcm_mult_h.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
280:59400faa4b44 | 380:d5faf4814ddb |
---|---|
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 $ */ |