From dcd1700591c767d997c903eba3f3953d562bf23a Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 12 Mar 2025 14:13:41 +0000 Subject: Provide an accelerated SHA-512 assembly implementation for aarch64. This provides a SHA-512 assembly implementation that makes use of the ARM Cryptographic Extension (CE), which is found on many arm64 CPUs. This gives a performance gain of up to 2.5x on an Apple M2 (dependent on block size). If an aarch64 machine does not have SHA512 support, then we'll fall back to using the existing C implementation. ok kettenis@ tb@ --- src/lib/libcrypto/arch/aarch64/Makefile.inc | 4 +++- src/lib/libcrypto/arch/aarch64/crypto_arch.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/lib/libcrypto/arch') diff --git a/src/lib/libcrypto/arch/aarch64/Makefile.inc b/src/lib/libcrypto/arch/aarch64/Makefile.inc index 41198b069f..d93cb815ef 100644 --- a/src/lib/libcrypto/arch/aarch64/Makefile.inc +++ b/src/lib/libcrypto/arch/aarch64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.15 2025/03/07 14:21:22 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.16 2025/03/12 14:13:41 jsing Exp $ # aarch64-specific libcrypto build rules @@ -6,5 +6,7 @@ SRCS += crypto_cpu_caps.c SRCS += sha256_aarch64.c SRCS += sha256_aarch64_ce.S +SRCS += sha512_aarch64.c +SRCS += sha512_aarch64_ce.S AFLAGS+= -mmark-bti-property diff --git a/src/lib/libcrypto/arch/aarch64/crypto_arch.h b/src/lib/libcrypto/arch/aarch64/crypto_arch.h index adc91cd19f..35ecba9394 100644 --- a/src/lib/libcrypto/arch/aarch64/crypto_arch.h +++ b/src/lib/libcrypto/arch/aarch64/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.3 2025/03/07 14:21:22 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.4 2025/03/12 14:13:41 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -34,7 +34,10 @@ extern uint64_t crypto_cpu_caps_aarch64; #define CRYPTO_CPU_CAPS_AARCH64_SHA3 (1ULL << 5) #ifndef OPENSSL_NO_ASM + #define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_DATA_ORDER + #endif #endif -- cgit v1.2.3-55-g6feb