summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha/sha1_amd64.c
diff options
context:
space:
mode:
authorjsing <>2024-12-04 13:13:33 +0000
committerjsing <>2024-12-04 13:13:33 +0000
commit2de3ee8c5940ebad54feb4303f6fc816daca784b (patch)
tree6adf1634c082704fca00fea488f843d1345662b2 /src/lib/libcrypto/sha/sha1_amd64.c
parent703bddb95d0d05878d0df6fcb67913f30f9dfabe (diff)
downloadopenbsd-2de3ee8c5940ebad54feb4303f6fc816daca784b.tar.gz
openbsd-2de3ee8c5940ebad54feb4303f6fc816daca784b.tar.bz2
openbsd-2de3ee8c5940ebad54feb4303f6fc816daca784b.zip
Provide a replacement assembly implementation for SHA-1 on amd64.
As already done for SHA-256 and SHA-512, replace the perlasm generated SHA-1 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. On a modern CPU the performance is around 5% faster than the base implementation generated by sha1-x86_64.pl, however it is around 15% slower than the excessively complex SSSE2/AVX version that is also generated by the same script (a SHA-NI version will greatly outperform this and is much cleaner/simpler). ok tb@
Diffstat (limited to 'src/lib/libcrypto/sha/sha1_amd64.c')
-rw-r--r--src/lib/libcrypto/sha/sha1_amd64.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/libcrypto/sha/sha1_amd64.c b/src/lib/libcrypto/sha/sha1_amd64.c
new file mode 100644
index 0000000000..b3d4ab1263
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha1_amd64.c
@@ -0,0 +1,28 @@
1/* $OpenBSD: sha1_amd64.c,v 1.1 2024/12/04 13:13:33 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
20#include "crypto_arch.h"
21
22void sha1_block_generic(SHA_CTX *ctx, const void *in, size_t num);
23
24void
25sha1_block_data_order(SHA_CTX *ctx, const void *in, size_t num)
26{
27 sha1_block_generic(ctx, in, num);
28}