aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/tls_aesgcm.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/networking/tls_aesgcm.c b/networking/tls_aesgcm.c
index 008dc9b5d..a4663cd79 100644
--- a/networking/tls_aesgcm.c
+++ b/networking/tls_aesgcm.c
@@ -97,25 +97,25 @@ static void RIGHTSHIFTX(byte* x)
97#undef l 97#undef l
98} 98}
99 99
100// Caller guarantees X is aligned
100static void GMULT(byte* X, byte* Y) 101static void GMULT(byte* X, byte* Y)
101{ 102{
102 byte Z[AES_BLOCK_SIZE] ALIGNED_long; 103 byte Z[AES_BLOCK_SIZE] ALIGNED_long;
103 byte V[AES_BLOCK_SIZE] ALIGNED_long; 104 //byte V[AES_BLOCK_SIZE] ALIGNED_long;
104 int i, j; 105 int i;
105 106
106 XMEMSET(Z, 0, AES_BLOCK_SIZE); 107 XMEMSET(Z, 0, AES_BLOCK_SIZE);
107 XMEMCPY(V, X, AES_BLOCK_SIZE); 108 //XMEMCPY(V, X, AES_BLOCK_SIZE);
108 for (i = 0; i < AES_BLOCK_SIZE; i++) 109 for (i = 0; i < AES_BLOCK_SIZE; i++) {
109 { 110 uint32_t y = 0x800000 | Y[i];
110 byte y = Y[i]; 111 for (;;) { // for every bit in Y[i], from msb to lsb
111 for (j = 0; j < 8; j++)
112 {
113 if (y & 0x80) { 112 if (y & 0x80) {
114 xorbuf_aligned_AES_BLOCK_SIZE(Z, V); 113 xorbuf_aligned_AES_BLOCK_SIZE(Z, X); // was V, not X
115 } 114 }
116 115 RIGHTSHIFTX(X); // was V, not X
117 RIGHTSHIFTX(V);
118 y = y << 1; 116 y = y << 1;
117 if ((int32_t)y < 0) // if bit 0x80000000 set = if 8 iterations done
118 break;
119 } 119 }
120 } 120 }
121 XMEMCPY(X, Z, AES_BLOCK_SIZE); 121 XMEMCPY(X, Z, AES_BLOCK_SIZE);