diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/modes/gcm128_amd64.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/lib/libcrypto/modes/gcm128_amd64.c b/src/lib/libcrypto/modes/gcm128_amd64.c new file mode 100644 index 0000000000..eaa66fb32f --- /dev/null +++ b/src/lib/libcrypto/modes/gcm128_amd64.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* $OpenBSD: gcm128_amd64.c,v 1.1 2025/06/28 12:39:10 jsing Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2025 Joel Sing <jsing@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include "crypto_arch.h" | ||
19 | #include "modes_local.h" | ||
20 | |||
21 | void gcm_init_4bit(u128 Htable[16], uint64_t H[2]); | ||
22 | void gcm_gmult_4bit(uint64_t Xi[2], const u128 Htable[16]); | ||
23 | void gcm_ghash_4bit(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, | ||
24 | size_t len); | ||
25 | |||
26 | void gcm_init_clmul(u128 Htable[16], const uint64_t Xi[2]); | ||
27 | void gcm_gmult_clmul(uint64_t Xi[2], const u128 Htable[16]); | ||
28 | void gcm_ghash_clmul(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, | ||
29 | size_t len); | ||
30 | |||
31 | void | ||
32 | gcm128_init(GCM128_CONTEXT *ctx) | ||
33 | { | ||
34 | if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_CLMUL) != 0) { | ||
35 | gcm_init_clmul(ctx->Htable, ctx->H.u); | ||
36 | ctx->gmult = gcm_gmult_clmul; | ||
37 | ctx->ghash = gcm_ghash_clmul; | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | gcm_init_4bit(ctx->Htable, ctx->H.u); | ||
42 | ctx->gmult = gcm_gmult_4bit; | ||
43 | ctx->ghash = gcm_ghash_4bit; | ||
44 | } | ||