diff options
author | jsing <> | 2025-06-28 12:32:27 +0000 |
---|---|---|
committer | jsing <> | 2025-06-28 12:32:27 +0000 |
commit | 5e7b2abaf553d1159c6b708b34998bddf2938170 (patch) | |
tree | 6278166b8c72b3f24a8004c70a10f418e7df14a1 /src | |
parent | 39b5277747ebc43b679dbee5c3dd1c3c75df3b75 (diff) | |
download | openbsd-5e7b2abaf553d1159c6b708b34998bddf2938170.tar.gz openbsd-5e7b2abaf553d1159c6b708b34998bddf2938170.tar.bz2 openbsd-5e7b2abaf553d1159c6b708b34998bddf2938170.zip |
Use a single implementation of gcm_mul()/gcm_ghash().
Since we always initialise the gmult/ghash function pointers, use the same
implementaion of gcm_mul() and gcm_ghash(), regardless of the actual
underlying implementation.
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/modes/gcm128.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/lib/libcrypto/modes/gcm128.c b/src/lib/libcrypto/modes/gcm128.c index 2f9510e2b6..b989915c4a 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.52 2025/06/28 12:25:22 jsing Exp $ */ | 1 | /* $OpenBSD: gcm128.c,v 1.53 2025/06/28 12:32:27 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 | * |
@@ -84,7 +84,12 @@ gcm_init_4bit(u128 Htable[16], uint64_t H[2]) | |||
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | #ifndef GHASH_ASM | 87 | #ifdef GHASH_ASM |
88 | void gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16]); | ||
89 | void gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, | ||
90 | size_t len); | ||
91 | |||
92 | #else | ||
88 | static const uint16_t rem_4bit[16] = { | 93 | static const uint16_t rem_4bit[16] = { |
89 | 0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0, | 94 | 0x0000, 0x1c20, 0x3840, 0x2460, 0x7080, 0x6ca0, 0x48c0, 0x54e0, |
90 | 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0, | 95 | 0xe100, 0xfd20, 0xd940, 0xc560, 0x9180, 0x8da0, 0xa9c0, 0xb5e0, |
@@ -177,22 +182,7 @@ gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], | |||
177 | Xi[1] = htobe64(Z.lo); | 182 | Xi[1] = htobe64(Z.lo); |
178 | } while (inp += 16, len -= 16); | 183 | } while (inp += 16, len -= 16); |
179 | } | 184 | } |
180 | 185 | #endif | |
181 | static inline void | ||
182 | gcm_mul(GCM128_CONTEXT *ctx, uint64_t u[2]) | ||
183 | { | ||
184 | gcm_gmult_4bit(u, ctx->Htable); | ||
185 | } | ||
186 | |||
187 | static inline void | ||
188 | gcm_ghash(GCM128_CONTEXT *ctx, const uint8_t *in, size_t len) | ||
189 | { | ||
190 | gcm_ghash_4bit(ctx->Xi.u, ctx->Htable, in, len); | ||
191 | } | ||
192 | #else | ||
193 | void gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16]); | ||
194 | void gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, | ||
195 | size_t len); | ||
196 | 186 | ||
197 | static inline void | 187 | static inline void |
198 | gcm_mul(GCM128_CONTEXT *ctx, uint64_t u[2]) | 188 | gcm_mul(GCM128_CONTEXT *ctx, uint64_t u[2]) |
@@ -205,7 +195,6 @@ gcm_ghash(GCM128_CONTEXT *ctx, const uint8_t *in, size_t len) | |||
205 | { | 195 | { |
206 | ctx->ghash(ctx->Xi.u, ctx->Htable, in, len); | 196 | ctx->ghash(ctx->Xi.u, ctx->Htable, in, len); |
207 | } | 197 | } |
208 | #endif | ||
209 | 198 | ||
210 | #if defined(GHASH_ASM) && \ | 199 | #if defined(GHASH_ASM) && \ |
211 | (defined(__i386) || defined(__i386__) || \ | 200 | (defined(__i386) || defined(__i386__) || \ |