Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/encauth/gcm/gcm_mult_h.c
5972 views
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
10
/**
11
@file gcm_mult_h.c
12
GCM implementation, do the GF mult, by Tom St Denis
13
*/
14
#include "tomcrypt.h"
15
16
#if defined(LTC_GCM_MODE)
17
/**
18
GCM multiply by H
19
@param gcm The GCM state which holds the H value
20
@param I The value to multiply H by
21
*/
22
void gcm_mult_h(gcm_state *gcm, unsigned char *I)
23
{
24
unsigned char T[16];
25
#ifdef LTC_GCM_TABLES
26
int x;
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]));
31
}
32
asm("movdqa %%xmm0,(%0)"::"r"(&T));
33
#else
34
int y;
35
XMEMCPY(T, &gcm->PC[0][I[0]][0], 16);
36
for (x = 1; x < 16; x++) {
37
#ifdef LTC_FAST
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]));
40
}
41
#else
42
for (y = 0; y < 16; y++) {
43
T[y] ^= gcm->PC[x][I[x]][y];
44
}
45
#endif /* LTC_FAST */
46
}
47
#endif /* LTC_GCM_TABLES_SSE2 */
48
#else
49
gcm_gf_mult(gcm->H, I, T);
50
#endif
51
XMEMCPY(I, T, 16);
52
}
53
#endif
54
55