comparison libtomcrypt/src/encauth/gcm/gcm_mult_h.c @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
3 * LibTomCrypt is a library that provides various cryptographic 3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 *
9 * Tom St Denis, [email protected], http://libtom.org
10 */ 8 */
11 9
12 /** 10 /**
13 @file gcm_mult_h.c 11 @file gcm_mult_h.c
14 GCM implementation, do the GF mult, by Tom St Denis 12 GCM implementation, do the GF mult, by Tom St Denis
23 */ 21 */
24 void gcm_mult_h(gcm_state *gcm, unsigned char *I) 22 void gcm_mult_h(gcm_state *gcm, unsigned char *I)
25 { 23 {
26 unsigned char T[16]; 24 unsigned char T[16];
27 #ifdef LTC_GCM_TABLES 25 #ifdef LTC_GCM_TABLES
28 int x, y; 26 int x;
29 #ifdef LTC_GCM_TABLES_SSE2 27 #ifdef LTC_GCM_TABLES_SSE2
30 asm("movdqa (%0),%%xmm0"::"r"(&gcm->PC[0][I[0]][0])); 28 asm("movdqa (%0),%%xmm0"::"r"(&gcm->PC[0][I[0]][0]));
31 for (x = 1; x < 16; x++) { 29 for (x = 1; x < 16; x++) {
32 asm("pxor (%0),%%xmm0"::"r"(&gcm->PC[x][I[x]][0])); 30 asm("pxor (%0),%%xmm0"::"r"(&gcm->PC[x][I[x]][0]));
33 } 31 }
34 asm("movdqa %%xmm0,(%0)"::"r"(&T)); 32 asm("movdqa %%xmm0,(%0)"::"r"(&T));
35 #else 33 #else
34 int y;
36 XMEMCPY(T, &gcm->PC[0][I[0]][0], 16); 35 XMEMCPY(T, &gcm->PC[0][I[0]][0], 16);
37 for (x = 1; x < 16; x++) { 36 for (x = 1; x < 16; x++) {
38 #ifdef LTC_FAST 37 #ifdef LTC_FAST
39 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { 38 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])); 39 *(LTC_FAST_TYPE_PTR_CAST(T + y)) ^= *(LTC_FAST_TYPE_PTR_CAST(&gcm->PC[x][I[x]][y]));
41 } 40 }
42 #else 41 #else
43 for (y = 0; y < 16; y++) { 42 for (y = 0; y < 16; y++) {
44 T[y] ^= gcm->PC[x][I[x]][y]; 43 T[y] ^= gcm->PC[x][I[x]][y];
45 } 44 }
46 #endif /* LTC_FAST */ 45 #endif /* LTC_FAST */
47 } 46 }
48 #endif /* LTC_GCM_TABLES_SSE2 */ 47 #endif /* LTC_GCM_TABLES_SSE2 */
49 #else 48 #else
50 gcm_gf_mult(gcm->H, I, T); 49 gcm_gf_mult(gcm->H, I, T);
51 #endif 50 #endif
52 XMEMCPY(I, T, 16); 51 XMEMCPY(I, T, 16);
53 } 52 }
54 #endif 53 #endif
55 54
56 /* $Source$ */ 55 /* ref: $Format:%D$ */
57 /* $Revision$ */ 56 /* git commit: $Format:%H$ */
58 /* $Date$ */ 57 /* commit time: $Format:%ai$ */