summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/modes/gcm128.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/modes/gcm128.c')
-rw-r--r--src/lib/libcrypto/modes/gcm128.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/lib/libcrypto/modes/gcm128.c b/src/lib/libcrypto/modes/gcm128.c
index 5eb616cef7..334e592aa5 100644
--- a/src/lib/libcrypto/modes/gcm128.c
+++ b/src/lib/libcrypto/modes/gcm128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: gcm128.c,v 1.37 2025/05/17 14:43:17 jsing Exp $ */ 1/* $OpenBSD: gcm128.c,v 1.38 2025/05/18 07:13:48 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2010 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -56,24 +56,13 @@
56#include "modes_local.h" 56#include "modes_local.h"
57 57
58#define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16)) 58#define PACK(s) ((size_t)(s)<<(sizeof(size_t)*8-16))
59#define REDUCE1BIT(V) \
60 do { \
61 if (sizeof(size_t)==8) { \
62 u64 T = U64(0xe100000000000000) & (0-(V.lo&1)); \
63 V.lo = (V.hi<<63)|(V.lo>>1); \
64 V.hi = (V.hi>>1 )^T; \
65 } else { \
66 u32 T = 0xe1000000U & (0-(u32)(V.lo&1)); \
67 V.lo = (V.hi<<63)|(V.lo>>1); \
68 V.hi = (V.hi>>1 )^((u64)T<<32); \
69 } \
70 } while(0)
71 59
72static void 60static void
73gcm_init_4bit(u128 Htable[16], u64 H[2]) 61gcm_init_4bit(u128 Htable[16], u64 H[2])
74{ 62{
75 u128 V; 63 u128 V;
76 int i; 64 u64 T;
65 int i;
77 66
78 Htable[0].hi = 0; 67 Htable[0].hi = 0;
79 Htable[0].lo = 0; 68 Htable[0].lo = 0;
@@ -81,7 +70,9 @@ gcm_init_4bit(u128 Htable[16], u64 H[2])
81 V.lo = H[1]; 70 V.lo = H[1];
82 71
83 for (Htable[8] = V, i = 4; i > 0; i >>= 1) { 72 for (Htable[8] = V, i = 4; i > 0; i >>= 1) {
84 REDUCE1BIT(V); 73 T = U64(0xe100000000000000) & (0 - (V.lo & 1));
74 V.lo = (V.hi << 63) | (V.lo >> 1);
75 V.hi = (V.hi >> 1 ) ^ T;
85 Htable[i] = V; 76 Htable[i] = V;
86 } 77 }
87 78