summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/arch/amd64
diff options
context:
space:
mode:
authorjsing <>2026-01-17 16:18:32 +0000
committerjsing <>2026-01-17 16:18:32 +0000
commit03fc8f9b9ecbb65326348dd8eccc5d22344abefe (patch)
tree304533a0e18e53486c5458ff9c69099a939484be /src/lib/libcrypto/arch/amd64
parentfdea186c25361674646de3b0a16b3ad37c8f0ec3 (diff)
downloadopenbsd-03fc8f9b9ecbb65326348dd8eccc5d22344abefe.tar.gz
openbsd-03fc8f9b9ecbb65326348dd8eccc5d22344abefe.tar.bz2
openbsd-03fc8f9b9ecbb65326348dd8eccc5d22344abefe.zip
Provide LIBRESSL_USE_.*_ASSEMBLY defines.
Make life easier for portable by providing LIBRESSL_USE_.*_ASSEMBLY defines, which enable/disable assembly for a specific algorithm. This means that selected platforms can include the assembly files and specify a define, rather than having to try to patch the crypto_arch.h headers. Discussed with tb@
Diffstat (limited to 'src/lib/libcrypto/arch/amd64')
-rw-r--r--src/lib/libcrypto/arch/amd64/Makefile.inc9
-rw-r--r--src/lib/libcrypto/arch/amd64/crypto_arch.h15
2 files changed, 18 insertions, 6 deletions
diff --git a/src/lib/libcrypto/arch/amd64/Makefile.inc b/src/lib/libcrypto/arch/amd64/Makefile.inc
index 8f1681322d..ea03944273 100644
--- a/src/lib/libcrypto/arch/amd64/Makefile.inc
+++ b/src/lib/libcrypto/arch/amd64/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.45 2026/01/17 14:53:09 jsing Exp $ 1# $OpenBSD: Makefile.inc,v 1.46 2026/01/17 16:18:32 jsing Exp $
2 2
3# amd64-specific libcrypto build rules 3# amd64-specific libcrypto build rules
4 4
@@ -8,6 +8,7 @@ EXTRA_PL = ${LCRYPTO_SRC}/perlasm/x86_64-xlate.pl
8SRCS += crypto_cpu_caps.c 8SRCS += crypto_cpu_caps.c
9 9
10# aes 10# aes
11CFLAGS+= -DLIBRESSL_USE_AES_ASSEMBLY
11SSLASM+= aes aes-x86_64 12SSLASM+= aes aes-x86_64
12SSLASM+= aes aesni-x86_64 13SSLASM+= aes aesni-x86_64
13SRCS += aes_amd64.c 14SRCS += aes_amd64.c
@@ -20,6 +21,7 @@ CFLAGS+= -DOPENSSL_BN_ASM_MONT5
20SSLASM+= bn x86_64-mont5 21SSLASM+= bn x86_64-mont5
21 22
22# bn s2n-bignum 23# bn s2n-bignum
24CFLAGS+= -DLIBRESSL_USE_BN_ASSEMBLY
23SRCS += bn_arch.c 25SRCS += bn_arch.c
24SRCS += bignum_add.S 26SRCS += bignum_add.S
25SRCS += bignum_cmadd.S 27SRCS += bignum_cmadd.S
@@ -44,17 +46,20 @@ SRCS += bignum_sub.S
44SRCS += word_clz.S 46SRCS += word_clz.S
45 47
46# md5 48# md5
49CFLAGS+= -DLIBRESSL_USE_MD5_ASSEMBLY
47SRCS+= md5_amd64_generic.S 50SRCS+= md5_amd64_generic.S
48 51
49# modes 52# modes
53CFLAGS+= -DLIBRESSL_USE_GCM_ASSEMBLY
50SSLASM+= modes ghash-x86_64 54SSLASM+= modes ghash-x86_64
51SRCS += gcm128_amd64.c 55SRCS += gcm128_amd64.c
52 56
53# rc4 57# rc4
58CFLAGS+= -DLIBRESSL_USE_RC4_ASSEMBLY
54SSLASM+= rc4 rc4-x86_64 59SSLASM+= rc4 rc4-x86_64
55 60
56# ripemd
57# sha 61# sha
62CFLAGS+= -DLIBRESSL_USE_SHA_ASSEMBLY
58SRCS+= sha1_amd64.c 63SRCS+= sha1_amd64.c
59SRCS+= sha1_amd64_generic.S 64SRCS+= sha1_amd64_generic.S
60SRCS+= sha1_amd64_shani.S 65SRCS+= sha1_amd64_shani.S
diff --git a/src/lib/libcrypto/arch/amd64/crypto_arch.h b/src/lib/libcrypto/arch/amd64/crypto_arch.h
index 411deb0e5d..09f771b6c6 100644
--- a/src/lib/libcrypto/arch/amd64/crypto_arch.h
+++ b/src/lib/libcrypto/arch/amd64/crypto_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: crypto_arch.h,v 1.17 2026/01/17 14:53:09 jsing Exp $ */ 1/* $OpenBSD: crypto_arch.h,v 1.18 2026/01/17 16:18:32 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -33,11 +33,11 @@ extern uint64_t crypto_cpu_caps_amd64;
33 33
34#ifndef OPENSSL_NO_ASM 34#ifndef OPENSSL_NO_ASM
35 35
36#ifdef LIBRESSL_USE_AES_ASSEMBLY
36#define HAVE_AES_SET_ENCRYPT_KEY_GENERIC 37#define HAVE_AES_SET_ENCRYPT_KEY_GENERIC
37#define HAVE_AES_SET_DECRYPT_KEY_GENERIC 38#define HAVE_AES_SET_DECRYPT_KEY_GENERIC
38#define HAVE_AES_ENCRYPT_GENERIC 39#define HAVE_AES_ENCRYPT_GENERIC
39#define HAVE_AES_DECRYPT_GENERIC 40#define HAVE_AES_DECRYPT_GENERIC
40
41#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL 41#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL
42#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL 42#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL
43#define HAVE_AES_ENCRYPT_INTERNAL 43#define HAVE_AES_ENCRYPT_INTERNAL
@@ -47,24 +47,31 @@ extern uint64_t crypto_cpu_caps_amd64;
47#define HAVE_AES_CTR32_ENCRYPT_INTERNAL 47#define HAVE_AES_CTR32_ENCRYPT_INTERNAL
48#define HAVE_AES_ECB_ENCRYPT_INTERNAL 48#define HAVE_AES_ECB_ENCRYPT_INTERNAL
49#define HAVE_AES_XTS_ENCRYPT_INTERNAL 49#define HAVE_AES_XTS_ENCRYPT_INTERNAL
50#endif
50 51
52#ifdef LIBRESSL_USE_GCM_ASSEMBLY
51#define HAVE_GCM128_INIT 53#define HAVE_GCM128_INIT
52#define HAVE_GCM_GHASH_4BIT 54#define HAVE_GCM_GHASH_4BIT
53#define HAVE_GCM_GMULT_4BIT 55#define HAVE_GCM_GMULT_4BIT
56#endif
54 57
58#ifdef LIBRESSL_USE_MD5_ASSEMBLY
55#define HAVE_MD5_BLOCK_DATA_ORDER 59#define HAVE_MD5_BLOCK_DATA_ORDER
60#endif
56 61
62#ifdef LIBRESSL_USE_RC4_ASSEMBLY
57#define HAVE_RC4_INTERNAL 63#define HAVE_RC4_INTERNAL
58#define HAVE_RC4_SET_KEY_INTERNAL 64#define HAVE_RC4_SET_KEY_INTERNAL
65#endif
59 66
67#ifdef LIBRESSL_USE_SHA_ASSEMBLY
60#define HAVE_SHA1_BLOCK_DATA_ORDER 68#define HAVE_SHA1_BLOCK_DATA_ORDER
61#define HAVE_SHA1_BLOCK_GENERIC 69#define HAVE_SHA1_BLOCK_GENERIC
62
63#define HAVE_SHA256_BLOCK_DATA_ORDER 70#define HAVE_SHA256_BLOCK_DATA_ORDER
64#define HAVE_SHA256_BLOCK_GENERIC 71#define HAVE_SHA256_BLOCK_GENERIC
65
66#define HAVE_SHA512_BLOCK_DATA_ORDER 72#define HAVE_SHA512_BLOCK_DATA_ORDER
67#define HAVE_SHA512_BLOCK_GENERIC 73#define HAVE_SHA512_BLOCK_GENERIC
74#endif
68 75
69#endif 76#endif
70 77