diff options
| author | jsing <> | 2024-12-06 11:57:18 +0000 |
|---|---|---|
| committer | jsing <> | 2024-12-06 11:57:18 +0000 |
| commit | 52aaf400e5a619fcab8ae52524e5aaf96e0b0894 (patch) | |
| tree | 4ddefe0cdee0b51074793a8db7ee53de07047a32 /src/lib/libcrypto/sha/sha1_amd64.c | |
| parent | 93ae38e3094b6e0813460de549534a0aab74875c (diff) | |
| download | openbsd-52aaf400e5a619fcab8ae52524e5aaf96e0b0894.tar.gz openbsd-52aaf400e5a619fcab8ae52524e5aaf96e0b0894.tar.bz2 openbsd-52aaf400e5a619fcab8ae52524e5aaf96e0b0894.zip | |
Provide a SHA-1 assembly implementation for amd64 using SHA-NI.
This provides a SHA-1 assembly implementation for amd64, which uses
the Intel SHA Extensions (aka SHA New Instructions or SHA-NI). This
provides a 2-2.5x performance gain on some Intel CPUs and many AMD CPUs.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/sha/sha1_amd64.c')
| -rw-r--r-- | src/lib/libcrypto/sha/sha1_amd64.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libcrypto/sha/sha1_amd64.c b/src/lib/libcrypto/sha/sha1_amd64.c index b3d4ab1263..2976cc7e6e 100644 --- a/src/lib/libcrypto/sha/sha1_amd64.c +++ b/src/lib/libcrypto/sha/sha1_amd64.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: sha1_amd64.c,v 1.1 2024/12/04 13:13:33 jsing Exp $ */ | 1 | /* $OpenBSD: sha1_amd64.c,v 1.2 2024/12/06 11:57:18 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -20,9 +20,15 @@ | |||
| 20 | #include "crypto_arch.h" | 20 | #include "crypto_arch.h" |
| 21 | 21 | ||
| 22 | void sha1_block_generic(SHA_CTX *ctx, const void *in, size_t num); | 22 | void sha1_block_generic(SHA_CTX *ctx, const void *in, size_t num); |
| 23 | void sha1_block_shani(SHA_CTX *ctx, const void *in, size_t num); | ||
| 23 | 24 | ||
| 24 | void | 25 | void |
| 25 | sha1_block_data_order(SHA_CTX *ctx, const void *in, size_t num) | 26 | sha1_block_data_order(SHA_CTX *ctx, const void *in, size_t num) |
| 26 | { | 27 | { |
| 28 | if ((crypto_cpu_caps_amd64 & CRYPTO_CPU_CAPS_AMD64_SHA) != 0) { | ||
| 29 | sha1_block_shani(ctx, in, num); | ||
| 30 | return; | ||
| 31 | } | ||
| 32 | |||
| 27 | sha1_block_generic(ctx, in, num); | 33 | sha1_block_generic(ctx, in, num); |
| 28 | } | 34 | } |
