mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1c6b70f7c | ||
|
|
b7c303d97b | ||
|
|
c066b057ed | ||
|
|
2347f20e24 | ||
|
|
334e682869 | ||
|
|
c68a7a7c7f | ||
|
|
8c9d27a339 | ||
|
|
176abc28e0 | ||
|
|
64a4de00fb | ||
|
|
84b1d49411 | ||
|
|
88b9c9b3b7 | ||
|
|
993467897d |
No files matched your search
@@ -25,6 +25,15 @@ jobs:
|
||||
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
|
||||
release-builds:
|
||||
name: Release builds
|
||||
uses: apple/swift-nio/.github/workflows/release_builds.yml@main
|
||||
with:
|
||||
windows_6_0_enabled: true
|
||||
windows_6_1_enabled: true
|
||||
windows_nightly_next_enabled: true
|
||||
windows_nightly_main_enabled: true
|
||||
|
||||
cxx-interop:
|
||||
name: Cxx interop
|
||||
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
|
||||
|
||||
@@ -30,6 +30,15 @@ jobs:
|
||||
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
|
||||
|
||||
release-builds:
|
||||
name: Release builds
|
||||
uses: apple/swift-nio/.github/workflows/release_builds.yml@main
|
||||
with:
|
||||
windows_6_0_enabled: true
|
||||
windows_6_1_enabled: true
|
||||
windows_nightly_next_enabled: true
|
||||
windows_nightly_main_enabled: true
|
||||
|
||||
cxx-interop:
|
||||
name: Cxx interop
|
||||
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
|
||||
|
||||
@@ -158,4 +158,49 @@ let benchmarks = {
|
||||
blackHole(try privateKey.evaluate(blindedElement))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark(
|
||||
"key-exchange-p256",
|
||||
configuration: Benchmark.Configuration(
|
||||
metrics: defaultMetrics,
|
||||
scalingFactor: .kilo,
|
||||
maxDuration: .seconds(10_000_000),
|
||||
maxIterations: 10
|
||||
)
|
||||
) { benchmark in
|
||||
for _ in benchmark.scaledIterations {
|
||||
let (key1, key2) = (P256.KeyAgreement.PrivateKey(), P256.KeyAgreement.PrivateKey())
|
||||
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark(
|
||||
"key-exchange-p384",
|
||||
configuration: Benchmark.Configuration(
|
||||
metrics: defaultMetrics,
|
||||
scalingFactor: .kilo,
|
||||
maxDuration: .seconds(10_000_000),
|
||||
maxIterations: 10
|
||||
)
|
||||
) { benchmark in
|
||||
for _ in benchmark.scaledIterations {
|
||||
let (key1, key2) = (P384.KeyAgreement.PrivateKey(), P384.KeyAgreement.PrivateKey())
|
||||
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
|
||||
}
|
||||
}
|
||||
|
||||
Benchmark(
|
||||
"key-exchange-p521",
|
||||
configuration: Benchmark.Configuration(
|
||||
metrics: defaultMetrics,
|
||||
scalingFactor: .kilo,
|
||||
maxDuration: .seconds(10_000_000),
|
||||
maxIterations: 10
|
||||
)
|
||||
) { benchmark in
|
||||
for _ in benchmark.scaledIterations {
|
||||
let (key1, key2) = (P521.KeyAgreement.PrivateKey(), P521.KeyAgreement.PrivateKey())
|
||||
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.15.1)
|
||||
|
||||
if(POLICY CMP0157)
|
||||
cmake_policy(SET CMP0157 NEW)
|
||||
endif()
|
||||
|
||||
project(SwiftCrypto
|
||||
LANGUAGES ASM C CXX Swift)
|
||||
|
||||
@@ -47,6 +51,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_RANLIB "/usr/bin/ranlib")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
# We need to ensure that we don't include the min/max macros from the Windows SDK.
|
||||
add_compile_definitions(NOMINMAX)
|
||||
# We can only link against the DLL version of the MSVC runtime library for now.
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
|
||||
# We need to set the static library prefix to "lib" so that we can link against the static libraries.
|
||||
set(CMAKE_STATIC_LIBRARY_PREFIX_Swift "lib")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
find_package(dispatch CONFIG)
|
||||
find_package(Foundation CONFIG)
|
||||
|
||||
@@ -98,7 +98,6 @@ let package = Package(
|
||||
name: "CCryptoBoringSSL",
|
||||
exclude: privacyManifestExclude + [
|
||||
"hash.txt",
|
||||
"include/boringssl_prefix_symbols_nasm.inc",
|
||||
"CMakeLists.txt",
|
||||
/*
|
||||
* These files are excluded to support WASI libc which doesn't provide <netdb.h>.
|
||||
|
||||
+20
-1
@@ -342,8 +342,27 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|OpenBSD" AND CMAKE_SYSTE
|
||||
gen/bcm/vpaes-armv8-linux.S
|
||||
gen/crypto/chacha-armv8-linux.S
|
||||
gen/crypto/chacha20_poly1305_armv8-linux.S)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows" AND CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|amd64|x86_64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows" AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|arm64|aarch64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
gen/bcm/aesv8-armv8-win.S
|
||||
gen/bcm/aesv8-gcm-armv8-win.S
|
||||
gen/bcm/armv8-mont-win.S
|
||||
gen/bcm/bn-armv8-win.S
|
||||
gen/bcm/ghash-neon-armv8-win.S
|
||||
gen/bcm/ghashv8-armv8-win.S
|
||||
gen/bcm/p256-armv8-asm-win.S
|
||||
gen/bcm/p256_beeu-armv8-asm-win.S
|
||||
gen/bcm/sha1-armv8-win.S
|
||||
gen/bcm/sha256-armv8-win.S
|
||||
gen/bcm/sha512-armv8-win.S
|
||||
gen/bcm/vpaes-armv8-win.S
|
||||
gen/crypto/chacha-armv8-win.S
|
||||
gen/crypto/chacha20_poly1305_armv8-win.S)
|
||||
else()
|
||||
message(FATAL_ERROR "platform sources are not defined here")
|
||||
message(FATAL_ERROR "platform sources are not defined here for ${CMAKE_SYSTEM_NAME} on ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
target_include_directories(CCryptoBoringSSL PUBLIC
|
||||
|
||||
@@ -640,6 +640,8 @@
|
||||
#define bn_mul4x_mont_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul4x_mont_capable)
|
||||
#define bn_mul4x_mont_gather5 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul4x_mont_gather5)
|
||||
#define bn_mul4x_mont_gather5_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul4x_mont_gather5_capable)
|
||||
#define bn_mul8x_mont_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul8x_mont_neon)
|
||||
#define bn_mul8x_mont_neon_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul8x_mont_neon_capable)
|
||||
#define bn_mulx_adx_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mulx_adx_capable)
|
||||
#define bn_mulx4x_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mulx4x_mont)
|
||||
#define bn_mulx4x_mont_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mulx4x_mont_capable)
|
||||
@@ -735,6 +737,7 @@
|
||||
#define boringssl_self_test_slhdsa BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, boringssl_self_test_slhdsa)
|
||||
#define bsaes_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bsaes_capable)
|
||||
#define bsaes_cbc_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bsaes_cbc_encrypt)
|
||||
#define bsaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bsaes_ctr32_encrypt_blocks)
|
||||
#define BUF_MEM_append BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BUF_MEM_append)
|
||||
#define BUF_MEM_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BUF_MEM_free)
|
||||
#define BUF_MEM_grow BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BUF_MEM_grow)
|
||||
@@ -931,6 +934,7 @@
|
||||
#define CRYPTO_get_thread_local BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_get_thread_local)
|
||||
#define CRYPTO_ghash_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_ghash_init)
|
||||
#define CRYPTO_has_asm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define CRYPTO_has_broken_NEON BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_has_broken_NEON)
|
||||
#define CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define CRYPTO_is_ADX_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ADX_capable)
|
||||
@@ -967,13 +971,17 @@
|
||||
#define CRYPTO_MUTEX_lock_write BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_MUTEX_lock_write)
|
||||
#define CRYPTO_MUTEX_unlock_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_MUTEX_unlock_read)
|
||||
#define CRYPTO_MUTEX_unlock_write BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_MUTEX_unlock_write)
|
||||
#define CRYPTO_needs_hwcap2_workaround BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_needs_hwcap2_workaround)
|
||||
#define CRYPTO_new_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_new_ex_data)
|
||||
#define CRYPTO_num_locks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_num_locks)
|
||||
#define CRYPTO_ofb128_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_ofb128_encrypt)
|
||||
#define CRYPTO_once BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_once)
|
||||
#define CRYPTO_poly1305_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_finish)
|
||||
#define CRYPTO_poly1305_finish_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_finish_neon)
|
||||
#define CRYPTO_poly1305_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_init)
|
||||
#define CRYPTO_poly1305_init_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_init_neon)
|
||||
#define CRYPTO_poly1305_update BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_update)
|
||||
#define CRYPTO_poly1305_update_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_poly1305_update_neon)
|
||||
#define CRYPTO_pre_sandbox_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_pre_sandbox_init)
|
||||
#define CRYPTO_rdrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_rdrand)
|
||||
#define CRYPTO_rdrand_multiple8_buf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_rdrand_multiple8_buf)
|
||||
@@ -2240,6 +2248,8 @@
|
||||
#define OPENSSL_malloc_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_malloc_init)
|
||||
#define OPENSSL_memdup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_memdup)
|
||||
#define OPENSSL_no_config BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_no_config)
|
||||
#define openssl_poly1305_neon2_addmulmod BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, openssl_poly1305_neon2_addmulmod)
|
||||
#define openssl_poly1305_neon2_blocks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, openssl_poly1305_neon2_blocks)
|
||||
#define OPENSSL_posix_to_tm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_posix_to_tm)
|
||||
#define OPENSSL_realloc BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_realloc)
|
||||
#define OPENSSL_secure_clear_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_secure_clear_free)
|
||||
@@ -2578,6 +2588,7 @@
|
||||
#define sha1_block_data_order_avx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_avx)
|
||||
#define sha1_block_data_order_avx2 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_avx2)
|
||||
#define sha1_block_data_order_hw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_hw)
|
||||
#define sha1_block_data_order_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_neon)
|
||||
#define sha1_block_data_order_nohw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_nohw)
|
||||
#define sha1_block_data_order_ssse3 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order_ssse3)
|
||||
#define SHA1_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA1_Final)
|
||||
@@ -2594,6 +2605,7 @@
|
||||
#define sha256_avx_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_avx_capable)
|
||||
#define sha256_block_data_order_avx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order_avx)
|
||||
#define sha256_block_data_order_hw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order_hw)
|
||||
#define sha256_block_data_order_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order_neon)
|
||||
#define sha256_block_data_order_nohw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order_nohw)
|
||||
#define sha256_block_data_order_ssse3 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order_ssse3)
|
||||
#define SHA256_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA256_Final)
|
||||
@@ -2615,6 +2627,7 @@
|
||||
#define sha512_avx_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_avx_capable)
|
||||
#define sha512_block_data_order_avx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_block_data_order_avx)
|
||||
#define sha512_block_data_order_hw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_block_data_order_hw)
|
||||
#define sha512_block_data_order_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_block_data_order_neon)
|
||||
#define sha512_block_data_order_nohw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_block_data_order_nohw)
|
||||
#define SHA512_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, SHA512_Final)
|
||||
#define sha512_hw_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_hw_capable)
|
||||
@@ -2955,9 +2968,11 @@
|
||||
#define vpaes_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_capable)
|
||||
#define vpaes_cbc_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_cbc_encrypt)
|
||||
#define vpaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks)
|
||||
#define vpaes_ctr32_encrypt_blocks_with_bsaes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks_with_bsaes)
|
||||
#define vpaes_decrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_decrypt)
|
||||
#define vpaes_decrypt_key_to_bsaes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_decrypt_key_to_bsaes)
|
||||
#define vpaes_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_encrypt)
|
||||
#define vpaes_encrypt_key_to_bsaes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_encrypt_key_to_bsaes)
|
||||
#define vpaes_set_decrypt_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_set_decrypt_key)
|
||||
#define vpaes_set_encrypt_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_set_encrypt_key)
|
||||
#define X25519 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X25519)
|
||||
@@ -2974,6 +2989,7 @@
|
||||
#define x25519_ge_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_sub)
|
||||
#define x25519_ge_tobytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_tobytes)
|
||||
#define X25519_keypair BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X25519_keypair)
|
||||
#define x25519_NEON BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_NEON)
|
||||
#define x25519_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_pkey_meth)
|
||||
#define X25519_public_from_private BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X25519_public_from_private)
|
||||
#define x25519_sc_reduce BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_sc_reduce)
|
||||
|
||||
@@ -645,6 +645,8 @@
|
||||
#define _bn_mul4x_mont_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul4x_mont_capable)
|
||||
#define _bn_mul4x_mont_gather5 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul4x_mont_gather5)
|
||||
#define _bn_mul4x_mont_gather5_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul4x_mont_gather5_capable)
|
||||
#define _bn_mul8x_mont_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul8x_mont_neon)
|
||||
#define _bn_mul8x_mont_neon_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul8x_mont_neon_capable)
|
||||
#define _bn_mulx_adx_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mulx_adx_capable)
|
||||
#define _bn_mulx4x_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mulx4x_mont)
|
||||
#define _bn_mulx4x_mont_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mulx4x_mont_capable)
|
||||
@@ -740,6 +742,7 @@
|
||||
#define _boringssl_self_test_slhdsa BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, boringssl_self_test_slhdsa)
|
||||
#define _bsaes_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bsaes_capable)
|
||||
#define _bsaes_cbc_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bsaes_cbc_encrypt)
|
||||
#define _bsaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bsaes_ctr32_encrypt_blocks)
|
||||
#define _BUF_MEM_append BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BUF_MEM_append)
|
||||
#define _BUF_MEM_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BUF_MEM_free)
|
||||
#define _BUF_MEM_grow BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BUF_MEM_grow)
|
||||
@@ -936,6 +939,7 @@
|
||||
#define _CRYPTO_get_thread_local BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_get_thread_local)
|
||||
#define _CRYPTO_ghash_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_ghash_init)
|
||||
#define _CRYPTO_has_asm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#define _CRYPTO_has_broken_NEON BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_has_broken_NEON)
|
||||
#define _CRYPTO_hchacha20 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_hchacha20)
|
||||
#define _CRYPTO_init_sysrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_init_sysrand)
|
||||
#define _CRYPTO_is_ADX_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ADX_capable)
|
||||
@@ -972,13 +976,17 @@
|
||||
#define _CRYPTO_MUTEX_lock_write BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_MUTEX_lock_write)
|
||||
#define _CRYPTO_MUTEX_unlock_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_MUTEX_unlock_read)
|
||||
#define _CRYPTO_MUTEX_unlock_write BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_MUTEX_unlock_write)
|
||||
#define _CRYPTO_needs_hwcap2_workaround BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_needs_hwcap2_workaround)
|
||||
#define _CRYPTO_new_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_new_ex_data)
|
||||
#define _CRYPTO_num_locks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_num_locks)
|
||||
#define _CRYPTO_ofb128_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_ofb128_encrypt)
|
||||
#define _CRYPTO_once BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_once)
|
||||
#define _CRYPTO_poly1305_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_finish)
|
||||
#define _CRYPTO_poly1305_finish_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_finish_neon)
|
||||
#define _CRYPTO_poly1305_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_init)
|
||||
#define _CRYPTO_poly1305_init_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_init_neon)
|
||||
#define _CRYPTO_poly1305_update BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_update)
|
||||
#define _CRYPTO_poly1305_update_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_poly1305_update_neon)
|
||||
#define _CRYPTO_pre_sandbox_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_pre_sandbox_init)
|
||||
#define _CRYPTO_rdrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_rdrand)
|
||||
#define _CRYPTO_rdrand_multiple8_buf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_rdrand_multiple8_buf)
|
||||
@@ -2245,6 +2253,8 @@
|
||||
#define _OPENSSL_malloc_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_malloc_init)
|
||||
#define _OPENSSL_memdup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_memdup)
|
||||
#define _OPENSSL_no_config BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_no_config)
|
||||
#define _openssl_poly1305_neon2_addmulmod BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, openssl_poly1305_neon2_addmulmod)
|
||||
#define _openssl_poly1305_neon2_blocks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, openssl_poly1305_neon2_blocks)
|
||||
#define _OPENSSL_posix_to_tm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_posix_to_tm)
|
||||
#define _OPENSSL_realloc BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_realloc)
|
||||
#define _OPENSSL_secure_clear_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_secure_clear_free)
|
||||
@@ -2583,6 +2593,7 @@
|
||||
#define _sha1_block_data_order_avx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_avx)
|
||||
#define _sha1_block_data_order_avx2 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_avx2)
|
||||
#define _sha1_block_data_order_hw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_hw)
|
||||
#define _sha1_block_data_order_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_neon)
|
||||
#define _sha1_block_data_order_nohw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_nohw)
|
||||
#define _sha1_block_data_order_ssse3 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order_ssse3)
|
||||
#define _SHA1_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA1_Final)
|
||||
@@ -2599,6 +2610,7 @@
|
||||
#define _sha256_avx_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_avx_capable)
|
||||
#define _sha256_block_data_order_avx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order_avx)
|
||||
#define _sha256_block_data_order_hw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order_hw)
|
||||
#define _sha256_block_data_order_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order_neon)
|
||||
#define _sha256_block_data_order_nohw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order_nohw)
|
||||
#define _sha256_block_data_order_ssse3 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order_ssse3)
|
||||
#define _SHA256_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA256_Final)
|
||||
@@ -2620,6 +2632,7 @@
|
||||
#define _sha512_avx_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_avx_capable)
|
||||
#define _sha512_block_data_order_avx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_block_data_order_avx)
|
||||
#define _sha512_block_data_order_hw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_block_data_order_hw)
|
||||
#define _sha512_block_data_order_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_block_data_order_neon)
|
||||
#define _sha512_block_data_order_nohw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_block_data_order_nohw)
|
||||
#define _SHA512_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, SHA512_Final)
|
||||
#define _sha512_hw_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_hw_capable)
|
||||
@@ -2960,9 +2973,11 @@
|
||||
#define _vpaes_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_capable)
|
||||
#define _vpaes_cbc_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_cbc_encrypt)
|
||||
#define _vpaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks)
|
||||
#define _vpaes_ctr32_encrypt_blocks_with_bsaes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks_with_bsaes)
|
||||
#define _vpaes_decrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_decrypt)
|
||||
#define _vpaes_decrypt_key_to_bsaes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_decrypt_key_to_bsaes)
|
||||
#define _vpaes_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_encrypt)
|
||||
#define _vpaes_encrypt_key_to_bsaes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_encrypt_key_to_bsaes)
|
||||
#define _vpaes_set_decrypt_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_set_decrypt_key)
|
||||
#define _vpaes_set_encrypt_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_set_encrypt_key)
|
||||
#define _X25519 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X25519)
|
||||
@@ -2979,6 +2994,7 @@
|
||||
#define _x25519_ge_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_sub)
|
||||
#define _x25519_ge_tobytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_tobytes)
|
||||
#define _X25519_keypair BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X25519_keypair)
|
||||
#define _x25519_NEON BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_NEON)
|
||||
#define _x25519_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_pkey_meth)
|
||||
#define _X25519_public_from_private BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X25519_public_from_private)
|
||||
#define _x25519_sc_reduce BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_sc_reduce)
|
||||
|
||||
@@ -637,6 +637,8 @@
|
||||
%xdefine _bn_mul4x_mont_capable _ %+ BORINGSSL_PREFIX %+ _bn_mul4x_mont_capable
|
||||
%xdefine _bn_mul4x_mont_gather5 _ %+ BORINGSSL_PREFIX %+ _bn_mul4x_mont_gather5
|
||||
%xdefine _bn_mul4x_mont_gather5_capable _ %+ BORINGSSL_PREFIX %+ _bn_mul4x_mont_gather5_capable
|
||||
%xdefine _bn_mul8x_mont_neon _ %+ BORINGSSL_PREFIX %+ _bn_mul8x_mont_neon
|
||||
%xdefine _bn_mul8x_mont_neon_capable _ %+ BORINGSSL_PREFIX %+ _bn_mul8x_mont_neon_capable
|
||||
%xdefine _bn_mulx_adx_capable _ %+ BORINGSSL_PREFIX %+ _bn_mulx_adx_capable
|
||||
%xdefine _bn_mulx4x_mont _ %+ BORINGSSL_PREFIX %+ _bn_mulx4x_mont
|
||||
%xdefine _bn_mulx4x_mont_capable _ %+ BORINGSSL_PREFIX %+ _bn_mulx4x_mont_capable
|
||||
@@ -732,6 +734,7 @@
|
||||
%xdefine _boringssl_self_test_slhdsa _ %+ BORINGSSL_PREFIX %+ _boringssl_self_test_slhdsa
|
||||
%xdefine _bsaes_capable _ %+ BORINGSSL_PREFIX %+ _bsaes_capable
|
||||
%xdefine _bsaes_cbc_encrypt _ %+ BORINGSSL_PREFIX %+ _bsaes_cbc_encrypt
|
||||
%xdefine _bsaes_ctr32_encrypt_blocks _ %+ BORINGSSL_PREFIX %+ _bsaes_ctr32_encrypt_blocks
|
||||
%xdefine _BUF_MEM_append _ %+ BORINGSSL_PREFIX %+ _BUF_MEM_append
|
||||
%xdefine _BUF_MEM_free _ %+ BORINGSSL_PREFIX %+ _BUF_MEM_free
|
||||
%xdefine _BUF_MEM_grow _ %+ BORINGSSL_PREFIX %+ _BUF_MEM_grow
|
||||
@@ -928,6 +931,7 @@
|
||||
%xdefine _CRYPTO_get_thread_local _ %+ BORINGSSL_PREFIX %+ _CRYPTO_get_thread_local
|
||||
%xdefine _CRYPTO_ghash_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_ghash_init
|
||||
%xdefine _CRYPTO_has_asm _ %+ BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine _CRYPTO_has_broken_NEON _ %+ BORINGSSL_PREFIX %+ _CRYPTO_has_broken_NEON
|
||||
%xdefine _CRYPTO_hchacha20 _ %+ BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine _CRYPTO_init_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine _CRYPTO_is_ADX_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ADX_capable
|
||||
@@ -964,13 +968,17 @@
|
||||
%xdefine _CRYPTO_MUTEX_lock_write _ %+ BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_lock_write
|
||||
%xdefine _CRYPTO_MUTEX_unlock_read _ %+ BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_unlock_read
|
||||
%xdefine _CRYPTO_MUTEX_unlock_write _ %+ BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_unlock_write
|
||||
%xdefine _CRYPTO_needs_hwcap2_workaround _ %+ BORINGSSL_PREFIX %+ _CRYPTO_needs_hwcap2_workaround
|
||||
%xdefine _CRYPTO_new_ex_data _ %+ BORINGSSL_PREFIX %+ _CRYPTO_new_ex_data
|
||||
%xdefine _CRYPTO_num_locks _ %+ BORINGSSL_PREFIX %+ _CRYPTO_num_locks
|
||||
%xdefine _CRYPTO_ofb128_encrypt _ %+ BORINGSSL_PREFIX %+ _CRYPTO_ofb128_encrypt
|
||||
%xdefine _CRYPTO_once _ %+ BORINGSSL_PREFIX %+ _CRYPTO_once
|
||||
%xdefine _CRYPTO_poly1305_finish _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish
|
||||
%xdefine _CRYPTO_poly1305_finish_neon _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish_neon
|
||||
%xdefine _CRYPTO_poly1305_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init
|
||||
%xdefine _CRYPTO_poly1305_init_neon _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init_neon
|
||||
%xdefine _CRYPTO_poly1305_update _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update
|
||||
%xdefine _CRYPTO_poly1305_update_neon _ %+ BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update_neon
|
||||
%xdefine _CRYPTO_pre_sandbox_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_pre_sandbox_init
|
||||
%xdefine _CRYPTO_rdrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_rdrand
|
||||
%xdefine _CRYPTO_rdrand_multiple8_buf _ %+ BORINGSSL_PREFIX %+ _CRYPTO_rdrand_multiple8_buf
|
||||
@@ -2237,6 +2245,8 @@
|
||||
%xdefine _OPENSSL_malloc_init _ %+ BORINGSSL_PREFIX %+ _OPENSSL_malloc_init
|
||||
%xdefine _OPENSSL_memdup _ %+ BORINGSSL_PREFIX %+ _OPENSSL_memdup
|
||||
%xdefine _OPENSSL_no_config _ %+ BORINGSSL_PREFIX %+ _OPENSSL_no_config
|
||||
%xdefine _openssl_poly1305_neon2_addmulmod _ %+ BORINGSSL_PREFIX %+ _openssl_poly1305_neon2_addmulmod
|
||||
%xdefine _openssl_poly1305_neon2_blocks _ %+ BORINGSSL_PREFIX %+ _openssl_poly1305_neon2_blocks
|
||||
%xdefine _OPENSSL_posix_to_tm _ %+ BORINGSSL_PREFIX %+ _OPENSSL_posix_to_tm
|
||||
%xdefine _OPENSSL_realloc _ %+ BORINGSSL_PREFIX %+ _OPENSSL_realloc
|
||||
%xdefine _OPENSSL_secure_clear_free _ %+ BORINGSSL_PREFIX %+ _OPENSSL_secure_clear_free
|
||||
@@ -2575,6 +2585,7 @@
|
||||
%xdefine _sha1_block_data_order_avx _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_avx
|
||||
%xdefine _sha1_block_data_order_avx2 _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_avx2
|
||||
%xdefine _sha1_block_data_order_hw _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_hw
|
||||
%xdefine _sha1_block_data_order_neon _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_neon
|
||||
%xdefine _sha1_block_data_order_nohw _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_nohw
|
||||
%xdefine _sha1_block_data_order_ssse3 _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order_ssse3
|
||||
%xdefine _SHA1_Final _ %+ BORINGSSL_PREFIX %+ _SHA1_Final
|
||||
@@ -2591,6 +2602,7 @@
|
||||
%xdefine _sha256_avx_capable _ %+ BORINGSSL_PREFIX %+ _sha256_avx_capable
|
||||
%xdefine _sha256_block_data_order_avx _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order_avx
|
||||
%xdefine _sha256_block_data_order_hw _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order_hw
|
||||
%xdefine _sha256_block_data_order_neon _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order_neon
|
||||
%xdefine _sha256_block_data_order_nohw _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order_nohw
|
||||
%xdefine _sha256_block_data_order_ssse3 _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order_ssse3
|
||||
%xdefine _SHA256_Final _ %+ BORINGSSL_PREFIX %+ _SHA256_Final
|
||||
@@ -2612,6 +2624,7 @@
|
||||
%xdefine _sha512_avx_capable _ %+ BORINGSSL_PREFIX %+ _sha512_avx_capable
|
||||
%xdefine _sha512_block_data_order_avx _ %+ BORINGSSL_PREFIX %+ _sha512_block_data_order_avx
|
||||
%xdefine _sha512_block_data_order_hw _ %+ BORINGSSL_PREFIX %+ _sha512_block_data_order_hw
|
||||
%xdefine _sha512_block_data_order_neon _ %+ BORINGSSL_PREFIX %+ _sha512_block_data_order_neon
|
||||
%xdefine _sha512_block_data_order_nohw _ %+ BORINGSSL_PREFIX %+ _sha512_block_data_order_nohw
|
||||
%xdefine _SHA512_Final _ %+ BORINGSSL_PREFIX %+ _SHA512_Final
|
||||
%xdefine _sha512_hw_capable _ %+ BORINGSSL_PREFIX %+ _sha512_hw_capable
|
||||
@@ -2952,9 +2965,11 @@
|
||||
%xdefine _vpaes_capable _ %+ BORINGSSL_PREFIX %+ _vpaes_capable
|
||||
%xdefine _vpaes_cbc_encrypt _ %+ BORINGSSL_PREFIX %+ _vpaes_cbc_encrypt
|
||||
%xdefine _vpaes_ctr32_encrypt_blocks _ %+ BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks
|
||||
%xdefine _vpaes_ctr32_encrypt_blocks_with_bsaes _ %+ BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks_with_bsaes
|
||||
%xdefine _vpaes_decrypt _ %+ BORINGSSL_PREFIX %+ _vpaes_decrypt
|
||||
%xdefine _vpaes_decrypt_key_to_bsaes _ %+ BORINGSSL_PREFIX %+ _vpaes_decrypt_key_to_bsaes
|
||||
%xdefine _vpaes_encrypt _ %+ BORINGSSL_PREFIX %+ _vpaes_encrypt
|
||||
%xdefine _vpaes_encrypt_key_to_bsaes _ %+ BORINGSSL_PREFIX %+ _vpaes_encrypt_key_to_bsaes
|
||||
%xdefine _vpaes_set_decrypt_key _ %+ BORINGSSL_PREFIX %+ _vpaes_set_decrypt_key
|
||||
%xdefine _vpaes_set_encrypt_key _ %+ BORINGSSL_PREFIX %+ _vpaes_set_encrypt_key
|
||||
%xdefine _X25519 _ %+ BORINGSSL_PREFIX %+ _X25519
|
||||
@@ -2971,6 +2986,7 @@
|
||||
%xdefine _x25519_ge_sub _ %+ BORINGSSL_PREFIX %+ _x25519_ge_sub
|
||||
%xdefine _x25519_ge_tobytes _ %+ BORINGSSL_PREFIX %+ _x25519_ge_tobytes
|
||||
%xdefine _X25519_keypair _ %+ BORINGSSL_PREFIX %+ _X25519_keypair
|
||||
%xdefine _x25519_NEON _ %+ BORINGSSL_PREFIX %+ _x25519_NEON
|
||||
%xdefine _x25519_pkey_meth _ %+ BORINGSSL_PREFIX %+ _x25519_pkey_meth
|
||||
%xdefine _X25519_public_from_private _ %+ BORINGSSL_PREFIX %+ _X25519_public_from_private
|
||||
%xdefine _x25519_sc_reduce _ %+ BORINGSSL_PREFIX %+ _x25519_sc_reduce
|
||||
@@ -4068,6 +4084,8 @@
|
||||
%xdefine bn_mul4x_mont_capable BORINGSSL_PREFIX %+ _bn_mul4x_mont_capable
|
||||
%xdefine bn_mul4x_mont_gather5 BORINGSSL_PREFIX %+ _bn_mul4x_mont_gather5
|
||||
%xdefine bn_mul4x_mont_gather5_capable BORINGSSL_PREFIX %+ _bn_mul4x_mont_gather5_capable
|
||||
%xdefine bn_mul8x_mont_neon BORINGSSL_PREFIX %+ _bn_mul8x_mont_neon
|
||||
%xdefine bn_mul8x_mont_neon_capable BORINGSSL_PREFIX %+ _bn_mul8x_mont_neon_capable
|
||||
%xdefine bn_mulx_adx_capable BORINGSSL_PREFIX %+ _bn_mulx_adx_capable
|
||||
%xdefine bn_mulx4x_mont BORINGSSL_PREFIX %+ _bn_mulx4x_mont
|
||||
%xdefine bn_mulx4x_mont_capable BORINGSSL_PREFIX %+ _bn_mulx4x_mont_capable
|
||||
@@ -4163,6 +4181,7 @@
|
||||
%xdefine boringssl_self_test_slhdsa BORINGSSL_PREFIX %+ _boringssl_self_test_slhdsa
|
||||
%xdefine bsaes_capable BORINGSSL_PREFIX %+ _bsaes_capable
|
||||
%xdefine bsaes_cbc_encrypt BORINGSSL_PREFIX %+ _bsaes_cbc_encrypt
|
||||
%xdefine bsaes_ctr32_encrypt_blocks BORINGSSL_PREFIX %+ _bsaes_ctr32_encrypt_blocks
|
||||
%xdefine BUF_MEM_append BORINGSSL_PREFIX %+ _BUF_MEM_append
|
||||
%xdefine BUF_MEM_free BORINGSSL_PREFIX %+ _BUF_MEM_free
|
||||
%xdefine BUF_MEM_grow BORINGSSL_PREFIX %+ _BUF_MEM_grow
|
||||
@@ -4359,6 +4378,7 @@
|
||||
%xdefine CRYPTO_get_thread_local BORINGSSL_PREFIX %+ _CRYPTO_get_thread_local
|
||||
%xdefine CRYPTO_ghash_init BORINGSSL_PREFIX %+ _CRYPTO_ghash_init
|
||||
%xdefine CRYPTO_has_asm BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine CRYPTO_has_broken_NEON BORINGSSL_PREFIX %+ _CRYPTO_has_broken_NEON
|
||||
%xdefine CRYPTO_hchacha20 BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine CRYPTO_init_sysrand BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine CRYPTO_is_ADX_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ADX_capable
|
||||
@@ -4395,13 +4415,17 @@
|
||||
%xdefine CRYPTO_MUTEX_lock_write BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_lock_write
|
||||
%xdefine CRYPTO_MUTEX_unlock_read BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_unlock_read
|
||||
%xdefine CRYPTO_MUTEX_unlock_write BORINGSSL_PREFIX %+ _CRYPTO_MUTEX_unlock_write
|
||||
%xdefine CRYPTO_needs_hwcap2_workaround BORINGSSL_PREFIX %+ _CRYPTO_needs_hwcap2_workaround
|
||||
%xdefine CRYPTO_new_ex_data BORINGSSL_PREFIX %+ _CRYPTO_new_ex_data
|
||||
%xdefine CRYPTO_num_locks BORINGSSL_PREFIX %+ _CRYPTO_num_locks
|
||||
%xdefine CRYPTO_ofb128_encrypt BORINGSSL_PREFIX %+ _CRYPTO_ofb128_encrypt
|
||||
%xdefine CRYPTO_once BORINGSSL_PREFIX %+ _CRYPTO_once
|
||||
%xdefine CRYPTO_poly1305_finish BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish
|
||||
%xdefine CRYPTO_poly1305_finish_neon BORINGSSL_PREFIX %+ _CRYPTO_poly1305_finish_neon
|
||||
%xdefine CRYPTO_poly1305_init BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init
|
||||
%xdefine CRYPTO_poly1305_init_neon BORINGSSL_PREFIX %+ _CRYPTO_poly1305_init_neon
|
||||
%xdefine CRYPTO_poly1305_update BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update
|
||||
%xdefine CRYPTO_poly1305_update_neon BORINGSSL_PREFIX %+ _CRYPTO_poly1305_update_neon
|
||||
%xdefine CRYPTO_pre_sandbox_init BORINGSSL_PREFIX %+ _CRYPTO_pre_sandbox_init
|
||||
%xdefine CRYPTO_rdrand BORINGSSL_PREFIX %+ _CRYPTO_rdrand
|
||||
%xdefine CRYPTO_rdrand_multiple8_buf BORINGSSL_PREFIX %+ _CRYPTO_rdrand_multiple8_buf
|
||||
@@ -5668,6 +5692,8 @@
|
||||
%xdefine OPENSSL_malloc_init BORINGSSL_PREFIX %+ _OPENSSL_malloc_init
|
||||
%xdefine OPENSSL_memdup BORINGSSL_PREFIX %+ _OPENSSL_memdup
|
||||
%xdefine OPENSSL_no_config BORINGSSL_PREFIX %+ _OPENSSL_no_config
|
||||
%xdefine openssl_poly1305_neon2_addmulmod BORINGSSL_PREFIX %+ _openssl_poly1305_neon2_addmulmod
|
||||
%xdefine openssl_poly1305_neon2_blocks BORINGSSL_PREFIX %+ _openssl_poly1305_neon2_blocks
|
||||
%xdefine OPENSSL_posix_to_tm BORINGSSL_PREFIX %+ _OPENSSL_posix_to_tm
|
||||
%xdefine OPENSSL_realloc BORINGSSL_PREFIX %+ _OPENSSL_realloc
|
||||
%xdefine OPENSSL_secure_clear_free BORINGSSL_PREFIX %+ _OPENSSL_secure_clear_free
|
||||
@@ -6006,6 +6032,7 @@
|
||||
%xdefine sha1_block_data_order_avx BORINGSSL_PREFIX %+ _sha1_block_data_order_avx
|
||||
%xdefine sha1_block_data_order_avx2 BORINGSSL_PREFIX %+ _sha1_block_data_order_avx2
|
||||
%xdefine sha1_block_data_order_hw BORINGSSL_PREFIX %+ _sha1_block_data_order_hw
|
||||
%xdefine sha1_block_data_order_neon BORINGSSL_PREFIX %+ _sha1_block_data_order_neon
|
||||
%xdefine sha1_block_data_order_nohw BORINGSSL_PREFIX %+ _sha1_block_data_order_nohw
|
||||
%xdefine sha1_block_data_order_ssse3 BORINGSSL_PREFIX %+ _sha1_block_data_order_ssse3
|
||||
%xdefine SHA1_Final BORINGSSL_PREFIX %+ _SHA1_Final
|
||||
@@ -6022,6 +6049,7 @@
|
||||
%xdefine sha256_avx_capable BORINGSSL_PREFIX %+ _sha256_avx_capable
|
||||
%xdefine sha256_block_data_order_avx BORINGSSL_PREFIX %+ _sha256_block_data_order_avx
|
||||
%xdefine sha256_block_data_order_hw BORINGSSL_PREFIX %+ _sha256_block_data_order_hw
|
||||
%xdefine sha256_block_data_order_neon BORINGSSL_PREFIX %+ _sha256_block_data_order_neon
|
||||
%xdefine sha256_block_data_order_nohw BORINGSSL_PREFIX %+ _sha256_block_data_order_nohw
|
||||
%xdefine sha256_block_data_order_ssse3 BORINGSSL_PREFIX %+ _sha256_block_data_order_ssse3
|
||||
%xdefine SHA256_Final BORINGSSL_PREFIX %+ _SHA256_Final
|
||||
@@ -6043,6 +6071,7 @@
|
||||
%xdefine sha512_avx_capable BORINGSSL_PREFIX %+ _sha512_avx_capable
|
||||
%xdefine sha512_block_data_order_avx BORINGSSL_PREFIX %+ _sha512_block_data_order_avx
|
||||
%xdefine sha512_block_data_order_hw BORINGSSL_PREFIX %+ _sha512_block_data_order_hw
|
||||
%xdefine sha512_block_data_order_neon BORINGSSL_PREFIX %+ _sha512_block_data_order_neon
|
||||
%xdefine sha512_block_data_order_nohw BORINGSSL_PREFIX %+ _sha512_block_data_order_nohw
|
||||
%xdefine SHA512_Final BORINGSSL_PREFIX %+ _SHA512_Final
|
||||
%xdefine sha512_hw_capable BORINGSSL_PREFIX %+ _sha512_hw_capable
|
||||
@@ -6383,9 +6412,11 @@
|
||||
%xdefine vpaes_capable BORINGSSL_PREFIX %+ _vpaes_capable
|
||||
%xdefine vpaes_cbc_encrypt BORINGSSL_PREFIX %+ _vpaes_cbc_encrypt
|
||||
%xdefine vpaes_ctr32_encrypt_blocks BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks
|
||||
%xdefine vpaes_ctr32_encrypt_blocks_with_bsaes BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks_with_bsaes
|
||||
%xdefine vpaes_decrypt BORINGSSL_PREFIX %+ _vpaes_decrypt
|
||||
%xdefine vpaes_decrypt_key_to_bsaes BORINGSSL_PREFIX %+ _vpaes_decrypt_key_to_bsaes
|
||||
%xdefine vpaes_encrypt BORINGSSL_PREFIX %+ _vpaes_encrypt
|
||||
%xdefine vpaes_encrypt_key_to_bsaes BORINGSSL_PREFIX %+ _vpaes_encrypt_key_to_bsaes
|
||||
%xdefine vpaes_set_decrypt_key BORINGSSL_PREFIX %+ _vpaes_set_decrypt_key
|
||||
%xdefine vpaes_set_encrypt_key BORINGSSL_PREFIX %+ _vpaes_set_encrypt_key
|
||||
%xdefine X25519 BORINGSSL_PREFIX %+ _X25519
|
||||
@@ -6402,6 +6433,7 @@
|
||||
%xdefine x25519_ge_sub BORINGSSL_PREFIX %+ _x25519_ge_sub
|
||||
%xdefine x25519_ge_tobytes BORINGSSL_PREFIX %+ _x25519_ge_tobytes
|
||||
%xdefine X25519_keypair BORINGSSL_PREFIX %+ _X25519_keypair
|
||||
%xdefine x25519_NEON BORINGSSL_PREFIX %+ _x25519_NEON
|
||||
%xdefine x25519_pkey_meth BORINGSSL_PREFIX %+ _x25519_pkey_meth
|
||||
%xdefine X25519_public_from_private BORINGSSL_PREFIX %+ _X25519_public_from_private
|
||||
%xdefine x25519_sc_reduce BORINGSSL_PREFIX %+ _x25519_sc_reduce
|
||||
|
||||
@@ -36,26 +36,20 @@ extension OpenSSLSupportedNISTCurve {
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension P256: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var group: BoringSSLEllipticCurveGroup {
|
||||
try! BoringSSLEllipticCurveGroup(.p256)
|
||||
}
|
||||
@usableFromInline
|
||||
static let group = try! BoringSSLEllipticCurveGroup(.p256)
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension P384: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var group: BoringSSLEllipticCurveGroup {
|
||||
try! BoringSSLEllipticCurveGroup(.p384)
|
||||
}
|
||||
@usableFromInline
|
||||
static let group = try! BoringSSLEllipticCurveGroup(.p384)
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension P521: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var group: BoringSSLEllipticCurveGroup {
|
||||
try! BoringSSLEllipticCurveGroup(.p521)
|
||||
}
|
||||
@usableFromInline
|
||||
static let group = try! BoringSSLEllipticCurveGroup(.p521)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
|
||||
@@ -21,15 +21,12 @@ private let emptyStorage:SecureBytes.Backing = SecureBytes.Backing.createEmpty()
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
struct SecureBytes {
|
||||
@usableFromInline
|
||||
var backing: Backing
|
||||
|
||||
@inlinable
|
||||
init() {
|
||||
self = .init(count: 0)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
init(count: Int) {
|
||||
if count == 0 {
|
||||
self.backing = emptyStorage
|
||||
@@ -43,7 +40,6 @@ struct SecureBytes {
|
||||
}
|
||||
|
||||
/// Allows initializing a SecureBytes object with a closure that will initialize the memory.
|
||||
@usableFromInline
|
||||
init(unsafeUninitializedCapacity: Int, initializingWith callback: (inout UnsafeMutableRawBufferPointer, inout Int) throws -> Void) rethrows {
|
||||
self.backing = Backing.create(capacity: unsafeUninitializedCapacity)
|
||||
try self.backing._withVeryUnsafeMutableBytes { veryUnsafePointer in
|
||||
@@ -59,7 +55,6 @@ struct SecureBytes {
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes {
|
||||
@inlinable
|
||||
mutating func append<C: Collection>(_ data: C) where C.Element == UInt8 {
|
||||
let requiredCapacity = self.count + data.count
|
||||
let backingCapacity = self.backing.allocatedCapacity
|
||||
@@ -71,7 +66,6 @@ extension SecureBytes {
|
||||
self.backing._appendBytes(data)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
mutating func reserveCapacity(_ n: Int) {
|
||||
let backingCapacity = self.backing.allocatedCapacity
|
||||
if backingCapacity >= n {
|
||||
@@ -95,32 +89,27 @@ extension SecureBytes: Equatable {
|
||||
// MARK: - Collection conformance
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes: Collection {
|
||||
@usableFromInline
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
struct Index {
|
||||
/* fileprivate but usableFromInline */ @usableFromInline var offset: Int
|
||||
/* fileprivate but usableFromInline */ var offset: Int
|
||||
|
||||
/*@inlinable*/ @usableFromInline internal init(offset: Int) {
|
||||
/*@inlinable*/ internal init(offset: Int) {
|
||||
self.offset = offset
|
||||
}
|
||||
}
|
||||
|
||||
@inlinable
|
||||
var startIndex: Index {
|
||||
return Index(offset: 0)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
var endIndex: Index {
|
||||
return Index(offset: self.count)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
var count: Int {
|
||||
return self.backing.count
|
||||
}
|
||||
|
||||
@inlinable
|
||||
subscript(_ index: Index) -> UInt8 {
|
||||
get {
|
||||
return self.backing[offset: index.offset]
|
||||
@@ -130,7 +119,6 @@ extension SecureBytes: Collection {
|
||||
}
|
||||
}
|
||||
|
||||
@inlinable
|
||||
func index(after index: Index) -> Index {
|
||||
return index.advanced(by: 1)
|
||||
}
|
||||
@@ -139,7 +127,6 @@ extension SecureBytes: Collection {
|
||||
// MARK: - BidirectionalCollection conformance
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes: BidirectionalCollection {
|
||||
@inlinable
|
||||
func index(before index: Index) -> Index {
|
||||
return index.advanced(by: -1)
|
||||
}
|
||||
@@ -156,7 +143,6 @@ extension SecureBytes: MutableCollection { }
|
||||
// MARK: - RangeReplaceableCollection conformance
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes: RangeReplaceableCollection {
|
||||
@inlinable
|
||||
mutating func replaceSubrange<C: Collection>(_ subrange: Range<Index>, with newElements: C) where C.Element == UInt8 {
|
||||
let requiredCapacity = self.backing.count - subrange.count + newElements.count
|
||||
let backingCapacity = self.backing.allocatedCapacity
|
||||
@@ -182,7 +168,6 @@ extension SecureBytes: RangeReplaceableCollection {
|
||||
}
|
||||
|
||||
// The default implementation of this from RangeReplaceableCollection can't take advantage of `ContiguousBytes`, so we override it here
|
||||
@inlinable
|
||||
public mutating func append<Elements: Sequence>(contentsOf newElements: Elements) where Elements.Element == UInt8 {
|
||||
let done:Void? = newElements.withContiguousStorageIfAvailable {
|
||||
replaceSubrange(endIndex..<endIndex, with: $0)
|
||||
@@ -199,12 +184,10 @@ extension SecureBytes: RangeReplaceableCollection {
|
||||
// MARK: - ContiguousBytes conformance
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes: ContiguousBytes {
|
||||
@inlinable
|
||||
func withUnsafeBytes<T>(_ body: (UnsafeRawBufferPointer) throws -> T) rethrows -> T {
|
||||
return try self.backing.withUnsafeBytes(body)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
mutating func withUnsafeMutableBytes<T>(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T {
|
||||
if !isKnownUniquelyReferenced(&self.backing) {
|
||||
self.backing = Backing.create(copying: self.backing)
|
||||
@@ -213,7 +196,6 @@ extension SecureBytes: ContiguousBytes {
|
||||
return try self.backing.withUnsafeMutableBytes(body)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<UInt8>) throws -> R) rethrows -> R? {
|
||||
return try self.backing.withContiguousStorageIfAvailable(body)
|
||||
}
|
||||
@@ -222,7 +204,6 @@ extension SecureBytes: ContiguousBytes {
|
||||
// MARK: - DataProtocol conformance
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes: DataProtocol {
|
||||
@inlinable
|
||||
var regions: CollectionOfOne<SecureBytes> {
|
||||
return CollectionOfOne(self)
|
||||
}
|
||||
@@ -257,37 +238,29 @@ extension SecureBytes.Index: Strideable {
|
||||
// MARK: - Heap allocated backing storage.
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes {
|
||||
@usableFromInline
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
internal struct BackingHeader {
|
||||
@usableFromInline
|
||||
internal var count: Int
|
||||
|
||||
@usableFromInline
|
||||
internal var capacity: Int
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
internal class Backing: ManagedBuffer<BackingHeader, UInt8> {
|
||||
|
||||
@usableFromInline
|
||||
class func createEmpty() -> Backing {
|
||||
return Backing.create(minimumCapacity: 0, makingHeaderWith: { _ in BackingHeader(count: 0, capacity: 0) }) as! Backing
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
class func create(capacity: Int) -> Backing {
|
||||
let capacity = Int(UInt32(capacity).nextPowerOf2ClampedToMax())
|
||||
return Backing.create(minimumCapacity: capacity, makingHeaderWith: { _ in BackingHeader(count: 0, capacity: capacity) }) as! Backing
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
class func create(copying original: Backing) -> Backing {
|
||||
return Backing.create(bytes: original)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
class func create<D: ContiguousBytes>(bytes: D) -> Backing {
|
||||
return bytes.withUnsafeBytes { bytesPtr in
|
||||
let backing = Backing.create(capacity: bytesPtr.count)
|
||||
@@ -300,7 +273,6 @@ extension SecureBytes {
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
class func create(randomBytes: Int) -> Backing {
|
||||
let backing = Backing.create(capacity: randomBytes)
|
||||
backing._withVeryUnsafeMutableBytes { targetPtr in
|
||||
@@ -320,7 +292,6 @@ extension SecureBytes {
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
var count: Int {
|
||||
get {
|
||||
return self.header.count
|
||||
@@ -330,7 +301,6 @@ extension SecureBytes {
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
subscript(offset offset: Int) -> UInt8 {
|
||||
get {
|
||||
// precondition(offset >= 0 && offset < self.count)
|
||||
@@ -346,7 +316,6 @@ extension SecureBytes {
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
extension SecureBytes.Backing {
|
||||
@usableFromInline
|
||||
var allocatedCapacity: Int {
|
||||
#if os(OpenBSD)
|
||||
return self.header.capacity
|
||||
@@ -419,7 +388,6 @@ extension SecureBytes.Backing {
|
||||
/// Moves the range of bytes identified by the slice by the delta, crashing if the move would
|
||||
/// place the bytes out of the storage. Note that this does not update the count: external code
|
||||
/// must ensure that that happens.
|
||||
@usableFromInline
|
||||
/* private but usableFromInline */ func _moveBytes(range: Range<Int>, by delta: Int) {
|
||||
// We have to check that the range is within the delta, as is the new location.
|
||||
precondition(range.lowerBound >= 0)
|
||||
@@ -437,7 +405,6 @@ extension SecureBytes.Backing {
|
||||
}
|
||||
|
||||
// Copies some bytes into the buffer at the appropriate place. Does not update count: external code must do so.
|
||||
@inlinable
|
||||
/* private but inlinable */ func _copyBytes<C: Collection>(_ bytes: C, at offset: Int) where C.Element == UInt8 {
|
||||
precondition(offset >= 0)
|
||||
precondition(offset + bytes.count <= self.allocatedCapacity)
|
||||
@@ -470,7 +437,6 @@ extension SecureBytes.Backing: ContiguousBytes {
|
||||
}
|
||||
|
||||
/// Very unsafe in the sense that this points to uninitialized memory. Used only for implementations within this file.
|
||||
@inlinable
|
||||
/* private but inlinable */ func _withVeryUnsafeMutableBytes<T>(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T {
|
||||
let capacity = self.allocatedCapacity
|
||||
|
||||
|
||||
@@ -69,6 +69,10 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.multiply(by: rhs, on: group, context: context)
|
||||
}
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package consuming func multiplying(
|
||||
by rhs: ArbitraryPrecisionInteger,
|
||||
@@ -78,6 +82,18 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.multiply(by: rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package func multiplying(
|
||||
by rhs: ArbitraryPrecisionInteger,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var `self` = self
|
||||
try self.multiply(by: rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#endif
|
||||
|
||||
@usableFromInline
|
||||
package static func multiplying(
|
||||
@@ -110,6 +126,10 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.add(rhs, on: group, context: context)
|
||||
}
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package consuming func adding(
|
||||
_ rhs: consuming EllipticCurvePoint,
|
||||
@@ -119,7 +139,23 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.add(rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package func adding(
|
||||
_ rhs: consuming EllipticCurvePoint,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var `self` = self
|
||||
try self.add(rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#endif
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package static func adding(
|
||||
_ lhs: consuming EllipticCurvePoint,
|
||||
@@ -130,6 +166,19 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try lhs.add(rhs, on: group, context: context)
|
||||
return lhs
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package static func adding(
|
||||
_ lhs: EllipticCurvePoint,
|
||||
_ rhs: EllipticCurvePoint,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var lhs = lhs
|
||||
try lhs.add(rhs, on: group, context: context)
|
||||
return lhs
|
||||
}
|
||||
#endif
|
||||
|
||||
@usableFromInline
|
||||
package mutating func invert(
|
||||
@@ -150,6 +199,10 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.invert(on: group, context: context)
|
||||
}
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package consuming func inverting(
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
@@ -158,7 +211,22 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.invert(on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package func inverting(
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var `self` = self
|
||||
try self.invert(on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#endif
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package static func inverting(
|
||||
_ point: consuming EllipticCurvePoint,
|
||||
@@ -168,6 +236,18 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try point.invert(on: group, context: context)
|
||||
return point
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package static func inverting(
|
||||
_ point: EllipticCurvePoint,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var point = point
|
||||
try point.invert(on: group, context: context)
|
||||
return point
|
||||
}
|
||||
#endif
|
||||
|
||||
@usableFromInline
|
||||
package mutating func subtract(
|
||||
@@ -190,6 +270,10 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.subtract(rhs, on: group, context: context)
|
||||
}
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package consuming func subtracting(
|
||||
_ rhs: consuming EllipticCurvePoint,
|
||||
@@ -199,7 +283,23 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try self.subtract(rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package func subtracting(
|
||||
_ rhs: EllipticCurvePoint,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var `self` = self
|
||||
try self.subtract(rhs, on: group, context: context)
|
||||
return self
|
||||
}
|
||||
#endif
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
@usableFromInline
|
||||
package static func subtracting(
|
||||
_ rhs: consuming EllipticCurvePoint,
|
||||
@@ -210,6 +310,19 @@ package struct EllipticCurvePoint: @unchecked Sendable {
|
||||
try lhs.subtract(rhs, on: group, context: context)
|
||||
return lhs
|
||||
}
|
||||
#else
|
||||
@usableFromInline
|
||||
package static func subtracting(
|
||||
_ rhs: EllipticCurvePoint,
|
||||
from lhs: EllipticCurvePoint,
|
||||
on group: BoringSSLEllipticCurveGroup,
|
||||
context: FiniteFieldArithmeticContext? = nil
|
||||
) throws -> EllipticCurvePoint {
|
||||
var lhs = lhs
|
||||
try lhs.subtract(rhs, on: group, context: context)
|
||||
return lhs
|
||||
}
|
||||
#endif
|
||||
|
||||
@usableFromInline
|
||||
package init<MessageBytes: ContiguousBytes, DSTBytes: ContiguousBytes>(
|
||||
|
||||
@@ -147,8 +147,9 @@ extension AES {
|
||||
extension AES._CBC {
|
||||
/// An initialization vector.
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
public struct IV: Sendable {
|
||||
public struct IV: Sendable, Sequence {
|
||||
// AES CBC uses a 128-bit IV.
|
||||
@usableFromInline
|
||||
var ivBytes: (
|
||||
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
|
||||
UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8
|
||||
@@ -193,6 +194,13 @@ extension AES._CBC {
|
||||
bytesPtr.copyBytes(from: ivBytes)
|
||||
}
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public func makeIterator() -> some IteratorProtocol<UInt8> {
|
||||
withUnsafeBytes(of: ivBytes) { unsafeRawBufferPointer in
|
||||
Array(unsafeRawBufferPointer).makeIterator()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) 2025 Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
@_implementationOnly import CCryptoBoringSSL
|
||||
import Crypto
|
||||
|
||||
#if canImport(FoundationEssentials)
|
||||
import FoundationEssentials
|
||||
#else
|
||||
import Foundation
|
||||
#endif
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
|
||||
extension AES {
|
||||
/// A cipher-based message authentication code.
|
||||
///
|
||||
/// CMAC uses AES to implement a MAC. CMAC is useful in contexts where access to
|
||||
/// a hash function is not guaranteed, but a block cipher will be available.
|
||||
public struct CMAC: @unchecked Sendable {
|
||||
// Unchecked sendable because this is CoW.
|
||||
fileprivate var backing: Backing
|
||||
|
||||
/// Creates a message authentication code generator.
|
||||
///
|
||||
/// Defaults the output size to 128 bits.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - key: The symmetric key used to secure the computation.
|
||||
public init(key: SymmetricKey) throws {
|
||||
try self.init(key: key, outputSize: 16)
|
||||
}
|
||||
|
||||
/// Creates a message authentication code generator.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - key: The symmetric key used to secure the computation.
|
||||
/// - outputSize: The number of bytes of MAC to generate. Must be in the range 0 to 16 inclusive.
|
||||
public init(key: SymmetricKey, outputSize: Int) throws {
|
||||
guard [128, 192, 256].contains(key.bitCount) else {
|
||||
throw CryptoError.incorrectKeySize
|
||||
}
|
||||
guard (0...16).contains(outputSize) else {
|
||||
throw CryptoKitError.incorrectParameterSize
|
||||
}
|
||||
|
||||
self.backing = Backing(key: key, outputSize: outputSize)
|
||||
}
|
||||
|
||||
/// Adds data to be authenticated by MAC function. This can be called one or more times to append additional data.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - bufferPointer: The data to be authenticated.
|
||||
public mutating func update(bufferPointer: UnsafeRawBufferPointer) {
|
||||
self.cowIfNeeded()
|
||||
self.backing.update(bufferPointer)
|
||||
}
|
||||
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
/// Finalizes the message authentication computation and returns the
|
||||
/// computed code.
|
||||
///
|
||||
/// - Returns: The message authentication code.
|
||||
public consuming func finalize() -> AES.CMAC.MAC {
|
||||
// The combination of "consuming" and "cowifneeded" should
|
||||
// produce an environment where, if users may choose to
|
||||
// keep using the MAC, they can, but if they aren't we'll
|
||||
// avoid an unnecessary CoW.
|
||||
self.cowIfNeeded()
|
||||
return self.backing.finalize()
|
||||
}
|
||||
#else
|
||||
/// Finalizes the message authentication computation and returns the
|
||||
/// computed code.
|
||||
///
|
||||
/// - Returns: The message authentication code.
|
||||
public func finalize() -> AES.CMAC.MAC {
|
||||
var `self` = self
|
||||
return self.backing.finalize()
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Updates the MAC with data.
|
||||
///
|
||||
/// - Parameter data: The data to update the MAC
|
||||
public mutating func update<D: DataProtocol>(data: D) {
|
||||
for memoryRegion in data.regions {
|
||||
memoryRegion.withUnsafeBytes { bp in
|
||||
self.update(bufferPointer: bp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private mutating func cowIfNeeded() {
|
||||
if !isKnownUniquelyReferenced(&self.backing) {
|
||||
self.backing = Backing(copying: self.backing)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
|
||||
extension AES.CMAC {
|
||||
/// A cipher-based message authentication code.
|
||||
public struct MAC: MessageAuthenticationCode {
|
||||
fileprivate let underlyingData: Data
|
||||
|
||||
init(underlyingData: Data) {
|
||||
self.underlyingData = underlyingData
|
||||
}
|
||||
|
||||
/// The number of bytes in the message authentication code.
|
||||
public var byteCount: Int {
|
||||
self.underlyingData.count
|
||||
}
|
||||
|
||||
/// Invokes the given closure with a buffer pointer covering the raw bytes
|
||||
/// of the code.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - body: A closure that takes a raw buffer pointer to the bytes of the
|
||||
/// code.
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
try self.underlyingData.withUnsafeBytes(body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
|
||||
extension AES.CMAC {
|
||||
fileprivate final class Backing {
|
||||
private let key: SymmetricKey
|
||||
private let context: OpaquePointer
|
||||
private let outputSize: Int
|
||||
|
||||
init(key: SymmetricKey, outputSize: Int) {
|
||||
self.key = key
|
||||
self.context = CCryptoBoringSSL_CMAC_CTX_new()
|
||||
self.outputSize = outputSize
|
||||
|
||||
let rc = self.key.withUnsafeBytes { keyPtr in
|
||||
CCryptoBoringSSL_CMAC_Init(
|
||||
self.context,
|
||||
keyPtr.baseAddress,
|
||||
keyPtr.count,
|
||||
key.aesEVP,
|
||||
nil
|
||||
)
|
||||
}
|
||||
precondition(rc == 1)
|
||||
}
|
||||
|
||||
init(copying other: Backing) {
|
||||
self.key = other.key
|
||||
self.context = CCryptoBoringSSL_CMAC_CTX_new()
|
||||
self.outputSize = other.outputSize
|
||||
let rc = CCryptoBoringSSL_CMAC_CTX_copy(self.context, other.context)
|
||||
precondition(rc == 1)
|
||||
|
||||
// Ensure we don't lose `other` at this time.
|
||||
withExtendedLifetime(other) {}
|
||||
}
|
||||
|
||||
deinit {
|
||||
CCryptoBoringSSL_CMAC_CTX_free(self.context)
|
||||
}
|
||||
|
||||
func update(_ bytes: UnsafeRawBufferPointer) {
|
||||
let rc = CCryptoBoringSSL_CMAC_Update(self.context, bytes.baseAddress, bytes.count)
|
||||
precondition(rc == 1)
|
||||
}
|
||||
|
||||
func finalize() -> AES.CMAC.MAC {
|
||||
let bytes = withUnsafeTemporaryAllocation(byteCount: 16, alignment: 1) { bytes in
|
||||
precondition(bytes.count >= 16)
|
||||
var count = 16
|
||||
let rc = CCryptoBoringSSL_CMAC_Final(self.context, bytes.baseAddress, &count)
|
||||
precondition(count == 16)
|
||||
precondition(rc == 1)
|
||||
|
||||
return Data(UnsafeRawBufferPointer(rebasing: bytes.prefix(self.outputSize)))
|
||||
}
|
||||
return AES.CMAC.MAC(underlyingData: bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
|
||||
extension SymmetricKey {
|
||||
fileprivate var aesEVP: OpaquePointer {
|
||||
switch self.bitCount {
|
||||
case 128:
|
||||
CCryptoBoringSSL_EVP_aes_128_cbc()
|
||||
case 192:
|
||||
CCryptoBoringSSL_EVP_aes_192_cbc()
|
||||
case 256:
|
||||
CCryptoBoringSSL_EVP_aes_256_cbc()
|
||||
default:
|
||||
fatalError("Should be unreachable")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ add_library(_CryptoExtras
|
||||
"AES/BoringSSL/AES_CFB_boring.swift"
|
||||
"AES/BoringSSL/AES_CTR_boring.swift"
|
||||
"AES/BoringSSL/AES_GCM_SIV_boring.swift"
|
||||
"AES/CMAC.swift"
|
||||
"ARC/ARC+API.swift"
|
||||
"ARC/ARC.swift"
|
||||
"ARC/ARCCredential.swift"
|
||||
|
||||
@@ -65,10 +65,16 @@ extension P256: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var hashToFieldByteCount: Int { 48 }
|
||||
|
||||
@TaskLocal
|
||||
@usableFromInline
|
||||
// NOTE: This could be a let when Swift 6.0 is the minimum supported version.
|
||||
static var __ffac = try! FiniteFieldArithmeticContext(fieldSize: P256.group.order)
|
||||
static var __ffac: FiniteFieldArithmeticContext {
|
||||
let key = "com.apple.swift-crypto.P256.__ffac"
|
||||
if let value = Thread.current.threadDictionary[key] as? FiniteFieldArithmeticContext {
|
||||
return value
|
||||
}
|
||||
let value = try! FiniteFieldArithmeticContext(fieldSize: P256.group.order)
|
||||
Thread.current.threadDictionary[key] = value
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
/// NOTE: This conformance applies to this type from the Crypto module even if it comes from the SDK.
|
||||
@@ -92,10 +98,16 @@ extension P384: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var hashToFieldByteCount: Int { 72 }
|
||||
|
||||
@TaskLocal
|
||||
@usableFromInline
|
||||
// NOTE: This could be a let when Swift 6.0 is the minimum supported version.
|
||||
static var __ffac = try! FiniteFieldArithmeticContext(fieldSize: P384.group.order)
|
||||
static var __ffac: FiniteFieldArithmeticContext {
|
||||
let key = "com.apple.swift-crypto.P384.__ffac"
|
||||
if let value = Thread.current.threadDictionary[key] as? FiniteFieldArithmeticContext {
|
||||
return value
|
||||
}
|
||||
let value = try! FiniteFieldArithmeticContext(fieldSize: P384.group.order)
|
||||
Thread.current.threadDictionary[key] = value
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
/// NOTE: This conformance applies to this type from the Crypto module even if it comes from the SDK.
|
||||
@@ -119,10 +131,16 @@ extension P521: OpenSSLSupportedNISTCurve {
|
||||
@inlinable
|
||||
static var hashToFieldByteCount: Int { 98 }
|
||||
|
||||
@TaskLocal
|
||||
@usableFromInline
|
||||
// NOTE: This could be a let when Swift 6.0 is the minimum supported version.
|
||||
static var __ffac = try! FiniteFieldArithmeticContext(fieldSize: P521.group.order)
|
||||
static var __ffac: FiniteFieldArithmeticContext {
|
||||
let key = "com.apple.swift-crypto.P521.__ffac"
|
||||
if let value = Thread.current.threadDictionary[key] as? FiniteFieldArithmeticContext {
|
||||
return value
|
||||
}
|
||||
let value = try! FiniteFieldArithmeticContext(fieldSize: P521.group.order)
|
||||
Thread.current.threadDictionary[key] = value
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
|
||||
|
||||
@@ -15,9 +15,14 @@
|
||||
import Foundation
|
||||
|
||||
extension Data {
|
||||
// This enhancement can only be present on 6.1 or later because of the
|
||||
// absence of https://github.com/swiftlang/swift/pull/76186 in older
|
||||
// compilers.
|
||||
#if compiler(>=6.1)
|
||||
// This overload reduces allocations when used in a chain of infix operations.
|
||||
static func + (lhs: consuming Data, rhs: consuming Data) -> Data {
|
||||
lhs.append(contentsOf: rhs)
|
||||
return lhs
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -158,6 +158,14 @@ final class CBCTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testToDataConversion() throws {
|
||||
let randomBytes = (0..<16).map { _ in UInt8.random(in: UInt8.min...UInt8.max) }
|
||||
let dataIn = Data(randomBytes)
|
||||
let iv = try AES._CBC.IV(ivBytes: dataIn)
|
||||
let dataOut = Data(iv)
|
||||
XCTAssertEqual(dataIn, dataOut)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) 2025 Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
import Crypto
|
||||
import Foundation
|
||||
import XCTest
|
||||
import _CryptoExtras
|
||||
|
||||
final class CMACTests: XCTestCase {
|
||||
// Borrowed from CryptoKit
|
||||
func testVector1() throws {
|
||||
let key = try Array(hexString: "a60269f095ad3c3bafae907c6f215de0")
|
||||
let mac = try Array(hexString: "172084c3fe99fde4af29aa8e6e5fe1")
|
||||
let msg = try Array(hexString: "cead1c5af16ca89bc0821775f8cba8c25620a03dfd27d6f1186f75f1c0bcfe4a20")
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 15)
|
||||
authenticator.update(data: msg)
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
// rfc4493 example vectors
|
||||
// https://datatracker.ietf.org/doc/html/rfc4493#page-11
|
||||
let exampleVector1 = ""
|
||||
|
||||
let exampleVector2 = """
|
||||
6bc1bee22e409f96e93d7e117393172a
|
||||
"""
|
||||
|
||||
let exampleVector3 = """
|
||||
6bc1bee22e409f96e93d7e117393172a\
|
||||
ae2d8a571e03ac9c9eb76fac45af8e51\
|
||||
30c81c46a35ce411
|
||||
"""
|
||||
|
||||
let exampleVector4 = """
|
||||
6bc1bee22e409f96e93d7e117393172a\
|
||||
ae2d8a571e03ac9c9eb76fac45af8e51\
|
||||
30c81c46a35ce411e5fbc1191a0a52ef\
|
||||
f69f2445df4f9b17ad2b417be66c3710
|
||||
"""
|
||||
|
||||
func testExampleVector1() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "bb1d6929e95937287fa37d129b756746")
|
||||
let msg = try Array(hexString: exampleVector1)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
authenticator.update(data: msg)
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
func testExampleVector2() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "070a16b46b4d4144f79bdd9dd04a287c")
|
||||
let msg = try Array(hexString: exampleVector2)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
authenticator.update(data: msg)
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
func testExampleVector2PerByte() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "070a16b46b4d4144f79bdd9dd04a287c")
|
||||
let msg = try Array(hexString: exampleVector2)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
for byte in msg {
|
||||
authenticator.update(data: [byte])
|
||||
}
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
func testExampleVector3() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "dfa66747de9ae63030ca32611497c827")
|
||||
let msg = try Array(hexString: exampleVector3)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
authenticator.update(data: msg)
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
func testExampleVector3PerByte() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "dfa66747de9ae63030ca32611497c827")
|
||||
let msg = try Array(hexString: exampleVector3)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
for byte in msg {
|
||||
authenticator.update(data: [byte])
|
||||
}
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
// rfc4493 example vector 4
|
||||
// https://datatracker.ietf.org/doc/html/rfc4493#page-11
|
||||
func testExampleVector4() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "51f0bebf7e3b9d92fc49741779363cfe")
|
||||
let msg = try Array(hexString: exampleVector4)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
authenticator.update(data: msg)
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
// rfc4493 example vector 4
|
||||
// https://datatracker.ietf.org/doc/html/rfc4493#page-11
|
||||
func testExampleVector4PerByte() throws {
|
||||
let key = try Array(hexString: "2b7e151628aed2a6abf7158809cf4f3c")
|
||||
let mac = try Array(hexString: "51f0bebf7e3b9d92fc49741779363cfe")
|
||||
let msg = try Array(hexString: exampleVector4)
|
||||
|
||||
var authenticator = try AES.CMAC(key: SymmetricKey(data: key), outputSize: 16)
|
||||
for byte in msg {
|
||||
authenticator.update(data: [byte])
|
||||
}
|
||||
XCTAssert(authenticator.finalize() == mac)
|
||||
}
|
||||
|
||||
func testWycheproof() throws {
|
||||
try wycheproofTest(jsonName: "aes_cmac_test") { (group: TestGroup) in
|
||||
for test in group.tests {
|
||||
precondition(test.flags.isEmpty)
|
||||
|
||||
do {
|
||||
var authenticator = try AES.CMAC(key: test.computedKey, outputSize: test.computedTag.count)
|
||||
authenticator.update(data: test.computedMsg)
|
||||
let result = authenticator.finalize()
|
||||
|
||||
switch test.result {
|
||||
case "valid":
|
||||
XCTAssertTrue(
|
||||
result == test.computedTag,
|
||||
"Unexpected invalid test \(test.tcId) (\(test.comment))"
|
||||
)
|
||||
case "invalid":
|
||||
XCTAssertFalse(
|
||||
result == test.computedTag,
|
||||
"Unexpected valid test \(test.tcId) (\(test.comment))"
|
||||
)
|
||||
default:
|
||||
fatalError("Unexpected result type")
|
||||
}
|
||||
} catch {
|
||||
XCTAssertTrue(test.result == "invalid", "Unexpected invalid test \(test.tcId) (\(test.comment))")
|
||||
XCTAssertTrue(
|
||||
test.comment == "invalid key size",
|
||||
"Unexpected invalid test \(test.tcId) (\(test.comment))"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TestGroup: Codable {
|
||||
var keySize: Int
|
||||
var tagSize: Int
|
||||
var type: String
|
||||
var tests: [Test]
|
||||
}
|
||||
|
||||
extension TestGroup {
|
||||
struct Test: Codable {
|
||||
var tcId: Int
|
||||
var comment: String
|
||||
var key: String
|
||||
var msg: String
|
||||
var tag: String
|
||||
var result: String
|
||||
var flags: [String]
|
||||
|
||||
var computedKey: SymmetricKey {
|
||||
SymmetricKey(hexEncoded: self.key)
|
||||
}
|
||||
|
||||
var computedMsg: Data {
|
||||
try! Data(hexString: self.msg)
|
||||
}
|
||||
|
||||
var computedTag: Data {
|
||||
try! Data(hexString: self.tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) 2025 Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
import Crypto
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
@testable import _CryptoExtras
|
||||
|
||||
final class ECToolboxBoringSSLTests: XCTestCase {
|
||||
func testThreadLocalFFAC() async {
|
||||
await testThreadLocalFFAC(P256.self)
|
||||
await testThreadLocalFFAC(P384.self)
|
||||
await testThreadLocalFFAC(P521.self)
|
||||
}
|
||||
|
||||
func testThreadLocalFFAC(_ Curve: (some OpenSSLSupportedNISTCurve & Sendable).Type) async {
|
||||
let numThreads = 3
|
||||
let numReadsPerThread = 2
|
||||
|
||||
var threads:
|
||||
[(
|
||||
thread: Thread,
|
||||
thisThreadDidReads: XCTestExpectation,
|
||||
allThreadsDidReads: XCTestExpectation,
|
||||
thisThreadFinished: XCTestExpectation
|
||||
)] = []
|
||||
|
||||
var objectIdentifiers: [(threadID: Int, ffacID: ObjectIdentifier)] = []
|
||||
let lock = NSLock()
|
||||
|
||||
for i in 1...numThreads {
|
||||
let thisThreadDidReads = expectation(description: "this thread did its reads")
|
||||
let allThreadsDidReads = expectation(description: "all threads did their reads")
|
||||
let thisThreadFinished = expectation(description: "this thread is finished")
|
||||
let thread = Thread {
|
||||
for _ in 1...numReadsPerThread {
|
||||
lock.lock()
|
||||
objectIdentifiers.append((i, ObjectIdentifier(Curve.__ffac)))
|
||||
lock.unlock()
|
||||
}
|
||||
thisThreadDidReads.fulfill()
|
||||
XCTWaiter().wait(for: [allThreadsDidReads], timeout: .greatestFiniteMagnitude)
|
||||
thisThreadFinished.fulfill()
|
||||
}
|
||||
thread.name = "thread-\(i)"
|
||||
threads.append((thread, thisThreadDidReads, allThreadsDidReads, thisThreadFinished))
|
||||
thread.start()
|
||||
}
|
||||
await fulfillment(of: threads.map(\.thisThreadDidReads), timeout: 0.5)
|
||||
for thread in threads { thread.allThreadsDidReads.fulfill() }
|
||||
await fulfillment(of: threads.map(\.thisThreadFinished), timeout: 0.5)
|
||||
|
||||
XCTAssertEqual(objectIdentifiers.count, numThreads * numReadsPerThread)
|
||||
for threadID in 1...numThreads {
|
||||
let partitionBoundary = objectIdentifiers.partition(by: { $0.threadID == threadID })
|
||||
let otherThreadsObjIDs = objectIdentifiers[..<partitionBoundary].map(\.ffacID)
|
||||
let thisThreadObjIDs = objectIdentifiers[partitionBoundary...].map(\.ffacID)
|
||||
let intersection = Set(thisThreadObjIDs).intersection(Set(otherThreadsObjIDs))
|
||||
XCTAssertEqual(thisThreadObjIDs.count, numReadsPerThread, "Thread should read \(numReadsPerThread) times.")
|
||||
XCTAssertEqual(Set(thisThreadObjIDs).count, 1, "Thread should see same object on every read.")
|
||||
XCTAssert(intersection.isEmpty, "Thread should see different objects from other threads.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,11 @@ extension Array where Element == UInt8 {
|
||||
init(hexString: String) throws {
|
||||
self.init()
|
||||
|
||||
guard hexString.count.isMultiple(of: 2), !hexString.isEmpty else {
|
||||
if hexString.count == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if hexString.count % 2 != 0 {
|
||||
throw ByteHexEncodingErrors.incorrectString
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2019-2025 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
#
|
||||
# This script generates Swift SDKs for Linux targets using the swift-sdk-generator.
|
||||
# It should be run once before running the `vendor-boringssl.sh` script, which requires
|
||||
# the Linux Swift SDKs to be installed.
|
||||
#
|
||||
# Usage:
|
||||
# 1. Run this script to generate and install the Swift SDKs. This script can be re-run to
|
||||
# re-generate Swift SDKs if needed. Old SDKs will be removed before installing newly
|
||||
# generated ones.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SWIFT_VERSION=5.10
|
||||
DISTRO_NAME=ubuntu
|
||||
DISTRO_VERSION=jammy
|
||||
DISTRO_VERSION_GENERATOR=22.04
|
||||
TMPDIR=$(mktemp -d /tmp/.workingXXXXXX)
|
||||
|
||||
function generate_swift_sdk {
|
||||
TARGET_ARCH=$1
|
||||
SDK_NAME="${SWIFT_VERSION}-RELEASE_${DISTRO_NAME}_${DISTRO_VERSION}_${TARGET_ARCH}"
|
||||
|
||||
cd "$TMPDIR"
|
||||
if [ ! -d swift-sdk-generator ]; then
|
||||
echo "Cloning SDK generator..."
|
||||
git clone https://github.com/swiftlang/swift-sdk-generator.git
|
||||
fi
|
||||
|
||||
cd swift-sdk-generator
|
||||
|
||||
if [ "$TARGET_ARCH" = "armv7" ]; then
|
||||
DOWNLOAD_FILE=swift-${SWIFT_VERSION}-RELEASE-${DISTRO_NAME}-${DISTRO_VERSION}-armv7-install
|
||||
DOWNLOAD_PATH="${TMPDIR}/${DOWNLOAD_FILE}"
|
||||
echo "Downloading armv7 runtime..."
|
||||
wget -nc https://github.com/swift-embedded-linux/armhf-debian/releases/download/${SWIFT_VERSION}/${DOWNLOAD_FILE}.tar.gz && \
|
||||
echo "Extracting armv7 runtime..." && \
|
||||
mkdir "${DOWNLOAD_PATH}" && true && \
|
||||
tar -xf ${DOWNLOAD_FILE}.tar.gz -C "${DOWNLOAD_PATH}"
|
||||
|
||||
echo "Creating Swift SDK for ${TARGET_ARCH}..."
|
||||
swift run swift-sdk-generator make-linux-sdk \
|
||||
--swift-version ${SWIFT_VERSION}-RELEASE \
|
||||
--distribution-name ${DISTRO_NAME} \
|
||||
--distribution-version ${DISTRO_VERSION_GENERATOR} \
|
||||
--target armv7-unknown-linux-gnueabihf \
|
||||
--target-swift-package-path "${DOWNLOAD_PATH}"
|
||||
else
|
||||
echo "Creating Swift SDK for ${TARGET_ARCH}..."
|
||||
swift run swift-sdk-generator make-linux-sdk \
|
||||
--swift-version ${SWIFT_VERSION}-RELEASE \
|
||||
--distribution-name ${DISTRO_NAME} \
|
||||
--distribution-version ${DISTRO_VERSION_GENERATOR} \
|
||||
--target "${TARGET_ARCH}-unknown-linux-gnu"
|
||||
fi
|
||||
|
||||
swift sdk remove "${SDK_NAME}" || true # ignore error if it doesn't exist
|
||||
swift sdk install "Bundles/${SDK_NAME}.artifactbundle"
|
||||
}
|
||||
|
||||
echo "Generating Swift SDKs for Linux targets..."
|
||||
generate_swift_sdk "x86_64"
|
||||
generate_swift_sdk "aarch64"
|
||||
generate_swift_sdk "armv7"
|
||||
@@ -45,6 +45,11 @@ DSTROOT=Sources/CCryptoBoringSSL
|
||||
TMPDIR=$(mktemp -d /tmp/.workingXXXXXX)
|
||||
SRCROOT="${TMPDIR}/src/boringssl.googlesource.com/boringssl"
|
||||
|
||||
# BoringSSL revision can be passed as the first argument to this script.
|
||||
if [ "$#" -gt 0 ]; then
|
||||
BORINGSSL_REVISION="$1"
|
||||
fi
|
||||
|
||||
# This function namespaces the awkward inline functions declared in OpenSSL
|
||||
# and BoringSSL.
|
||||
function namespace_inlines {
|
||||
@@ -101,16 +106,16 @@ function mangle_symbols {
|
||||
)
|
||||
|
||||
# Now cross compile for our targets.
|
||||
docker run -t -i --rm --privileged -v"$(pwd)":/src -w/src --platform linux/arm64 swift:5.10-jammy \
|
||||
swift build --product CCryptoBoringSSL
|
||||
docker run -t -i --rm --privileged -v"$(pwd)":/src -w/src --platform linux/amd64 swift:5.10-jammy \
|
||||
swift build --product CCryptoBoringSSL
|
||||
# NOTE: This requires running the `generate-linux-sdks.sh` script first to generate the Swift SDKs.
|
||||
swift build --swift-sdk 5.10-RELEASE_ubuntu_jammy_x86_64 --product CCryptoBoringSSL
|
||||
swift build --swift-sdk 5.10-RELEASE_ubuntu_jammy_aarch64 --product CCryptoBoringSSL
|
||||
swift build --swift-sdk 5.10-RELEASE_ubuntu_jammy_armv7 --product CCryptoBoringSSL
|
||||
|
||||
# Now we need to generate symbol mangles for Linux. We can do this in
|
||||
# one go for all of them.
|
||||
(
|
||||
cd "${SRCROOT}"
|
||||
go run "util/read_symbols.go" -obj-file-format elf -out "${TMPDIR}/symbols-linux-all.txt" "${HERE}"/.build/*-unknown-linux-gnu/debug/libCCryptoBoringSSL.a
|
||||
go run "util/read_symbols.go" -obj-file-format elf -out "${TMPDIR}/symbols-linux-all.txt" "${HERE}"/.build/*-unknown-linux-*/debug/libCCryptoBoringSSL.a
|
||||
)
|
||||
|
||||
# Now we concatenate all the symbols together and uniquify it. At this stage remove anything that
|
||||
@@ -170,9 +175,14 @@ echo "CLONING boringssl"
|
||||
mkdir -p "$SRCROOT"
|
||||
git clone https://boringssl.googlesource.com/boringssl "$SRCROOT"
|
||||
cd "$SRCROOT"
|
||||
BORINGSSL_REVISION=$(git rev-parse HEAD)
|
||||
if [ "$BORINGSSL_REVISION" ]; then
|
||||
echo "CHECKING OUT boringssl@${BORINGSSL_REVISION}"
|
||||
git checkout "$BORINGSSL_REVISION"
|
||||
else
|
||||
BORINGSSL_REVISION=$(git rev-parse HEAD)
|
||||
echo "CLONED boringssl@${BORINGSSL_REVISION}"
|
||||
fi
|
||||
cd "$HERE"
|
||||
echo "CLONED boringssl@${BORINGSSL_REVISION}"
|
||||
|
||||
echo "OBTAINING submodules"
|
||||
(
|
||||
@@ -248,7 +258,7 @@ echo "DISABLING assembly on x86 Windows"
|
||||
# x86 Windows builds require nasm for acceleration. SwiftPM can't do that right now,
|
||||
# so we disable the assembly.
|
||||
cd "$DSTROOT"
|
||||
gsed -i "/#define OPENSSL_HEADER_BASE_H/a#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))\n#define OPENSSL_NO_ASM\n#endif" "include/openssl/base.h"
|
||||
$sed -i "/#define OPENSSL_HEADER_BASE_H/a#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))\n#define OPENSSL_NO_ASM\n#endif" "include/openssl/base.h"
|
||||
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user