1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
12 GCM implementation, do the GF mult, by Tom St Denis
16 #if defined(LTC_GCM_MODE)
19 @param gcm The GCM state which holds the H value
20 @param I The value to multiply H by
22 void gcm_mult_h(gcm_state *gcm, unsigned char *I)
27 #ifdef LTC_GCM_TABLES_SSE2
28 asm("movdqa (%0),%%xmm0"::"r"(&gcm->PC[0][I[0]][0]));
29 for (x = 1; x < 16; x++) {
30 asm("pxor (%0),%%xmm0"::"r"(&gcm->PC[x][I[x]][0]));
32 asm("movdqa %%xmm0,(%0)"::"r"(&T));
35 XMEMCPY(T, &gcm->PC[0][I[0]][0], 16);
36 for (x = 1; x < 16; x++) {
38 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
39 *(LTC_FAST_TYPE_PTR_CAST(T + y)) ^= *(LTC_FAST_TYPE_PTR_CAST(&gcm->PC[x][I[x]][y]));
42 for (y = 0; y < 16; y++) {
43 T[y] ^= gcm->PC[x][I[x]][y];
47 #endif /* LTC_GCM_TABLES_SSE2 */
49 gcm_gf_mult(gcm->H, I, T);
55 /* ref: $Format:%D$ */
56 /* git commit: $Format:%H$ */
57 /* commit time: $Format:%ai$ */