summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha/sha256_amd64.c
diff options
context:
space:
mode:
authorjsing <>2024-11-08 15:09:48 +0000
committerjsing <>2024-11-08 15:09:48 +0000
commit487da616d8ed3fd6ad6c30584c6405c6979ede11 (patch)
tree84d6d8d2658114716d976529462bcebc29b879ca /src/lib/libcrypto/sha/sha256_amd64.c
parentacc652186bbeb9458b641b1bffef14c7599bf465 (diff)
downloadopenbsd-487da616d8ed3fd6ad6c30584c6405c6979ede11.tar.gz
openbsd-487da616d8ed3fd6ad6c30584c6405c6979ede11.tar.bz2
openbsd-487da616d8ed3fd6ad6c30584c6405c6979ede11.zip
Provide a replacement assembly implementation for SHA-256 on amd64.
Replace the perlasm generated SHA-256 assembly implementation with one that is actually readable. Call the assembly implementation from a C wrapper that can, in the future, dispatch to alternate implementations. Performance is similar (or even better) on modern CPUs, while somewhat slower on older CPUs (this is in part due to the wrapper, the impact of which is more noticable with small block sizes). Thanks to gkoehler@ and tb@ for testing. ok tb@
Diffstat (limited to 'src/lib/libcrypto/sha/sha256_amd64.c')
-rw-r--r--src/lib/libcrypto/sha/sha256_amd64.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sha/sha256_amd64.c b/src/lib/libcrypto/sha/sha256_amd64.c
new file mode 100644
index 0000000000..f7531b340f
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha256_amd64.c
@@ -0,0 +1,26 @@
1/* $OpenBSD: sha256_amd64.c,v 1.1 2024/11/08 15:09:48 jsing Exp $ */
2/*
3 * Copyright (c) 2024 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 <openssl/sha.h>
19
20void sha256_block_generic(SHA256_CTX *ctx, const void *in, size_t num);
21
22void
23sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num)
24{
25 sha256_block_generic(ctx, in, num);
26}