aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--crypto/CMakeLists.txt262
-rw-r--r--crypto/Makefile.am170
-rw-r--r--crypto/Makefile.am.elf-arm21
-rw-r--r--crypto/Makefile.am.elf-mips3
-rw-r--r--crypto/Makefile.am.elf-mips643
-rw-r--r--crypto/Makefile.am.elf-x86_6423
-rw-r--r--crypto/Makefile.am.macosx-x86_6423
-rw-r--r--crypto/Makefile.am.masm-x86_6421
-rw-r--r--crypto/Makefile.am.mingw64-x86_6421
-rw-r--r--crypto/arch/aarch64/crypto_cpu_caps_darwin.c60
-rw-r--r--crypto/arch/aarch64/crypto_cpu_caps_linux.c62
-rw-r--r--crypto/arch/aarch64/crypto_cpu_caps_none.c26
-rw-r--r--crypto/arch/aarch64/crypto_cpu_caps_windows.c36
-rw-r--r--crypto/arch/loongarch64/crypto_arch.h21
-rw-r--r--crypto/arch/mips/crypto_arch.h21
-rw-r--r--crypto/bn/arch/loongarch64/bn_arch.h23
-rw-r--r--crypto/compat/.gitignore31
-rw-r--r--crypto/compat/b_win.c5
-rw-r--r--crypto/compat/getdelim.c78
-rw-r--r--crypto/compat/getline.c40
-rw-r--r--crypto/compat/posix_win.c91
-rw-r--r--crypto/compat/ui_openssl_win.c4
22 files changed, 665 insertions, 380 deletions
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index 5ee20ff..047c228 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -1,45 +1,34 @@
1add_definitions(-DLIBRESSL_CRYPTO_INTERNAL) 1#
2# Copyright (c) 2014 Brent Cook
3#
4# Permission to use, copy, modify, and distribute this software for any
5# purpose with or without fee is hereby granted, provided that the above
6# copyright notice and this permission notice appear in all copies.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2 15
3if(HOST_ASM_ELF_ARMV4) 16add_definitions(-DLIBRESSL_CRYPTO_INTERNAL)
4 set(
5 ASM_ARMV4_ELF_SRC
6 aes/aes-elf-armv4.S
7 bn/mont-elf-armv4.S
8 sha/sha1-elf-armv4.S
9 sha/sha512-elf-armv4.S
10 sha/sha256-elf-armv4.S
11 modes/ghash-elf-armv4.S
12 armv4cpuid.S
13 armcap.c
14 )
15 add_definitions(-DAES_ASM)
16 add_definitions(-DOPENSSL_BN_ASM_MONT)
17 add_definitions(-DGHASH_ASM)
18 add_definitions(-DSHA1_ASM)
19 add_definitions(-DSHA256_ASM)
20 add_definitions(-DSHA512_ASM)
21 add_definitions(-DOPENSSL_CPUID_OBJ)
22 set_property(SOURCE ${ASM_ARMV4_ELF_SRC} PROPERTY LANGUAGE C)
23 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_ARMV4_ELF_SRC})
24endif()
25 17
26if(HOST_ASM_ELF_X86_64) 18if(HOST_ASM_ELF_X86_64)
19 set(CRYPTO_SRC ${CRYPTO_SRC} aes/aes_amd64.c)
20 set(CRYPTO_SRC ${CRYPTO_SRC} bn/arch/amd64/bn_arch.c)
21 set(CRYPTO_SRC ${CRYPTO_SRC} modes/gcm128_amd64.c)
22
27 set( 23 set(
28 ASM_X86_64_ELF_SRC 24 ASM_X86_64_ELF_SRC
29 aes/aes-elf-x86_64.S 25 aes/aes-elf-x86_64.S
30 aes/bsaes-elf-x86_64.S
31 aes/vpaes-elf-x86_64.S
32 aes/aesni-elf-x86_64.S 26 aes/aesni-elf-x86_64.S
33 bn/modexp512-elf-x86_64.S 27 bn/modexp512-elf-x86_64.S
34 bn/mont-elf-x86_64.S 28 bn/mont-elf-x86_64.S
35 bn/mont5-elf-x86_64.S 29 bn/mont5-elf-x86_64.S
36 md5/md5-elf-x86_64.S
37 modes/ghash-elf-x86_64.S 30 modes/ghash-elf-x86_64.S
38 rc4/rc4-elf-x86_64.S 31 rc4/rc4-elf-x86_64.S
39 sha/sha1-elf-x86_64.S
40 sha/sha256-elf-x86_64.S
41 sha/sha512-elf-x86_64.S
42 cpuid-elf-x86_64.S
43 32
44 bn/arch/amd64/bignum_add.S 33 bn/arch/amd64/bignum_add.S
45 bn/arch/amd64/bignum_cmadd.S 34 bn/arch/amd64/bignum_cmadd.S
@@ -52,48 +41,32 @@ if(HOST_ASM_ELF_X86_64)
52 bn/arch/amd64/bignum_sqr_8_16_alt.S 41 bn/arch/amd64/bignum_sqr_8_16_alt.S
53 bn/arch/amd64/bignum_sub.S 42 bn/arch/amd64/bignum_sub.S
54 bn/arch/amd64/word_clz.S 43 bn/arch/amd64/word_clz.S
55 bn/arch/amd64/bn_arch.c
56 ) 44 )
57 add_definitions(-DAES_ASM) 45 add_definitions(-DAES_ASM)
58 add_definitions(-DBSAES_ASM) 46 add_definitions(-DBSAES_ASM)
59 add_definitions(-DVPAES_ASM) 47 add_definitions(-DVPAES_ASM)
60 add_definitions(-DHAVE_AES_CBC_ENCRYPT_INTERNAL)
61 add_definitions(-DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL)
62 add_definitions(-DHAVE_AES_SET_DECRYPT_KEY_INTERNAL)
63 add_definitions(-DHAVE_AES_ENCRYPT_INTERNAL)
64 add_definitions(-DHAVE_AES_DECRYPT_INTERNAL)
65 add_definitions(-DOPENSSL_IA32_SSE2) 48 add_definitions(-DOPENSSL_IA32_SSE2)
66 add_definitions(-DOPENSSL_BN_ASM_MONT) 49 add_definitions(-DOPENSSL_BN_ASM_MONT)
67 add_definitions(-DOPENSSL_BN_ASM_MONT5) 50 add_definitions(-DOPENSSL_BN_ASM_MONT5)
68 add_definitions(-DMD5_ASM)
69 add_definitions(-DGHASH_ASM) 51 add_definitions(-DGHASH_ASM)
70 add_definitions(-DRSA_ASM) 52 add_definitions(-DRSA_ASM)
71 add_definitions(-DSHA1_ASM)
72 add_definitions(-DSHA256_ASM)
73 add_definitions(-DSHA512_ASM)
74 add_definitions(-DWHIRLPOOL_ASM)
75 add_definitions(-DOPENSSL_CPUID_OBJ)
76 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_ELF_SRC}) 53 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_ELF_SRC})
77 set_property(SOURCE ${ASM_X86_64_ELF_SRC} PROPERTY LANGUAGE C)
78endif() 54endif()
79 55
80if(HOST_ASM_MACOSX_X86_64) 56if(HOST_ASM_MACOSX_X86_64)
57 set(CRYPTO_SRC ${CRYPTO_SRC} aes/aes_amd64.c)
58 set(CRYPTO_SRC ${CRYPTO_SRC} bn/arch/amd64/bn_arch.c)
59 set(CRYPTO_SRC ${CRYPTO_SRC} modes/gcm128_amd64.c)
60
81 set( 61 set(
82 ASM_X86_64_MACOSX_SRC 62 ASM_X86_64_MACOSX_SRC
83 aes/aes-macosx-x86_64.S 63 aes/aes-macosx-x86_64.S
84 aes/bsaes-macosx-x86_64.S
85 aes/vpaes-macosx-x86_64.S
86 aes/aesni-macosx-x86_64.S 64 aes/aesni-macosx-x86_64.S
87 bn/modexp512-macosx-x86_64.S 65 bn/modexp512-macosx-x86_64.S
88 bn/mont-macosx-x86_64.S 66 bn/mont-macosx-x86_64.S
89 bn/mont5-macosx-x86_64.S 67 bn/mont5-macosx-x86_64.S
90 md5/md5-macosx-x86_64.S
91 modes/ghash-macosx-x86_64.S 68 modes/ghash-macosx-x86_64.S
92 rc4/rc4-macosx-x86_64.S 69 rc4/rc4-macosx-x86_64.S
93 sha/sha1-macosx-x86_64.S
94 sha/sha256-macosx-x86_64.S
95 sha/sha512-macosx-x86_64.S
96 cpuid-macosx-x86_64.S
97 70
98 bn/arch/amd64/bignum_add.S 71 bn/arch/amd64/bignum_add.S
99 bn/arch/amd64/bignum_cmadd.S 72 bn/arch/amd64/bignum_cmadd.S
@@ -106,131 +79,100 @@ if(HOST_ASM_MACOSX_X86_64)
106 bn/arch/amd64/bignum_sqr_8_16_alt.S 79 bn/arch/amd64/bignum_sqr_8_16_alt.S
107 bn/arch/amd64/bignum_sub.S 80 bn/arch/amd64/bignum_sub.S
108 bn/arch/amd64/word_clz.S 81 bn/arch/amd64/word_clz.S
109 bn/arch/amd64/bn_arch.c
110 ) 82 )
111 add_definitions(-DAES_ASM) 83 add_definitions(-DAES_ASM)
112 add_definitions(-DBSAES_ASM) 84 add_definitions(-DBSAES_ASM)
113 add_definitions(-DVPAES_ASM) 85 add_definitions(-DVPAES_ASM)
114 add_definitions(-DHAVE_AES_CBC_ENCRYPT_INTERNAL)
115 add_definitions(-DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL)
116 add_definitions(-DHAVE_AES_SET_DECRYPT_KEY_INTERNAL)
117 add_definitions(-DHAVE_AES_ENCRYPT_INTERNAL)
118 add_definitions(-DHAVE_AES_DECRYPT_INTERNAL)
119 add_definitions(-DOPENSSL_IA32_SSE2) 86 add_definitions(-DOPENSSL_IA32_SSE2)
120 add_definitions(-DOPENSSL_BN_ASM_MONT) 87 add_definitions(-DOPENSSL_BN_ASM_MONT)
121 add_definitions(-DOPENSSL_BN_ASM_MONT5) 88 add_definitions(-DOPENSSL_BN_ASM_MONT5)
122 add_definitions(-DMD5_ASM)
123 add_definitions(-DGHASH_ASM) 89 add_definitions(-DGHASH_ASM)
124 add_definitions(-DRSA_ASM) 90 add_definitions(-DRSA_ASM)
125 add_definitions(-DSHA1_ASM)
126 add_definitions(-DSHA256_ASM)
127 add_definitions(-DSHA512_ASM)
128 add_definitions(-DWHIRLPOOL_ASM)
129 add_definitions(-DOPENSSL_CPUID_OBJ)
130 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MACOSX_SRC}) 91 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MACOSX_SRC})
131 set_property(SOURCE ${ASM_X86_64_MACOSX_SRC} PROPERTY LANGUAGE C)
132 set_property(SOURCE ${ASM_X86_64_MACOSX_SRC} PROPERTY XCODE_EXPLICIT_FILE_TYPE "sourcecode.asm") 92 set_property(SOURCE ${ASM_X86_64_MACOSX_SRC} PROPERTY XCODE_EXPLICIT_FILE_TYPE "sourcecode.asm")
133endif() 93endif()
134 94
135if(HOST_ASM_MASM_X86_64) 95if(HOST_ASM_MASM_X86_64)
96 set(CRYPTO_SRC ${CRYPTO_SRC} aes/aes_amd64.c)
97 set(CRYPTO_SRC ${CRYPTO_SRC} modes/gcm128_amd64.c)
98
136 set( 99 set(
137 ASM_X86_64_MASM_SRC 100 ASM_X86_64_MASM_SRC
138 aes/aes-masm-x86_64.S 101 aes/aes-masm-x86_64.S
139 aes/bsaes-masm-x86_64.S
140 aes/vpaes-masm-x86_64.S
141 aes/aesni-masm-x86_64.S 102 aes/aesni-masm-x86_64.S
142 #bn/modexp512-masm-x86_64.S 103 #bn/modexp512-masm-x86_64.S
143 #bn/mont-masm-x86_64.S 104 #bn/mont-masm-x86_64.S
144 #bn/mont5-masm-x86_64.S 105 #bn/mont5-masm-x86_64.S
145 md5/md5-masm-x86_64.S
146 modes/ghash-masm-x86_64.S 106 modes/ghash-masm-x86_64.S
147 rc4/rc4-masm-x86_64.S 107 rc4/rc4-masm-x86_64.S
148 sha/sha1-masm-x86_64.S
149 sha/sha256-masm-x86_64.S
150 sha/sha512-masm-x86_64.S
151 cpuid-masm-x86_64.S
152 ) 108 )
153 add_definitions(-Dendbr64=) 109 add_definitions(-Dendbr64=)
154 add_definitions(-DAES_ASM) 110 add_definitions(-DAES_ASM)
155 add_definitions(-DBSAES_ASM) 111 add_definitions(-DBSAES_ASM)
156 add_definitions(-DVPAES_ASM) 112 add_definitions(-DVPAES_ASM)
157 add_definitions(-DHAVE_AES_CBC_ENCRYPT_INTERNAL)
158 add_definitions(-DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL)
159 add_definitions(-DHAVE_AES_SET_DECRYPT_KEY_INTERNAL)
160 add_definitions(-DHAVE_AES_ENCRYPT_INTERNAL)
161 add_definitions(-DHAVE_AES_DECRYPT_INTERNAL)
162 add_definitions(-DOPENSSL_IA32_SSE2) 113 add_definitions(-DOPENSSL_IA32_SSE2)
163 #add_definitions(-DOPENSSL_BN_ASM_MONT) 114 #add_definitions(-DOPENSSL_BN_ASM_MONT)
164 #add_definitions(-DOPENSSL_BN_ASM_MONT5) 115 #add_definitions(-DOPENSSL_BN_ASM_MONT5)
165 add_definitions(-DMD5_ASM)
166 add_definitions(-DGHASH_ASM) 116 add_definitions(-DGHASH_ASM)
167 add_definitions(-DRSA_ASM) 117 add_definitions(-DRSA_ASM)
168 add_definitions(-DSHA1_ASM)
169 add_definitions(-DSHA256_ASM)
170 add_definitions(-DSHA512_ASM)
171 add_definitions(-DWHIRLPOOL_ASM)
172 add_definitions(-DOPENSSL_CPUID_OBJ)
173 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MASM_SRC}) 118 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MASM_SRC})
174 set_property(SOURCE ${ASM_X86_64_MASM_SRC} PROPERTY LANGUAGE ASM_MASM) 119 set_property(SOURCE ${ASM_X86_64_MASM_SRC} PROPERTY LANGUAGE ASM_MASM)
175endif() 120endif()
176 121
177if(HOST_ASM_MINGW64_X86_64) 122if(HOST_ASM_MINGW64_X86_64)
123 set(CRYPTO_SRC ${CRYPTO_SRC} aes/aes_amd64.c)
124 set(CRYPTO_SRC ${CRYPTO_SRC} modes/gcm128_amd64.c)
125
178 set( 126 set(
179 ASM_X86_64_MINGW64_SRC 127 ASM_X86_64_MINGW64_SRC
180 aes/aes-mingw64-x86_64.S 128 aes/aes-mingw64-x86_64.S
181 aes/bsaes-mingw64-x86_64.S
182 aes/vpaes-mingw64-x86_64.S
183 aes/aesni-mingw64-x86_64.S 129 aes/aesni-mingw64-x86_64.S
184 #bn/modexp512-mingw64-x86_64.S 130 #bn/modexp512-mingw64-x86_64.S
185 #bn/mont-mingw64-x86_64.S 131 #bn/mont-mingw64-x86_64.S
186 #bn/mont5-mingw64-x86_64.S 132 #bn/mont5-mingw64-x86_64.S
187 md5/md5-mingw64-x86_64.S
188 modes/ghash-mingw64-x86_64.S 133 modes/ghash-mingw64-x86_64.S
189 rc4/rc4-mingw64-x86_64.S 134 rc4/rc4-mingw64-x86_64.S
190 sha/sha1-mingw64-x86_64.S
191 sha/sha256-mingw64-x86_64.S
192 sha/sha512-mingw64-x86_64.S
193 cpuid-mingw64-x86_64.S
194 ) 135 )
195 add_definitions(-Dendbr32=endbr64) 136 add_definitions(-Dendbr32=endbr64)
196 add_definitions(-DAES_ASM) 137 add_definitions(-DAES_ASM)
197 add_definitions(-DBSAES_ASM) 138 add_definitions(-DBSAES_ASM)
198 add_definitions(-DVPAES_ASM) 139 add_definitions(-DVPAES_ASM)
199 add_definitions(-DHAVE_AES_CBC_ENCRYPT_INTERNAL)
200 add_definitions(-DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL)
201 add_definitions(-DHAVE_AES_SET_DECRYPT_KEY_INTERNAL)
202 add_definitions(-DHAVE_AES_ENCRYPT_INTERNAL)
203 add_definitions(-DHAVE_AES_DECRYPT_INTERNAL)
204 add_definitions(-DOPENSSL_IA32_SSE2) 140 add_definitions(-DOPENSSL_IA32_SSE2)
205 #add_definitions(-DOPENSSL_BN_ASM_MONT) 141 #add_definitions(-DOPENSSL_BN_ASM_MONT)
206 #add_definitions(-DOPENSSL_BN_ASM_MONT5) 142 #add_definitions(-DOPENSSL_BN_ASM_MONT5)
207 add_definitions(-DMD5_ASM)
208 add_definitions(-DGHASH_ASM) 143 add_definitions(-DGHASH_ASM)
209 add_definitions(-DRSA_ASM) 144 add_definitions(-DRSA_ASM)
210 add_definitions(-DSHA1_ASM)
211 add_definitions(-DSHA256_ASM)
212 add_definitions(-DSHA512_ASM)
213 add_definitions(-DWHIRLPOOL_ASM)
214 add_definitions(-DOPENSSL_CPUID_OBJ)
215 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MINGW64_SRC}) 145 set(CRYPTO_SRC ${CRYPTO_SRC} ${ASM_X86_64_MINGW64_SRC})
216 set_property(SOURCE ${ASM_X86_64_MINGW64_SRC} PROPERTY LANGUAGE C) 146endif()
147
148if(HOST_AARCH64)
149 if(APPLE)
150 set(CRYPTO_SRC ${CRYPTO_SRC} arch/aarch64/crypto_cpu_caps_darwin.c)
151 elseif(LINUX)
152 set(CRYPTO_SRC ${CRYPTO_SRC} arch/aarch64/crypto_cpu_caps_linux.c)
153 elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
154 set(CRYPTO_SRC ${CRYPTO_SRC} arch/aarch64/crypto_cpu_caps.c)
155 elseif(WIN32)
156 set(CRYPTO_SRC ${CRYPTO_SRC} arch/aarch64/crypto_cpu_caps_windows.c)
157 else()
158 set(CRYPTO_SRC ${CRYPTO_SRC} arch/aarch64/crypto_cpu_caps_none.c)
159 endif()
160elseif(HOST_X86_64)
161 set(CRYPTO_SRC ${CRYPTO_SRC} arch/amd64/crypto_cpu_caps.c)
162elseif(HOST_I386)
163 set(CRYPTO_SRC ${CRYPTO_SRC} arch/i386/crypto_cpu_caps.c)
217endif() 164endif()
218 165
219set( 166set(
220 CRYPTO_SRC 167 CRYPTO_SRC
221 ${CRYPTO_SRC} 168 ${CRYPTO_SRC}
222 cpt_err.c 169 crypto_err.c
223 cryptlib.c 170 crypto_ex_data.c
224 crypto_init.c 171 crypto_init.c
225 cversion.c 172 crypto_legacy.c
226 ex_data.c 173 crypto_memory.c
227 malloc-wrapper.c
228 mem_clr.c
229 mem_dbg.c
230 o_fips.c
231 aes/aes.c 174 aes/aes.c
232 aes/aes_core.c 175 aes/aes_core.c
233 aes/aes_ige.c
234 asn1/a_bitstr.c 176 asn1/a_bitstr.c
235 asn1/a_enum.c 177 asn1/a_enum.c
236 asn1/a_int.c 178 asn1/a_int.c
@@ -280,10 +222,8 @@ set(
280 asn1/x_bignum.c 222 asn1/x_bignum.c
281 asn1/x_crl.c 223 asn1/x_crl.c
282 asn1/x_exten.c 224 asn1/x_exten.c
283 asn1/x_info.c
284 asn1/x_long.c 225 asn1/x_long.c
285 asn1/x_name.c 226 asn1/x_name.c
286 asn1/x_pkey.c
287 asn1/x_pubkey.c 227 asn1/x_pubkey.c
288 asn1/x_req.c 228 asn1/x_req.c
289 asn1/x_sig.c 229 asn1/x_sig.c
@@ -312,6 +252,7 @@ set(
312 bio/bss_null.c 252 bio/bss_null.c
313 bio/bss_sock.c 253 bio/bss_sock.c
314 bn/bn_add.c 254 bn/bn_add.c
255 bn/bn_add_sub.c
315 bn/bn_bpsw.c 256 bn/bn_bpsw.c
316 bn/bn_const.c 257 bn/bn_const.c
317 bn/bn_convert.c 258 bn/bn_convert.c
@@ -325,6 +266,7 @@ set(
325 bn/bn_lib.c 266 bn/bn_lib.c
326 bn/bn_mod.c 267 bn/bn_mod.c
327 bn/bn_mod_sqrt.c 268 bn/bn_mod_sqrt.c
269 bn/bn_mod_words.c
328 bn/bn_mont.c 270 bn/bn_mont.c
329 bn/bn_mul.c 271 bn/bn_mul.c
330 bn/bn_prime.c 272 bn/bn_prime.c
@@ -364,7 +306,6 @@ set(
364 conf/conf_def.c 306 conf/conf_def.c
365 conf/conf_err.c 307 conf/conf_err.c
366 conf/conf_lib.c 308 conf/conf_lib.c
367 conf/conf_mall.c
368 conf/conf_mod.c 309 conf/conf_mod.c
369 conf/conf_sap.c 310 conf/conf_sap.c
370 ct/ct_b64.c 311 ct/ct_b64.c
@@ -379,26 +320,11 @@ set(
379 ct/ct_x509v3.c 320 ct/ct_x509v3.c
380 curve25519/curve25519-generic.c 321 curve25519/curve25519-generic.c
381 curve25519/curve25519.c 322 curve25519/curve25519.c
382 des/cbc_cksm.c 323 des/des.c
383 des/cbc_enc.c 324 des/des_cksum.c
384 des/cfb64ede.c
385 des/cfb64enc.c
386 des/cfb_enc.c
387 des/des_enc.c 325 des/des_enc.c
388 des/ecb3_enc.c 326 des/des_fcrypt.c
389 des/ecb_enc.c 327 des/des_key.c
390 des/ede_cbcm_enc.c
391 des/enc_read.c
392 des/fcrypt.c
393 des/fcrypt_b.c
394 des/ofb64ede.c
395 des/ofb64enc.c
396 des/ofb_enc.c
397 des/pcbc_enc.c
398 des/qud_cksm.c
399 des/set_key.c
400 des/str2key.c
401 des/xcbc_enc.c
402 dh/dh_ameth.c 328 dh/dh_ameth.c
403 dh/dh_asn1.c 329 dh/dh_asn1.c
404 dh/dh_check.c 330 dh/dh_check.c
@@ -419,21 +345,17 @@ set(
419 dsa/dsa_prn.c 345 dsa/dsa_prn.c
420 ec/ec_ameth.c 346 ec/ec_ameth.c
421 ec/ec_asn1.c 347 ec/ec_asn1.c
422 ec/ec_check.c 348 ec/ec_convert.c
423 ec/ec_curve.c 349 ec/ec_curve.c
424 ec/ec_cvt.c
425 ec/ec_err.c 350 ec/ec_err.c
351 ec/ec_field.c
426 ec/ec_key.c 352 ec/ec_key.c
427 ec/ec_kmeth.c
428 ec/ec_lib.c 353 ec/ec_lib.c
429 ec/ec_mult.c 354 ec/ec_mult.c
430 ec/ec_oct.c
431 ec/ec_pmeth.c 355 ec/ec_pmeth.c
432 ec/ec_print.c
433 ec/eck_prn.c 356 ec/eck_prn.c
434 ec/ecp_mont.c 357 ec/ecp_hp_methods.c
435 ec/ecp_oct.c 358 ec/ecp_methods.c
436 ec/ecp_smpl.c
437 ec/ecx_methods.c 359 ec/ecx_methods.c
438 ecdh/ecdh.c 360 ecdh/ecdh.c
439 ecdsa/ecdsa.c 361 ecdsa/ecdsa.c
@@ -476,7 +398,6 @@ set(
476 evp/m_sha3.c 398 evp/m_sha3.c
477 evp/m_sigver.c 399 evp/m_sigver.c
478 evp/m_sm3.c 400 evp/m_sm3.c
479 evp/m_wp.c
480 evp/p_legacy.c 401 evp/p_legacy.c
481 evp/p_lib.c 402 evp/p_lib.c
482 evp/p_sign.c 403 evp/p_sign.c
@@ -495,6 +416,8 @@ set(
495 lhash/lhash.c 416 lhash/lhash.c
496 md4/md4.c 417 md4/md4.c
497 md5/md5.c 418 md5/md5.c
419 mlkem/mlkem768.c
420 mlkem/mlkem1024.c
498 modes/cbc128.c 421 modes/cbc128.c
499 modes/ccm128.c 422 modes/ccm128.c
500 modes/cfb128.c 423 modes/cfb128.c
@@ -552,11 +475,7 @@ set(
552 rand/rand_err.c 475 rand/rand_err.c
553 rand/rand_lib.c 476 rand/rand_lib.c
554 rand/randfile.c 477 rand/randfile.c
555 rc2/rc2_cbc.c 478 rc2/rc2.c
556 rc2/rc2_ecb.c
557 rc2/rc2_skey.c
558 rc2/rc2cfb64.c
559 rc2/rc2ofb64.c
560 rc4/rc4.c 479 rc4/rc4.c
561 ripemd/ripemd.c 480 ripemd/ripemd.c
562 rsa/rsa_ameth.c 481 rsa/rsa_ameth.c
@@ -599,8 +518,6 @@ set(
599 ui/ui_err.c 518 ui/ui_err.c
600 ui/ui_lib.c 519 ui/ui_lib.c
601 ui/ui_null.c 520 ui/ui_null.c
602 ui/ui_util.c
603 whrlpool/whirlpool.c
604 x509/by_dir.c 521 x509/by_dir.c
605 x509/by_file.c 522 x509/by_file.c
606 x509/by_mem.c 523 x509/by_mem.c
@@ -641,6 +558,7 @@ set(
641 x509/x509_r2x.c 558 x509/x509_r2x.c
642 x509/x509_req.c 559 x509/x509_req.c
643 x509/x509_set.c 560 x509/x509_set.c
561 x509/x509_siginfo.c
644 x509/x509_skey.c 562 x509/x509_skey.c
645 x509/x509_trs.c 563 x509/x509_trs.c
646 x509/x509_txt.c 564 x509/x509_txt.c
@@ -659,17 +577,17 @@ set(
659 577
660set(COMPAT_SRC empty.c) 578set(COMPAT_SRC empty.c)
661 579
580set(CRYPTO_UNEXPORT ${CRYPTO_UNEXPORT} BIO_s_log)
581
662if(UNIX) 582if(UNIX)
663 set(CRYPTO_SRC ${CRYPTO_SRC} crypto_lock.c) 583 set(CRYPTO_SRC ${CRYPTO_SRC} crypto_lock.c)
664 set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_posix.c) 584 set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_posix.c)
665 set(CRYPTO_SRC ${CRYPTO_SRC} bio/bss_log.c)
666 set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl.c) 585 set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl.c)
667endif() 586endif()
668 587
669if(WIN32) 588if(WIN32)
670 set(CRYPTO_SRC ${CRYPTO_SRC} compat/crypto_lock_win.c) 589 set(CRYPTO_SRC ${CRYPTO_SRC} compat/crypto_lock_win.c)
671 set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_win.c) 590 set(CRYPTO_SRC ${CRYPTO_SRC} bio/b_win.c)
672 set(CRYPTO_UNEXPORT ${CRYPTO_UNEXPORT} BIO_s_log)
673 set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl_win.c) 591 set(CRYPTO_SRC ${CRYPTO_SRC} ui/ui_openssl_win.c)
674endif() 592endif()
675 593
@@ -685,6 +603,14 @@ if(NOT HAVE_FREEZERO)
685 set(COMPAT_SRC ${COMPAT_SRC} compat/freezero.c) 603 set(COMPAT_SRC ${COMPAT_SRC} compat/freezero.c)
686endif() 604endif()
687 605
606if(NOT HAVE_GETDELIM)
607 set(COMPAT_SRC ${COMPAT_SRC} compat/getdelim.c)
608endif()
609
610if(NOT HAVE_GETLINE)
611 set(COMPAT_SRC ${COMPAT_SRC} compat/getline.c)
612endif()
613
688if(NOT HAVE_GETOPT) 614if(NOT HAVE_GETOPT)
689 set(COMPAT_SRC ${COMPAT_SRC} compat/getopt_long.c) 615 set(COMPAT_SRC ${COMPAT_SRC} compat/getopt_long.c)
690endif() 616endif()
@@ -817,10 +743,12 @@ add_library(crypto_obj OBJECT ${CRYPTO_SRC})
817target_include_directories(crypto_obj 743target_include_directories(crypto_obj
818 PRIVATE 744 PRIVATE
819 . 745 .
746 aes
820 asn1 747 asn1
821 bio 748 bio
822 bn 749 bn
823 bytestring 750 bytestring
751 conf
824 dh 752 dh
825 dsa 753 dsa
826 curve25519 754 curve25519
@@ -832,6 +760,7 @@ target_include_directories(crypto_obj
832 hidden 760 hidden
833 hmac 761 hmac
834 lhash 762 lhash
763 mlkem
835 modes 764 modes
836 ocsp 765 ocsp
837 pkcs12 766 pkcs12
@@ -845,41 +774,65 @@ target_include_directories(crypto_obj
845 ${CMAKE_BINARY_DIR}/include) 774 ${CMAKE_BINARY_DIR}/include)
846 775
847if(HOST_AARCH64) 776if(HOST_AARCH64)
777 target_include_directories(crypto_obj PRIVATE arch/aarch64/)
848 target_include_directories(crypto_obj PRIVATE bn/arch/aarch64/) 778 target_include_directories(crypto_obj PRIVATE bn/arch/aarch64/)
849elseif(HOST_ARM) 779elseif(HOST_ARM)
780 target_include_directories(crypto_obj PRIVATE arch/arm/)
850 target_include_directories(crypto_obj PRIVATE bn/arch/arm/) 781 target_include_directories(crypto_obj PRIVATE bn/arch/arm/)
851elseif(HOST_I386) 782elseif(HOST_I386)
783 target_include_directories(crypto_obj PRIVATE arch/i386/)
852 target_include_directories(crypto_obj PRIVATE bn/arch/i386/) 784 target_include_directories(crypto_obj PRIVATE bn/arch/i386/)
785elseif(HOST_LOONGARCH64)
786 target_include_directories(crypto_obj PRIVATE arch/loongarch64)
787 target_include_directories(crypto_obj PRIVATE bn/arch/loongarch64)
853elseif(HOST_MIPS64) 788elseif(HOST_MIPS64)
789 target_include_directories(crypto_obj PRIVATE arch/mips64)
854 target_include_directories(crypto_obj PRIVATE bn/arch/mips64) 790 target_include_directories(crypto_obj PRIVATE bn/arch/mips64)
855elseif(HOST_MIPS) 791elseif(HOST_MIPS)
792 target_include_directories(crypto_obj PRIVATE arch/mips)
856 target_include_directories(crypto_obj PRIVATE bn/arch/mips) 793 target_include_directories(crypto_obj PRIVATE bn/arch/mips)
857elseif(HOST_POWERPC) 794elseif(HOST_POWERPC)
795 target_include_directories(crypto_obj PRIVATE arch/powerpc)
858 target_include_directories(crypto_obj PRIVATE bn/arch/powerpc) 796 target_include_directories(crypto_obj PRIVATE bn/arch/powerpc)
859elseif(HOST_POWERPC64) 797elseif(HOST_POWERPC64)
798 target_include_directories(crypto_obj PRIVATE arch/powerpc64)
860 target_include_directories(crypto_obj PRIVATE bn/arch/powerpc64) 799 target_include_directories(crypto_obj PRIVATE bn/arch/powerpc64)
861elseif(HOST_RISCV64) 800elseif(HOST_RISCV64)
801 target_include_directories(crypto_obj PRIVATE arch/riscv64)
862 target_include_directories(crypto_obj PRIVATE bn/arch/riscv64) 802 target_include_directories(crypto_obj PRIVATE bn/arch/riscv64)
863elseif(HOST_SPARC64) 803elseif(HOST_SPARC64)
804 target_include_directories(crypto_obj PRIVATE arch/sparc64)
864 target_include_directories(crypto_obj PRIVATE bn/arch/sparc64) 805 target_include_directories(crypto_obj PRIVATE bn/arch/sparc64)
865elseif(HOST_X86_64) 806elseif(HOST_X86_64)
807 target_include_directories(crypto_obj PRIVATE arch/amd64)
866 target_include_directories(crypto_obj PRIVATE bn/arch/amd64) 808 target_include_directories(crypto_obj PRIVATE bn/arch/amd64)
867endif() 809endif()
868 810
811if(MSVC)
812 # "C4701" - Potentially uninitialized local variable 'name' used
813 set_source_files_properties(bn/bn_convert.c pem/pem_lib.c PROPERTIES
814 COMPILE_OPTIONS /wd4701
815 )
816 # "C4702" - unreachable code
817 set_source_files_properties(pkcs7/pk7_doit.c PROPERTIES
818 COMPILE_OPTIONS /wd4702
819 )
820endif()
821
869add_library(crypto $<TARGET_OBJECTS:crypto_obj> $<TARGET_OBJECTS:compat_obj> empty.c) 822add_library(crypto $<TARGET_OBJECTS:crypto_obj> $<TARGET_OBJECTS:compat_obj> empty.c)
870 823
871export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym) 824export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym)
872target_link_libraries(crypto ${PLATFORM_LIBS}) 825target_link_libraries(crypto ${PLATFORM_LIBS})
873if (WIN32)
874 set(CRYPTO_POSTFIX -${CRYPTO_MAJOR_VERSION} PARENT_SCOPE)
875endif()
876set_target_properties(crypto PROPERTIES 826set_target_properties(crypto PROPERTIES
877 OUTPUT_NAME crypto${CRYPTO_POSTFIX} 827 OUTPUT_NAME crypto
878 ARCHIVE_OUTPUT_NAME crypto${CRYPTO_POSTFIX} 828 ARCHIVE_OUTPUT_NAME crypto
879 EXPORT_NAME Crypto 829 EXPORT_NAME Crypto
880 VERSION ${CRYPTO_VERSION} 830 VERSION ${CRYPTO_VERSION}
881 SOVERSION ${CRYPTO_MAJOR_VERSION} 831 SOVERSION ${CRYPTO_MAJOR_VERSION}
882) 832)
833if(NOT CMAKE_VERSION VERSION_LESS 3.27.0)
834 set_target_properties(crypto PROPERTIES DLL_NAME_WITH_SOVERSION TRUE)
835endif()
883 836
884target_include_directories( 837target_include_directories(
885 crypto 838 crypto
@@ -919,4 +872,3 @@ if(BUILD_SHARED_LIBS)
919 add_library(crypto-static STATIC $<TARGET_OBJECTS:crypto_obj>) 872 add_library(crypto-static STATIC $<TARGET_OBJECTS:crypto_obj>)
920 target_link_libraries(crypto-static ${PLATFORM_LIBS}) 873 target_link_libraries(crypto-static ${PLATFORM_LIBS})
921endif() 874endif()
922
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
index 6e1e975..ad241ab 100644
--- a/crypto/Makefile.am
+++ b/crypto/Makefile.am
@@ -1,10 +1,27 @@
1#
2# Copyright (c) 2014 Brent Cook
3#
4# Permission to use, copy, modify, and distribute this software for any
5# purpose with or without fee is hereby granted, provided that the above
6# copyright notice and this permission notice appear in all copies.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
1include $(top_srcdir)/Makefile.am.common 16include $(top_srcdir)/Makefile.am.common
2 17
3AM_CPPFLAGS += -DLIBRESSL_CRYPTO_INTERNAL 18AM_CPPFLAGS += -DLIBRESSL_CRYPTO_INTERNAL
19AM_CPPFLAGS += -I$(top_srcdir)/crypto/aes
4AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1 20AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1
5AM_CPPFLAGS += -I$(top_srcdir)/crypto/bio 21AM_CPPFLAGS += -I$(top_srcdir)/crypto/bio
6AM_CPPFLAGS += -I$(top_srcdir)/crypto/bn 22AM_CPPFLAGS += -I$(top_srcdir)/crypto/bn
7AM_CPPFLAGS += -I$(top_srcdir)/crypto/bytestring 23AM_CPPFLAGS += -I$(top_srcdir)/crypto/bytestring
24AM_CPPFLAGS += -I$(top_srcdir)/crypto/conf
8AM_CPPFLAGS += -I$(top_srcdir)/crypto/curve25519 25AM_CPPFLAGS += -I$(top_srcdir)/crypto/curve25519
9AM_CPPFLAGS += -I$(top_srcdir)/crypto/dh 26AM_CPPFLAGS += -I$(top_srcdir)/crypto/dh
10AM_CPPFLAGS += -I$(top_srcdir)/crypto/dsa 27AM_CPPFLAGS += -I$(top_srcdir)/crypto/dsa
@@ -15,6 +32,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/crypto/err
15AM_CPPFLAGS += -I$(top_srcdir)/crypto/evp 32AM_CPPFLAGS += -I$(top_srcdir)/crypto/evp
16AM_CPPFLAGS += -I$(top_srcdir)/crypto/hmac 33AM_CPPFLAGS += -I$(top_srcdir)/crypto/hmac
17AM_CPPFLAGS += -I$(top_srcdir)/crypto/lhash 34AM_CPPFLAGS += -I$(top_srcdir)/crypto/lhash
35AM_CPPFLAGS += -I$(top_srcdir)/crypto/mlkem
18AM_CPPFLAGS += -I$(top_srcdir)/crypto/modes 36AM_CPPFLAGS += -I$(top_srcdir)/crypto/modes
19AM_CPPFLAGS += -I$(top_srcdir)/crypto/ocsp 37AM_CPPFLAGS += -I$(top_srcdir)/crypto/ocsp
20AM_CPPFLAGS += -I$(top_srcdir)/crypto/pkcs12 38AM_CPPFLAGS += -I$(top_srcdir)/crypto/pkcs12
@@ -49,20 +67,18 @@ crypto_portable.sym: crypto.sym Makefile
49 -echo "generating crypto_portable.sym ..." 67 -echo "generating crypto_portable.sym ..."
50 -cp $(top_srcdir)/crypto/crypto.sym crypto_portable.sym 68 -cp $(top_srcdir)/crypto/crypto.sym crypto_portable.sym
51 -chmod u+w crypto_portable.sym 69 -chmod u+w crypto_portable.sym
52if HOST_WIN
53 -grep -v BIO_s_log crypto_portable.sym > crypto_portable.sym.tmp 70 -grep -v BIO_s_log crypto_portable.sym > crypto_portable.sym.tmp
54 -mv crypto_portable.sym.tmp crypto_portable.sym 71 -mv crypto_portable.sym.tmp crypto_portable.sym
55endif
56 72
57libcrypto_la_objects.mk: Makefile 73libcrypto_la_objects.mk: Makefile
58 @echo "libcrypto_la_objects= $(libcrypto_la_OBJECTS)" \ 74 @echo "libcrypto_la_objects= $(libcrypto_la_OBJECTS)" \
59 | sed 's/ */ $$\(abs_top_builddir\)\/crypto\//g' \ 75 | sed 's/ */ $$\(top_builddir\)\/crypto\//g' \
60 > libcrypto_la_objects.mk 76 > libcrypto_la_objects.mk
61 @echo "libcompat_la_objects= $(libcompat_la_OBJECTS)" \ 77 @echo "libcompat_la_objects= $(libcompat_la_OBJECTS)" \
62 | sed 's/compat\// $$\(abs_top_builddir\)\/crypto\/&/g' \ 78 | sed 's/compat\// $$\(top_builddir\)\/crypto\/&/g' \
63 >> libcrypto_la_objects.mk 79 >> libcrypto_la_objects.mk
64 @echo "libcompatnoopt_la_objects= $(libcompatnoopt_la_OBJECTS)" \ 80 @echo "libcompatnoopt_la_objects= $(libcompatnoopt_la_OBJECTS)" \
65 | sed 's/compat\// $$\(abs_top_builddir\)\/crypto\/&/g' \ 81 | sed 's/compat\// $$\(top_builddir\)\/crypto\/&/g' \
66 >> libcrypto_la_objects.mk 82 >> libcrypto_la_objects.mk
67 83
68libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ -no-undefined -export-symbols crypto_portable.sym 84libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ -no-undefined -export-symbols crypto_portable.sym
@@ -132,6 +148,14 @@ if !HAVE_FREEZERO
132libcompat_la_SOURCES += compat/freezero.c 148libcompat_la_SOURCES += compat/freezero.c
133endif 149endif
134 150
151if !HAVE_GETDELIM
152libcompat_la_SOURCES += compat/getdelim.c
153endif
154
155if !HAVE_GETLINE
156libcompat_la_SOURCES += compat/getline.c
157endif
158
135if !HAVE_GETPAGESIZE 159if !HAVE_GETPAGESIZE
136libcompat_la_SOURCES += compat/getpagesize.c 160libcompat_la_SOURCES += compat/getpagesize.c
137endif 161endif
@@ -177,7 +201,6 @@ include Makefile.am.arc4random
177libcrypto_la_SOURCES = 201libcrypto_la_SOURCES =
178EXTRA_libcrypto_la_SOURCES = 202EXTRA_libcrypto_la_SOURCES =
179 203
180include Makefile.am.elf-arm
181include Makefile.am.elf-mips 204include Makefile.am.elf-mips
182include Makefile.am.elf-mips64 205include Makefile.am.elf-mips64
183include Makefile.am.elf-x86_64 206include Makefile.am.elf-x86_64
@@ -185,7 +208,6 @@ include Makefile.am.macosx-x86_64
185include Makefile.am.masm-x86_64 208include Makefile.am.masm-x86_64
186include Makefile.am.mingw64-x86_64 209include Makefile.am.mingw64-x86_64
187 210
188if !HOST_ASM_ELF_ARM
189if !HOST_ASM_ELF_MIPS 211if !HOST_ASM_ELF_MIPS
190if !HOST_ASM_ELF_MIPS64 212if !HOST_ASM_ELF_MIPS64
191if !HOST_ASM_ELF_X86_64 213if !HOST_ASM_ELF_X86_64
@@ -199,25 +221,41 @@ endif
199endif 221endif
200endif 222endif
201endif 223endif
224
225if HOST_AARCH64
226if HOST_DARWIN
227libcrypto_la_SOURCES += arch/aarch64/crypto_cpu_caps_darwin.c
228else
229if HOST_LINUX
230libcrypto_la_SOURCES += arch/aarch64/crypto_cpu_caps_linux.c
231else
232if HOST_OPENBSD
233libcrypto_la_SOURCES += arch/aarch64/crypto_cpu_caps.c
234else
235libcrypto_la_SOURCES += arch/aarch64/crypto_cpu_caps_none.c
236endif
237endif
238endif
239endif
240
241if HOST_X86_64
242libcrypto_la_SOURCES += arch/amd64/crypto_cpu_caps.c
243endif
244if HOST_I386
245libcrypto_la_SOURCES += arch/i386/crypto_cpu_caps.c
202endif 246endif
203 247
204libcrypto_la_SOURCES += cpt_err.c 248libcrypto_la_SOURCES += crypto_err.c
205libcrypto_la_SOURCES += cryptlib.c 249libcrypto_la_SOURCES += crypto_ex_data.c
206libcrypto_la_SOURCES += crypto_init.c 250libcrypto_la_SOURCES += crypto_init.c
251libcrypto_la_SOURCES += crypto_legacy.c
207if !HOST_WIN 252if !HOST_WIN
208libcrypto_la_SOURCES += crypto_lock.c 253libcrypto_la_SOURCES += crypto_lock.c
209else 254else
210libcrypto_la_SOURCES += compat/crypto_lock_win.c 255libcrypto_la_SOURCES += compat/crypto_lock_win.c
211endif 256endif
212libcrypto_la_SOURCES += cversion.c 257libcrypto_la_SOURCES += crypto_memory.c
213libcrypto_la_SOURCES += ex_data.c
214libcrypto_la_SOURCES += malloc-wrapper.c
215libcrypto_la_SOURCES += mem_clr.c
216libcrypto_la_SOURCES += mem_dbg.c
217libcrypto_la_SOURCES += o_fips.c
218noinst_HEADERS += arm_arch.h
219noinst_HEADERS += constant_time.h 258noinst_HEADERS += constant_time.h
220noinst_HEADERS += cryptlib.h
221noinst_HEADERS += crypto_internal.h 259noinst_HEADERS += crypto_internal.h
222noinst_HEADERS += crypto_local.h 260noinst_HEADERS += crypto_local.h
223noinst_HEADERS += x86_arch.h 261noinst_HEADERS += x86_arch.h
@@ -225,7 +263,6 @@ noinst_HEADERS += x86_arch.h
225# aes 263# aes
226libcrypto_la_SOURCES += aes/aes.c 264libcrypto_la_SOURCES += aes/aes.c
227libcrypto_la_SOURCES += aes/aes_core.c 265libcrypto_la_SOURCES += aes/aes_core.c
228libcrypto_la_SOURCES += aes/aes_ige.c
229noinst_HEADERS += aes/aes_local.h 266noinst_HEADERS += aes/aes_local.h
230 267
231# asn1 268# asn1
@@ -278,10 +315,8 @@ libcrypto_la_SOURCES += asn1/x_attrib.c
278libcrypto_la_SOURCES += asn1/x_bignum.c 315libcrypto_la_SOURCES += asn1/x_bignum.c
279libcrypto_la_SOURCES += asn1/x_crl.c 316libcrypto_la_SOURCES += asn1/x_crl.c
280libcrypto_la_SOURCES += asn1/x_exten.c 317libcrypto_la_SOURCES += asn1/x_exten.c
281libcrypto_la_SOURCES += asn1/x_info.c
282libcrypto_la_SOURCES += asn1/x_long.c 318libcrypto_la_SOURCES += asn1/x_long.c
283libcrypto_la_SOURCES += asn1/x_name.c 319libcrypto_la_SOURCES += asn1/x_name.c
284libcrypto_la_SOURCES += asn1/x_pkey.c
285libcrypto_la_SOURCES += asn1/x_pubkey.c 320libcrypto_la_SOURCES += asn1/x_pubkey.c
286libcrypto_la_SOURCES += asn1/x_req.c 321libcrypto_la_SOURCES += asn1/x_req.c
287libcrypto_la_SOURCES += asn1/x_sig.c 322libcrypto_la_SOURCES += asn1/x_sig.c
@@ -319,9 +354,6 @@ libcrypto_la_SOURCES += bio/bss_conn.c
319libcrypto_la_SOURCES += bio/bss_dgram.c 354libcrypto_la_SOURCES += bio/bss_dgram.c
320libcrypto_la_SOURCES += bio/bss_fd.c 355libcrypto_la_SOURCES += bio/bss_fd.c
321libcrypto_la_SOURCES += bio/bss_file.c 356libcrypto_la_SOURCES += bio/bss_file.c
322if !HOST_WIN
323libcrypto_la_SOURCES += bio/bss_log.c
324endif
325libcrypto_la_SOURCES += bio/bss_mem.c 357libcrypto_la_SOURCES += bio/bss_mem.c
326libcrypto_la_SOURCES += bio/bss_null.c 358libcrypto_la_SOURCES += bio/bss_null.c
327libcrypto_la_SOURCES += bio/bss_sock.c 359libcrypto_la_SOURCES += bio/bss_sock.c
@@ -329,6 +361,7 @@ noinst_HEADERS += bio/bio_local.h
329 361
330# bn 362# bn
331libcrypto_la_SOURCES += bn/bn_add.c 363libcrypto_la_SOURCES += bn/bn_add.c
364libcrypto_la_SOURCES += bn/bn_add_sub.c
332libcrypto_la_SOURCES += bn/bn_bpsw.c 365libcrypto_la_SOURCES += bn/bn_bpsw.c
333libcrypto_la_SOURCES += bn/bn_const.c 366libcrypto_la_SOURCES += bn/bn_const.c
334libcrypto_la_SOURCES += bn/bn_convert.c 367libcrypto_la_SOURCES += bn/bn_convert.c
@@ -342,6 +375,7 @@ libcrypto_la_SOURCES += bn/bn_kron.c
342libcrypto_la_SOURCES += bn/bn_lib.c 375libcrypto_la_SOURCES += bn/bn_lib.c
343libcrypto_la_SOURCES += bn/bn_mod.c 376libcrypto_la_SOURCES += bn/bn_mod.c
344libcrypto_la_SOURCES += bn/bn_mod_sqrt.c 377libcrypto_la_SOURCES += bn/bn_mod_sqrt.c
378libcrypto_la_SOURCES += bn/bn_mod_words.c
345libcrypto_la_SOURCES += bn/bn_mont.c 379libcrypto_la_SOURCES += bn/bn_mont.c
346libcrypto_la_SOURCES += bn/bn_mul.c 380libcrypto_la_SOURCES += bn/bn_mul.c
347libcrypto_la_SOURCES += bn/bn_prime.c 381libcrypto_la_SOURCES += bn/bn_prime.c
@@ -359,55 +393,82 @@ noinst_HEADERS += bn/bn_prime.h
359noinst_HEADERS += bn/s2n_bignum.h 393noinst_HEADERS += bn/s2n_bignum.h
360noinst_HEADERS += bn/s2n_bignum_internal.h 394noinst_HEADERS += bn/s2n_bignum_internal.h
361 395
362# bn/arch 396# arch, bn/arch
363if HOST_AARCH64 397if HOST_AARCH64
398libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/aarch64/
364libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/aarch64/ 399libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/aarch64/
365endif 400endif
401noinst_HEADERS += arch/aarch64/crypto_arch.h
366noinst_HEADERS += bn/arch/aarch64/bn_arch.h 402noinst_HEADERS += bn/arch/aarch64/bn_arch.h
367 403
368if HOST_ARM 404if HOST_ARM
405libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/arm/
369libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/arm/ 406libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/arm/
370endif 407endif
408noinst_HEADERS += arch/arm/crypto_arch.h
371noinst_HEADERS += bn/arch/arm/bn_arch.h 409noinst_HEADERS += bn/arch/arm/bn_arch.h
372 410
373if HOST_I386 411if HOST_I386
412libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/i386/
374libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/i386/ 413libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/i386/
375endif 414endif
415noinst_HEADERS += arch/i386/crypto_arch.h
376noinst_HEADERS += bn/arch/i386/bn_arch.h 416noinst_HEADERS += bn/arch/i386/bn_arch.h
377 417
418if HOST_LOONGARCH64
419libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/loongarch64/
420libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/loongarch64/
421endif
422noinst_HEADERS += arch/loongarch64/crypto_arch.h
423noinst_HEADERS += bn/arch/loongarch64/bn_arch.h
424
378if HOST_MIPS 425if HOST_MIPS
426libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/mips/
379libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips/ 427libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips/
380endif 428endif
429noinst_HEADERS += arch/mips/crypto_arch.h
381noinst_HEADERS += bn/arch/mips/bn_arch.h 430noinst_HEADERS += bn/arch/mips/bn_arch.h
382 431
383if HOST_MIPS64 432if HOST_MIPS64
433libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/mips64/
384libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips64/ 434libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips64/
385endif 435endif
436noinst_HEADERS += arch/mips64/crypto_arch.h
386noinst_HEADERS += bn/arch/mips64/bn_arch.h 437noinst_HEADERS += bn/arch/mips64/bn_arch.h
387 438
388if HOST_POWERPC 439if HOST_POWERPC
440libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/powerpc/
389libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc/ 441libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc/
390endif 442endif
443noinst_HEADERS += arch/powerpc/crypto_arch.h
391noinst_HEADERS += bn/arch/powerpc/bn_arch.h 444noinst_HEADERS += bn/arch/powerpc/bn_arch.h
392 445
393if HOST_POWERPC64 446if HOST_POWERPC64
447libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/powerpc64/
394libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc64/ 448libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc64/
395endif 449endif
450noinst_HEADERS += arch/powerpc64/crypto_arch.h
396noinst_HEADERS += bn/arch/powerpc64/bn_arch.h 451noinst_HEADERS += bn/arch/powerpc64/bn_arch.h
397 452
398if HOST_RISCV64 453if HOST_RISCV64
454libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/riscv64/
399libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/riscv64/ 455libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/riscv64/
400endif 456endif
457noinst_HEADERS += arch/riscv64/crypto_arch.h
401noinst_HEADERS += bn/arch/riscv64/bn_arch.h 458noinst_HEADERS += bn/arch/riscv64/bn_arch.h
402 459
403if HOST_SPARC64 460if HOST_SPARC64
461libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/sparc64/
404libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/sparc64/ 462libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/sparc64/
405endif 463endif
464noinst_HEADERS += arch/sparc64/crypto_arch.h
406noinst_HEADERS += bn/arch/sparc64/bn_arch.h 465noinst_HEADERS += bn/arch/sparc64/bn_arch.h
407 466
408if HOST_X86_64 467if HOST_X86_64
468libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/arch/amd64/
409libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/amd64/ 469libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/amd64/
410endif 470endif
471noinst_HEADERS += arch/amd64/crypto_arch.h
411noinst_HEADERS += bn/arch/amd64/bn_arch.h 472noinst_HEADERS += bn/arch/amd64/bn_arch.h
412 473
413# buffer 474# buffer
@@ -458,10 +519,10 @@ libcrypto_la_SOURCES += conf/conf_api.c
458libcrypto_la_SOURCES += conf/conf_def.c 519libcrypto_la_SOURCES += conf/conf_def.c
459libcrypto_la_SOURCES += conf/conf_err.c 520libcrypto_la_SOURCES += conf/conf_err.c
460libcrypto_la_SOURCES += conf/conf_lib.c 521libcrypto_la_SOURCES += conf/conf_lib.c
461libcrypto_la_SOURCES += conf/conf_mall.c
462libcrypto_la_SOURCES += conf/conf_mod.c 522libcrypto_la_SOURCES += conf/conf_mod.c
463libcrypto_la_SOURCES += conf/conf_sap.c 523libcrypto_la_SOURCES += conf/conf_sap.c
464noinst_HEADERS += conf/conf_def.h 524noinst_HEADERS += conf/conf_def.h
525noinst_HEADERS += conf/conf_local.h
465 526
466# ct 527# ct
467libcrypto_la_SOURCES += ct/ct_b64.c 528libcrypto_la_SOURCES += ct/ct_b64.c
@@ -483,29 +544,12 @@ noinst_HEADERS += curve25519/curve25519_internal.h
483 544
484 545
485# des 546# des
486libcrypto_la_SOURCES += des/cbc_cksm.c 547libcrypto_la_SOURCES += des/des.c
487libcrypto_la_SOURCES += des/cbc_enc.c 548libcrypto_la_SOURCES += des/des_cksum.c
488libcrypto_la_SOURCES += des/cfb64ede.c
489libcrypto_la_SOURCES += des/cfb64enc.c
490libcrypto_la_SOURCES += des/cfb_enc.c
491libcrypto_la_SOURCES += des/des_enc.c 549libcrypto_la_SOURCES += des/des_enc.c
492libcrypto_la_SOURCES += des/ecb3_enc.c 550libcrypto_la_SOURCES += des/des_fcrypt.c
493libcrypto_la_SOURCES += des/ecb_enc.c 551libcrypto_la_SOURCES += des/des_key.c
494libcrypto_la_SOURCES += des/ede_cbcm_enc.c
495libcrypto_la_SOURCES += des/enc_read.c
496libcrypto_la_SOURCES += des/fcrypt.c
497libcrypto_la_SOURCES += des/fcrypt_b.c
498EXTRA_libcrypto_la_SOURCES += des/ncbc_enc.c
499libcrypto_la_SOURCES += des/ofb64ede.c
500libcrypto_la_SOURCES += des/ofb64enc.c
501libcrypto_la_SOURCES += des/ofb_enc.c
502libcrypto_la_SOURCES += des/pcbc_enc.c
503libcrypto_la_SOURCES += des/qud_cksm.c
504libcrypto_la_SOURCES += des/set_key.c
505libcrypto_la_SOURCES += des/str2key.c
506libcrypto_la_SOURCES += des/xcbc_enc.c
507noinst_HEADERS += des/des_local.h 552noinst_HEADERS += des/des_local.h
508noinst_HEADERS += des/spr.h
509 553
510# dh 554# dh
511libcrypto_la_SOURCES += dh/dh_ameth.c 555libcrypto_la_SOURCES += dh/dh_ameth.c
@@ -534,22 +578,19 @@ noinst_HEADERS += dsa/dsa_local.h
534# ec 578# ec
535libcrypto_la_SOURCES += ec/ec_ameth.c 579libcrypto_la_SOURCES += ec/ec_ameth.c
536libcrypto_la_SOURCES += ec/ec_asn1.c 580libcrypto_la_SOURCES += ec/ec_asn1.c
537libcrypto_la_SOURCES += ec/ec_check.c 581libcrypto_la_SOURCES += ec/ec_convert.c
538libcrypto_la_SOURCES += ec/ec_curve.c 582libcrypto_la_SOURCES += ec/ec_curve.c
539libcrypto_la_SOURCES += ec/ec_cvt.c
540libcrypto_la_SOURCES += ec/ec_err.c 583libcrypto_la_SOURCES += ec/ec_err.c
584libcrypto_la_SOURCES += ec/ec_field.c
541libcrypto_la_SOURCES += ec/ec_key.c 585libcrypto_la_SOURCES += ec/ec_key.c
542libcrypto_la_SOURCES += ec/ec_kmeth.c
543libcrypto_la_SOURCES += ec/ec_lib.c 586libcrypto_la_SOURCES += ec/ec_lib.c
544libcrypto_la_SOURCES += ec/ec_mult.c 587libcrypto_la_SOURCES += ec/ec_mult.c
545libcrypto_la_SOURCES += ec/ec_oct.c
546libcrypto_la_SOURCES += ec/ec_pmeth.c 588libcrypto_la_SOURCES += ec/ec_pmeth.c
547libcrypto_la_SOURCES += ec/ec_print.c
548libcrypto_la_SOURCES += ec/eck_prn.c 589libcrypto_la_SOURCES += ec/eck_prn.c
549libcrypto_la_SOURCES += ec/ecp_mont.c 590libcrypto_la_SOURCES += ec/ecp_hp_methods.c
550libcrypto_la_SOURCES += ec/ecp_oct.c 591libcrypto_la_SOURCES += ec/ecp_methods.c
551libcrypto_la_SOURCES += ec/ecp_smpl.c
552libcrypto_la_SOURCES += ec/ecx_methods.c 592libcrypto_la_SOURCES += ec/ecx_methods.c
593noinst_HEADERS += ec/ec_internal.h
553noinst_HEADERS += ec/ec_local.h 594noinst_HEADERS += ec/ec_local.h
554 595
555# ecdh 596# ecdh
@@ -604,7 +645,6 @@ libcrypto_la_SOURCES += evp/m_sha1.c
604libcrypto_la_SOURCES += evp/m_sha3.c 645libcrypto_la_SOURCES += evp/m_sha3.c
605libcrypto_la_SOURCES += evp/m_sigver.c 646libcrypto_la_SOURCES += evp/m_sigver.c
606libcrypto_la_SOURCES += evp/m_sm3.c 647libcrypto_la_SOURCES += evp/m_sm3.c
607libcrypto_la_SOURCES += evp/m_wp.c
608libcrypto_la_SOURCES += evp/p_legacy.c 648libcrypto_la_SOURCES += evp/p_legacy.c
609libcrypto_la_SOURCES += evp/p_lib.c 649libcrypto_la_SOURCES += evp/p_lib.c
610libcrypto_la_SOURCES += evp/p_sign.c 650libcrypto_la_SOURCES += evp/p_sign.c
@@ -629,7 +669,6 @@ noinst_HEADERS += hidden/openssl/chacha.h
629noinst_HEADERS += hidden/openssl/cmac.h 669noinst_HEADERS += hidden/openssl/cmac.h
630noinst_HEADERS += hidden/openssl/cms.h 670noinst_HEADERS += hidden/openssl/cms.h
631noinst_HEADERS += hidden/openssl/conf.h 671noinst_HEADERS += hidden/openssl/conf.h
632noinst_HEADERS += hidden/openssl/conf_api.h
633noinst_HEADERS += hidden/openssl/crypto.h 672noinst_HEADERS += hidden/openssl/crypto.h
634noinst_HEADERS += hidden/openssl/ct.h 673noinst_HEADERS += hidden/openssl/ct.h
635noinst_HEADERS += hidden/openssl/curve25519.h 674noinst_HEADERS += hidden/openssl/curve25519.h
@@ -646,6 +685,7 @@ noinst_HEADERS += hidden/openssl/idea.h
646noinst_HEADERS += hidden/openssl/lhash.h 685noinst_HEADERS += hidden/openssl/lhash.h
647noinst_HEADERS += hidden/openssl/md4.h 686noinst_HEADERS += hidden/openssl/md4.h
648noinst_HEADERS += hidden/openssl/md5.h 687noinst_HEADERS += hidden/openssl/md5.h
688noinst_HEADERS += hidden/openssl/mlkem.h
649noinst_HEADERS += hidden/openssl/modes.h 689noinst_HEADERS += hidden/openssl/modes.h
650noinst_HEADERS += hidden/openssl/objects.h 690noinst_HEADERS += hidden/openssl/objects.h
651noinst_HEADERS += hidden/openssl/ocsp.h 691noinst_HEADERS += hidden/openssl/ocsp.h
@@ -666,7 +706,6 @@ noinst_HEADERS += hidden/openssl/stack.h
666noinst_HEADERS += hidden/openssl/ts.h 706noinst_HEADERS += hidden/openssl/ts.h
667noinst_HEADERS += hidden/openssl/txt_db.h 707noinst_HEADERS += hidden/openssl/txt_db.h
668noinst_HEADERS += hidden/openssl/ui.h 708noinst_HEADERS += hidden/openssl/ui.h
669noinst_HEADERS += hidden/openssl/whrlpool.h
670noinst_HEADERS += hidden/openssl/x509.h 709noinst_HEADERS += hidden/openssl/x509.h
671noinst_HEADERS += hidden/openssl/x509_vfy.h 710noinst_HEADERS += hidden/openssl/x509_vfy.h
672noinst_HEADERS += hidden/openssl/x509v3.h 711noinst_HEADERS += hidden/openssl/x509v3.h
@@ -698,6 +737,12 @@ libcrypto_la_SOURCES += md4/md4.c
698# md5 737# md5
699libcrypto_la_SOURCES += md5/md5.c 738libcrypto_la_SOURCES += md5/md5.c
700 739
740# mlkem
741libcrypto_la_SOURCES += mlkem/mlkem768.c
742libcrypto_la_SOURCES += mlkem/mlkem1024.c
743noinst_HEADERS += mlkem/mlkem.h
744noinst_HEADERS += mlkem/mlkem_internal.h
745
701# modes 746# modes
702libcrypto_la_SOURCES += modes/cbc128.c 747libcrypto_la_SOURCES += modes/cbc128.c
703libcrypto_la_SOURCES += modes/ccm128.c 748libcrypto_la_SOURCES += modes/ccm128.c
@@ -777,11 +822,7 @@ libcrypto_la_SOURCES += rand/rand_lib.c
777libcrypto_la_SOURCES += rand/randfile.c 822libcrypto_la_SOURCES += rand/randfile.c
778 823
779# rc2 824# rc2
780libcrypto_la_SOURCES += rc2/rc2_cbc.c 825libcrypto_la_SOURCES += rc2/rc2.c
781libcrypto_la_SOURCES += rc2/rc2_ecb.c
782libcrypto_la_SOURCES += rc2/rc2_skey.c
783libcrypto_la_SOURCES += rc2/rc2cfb64.c
784libcrypto_la_SOURCES += rc2/rc2ofb64.c
785noinst_HEADERS += rc2/rc2_local.h 826noinst_HEADERS += rc2/rc2_local.h
786 827
787# rc4 828# rc4
@@ -856,12 +897,8 @@ endif
856if HOST_WIN 897if HOST_WIN
857libcrypto_la_SOURCES += ui/ui_openssl_win.c 898libcrypto_la_SOURCES += ui/ui_openssl_win.c
858endif 899endif
859libcrypto_la_SOURCES += ui/ui_util.c
860noinst_HEADERS += ui/ui_local.h 900noinst_HEADERS += ui/ui_local.h
861 901
862# whrlpool
863libcrypto_la_SOURCES += whrlpool/whirlpool.c
864
865# x509 902# x509
866libcrypto_la_SOURCES += x509/by_dir.c 903libcrypto_la_SOURCES += x509/by_dir.c
867libcrypto_la_SOURCES += x509/by_file.c 904libcrypto_la_SOURCES += x509/by_file.c
@@ -903,6 +940,7 @@ libcrypto_la_SOURCES += x509/x509_purp.c
903libcrypto_la_SOURCES += x509/x509_r2x.c 940libcrypto_la_SOURCES += x509/x509_r2x.c
904libcrypto_la_SOURCES += x509/x509_req.c 941libcrypto_la_SOURCES += x509/x509_req.c
905libcrypto_la_SOURCES += x509/x509_set.c 942libcrypto_la_SOURCES += x509/x509_set.c
943libcrypto_la_SOURCES += x509/x509_siginfo.c
906libcrypto_la_SOURCES += x509/x509_skey.c 944libcrypto_la_SOURCES += x509/x509_skey.c
907libcrypto_la_SOURCES += x509/x509_trs.c 945libcrypto_la_SOURCES += x509/x509_trs.c
908libcrypto_la_SOURCES += x509/x509_txt.c 946libcrypto_la_SOURCES += x509/x509_txt.c
diff --git a/crypto/Makefile.am.elf-arm b/crypto/Makefile.am.elf-arm
deleted file mode 100644
index 4f88994..0000000
--- a/crypto/Makefile.am.elf-arm
+++ /dev/null
@@ -1,21 +0,0 @@
1ASM_ARM_ELF = aes/aes-elf-armv4.S
2ASM_ARM_ELF += bn/mont-elf-armv4.S
3ASM_ARM_ELF += sha/sha1-elf-armv4.S
4ASM_ARM_ELF += sha/sha512-elf-armv4.S
5ASM_ARM_ELF += sha/sha256-elf-armv4.S
6ASM_ARM_ELF += modes/ghash-elf-armv4.S
7ASM_ARM_ELF += armv4cpuid.S
8ASM_ARM_ELF += armcap.c
9
10EXTRA_DIST += $(ASM_ARM_ELF)
11
12if HOST_ASM_ELF_ARM
13libcrypto_la_CPPFLAGS += -DAES_ASM
14libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
15libcrypto_la_CPPFLAGS += -DGHASH_ASM
16libcrypto_la_CPPFLAGS += -DSHA1_ASM
17libcrypto_la_CPPFLAGS += -DSHA256_ASM
18libcrypto_la_CPPFLAGS += -DSHA512_ASM
19libcrypto_la_CPPFLAGS += -DOPENSSL_CPUID_OBJ
20libcrypto_la_SOURCES += $(ASM_ARM_ELF)
21endif
diff --git a/crypto/Makefile.am.elf-mips b/crypto/Makefile.am.elf-mips
index ea0a730..f7a44f2 100644
--- a/crypto/Makefile.am.elf-mips
+++ b/crypto/Makefile.am.elf-mips
@@ -10,8 +10,5 @@ EXTRA_DIST += $(ASM_MIPS_ELF)
10if HOST_ASM_ELF_MIPS 10if HOST_ASM_ELF_MIPS
11libcrypto_la_CPPFLAGS += -DAES_ASM 11libcrypto_la_CPPFLAGS += -DAES_ASM
12libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 12libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
13libcrypto_la_CPPFLAGS += -DSHA1_ASM
14libcrypto_la_CPPFLAGS += -DSHA256_ASM
15libcrypto_la_CPPFLAGS += -DSHA512_ASM
16libcrypto_la_SOURCES += $(ASM_MIPS_ELF) 13libcrypto_la_SOURCES += $(ASM_MIPS_ELF)
17endif 14endif
diff --git a/crypto/Makefile.am.elf-mips64 b/crypto/Makefile.am.elf-mips64
index 8f851f3..7d90bc0 100644
--- a/crypto/Makefile.am.elf-mips64
+++ b/crypto/Makefile.am.elf-mips64
@@ -10,8 +10,5 @@ EXTRA_DIST += $(ASM_MIPS64_ELF)
10if HOST_ASM_ELF_MIPS64 10if HOST_ASM_ELF_MIPS64
11libcrypto_la_CPPFLAGS += -DAES_ASM 11libcrypto_la_CPPFLAGS += -DAES_ASM
12libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 12libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
13libcrypto_la_CPPFLAGS += -DSHA1_ASM
14libcrypto_la_CPPFLAGS += -DSHA256_ASM
15libcrypto_la_CPPFLAGS += -DSHA512_ASM
16libcrypto_la_SOURCES += $(ASM_MIPS64_ELF) 13libcrypto_la_SOURCES += $(ASM_MIPS64_ELF)
17endif 14endif
diff --git a/crypto/Makefile.am.elf-x86_64 b/crypto/Makefile.am.elf-x86_64
index 6933a11..ad49787 100644
--- a/crypto/Makefile.am.elf-x86_64
+++ b/crypto/Makefile.am.elf-x86_64
@@ -1,18 +1,11 @@
1 1
2ASM_X86_64_ELF = aes/aes-elf-x86_64.S 2ASM_X86_64_ELF = aes/aes-elf-x86_64.S
3ASM_X86_64_ELF += aes/bsaes-elf-x86_64.S
4ASM_X86_64_ELF += aes/vpaes-elf-x86_64.S
5ASM_X86_64_ELF += aes/aesni-elf-x86_64.S 3ASM_X86_64_ELF += aes/aesni-elf-x86_64.S
6ASM_X86_64_ELF += bn/modexp512-elf-x86_64.S 4ASM_X86_64_ELF += bn/modexp512-elf-x86_64.S
7ASM_X86_64_ELF += bn/mont-elf-x86_64.S 5ASM_X86_64_ELF += bn/mont-elf-x86_64.S
8ASM_X86_64_ELF += bn/mont5-elf-x86_64.S 6ASM_X86_64_ELF += bn/mont5-elf-x86_64.S
9ASM_X86_64_ELF += md5/md5-elf-x86_64.S
10ASM_X86_64_ELF += modes/ghash-elf-x86_64.S 7ASM_X86_64_ELF += modes/ghash-elf-x86_64.S
11ASM_X86_64_ELF += rc4/rc4-elf-x86_64.S 8ASM_X86_64_ELF += rc4/rc4-elf-x86_64.S
12ASM_X86_64_ELF += sha/sha1-elf-x86_64.S
13ASM_X86_64_ELF += sha/sha256-elf-x86_64.S
14ASM_X86_64_ELF += sha/sha512-elf-x86_64.S
15ASM_X86_64_ELF += cpuid-elf-x86_64.S
16 9
17ASM_X86_64_ELF += bn/arch/amd64/bignum_add.S 10ASM_X86_64_ELF += bn/arch/amd64/bignum_add.S
18ASM_X86_64_ELF += bn/arch/amd64/bignum_cmadd.S 11ASM_X86_64_ELF += bn/arch/amd64/bignum_cmadd.S
@@ -25,29 +18,21 @@ ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr_4_8_alt.S
25ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr_8_16_alt.S 18ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr_8_16_alt.S
26ASM_X86_64_ELF += bn/arch/amd64/bignum_sub.S 19ASM_X86_64_ELF += bn/arch/amd64/bignum_sub.S
27ASM_X86_64_ELF += bn/arch/amd64/word_clz.S 20ASM_X86_64_ELF += bn/arch/amd64/word_clz.S
28ASM_X86_64_ELF += bn/arch/amd64/bn_arch.c
29 21
30EXTRA_DIST += $(ASM_X86_64_ELF) 22EXTRA_DIST += $(ASM_X86_64_ELF)
31 23
32if HOST_ASM_ELF_X86_64 24if HOST_ASM_ELF_X86_64
25libcrypto_la_SOURCES += aes/aes_amd64.c
26libcrypto_la_SOURCES += bn/arch/amd64/bn_arch.c
27libcrypto_la_SOURCES += modes/gcm128_amd64.c
28
33libcrypto_la_CPPFLAGS += -DAES_ASM 29libcrypto_la_CPPFLAGS += -DAES_ASM
34libcrypto_la_CPPFLAGS += -DBSAES_ASM 30libcrypto_la_CPPFLAGS += -DBSAES_ASM
35libcrypto_la_CPPFLAGS += -DVPAES_ASM 31libcrypto_la_CPPFLAGS += -DVPAES_ASM
36libcrypto_la_CPPFLAGS += -DHAVE_AES_CBC_ENCRYPT_INTERNAL
37libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL
38libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_DECRYPT_KEY_INTERNAL
39libcrypto_la_CPPFLAGS += -DHAVE_AES_ENCRYPT_INTERNAL
40libcrypto_la_CPPFLAGS += -DHAVE_AES_DECRYPT_INTERNAL
41libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2 32libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2
42libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 33libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
43libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5 34libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5
44libcrypto_la_CPPFLAGS += -DMD5_ASM
45libcrypto_la_CPPFLAGS += -DGHASH_ASM 35libcrypto_la_CPPFLAGS += -DGHASH_ASM
46libcrypto_la_CPPFLAGS += -DRSA_ASM 36libcrypto_la_CPPFLAGS += -DRSA_ASM
47libcrypto_la_CPPFLAGS += -DSHA1_ASM
48libcrypto_la_CPPFLAGS += -DSHA256_ASM
49libcrypto_la_CPPFLAGS += -DSHA512_ASM
50libcrypto_la_CPPFLAGS += -DWHIRLPOOL_ASM
51libcrypto_la_CPPFLAGS += -DOPENSSL_CPUID_OBJ
52libcrypto_la_SOURCES += $(ASM_X86_64_ELF) 37libcrypto_la_SOURCES += $(ASM_X86_64_ELF)
53endif 38endif
diff --git a/crypto/Makefile.am.macosx-x86_64 b/crypto/Makefile.am.macosx-x86_64
index 1020567..bbccfd6 100644
--- a/crypto/Makefile.am.macosx-x86_64
+++ b/crypto/Makefile.am.macosx-x86_64
@@ -1,18 +1,11 @@
1 1
2ASM_X86_64_MACOSX = aes/aes-macosx-x86_64.S 2ASM_X86_64_MACOSX = aes/aes-macosx-x86_64.S
3ASM_X86_64_MACOSX += aes/bsaes-macosx-x86_64.S
4ASM_X86_64_MACOSX += aes/vpaes-macosx-x86_64.S
5ASM_X86_64_MACOSX += aes/aesni-macosx-x86_64.S 3ASM_X86_64_MACOSX += aes/aesni-macosx-x86_64.S
6ASM_X86_64_MACOSX += bn/modexp512-macosx-x86_64.S 4ASM_X86_64_MACOSX += bn/modexp512-macosx-x86_64.S
7ASM_X86_64_MACOSX += bn/mont-macosx-x86_64.S 5ASM_X86_64_MACOSX += bn/mont-macosx-x86_64.S
8ASM_X86_64_MACOSX += bn/mont5-macosx-x86_64.S 6ASM_X86_64_MACOSX += bn/mont5-macosx-x86_64.S
9ASM_X86_64_MACOSX += md5/md5-macosx-x86_64.S
10ASM_X86_64_MACOSX += modes/ghash-macosx-x86_64.S 7ASM_X86_64_MACOSX += modes/ghash-macosx-x86_64.S
11ASM_X86_64_MACOSX += rc4/rc4-macosx-x86_64.S 8ASM_X86_64_MACOSX += rc4/rc4-macosx-x86_64.S
12ASM_X86_64_MACOSX += sha/sha1-macosx-x86_64.S
13ASM_X86_64_MACOSX += sha/sha256-macosx-x86_64.S
14ASM_X86_64_MACOSX += sha/sha512-macosx-x86_64.S
15ASM_X86_64_MACOSX += cpuid-macosx-x86_64.S
16 9
17ASM_X86_64_MACOSX += bn/arch/amd64/bignum_add.S 10ASM_X86_64_MACOSX += bn/arch/amd64/bignum_add.S
18ASM_X86_64_MACOSX += bn/arch/amd64/bignum_cmadd.S 11ASM_X86_64_MACOSX += bn/arch/amd64/bignum_cmadd.S
@@ -25,29 +18,21 @@ ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr_4_8_alt.S
25ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr_8_16_alt.S 18ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr_8_16_alt.S
26ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sub.S 19ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sub.S
27ASM_X86_64_MACOSX += bn/arch/amd64/word_clz.S 20ASM_X86_64_MACOSX += bn/arch/amd64/word_clz.S
28ASM_X86_64_MACOSX += bn/arch/amd64/bn_arch.c
29 21
30EXTRA_DIST += $(ASM_X86_64_MACOSX) 22EXTRA_DIST += $(ASM_X86_64_MACOSX)
31 23
32if HOST_ASM_MACOSX_X86_64 24if HOST_ASM_MACOSX_X86_64
25libcrypto_la_SOURCES += aes/aes_amd64.c
26libcrypto_la_SOURCES += bn/arch/amd64/bn_arch.c
27libcrypto_la_SOURCES += modes/gcm128_amd64.c
28
33libcrypto_la_CPPFLAGS += -DAES_ASM 29libcrypto_la_CPPFLAGS += -DAES_ASM
34libcrypto_la_CPPFLAGS += -DBSAES_ASM 30libcrypto_la_CPPFLAGS += -DBSAES_ASM
35libcrypto_la_CPPFLAGS += -DVPAES_ASM 31libcrypto_la_CPPFLAGS += -DVPAES_ASM
36libcrypto_la_CPPFLAGS += -DHAVE_AES_CBC_ENCRYPT_INTERNAL
37libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL
38libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_DECRYPT_KEY_INTERNAL
39libcrypto_la_CPPFLAGS += -DHAVE_AES_ENCRYPT_INTERNAL
40libcrypto_la_CPPFLAGS += -DHAVE_AES_DECRYPT_INTERNAL
41libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2 32libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2
42libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 33libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
43libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5 34libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5
44libcrypto_la_CPPFLAGS += -DMD5_ASM
45libcrypto_la_CPPFLAGS += -DGHASH_ASM 35libcrypto_la_CPPFLAGS += -DGHASH_ASM
46libcrypto_la_CPPFLAGS += -DRSA_ASM 36libcrypto_la_CPPFLAGS += -DRSA_ASM
47libcrypto_la_CPPFLAGS += -DSHA1_ASM
48libcrypto_la_CPPFLAGS += -DSHA256_ASM
49libcrypto_la_CPPFLAGS += -DSHA512_ASM
50libcrypto_la_CPPFLAGS += -DWHIRLPOOL_ASM
51libcrypto_la_CPPFLAGS += -DOPENSSL_CPUID_OBJ
52libcrypto_la_SOURCES += $(ASM_X86_64_MACOSX) 37libcrypto_la_SOURCES += $(ASM_X86_64_MACOSX)
53endif 38endif
diff --git a/crypto/Makefile.am.masm-x86_64 b/crypto/Makefile.am.masm-x86_64
index 7da3cc2..bb94e3a 100644
--- a/crypto/Makefile.am.masm-x86_64
+++ b/crypto/Makefile.am.masm-x86_64
@@ -1,40 +1,25 @@
1 1
2ASM_X86_64_MASM = aes/aes-masm-x86_64.S 2ASM_X86_64_MASM = aes/aes-masm-x86_64.S
3ASM_X86_64_MASM += aes/bsaes-masm-x86_64.S
4ASM_X86_64_MASM += aes/vpaes-masm-x86_64.S
5ASM_X86_64_MASM += aes/aesni-masm-x86_64.S 3ASM_X86_64_MASM += aes/aesni-masm-x86_64.S
6ASM_X86_64_MASM += bn/modexp512-masm-x86_64.S 4ASM_X86_64_MASM += bn/modexp512-masm-x86_64.S
7ASM_X86_64_MASM += bn/mont-masm-x86_64.S 5ASM_X86_64_MASM += bn/mont-masm-x86_64.S
8ASM_X86_64_MASM += bn/mont5-masm-x86_64.S 6ASM_X86_64_MASM += bn/mont5-masm-x86_64.S
9ASM_X86_64_MASM += md5/md5-masm-x86_64.S
10ASM_X86_64_MASM += modes/ghash-masm-x86_64.S 7ASM_X86_64_MASM += modes/ghash-masm-x86_64.S
11ASM_X86_64_MASM += rc4/rc4-masm-x86_64.S 8ASM_X86_64_MASM += rc4/rc4-masm-x86_64.S
12ASM_X86_64_MASM += sha/sha1-masm-x86_64.S
13ASM_X86_64_MASM += sha/sha256-masm-x86_64.S
14ASM_X86_64_MASM += sha/sha512-masm-x86_64.S
15ASM_X86_64_MASM += cpuid-masm-x86_64.S
16 9
17EXTRA_DIST += $(ASM_X86_64_MASM) 10EXTRA_DIST += $(ASM_X86_64_MASM)
18 11
19if HOST_ASM_MASM_X86_64 12if HOST_ASM_MASM_X86_64
13libcrypto_la_SOURCES += aes/aes_amd64.c
14libcrypto_la_SOURCES += modes/gcm128_amd64.c
15
20libcrypto_la_CPPFLAGS += -DAES_ASM 16libcrypto_la_CPPFLAGS += -DAES_ASM
21libcrypto_la_CPPFLAGS += -DBSAES_ASM 17libcrypto_la_CPPFLAGS += -DBSAES_ASM
22libcrypto_la_CPPFLAGS += -DVPAES_ASM 18libcrypto_la_CPPFLAGS += -DVPAES_ASM
23libcrypto_la_CPPFLAGS += -DHAVE_AES_CBC_ENCRYPT_INTERNAL
24libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL
25libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_DECRYPT_KEY_INTERNAL
26libcrypto_la_CPPFLAGS += -DHAVE_AES_ENCRYPT_INTERNAL
27libcrypto_la_CPPFLAGS += -DHAVE_AES_DECRYPT_INTERNAL
28libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2 19libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2
29libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 20libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
30libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5 21libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5
31libcrypto_la_CPPFLAGS += -DMD5_ASM
32libcrypto_la_CPPFLAGS += -DGHASH_ASM 22libcrypto_la_CPPFLAGS += -DGHASH_ASM
33libcrypto_la_CPPFLAGS += -DRSA_ASM 23libcrypto_la_CPPFLAGS += -DRSA_ASM
34libcrypto_la_CPPFLAGS += -DSHA1_ASM
35libcrypto_la_CPPFLAGS += -DSHA256_ASM
36libcrypto_la_CPPFLAGS += -DSHA512_ASM
37libcrypto_la_CPPFLAGS += -DWHIRLPOOL_ASM
38libcrypto_la_CPPFLAGS += -DOPENSSL_CPUID_OBJ
39libcrypto_la_SOURCES += $(ASM_X86_64_MASM) 24libcrypto_la_SOURCES += $(ASM_X86_64_MASM)
40endif 25endif
diff --git a/crypto/Makefile.am.mingw64-x86_64 b/crypto/Makefile.am.mingw64-x86_64
index 7d0d3f7..efe2643 100644
--- a/crypto/Makefile.am.mingw64-x86_64
+++ b/crypto/Makefile.am.mingw64-x86_64
@@ -1,41 +1,26 @@
1 1
2ASM_X86_64_MINGW64 = aes/aes-mingw64-x86_64.S 2ASM_X86_64_MINGW64 = aes/aes-mingw64-x86_64.S
3ASM_X86_64_MINGW64 += aes/bsaes-mingw64-x86_64.S
4ASM_X86_64_MINGW64 += aes/vpaes-mingw64-x86_64.S
5ASM_X86_64_MINGW64 += aes/aesni-mingw64-x86_64.S 3ASM_X86_64_MINGW64 += aes/aesni-mingw64-x86_64.S
6#ASM_X86_64_MINGW64 += bn/modexp512-mingw64-x86_64.S 4#ASM_X86_64_MINGW64 += bn/modexp512-mingw64-x86_64.S
7#ASM_X86_64_MINGW64 += bn/mont-mingw64-x86_64.S 5#ASM_X86_64_MINGW64 += bn/mont-mingw64-x86_64.S
8#ASM_X86_64_MINGW64 += bn/mont5-mingw64-x86_64.S 6#ASM_X86_64_MINGW64 += bn/mont5-mingw64-x86_64.S
9ASM_X86_64_MINGW64 += md5/md5-mingw64-x86_64.S
10ASM_X86_64_MINGW64 += modes/ghash-mingw64-x86_64.S 7ASM_X86_64_MINGW64 += modes/ghash-mingw64-x86_64.S
11ASM_X86_64_MINGW64 += rc4/rc4-mingw64-x86_64.S 8ASM_X86_64_MINGW64 += rc4/rc4-mingw64-x86_64.S
12ASM_X86_64_MINGW64 += sha/sha1-mingw64-x86_64.S
13ASM_X86_64_MINGW64 += sha/sha256-mingw64-x86_64.S
14ASM_X86_64_MINGW64 += sha/sha512-mingw64-x86_64.S
15ASM_X86_64_MINGW64 += cpuid-mingw64-x86_64.S
16 9
17EXTRA_DIST += $(ASM_X86_64_MINGW64) 10EXTRA_DIST += $(ASM_X86_64_MINGW64)
18 11
19if HOST_ASM_MINGW64_X86_64 12if HOST_ASM_MINGW64_X86_64
13libcrypto_la_SOURCES += aes/aes_amd64.c
14libcrypto_la_SOURCES += modes/gcm128_amd64.c
15
20libcrypto_la_CPPFLAGS += -Dendbr32=endbr64 16libcrypto_la_CPPFLAGS += -Dendbr32=endbr64
21libcrypto_la_CPPFLAGS += -DAES_ASM 17libcrypto_la_CPPFLAGS += -DAES_ASM
22libcrypto_la_CPPFLAGS += -DBSAES_ASM 18libcrypto_la_CPPFLAGS += -DBSAES_ASM
23libcrypto_la_CPPFLAGS += -DVPAES_ASM 19libcrypto_la_CPPFLAGS += -DVPAES_ASM
24libcrypto_la_CPPFLAGS += -DHAVE_AES_CBC_ENCRYPT_INTERNAL
25libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_ENCRYPT_KEY_INTERNAL
26libcrypto_la_CPPFLAGS += -DHAVE_AES_SET_DECRYPT_KEY_INTERNAL
27libcrypto_la_CPPFLAGS += -DHAVE_AES_ENCRYPT_INTERNAL
28libcrypto_la_CPPFLAGS += -DHAVE_AES_DECRYPT_INTERNAL
29libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2 20libcrypto_la_CPPFLAGS += -DOPENSSL_IA32_SSE2
30#libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT 21#libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT
31#libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5 22#libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5
32libcrypto_la_CPPFLAGS += -DMD5_ASM
33libcrypto_la_CPPFLAGS += -DGHASH_ASM 23libcrypto_la_CPPFLAGS += -DGHASH_ASM
34libcrypto_la_CPPFLAGS += -DRSA_ASM 24libcrypto_la_CPPFLAGS += -DRSA_ASM
35libcrypto_la_CPPFLAGS += -DSHA1_ASM
36libcrypto_la_CPPFLAGS += -DSHA256_ASM
37libcrypto_la_CPPFLAGS += -DSHA512_ASM
38libcrypto_la_CPPFLAGS += -DWHIRLPOOL_ASM
39libcrypto_la_CPPFLAGS += -DOPENSSL_CPUID_OBJ
40libcrypto_la_SOURCES += $(ASM_X86_64_MINGW64) 25libcrypto_la_SOURCES += $(ASM_X86_64_MINGW64)
41endif 26endif
diff --git a/crypto/arch/aarch64/crypto_cpu_caps_darwin.c b/crypto/arch/aarch64/crypto_cpu_caps_darwin.c
new file mode 100644
index 0000000..1dd91b2
--- /dev/null
+++ b/crypto/arch/aarch64/crypto_cpu_caps_darwin.c
@@ -0,0 +1,60 @@
1/* $OpenBSD: crypto_cpu_caps.c,v 1.2 2024/11/12 13:52:31 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Brent Cook <bcook@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 <sys/sysctl.h>
19
20#include "crypto_arch.h"
21
22/* Machine dependent CPU capabilities. */
23uint64_t crypto_cpu_caps_aarch64;
24
25static uint64_t
26check_cpu_cap(const char *cap_name, uint64_t cap_flag)
27{
28 int has_cap = 0;
29 size_t len = sizeof(has_cap);
30
31 sysctlbyname(cap_name, &has_cap, &len, NULL, 0);
32
33 return has_cap ? cap_flag : 0;
34}
35
36void
37crypto_cpu_caps_init(void)
38{
39 crypto_cpu_caps_aarch64 = 0;
40
41 /* from https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3918855 */
42
43 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_AES",
44 CRYPTO_CPU_CAPS_AARCH64_AES);
45
46 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_PMULL",
47 CRYPTO_CPU_CAPS_AARCH64_PMULL);
48
49 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_SHA1",
50 CRYPTO_CPU_CAPS_AARCH64_SHA1);
51
52 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_SHA256",
53 CRYPTO_CPU_CAPS_AARCH64_SHA2);
54
55 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_SHA512",
56 CRYPTO_CPU_CAPS_AARCH64_SHA512);
57
58 crypto_cpu_caps_aarch64 |= check_cpu_cap("hw.optional.arm.FEAT_SHA3",
59 CRYPTO_CPU_CAPS_AARCH64_SHA3);
60}
diff --git a/crypto/arch/aarch64/crypto_cpu_caps_linux.c b/crypto/arch/aarch64/crypto_cpu_caps_linux.c
new file mode 100644
index 0000000..ae28120
--- /dev/null
+++ b/crypto/arch/aarch64/crypto_cpu_caps_linux.c
@@ -0,0 +1,62 @@
1/* $OpenBSD: crypto_cpu_caps.c,v 1.2 2024/11/12 13:52:31 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Brent Cook <bcook@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 <sys/auxv.h>
19
20/* from arch/arm64/include/uapi/asm/hwcap.h */
21#define HWCAP_AES (1 << 3)
22#define HWCAP_PMULL (1 << 4)
23#define HWCAP_SHA1 (1 << 5)
24#define HWCAP_SHA2 (1 << 6)
25#define HWCAP_CRC32 (1 << 7)
26#define HWCAP_SHA3 (1 << 17)
27#define HWCAP_SHA512 (1 << 21)
28
29#include "crypto_arch.h"
30
31/* Machine dependent CPU capabilities. */
32uint64_t crypto_cpu_caps_aarch64;
33
34static uint64_t
35check_cpu_cap(unsigned long hwcap, uint64_t cap_flag)
36{
37 return (getauxval(AT_HWCAP) & hwcap) ? cap_flag : 0;
38}
39
40void
41crypto_cpu_caps_init(void)
42{
43 crypto_cpu_caps_aarch64 = 0;
44
45 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_AES,
46 CRYPTO_CPU_CAPS_AARCH64_AES);
47
48 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_PMULL,
49 CRYPTO_CPU_CAPS_AARCH64_PMULL);
50
51 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_SHA1,
52 CRYPTO_CPU_CAPS_AARCH64_SHA1);
53
54 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_SHA2,
55 CRYPTO_CPU_CAPS_AARCH64_SHA2);
56
57 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_SHA512,
58 CRYPTO_CPU_CAPS_AARCH64_SHA512);
59
60 crypto_cpu_caps_aarch64 |= check_cpu_cap(HWCAP_SHA3,
61 CRYPTO_CPU_CAPS_AARCH64_SHA3);
62}
diff --git a/crypto/arch/aarch64/crypto_cpu_caps_none.c b/crypto/arch/aarch64/crypto_cpu_caps_none.c
new file mode 100644
index 0000000..dcd96b7
--- /dev/null
+++ b/crypto/arch/aarch64/crypto_cpu_caps_none.c
@@ -0,0 +1,26 @@
1/*
2 * Copyright (c) 2025 Brent Cook <bcook@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "crypto_arch.h"
18
19/* Machine dependent CPU capabilities. */
20uint64_t crypto_cpu_caps_aarch64;
21
22void
23crypto_cpu_caps_init(void)
24{
25 crypto_cpu_caps_aarch64 = 0;
26}
diff --git a/crypto/arch/aarch64/crypto_cpu_caps_windows.c b/crypto/arch/aarch64/crypto_cpu_caps_windows.c
new file mode 100644
index 0000000..e7cdded
--- /dev/null
+++ b/crypto/arch/aarch64/crypto_cpu_caps_windows.c
@@ -0,0 +1,36 @@
1/* $OpenBSD: crypto_cpu_caps.c,v 1.2 2024/11/12 13:52:31 jsing Exp $ */
2/*
3 * Copyright (c) 2025 Brent Cook <bcook@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 <windows.h>
19
20#include "crypto_arch.h"
21
22/* Machine dependent CPU capabilities. */
23uint64_t crypto_cpu_caps_aarch64;
24
25void
26crypto_cpu_caps_init(void)
27{
28 crypto_cpu_caps_aarch64 = 0;
29
30 if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)) {
31 crypto_cpu_caps_aarch64 |= CRYPTO_CPU_CAPS_AARCH64_AES;
32 crypto_cpu_caps_aarch64 |= CRYPTO_CPU_CAPS_AARCH64_PMULL;
33 crypto_cpu_caps_aarch64 |= CRYPTO_CPU_CAPS_AARCH64_SHA1;
34 crypto_cpu_caps_aarch64 |= CRYPTO_CPU_CAPS_AARCH64_SHA2;
35 }
36}
diff --git a/crypto/arch/loongarch64/crypto_arch.h b/crypto/arch/loongarch64/crypto_arch.h
new file mode 100644
index 0000000..a3dd98d
--- /dev/null
+++ b/crypto/arch/loongarch64/crypto_arch.h
@@ -0,0 +1,21 @@
1/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 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#ifndef HEADER_CRYPTO_ARCH_H
19#define HEADER_CRYPTO_ARCH_H
20
21#endif
diff --git a/crypto/arch/mips/crypto_arch.h b/crypto/arch/mips/crypto_arch.h
new file mode 100644
index 0000000..274879c
--- /dev/null
+++ b/crypto/arch/mips/crypto_arch.h
@@ -0,0 +1,21 @@
1/* $OpenBSD$ */
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#ifndef HEADER_CRYPTO_ARCH_H
19#define HEADER_CRYPTO_ARCH_H
20
21#endif
diff --git a/crypto/bn/arch/loongarch64/bn_arch.h b/crypto/bn/arch/loongarch64/bn_arch.h
new file mode 100644
index 0000000..672ac12
--- /dev/null
+++ b/crypto/bn/arch/loongarch64/bn_arch.h
@@ -0,0 +1,23 @@
1/* $OpenBSD: bn_arch.h,v 1.7 2023/07/09 10:37:32 jsing Exp $ */
2/*
3 * Copyright (c) 2023 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/bn.h>
19
20#ifndef HEADER_BN_ARCH_H
21#define HEADER_BN_ARCH_H
22
23#endif
diff --git a/crypto/compat/.gitignore b/crypto/compat/.gitignore
new file mode 100644
index 0000000..7f05049
--- /dev/null
+++ b/crypto/compat/.gitignore
@@ -0,0 +1,31 @@
1arc4random.c
2arc4random_aix.h
3arc4random_freebsd.h
4arc4random_hpux.h
5arc4random_linux.h
6arc4random_netbsd.h
7arc4random_osx.h
8arc4random_solaris.h
9arc4random_uniform.c
10arc4random_win.h
11chacha_private.h
12explicit_bzero.c
13getentropy_aix.c
14getentropy_freebsd.c
15getentropy_hpux.c
16getentropy_linux.c
17getentropy_netbsd.c
18getentropy_osx.c
19getentropy_solaris.c
20getentropy_win.c
21reallocarray.c
22recallocarray.c
23strcasecmp.c
24strlcat.c
25strlcpy.c
26strndup.c
27strnlen.c
28strsep.c
29strtonum.c
30timingsafe_bcmp.c
31timingsafe_memcmp.c
diff --git a/crypto/compat/b_win.c b/crypto/compat/b_win.c
index e261cd2..45af839 100644
--- a/crypto/compat/b_win.c
+++ b/crypto/compat/b_win.c
@@ -8,7 +8,8 @@
8#include <ws2tcpip.h> 8#include <ws2tcpip.h>
9 9
10#include <openssl/bio.h> 10#include <openssl/bio.h>
11#include <openssl/err.h> 11
12#include "err_local.h"
12 13
13int 14int
14BIO_sock_init(void) 15BIO_sock_init(void)
@@ -29,7 +30,7 @@ BIO_sock_init(void)
29 } 30 }
30 wsa_init_done = 1; 31 wsa_init_done = 1;
31 } 32 }
32 return (1); 33 return (1);
33} 34}
34 35
35void 36void
diff --git a/crypto/compat/getdelim.c b/crypto/compat/getdelim.c
new file mode 100644
index 0000000..caec3f2
--- /dev/null
+++ b/crypto/compat/getdelim.c
@@ -0,0 +1,78 @@
1/*-
2 * Copyright (c) 2011 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Christos Zoulas.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <stdio.h>
31#include <stdlib.h>
32
33#ifndef HAVE_GETDELIM
34
35ssize_t
36getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
37{
38 char *ptr, *eptr;
39
40
41 if (*buf == NULL || *bufsiz == 0) {
42 *bufsiz = BUFSIZ;
43 if ((*buf = malloc(*bufsiz)) == NULL)
44 return -1;
45 }
46
47 for (ptr = *buf, eptr = *buf + *bufsiz;;) {
48 int c = fgetc(fp);
49 if (c == -1) {
50 if (feof(fp)) {
51 ssize_t diff = (ssize_t)(ptr - *buf);
52 if (diff != 0) {
53 *ptr = '\0';
54 return diff;
55 }
56 }
57 return -1;
58 }
59 *ptr++ = c;
60 if (c == delimiter) {
61 *ptr = '\0';
62 return ptr - *buf;
63 }
64 if (ptr + 2 >= eptr) {
65 char *nbuf;
66 size_t nbufsiz = *bufsiz * 2;
67 ssize_t d = ptr - *buf;
68 if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
69 return -1;
70 *buf = nbuf;
71 *bufsiz = nbufsiz;
72 eptr = nbuf + nbufsiz;
73 ptr = nbuf + d;
74 }
75 }
76}
77
78#endif /* HAVE_GETDELIM */
diff --git a/crypto/compat/getline.c b/crypto/compat/getline.c
new file mode 100644
index 0000000..e6ecde0
--- /dev/null
+++ b/crypto/compat/getline.c
@@ -0,0 +1,40 @@
1/*-
2 * Copyright (c) 2011 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Christos Zoulas.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <stdio.h>
31
32#ifndef HAVE_GETLINE
33
34ssize_t
35getline(char **buf, size_t *bufsiz, FILE *fp)
36{
37 return getdelim(buf, bufsiz, '\n', fp);
38}
39
40#endif /* HAVE_GETLINE */
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c
index bb3e653..572e527 100644
--- a/crypto/compat/posix_win.c
+++ b/crypto/compat/posix_win.c
@@ -9,6 +9,8 @@
9 9
10#define NO_REDEF_POSIX_FUNCTIONS 10#define NO_REDEF_POSIX_FUNCTIONS
11 11
12#include <sys/time.h>
13
12#include <ws2tcpip.h> 14#include <ws2tcpip.h>
13#include <windows.h> 15#include <windows.h>
14 16
@@ -20,6 +22,25 @@
20#include <string.h> 22#include <string.h>
21#include <unistd.h> 23#include <unistd.h>
22 24
25#include <sys/stat.h>
26
27static int
28is_socket(int fd)
29{
30 // Border case: Don't break std* file descriptors
31 if (fd < 3)
32 return 0;
33
34 // All locally-allocated file descriptors will have the high bit set
35 return (fd & 0x80000000) == 0;
36}
37
38static int
39get_real_fd(int fd)
40{
41 return (fd & 0x7fffffff);
42}
43
23void 44void
24posix_perror(const char *s) 45posix_perror(const char *s)
25{ 46{
@@ -42,6 +63,12 @@ posix_fopen(const char *path, const char *mode)
42} 63}
43 64
44int 65int
66libressl_fstat(int fd, struct stat *statbuf)
67{
68 return fstat(get_real_fd(fd), statbuf);
69}
70
71int
45posix_open(const char *path, ...) 72posix_open(const char *path, ...)
46{ 73{
47 va_list ap; 74 va_list ap;
@@ -60,7 +87,11 @@ posix_open(const char *path, ...)
60 flags |= O_NOINHERIT; 87 flags |= O_NOINHERIT;
61 } 88 }
62 flags &= ~O_NONBLOCK; 89 flags &= ~O_NONBLOCK;
63 return open(path, flags, mode); 90
91 const int fh = open(path, flags, mode);
92
93 // Set high bit to mark file descriptor as a file handle
94 return fh + 0x80000000;
64} 95}
65 96
66char * 97char *
@@ -148,52 +179,6 @@ wsa_errno(int err)
148 return -1; 179 return -1;
149} 180}
150 181
151/*
152 * Employ a similar trick to cpython (pycore_fileutils.h) where the CRT report
153 * handler is disabled while checking if a descriptor is a socket or a file
154 */
155#if defined _MSC_VER && _MSC_VER >= 1900
156
157#include <crtdbg.h>
158#include <stdlib.h>
159
160static void noop_handler(const wchar_t *expression, const wchar_t *function,
161 const wchar_t *file, unsigned int line, uintptr_t pReserved)
162{
163 return;
164}
165
166#define BEGIN_SUPPRESS_IPH \
167 const int old_report_mode = _CrtSetReportMode(_CRT_ASSERT, 0); \
168 const _invalid_parameter_handler old_handler = _set_thread_local_invalid_parameter_handler(noop_handler)
169#define END_SUPPRESS_IPH \
170 (void)old_report_mode; /* Silence warning in release mode when _CrtSetReportMode compiles to void. */ \
171 _CrtSetReportMode(_CRT_ASSERT, old_report_mode); \
172 _set_thread_local_invalid_parameter_handler(old_handler)
173
174#else
175
176#define BEGIN_SUPPRESS_IPH
177#define END_SUPPRESS_IPH
178
179#endif
180
181static int
182is_socket(int fd)
183{
184 intptr_t hd;
185
186 BEGIN_SUPPRESS_IPH;
187 hd = _get_osfhandle(fd);
188 END_SUPPRESS_IPH;
189
190 if (hd == (intptr_t)INVALID_HANDLE_VALUE) {
191 return 1; /* fd is not file descriptor */
192 }
193
194 return 0;
195}
196
197int 182int
198posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) 183posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
199{ 184{
@@ -207,14 +192,13 @@ int
207posix_close(int fd) 192posix_close(int fd)
208{ 193{
209 int rc; 194 int rc;
210
211 if (is_socket(fd)) { 195 if (is_socket(fd)) {
212 if ((rc = closesocket(fd)) == SOCKET_ERROR) { 196 if ((rc = closesocket(fd)) == SOCKET_ERROR) {
213 int err = WSAGetLastError(); 197 int err = WSAGetLastError();
214 rc = wsa_errno(err); 198 rc = wsa_errno(err);
215 } 199 }
216 } else { 200 } else {
217 rc = close(fd); 201 rc = close(get_real_fd(fd));
218 } 202 }
219 return rc; 203 return rc;
220} 204}
@@ -223,14 +207,13 @@ ssize_t
223posix_read(int fd, void *buf, size_t count) 207posix_read(int fd, void *buf, size_t count)
224{ 208{
225 ssize_t rc; 209 ssize_t rc;
226
227 if (is_socket(fd)) { 210 if (is_socket(fd)) {
228 if ((rc = recv(fd, buf, count, 0)) == SOCKET_ERROR) { 211 if ((rc = recv(fd, buf, count, 0)) == SOCKET_ERROR) {
229 int err = WSAGetLastError(); 212 int err = WSAGetLastError();
230 rc = wsa_errno(err); 213 rc = wsa_errno(err);
231 } 214 }
232 } else { 215 } else {
233 rc = read(fd, buf, count); 216 rc = read(get_real_fd(fd), buf, count);
234 } 217 }
235 return rc; 218 return rc;
236} 219}
@@ -244,7 +227,7 @@ posix_write(int fd, const void *buf, size_t count)
244 rc = wsa_errno(WSAGetLastError()); 227 rc = wsa_errno(WSAGetLastError());
245 } 228 }
246 } else { 229 } else {
247 rc = write(fd, buf, count); 230 rc = write(get_real_fd(fd), buf, count);
248 } 231 }
249 return rc; 232 return rc;
250} 233}
@@ -289,7 +272,7 @@ uid_t getuid(void)
289 272
290#ifdef _MSC_VER 273#ifdef _MSC_VER
291struct timezone; 274struct timezone;
292int gettimeofday(struct timeval * tp, struct timezone * tzp) 275int gettimeofday(struct timeval *tp, void *tzp)
293{ 276{
294 /* 277 /*
295 * Note: some broken versions only have 8 trailing zero's, the correct 278 * Note: some broken versions only have 8 trailing zero's, the correct
@@ -306,7 +289,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp)
306 time = ((uint64_t)file_time.dwLowDateTime); 289 time = ((uint64_t)file_time.dwLowDateTime);
307 time += ((uint64_t)file_time.dwHighDateTime) << 32; 290 time += ((uint64_t)file_time.dwHighDateTime) << 32;
308 291
309 tp->tv_sec = (long)((time - EPOCH) / 10000000L); 292 tp->tv_sec = (long long)((time - EPOCH) / 10000000L);
310 tp->tv_usec = (long)(system_time.wMilliseconds * 1000); 293 tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
311 return 0; 294 return 0;
312} 295}
diff --git a/crypto/compat/ui_openssl_win.c b/crypto/compat/ui_openssl_win.c
index 09705e4..4ae2c5d 100644
--- a/crypto/compat/ui_openssl_win.c
+++ b/crypto/compat/ui_openssl_win.c
@@ -146,7 +146,7 @@ static int echo_console(UI *ui);
146static int noecho_console(UI *ui); 146static int noecho_console(UI *ui);
147static int close_console(UI *ui); 147static int close_console(UI *ui);
148 148
149static UI_METHOD ui_openssl = { 149static const UI_METHOD ui_openssl = {
150 .name = "OpenSSL default user interface", 150 .name = "OpenSSL default user interface",
151 .ui_open_session = open_console, 151 .ui_open_session = open_console,
152 .ui_write_string = write_string, 152 .ui_write_string = write_string,
@@ -155,7 +155,7 @@ static UI_METHOD ui_openssl = {
155}; 155};
156 156
157/* The method with all the built-in thingies */ 157/* The method with all the built-in thingies */
158UI_METHOD * 158const UI_METHOD *
159UI_OpenSSL(void) 159UI_OpenSSL(void)
160{ 160{
161 return &ui_openssl; 161 return &ui_openssl;