mirror of
https://github.com/apple/swift-crypto
synced 2026-11-23 04:34:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddb07e896a | ||
|
|
3bea268b22 | ||
|
|
0141f53dd5 | ||
|
|
b985ba6482 | ||
|
|
296d3308b4 | ||
|
|
8ff3d9dc83 | ||
|
|
5c066af98c | ||
|
|
26d3f525eb | ||
|
|
03581fe6ef | ||
|
|
f9e47ba809 | ||
|
|
42f5ffecd4 | ||
|
|
47640ada33 | ||
|
|
73dc51e2b2 | ||
|
|
f8034c8319 | ||
|
|
85d00fea15 |
No files matched your search
@@ -8,7 +8,7 @@ about: If something isn't working as expected
|
||||
|
||||
### New Issue Checklist
|
||||
|
||||
- [ ] I'm using the latest version of Swift Crypto (master branch)
|
||||
- [ ] I'm using the latest version of Swift Crypto (`main` branch)
|
||||
- [ ] I read the [Contribution Guidelines](https://github.com/apple/swift-crypto/blob/master/CONTRIBUTING.md)
|
||||
- [ ] I searched for [existing GitHub issues](https://github.com/apple/swift-crypto/issues)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/out
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
Package.pins
|
||||
@@ -13,3 +14,4 @@ DerivedData
|
||||
**/gyb.pyc
|
||||
|
||||
.*.sw[nop]
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
cmake_minimum_required(VERSION 3.15.1)
|
||||
|
||||
project(SwiftCrypto
|
||||
LANGUAGES ASM C Swift)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
include(SwiftSupport)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
else()
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
endif()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_AR "/usr/bin/ar")
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
find_package(dispatch CONFIG)
|
||||
find_package(Foundation CONFIG)
|
||||
endif()
|
||||
|
||||
add_subdirectory(Sources)
|
||||
add_subdirectory(cmake/modules)
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
// Sources/CCryptoBoringSSL directory. The source repository is at
|
||||
// https://boringssl.googlesource.com/boringssl.
|
||||
//
|
||||
// BoringSSL Commit: 9dae0ac4f0ae18ebed988d36bfb4c4e4023fc574
|
||||
// BoringSSL Commit: 04b3213d43492b6c9e0434d8e2a4530a9938f958
|
||||
|
||||
import PackageDescription
|
||||
|
||||
|
||||
+392
@@ -0,0 +1,392 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
add_library(CCryptoBoringSSL STATIC
|
||||
"crypto/asn1/a_bitstr.c"
|
||||
"crypto/asn1/a_bool.c"
|
||||
"crypto/asn1/a_d2i_fp.c"
|
||||
"crypto/asn1/a_dup.c"
|
||||
"crypto/asn1/a_enum.c"
|
||||
"crypto/asn1/a_gentm.c"
|
||||
"crypto/asn1/a_i2d_fp.c"
|
||||
"crypto/asn1/a_int.c"
|
||||
"crypto/asn1/a_mbstr.c"
|
||||
"crypto/asn1/a_object.c"
|
||||
"crypto/asn1/a_octet.c"
|
||||
"crypto/asn1/a_print.c"
|
||||
"crypto/asn1/a_strnid.c"
|
||||
"crypto/asn1/a_time.c"
|
||||
"crypto/asn1/a_type.c"
|
||||
"crypto/asn1/a_utctm.c"
|
||||
"crypto/asn1/a_utf8.c"
|
||||
"crypto/asn1/asn1_lib.c"
|
||||
"crypto/asn1/asn1_par.c"
|
||||
"crypto/asn1/asn_pack.c"
|
||||
"crypto/asn1/f_enum.c"
|
||||
"crypto/asn1/f_int.c"
|
||||
"crypto/asn1/f_string.c"
|
||||
"crypto/asn1/tasn_dec.c"
|
||||
"crypto/asn1/tasn_enc.c"
|
||||
"crypto/asn1/tasn_fre.c"
|
||||
"crypto/asn1/tasn_new.c"
|
||||
"crypto/asn1/tasn_typ.c"
|
||||
"crypto/asn1/tasn_utl.c"
|
||||
"crypto/asn1/time_support.c"
|
||||
"crypto/base64/base64.c"
|
||||
"crypto/bio/bio.c"
|
||||
"crypto/bio/bio_mem.c"
|
||||
"crypto/bio/connect.c"
|
||||
"crypto/bio/fd.c"
|
||||
"crypto/bio/file.c"
|
||||
"crypto/bio/hexdump.c"
|
||||
"crypto/bio/pair.c"
|
||||
"crypto/bio/printf.c"
|
||||
"crypto/bio/socket.c"
|
||||
"crypto/bio/socket_helper.c"
|
||||
"crypto/blake2/blake2.c"
|
||||
"crypto/bn_extra/bn_asn1.c"
|
||||
"crypto/bn_extra/convert.c"
|
||||
"crypto/buf/buf.c"
|
||||
"crypto/bytestring/asn1_compat.c"
|
||||
"crypto/bytestring/ber.c"
|
||||
"crypto/bytestring/cbb.c"
|
||||
"crypto/bytestring/cbs.c"
|
||||
"crypto/bytestring/unicode.c"
|
||||
"crypto/chacha/chacha.c"
|
||||
"crypto/cipher_extra/cipher_extra.c"
|
||||
"crypto/cipher_extra/derive_key.c"
|
||||
"crypto/cipher_extra/e_aesccm.c"
|
||||
"crypto/cipher_extra/e_aesctrhmac.c"
|
||||
"crypto/cipher_extra/e_aesgcmsiv.c"
|
||||
"crypto/cipher_extra/e_chacha20poly1305.c"
|
||||
"crypto/cipher_extra/e_null.c"
|
||||
"crypto/cipher_extra/e_rc2.c"
|
||||
"crypto/cipher_extra/e_rc4.c"
|
||||
"crypto/cipher_extra/e_tls.c"
|
||||
"crypto/cipher_extra/tls_cbc.c"
|
||||
"crypto/cmac/cmac.c"
|
||||
"crypto/conf/conf.c"
|
||||
"crypto/cpu-aarch64-fuchsia.c"
|
||||
"crypto/cpu-aarch64-linux.c"
|
||||
"crypto/cpu-aarch64-win.c"
|
||||
"crypto/cpu-arm-linux.c"
|
||||
"crypto/cpu-arm.c"
|
||||
"crypto/cpu-intel.c"
|
||||
"crypto/cpu-ppc64le.c"
|
||||
"crypto/crypto.c"
|
||||
"crypto/curve25519/curve25519.c"
|
||||
"crypto/curve25519/spake25519.c"
|
||||
"crypto/dh_extra/dh_asn1.c"
|
||||
"crypto/dh_extra/params.c"
|
||||
"crypto/digest_extra/digest_extra.c"
|
||||
"crypto/dsa/dsa.c"
|
||||
"crypto/dsa/dsa_asn1.c"
|
||||
"crypto/ec_extra/ec_asn1.c"
|
||||
"crypto/ec_extra/ec_derive.c"
|
||||
"crypto/ec_extra/hash_to_curve.c"
|
||||
"crypto/ecdh_extra/ecdh_extra.c"
|
||||
"crypto/ecdsa_extra/ecdsa_asn1.c"
|
||||
"crypto/engine/engine.c"
|
||||
"crypto/err/err.c"
|
||||
"crypto/err/err_data.c"
|
||||
"crypto/evp/digestsign.c"
|
||||
"crypto/evp/evp.c"
|
||||
"crypto/evp/evp_asn1.c"
|
||||
"crypto/evp/evp_ctx.c"
|
||||
"crypto/evp/p_dsa_asn1.c"
|
||||
"crypto/evp/p_ec.c"
|
||||
"crypto/evp/p_ec_asn1.c"
|
||||
"crypto/evp/p_ed25519.c"
|
||||
"crypto/evp/p_ed25519_asn1.c"
|
||||
"crypto/evp/p_rsa.c"
|
||||
"crypto/evp/p_rsa_asn1.c"
|
||||
"crypto/evp/p_x25519.c"
|
||||
"crypto/evp/p_x25519_asn1.c"
|
||||
"crypto/evp/pbkdf.c"
|
||||
"crypto/evp/print.c"
|
||||
"crypto/evp/scrypt.c"
|
||||
"crypto/evp/sign.c"
|
||||
"crypto/ex_data.c"
|
||||
"crypto/fipsmodule/aes/aes.c"
|
||||
"crypto/fipsmodule/aes/aes_nohw.c"
|
||||
"crypto/fipsmodule/aes/key_wrap.c"
|
||||
"crypto/fipsmodule/aes/mode_wrappers.c"
|
||||
"crypto/fipsmodule/bn/add.c"
|
||||
"crypto/fipsmodule/bn/asm/x86_64-gcc.c"
|
||||
"crypto/fipsmodule/bn/bn.c"
|
||||
"crypto/fipsmodule/bn/bytes.c"
|
||||
"crypto/fipsmodule/bn/cmp.c"
|
||||
"crypto/fipsmodule/bn/ctx.c"
|
||||
"crypto/fipsmodule/bn/div.c"
|
||||
"crypto/fipsmodule/bn/div_extra.c"
|
||||
"crypto/fipsmodule/bn/exponentiation.c"
|
||||
"crypto/fipsmodule/bn/gcd.c"
|
||||
"crypto/fipsmodule/bn/gcd_extra.c"
|
||||
"crypto/fipsmodule/bn/generic.c"
|
||||
"crypto/fipsmodule/bn/jacobi.c"
|
||||
"crypto/fipsmodule/bn/montgomery.c"
|
||||
"crypto/fipsmodule/bn/montgomery_inv.c"
|
||||
"crypto/fipsmodule/bn/mul.c"
|
||||
"crypto/fipsmodule/bn/prime.c"
|
||||
"crypto/fipsmodule/bn/random.c"
|
||||
"crypto/fipsmodule/bn/rsaz_exp.c"
|
||||
"crypto/fipsmodule/bn/shift.c"
|
||||
"crypto/fipsmodule/bn/sqrt.c"
|
||||
"crypto/fipsmodule/cipher/aead.c"
|
||||
"crypto/fipsmodule/cipher/cipher.c"
|
||||
"crypto/fipsmodule/cipher/e_aes.c"
|
||||
"crypto/fipsmodule/cipher/e_des.c"
|
||||
"crypto/fipsmodule/des/des.c"
|
||||
"crypto/fipsmodule/dh/check.c"
|
||||
"crypto/fipsmodule/dh/dh.c"
|
||||
"crypto/fipsmodule/digest/digest.c"
|
||||
"crypto/fipsmodule/digest/digests.c"
|
||||
"crypto/fipsmodule/ec/ec.c"
|
||||
"crypto/fipsmodule/ec/ec_key.c"
|
||||
"crypto/fipsmodule/ec/ec_montgomery.c"
|
||||
"crypto/fipsmodule/ec/felem.c"
|
||||
"crypto/fipsmodule/ec/oct.c"
|
||||
"crypto/fipsmodule/ec/p224-64.c"
|
||||
"crypto/fipsmodule/ec/p256-x86_64.c"
|
||||
"crypto/fipsmodule/ec/p256.c"
|
||||
"crypto/fipsmodule/ec/scalar.c"
|
||||
"crypto/fipsmodule/ec/simple.c"
|
||||
"crypto/fipsmodule/ec/simple_mul.c"
|
||||
"crypto/fipsmodule/ec/util.c"
|
||||
"crypto/fipsmodule/ec/wnaf.c"
|
||||
"crypto/fipsmodule/ecdh/ecdh.c"
|
||||
"crypto/fipsmodule/ecdsa/ecdsa.c"
|
||||
"crypto/fipsmodule/fips_shared_support.c"
|
||||
"crypto/fipsmodule/hmac/hmac.c"
|
||||
"crypto/fipsmodule/is_fips.c"
|
||||
"crypto/fipsmodule/md4/md4.c"
|
||||
"crypto/fipsmodule/md5/md5.c"
|
||||
"crypto/fipsmodule/modes/cbc.c"
|
||||
"crypto/fipsmodule/modes/cfb.c"
|
||||
"crypto/fipsmodule/modes/ctr.c"
|
||||
"crypto/fipsmodule/modes/gcm.c"
|
||||
"crypto/fipsmodule/modes/gcm_nohw.c"
|
||||
"crypto/fipsmodule/modes/ofb.c"
|
||||
"crypto/fipsmodule/modes/polyval.c"
|
||||
"crypto/fipsmodule/rand/ctrdrbg.c"
|
||||
"crypto/fipsmodule/rand/fork_detect.c"
|
||||
"crypto/fipsmodule/rand/rand.c"
|
||||
"crypto/fipsmodule/rand/urandom.c"
|
||||
"crypto/fipsmodule/rsa/blinding.c"
|
||||
"crypto/fipsmodule/rsa/padding.c"
|
||||
"crypto/fipsmodule/rsa/rsa.c"
|
||||
"crypto/fipsmodule/rsa/rsa_impl.c"
|
||||
"crypto/fipsmodule/self_check/self_check.c"
|
||||
"crypto/fipsmodule/sha/sha1-altivec.c"
|
||||
"crypto/fipsmodule/sha/sha1.c"
|
||||
"crypto/fipsmodule/sha/sha256.c"
|
||||
"crypto/fipsmodule/sha/sha512.c"
|
||||
"crypto/fipsmodule/tls/kdf.c"
|
||||
"crypto/hkdf/hkdf.c"
|
||||
"crypto/hpke/hpke.c"
|
||||
"crypto/hrss/hrss.c"
|
||||
"crypto/lhash/lhash.c"
|
||||
"crypto/mem.c"
|
||||
"crypto/obj/obj.c"
|
||||
"crypto/obj/obj_xref.c"
|
||||
"crypto/pem/pem_all.c"
|
||||
"crypto/pem/pem_info.c"
|
||||
"crypto/pem/pem_lib.c"
|
||||
"crypto/pem/pem_oth.c"
|
||||
"crypto/pem/pem_pk8.c"
|
||||
"crypto/pem/pem_pkey.c"
|
||||
"crypto/pem/pem_x509.c"
|
||||
"crypto/pem/pem_xaux.c"
|
||||
"crypto/pkcs7/pkcs7.c"
|
||||
"crypto/pkcs7/pkcs7_x509.c"
|
||||
"crypto/pkcs8/p5_pbev2.c"
|
||||
"crypto/pkcs8/pkcs8.c"
|
||||
"crypto/pkcs8/pkcs8_x509.c"
|
||||
"crypto/poly1305/poly1305.c"
|
||||
"crypto/poly1305/poly1305_arm.c"
|
||||
"crypto/poly1305/poly1305_vec.c"
|
||||
"crypto/pool/pool.c"
|
||||
"crypto/rand_extra/deterministic.c"
|
||||
"crypto/rand_extra/forkunsafe.c"
|
||||
"crypto/rand_extra/fuchsia.c"
|
||||
"crypto/rand_extra/passive.c"
|
||||
"crypto/rand_extra/rand_extra.c"
|
||||
"crypto/rand_extra/windows.c"
|
||||
"crypto/rc4/rc4.c"
|
||||
"crypto/refcount_c11.c"
|
||||
"crypto/refcount_lock.c"
|
||||
"crypto/rsa_extra/rsa_asn1.c"
|
||||
"crypto/rsa_extra/rsa_print.c"
|
||||
"crypto/siphash/siphash.c"
|
||||
"crypto/stack/stack.c"
|
||||
"crypto/thread.c"
|
||||
"crypto/thread_none.c"
|
||||
"crypto/thread_pthread.c"
|
||||
"crypto/thread_win.c"
|
||||
"crypto/trust_token/pmbtoken.c"
|
||||
"crypto/trust_token/trust_token.c"
|
||||
"crypto/trust_token/voprf.c"
|
||||
"crypto/x509/a_digest.c"
|
||||
"crypto/x509/a_sign.c"
|
||||
"crypto/x509/a_strex.c"
|
||||
"crypto/x509/a_verify.c"
|
||||
"crypto/x509/algorithm.c"
|
||||
"crypto/x509/asn1_gen.c"
|
||||
"crypto/x509/by_dir.c"
|
||||
"crypto/x509/by_file.c"
|
||||
"crypto/x509/i2d_pr.c"
|
||||
"crypto/x509/rsa_pss.c"
|
||||
"crypto/x509/t_crl.c"
|
||||
"crypto/x509/t_req.c"
|
||||
"crypto/x509/t_x509.c"
|
||||
"crypto/x509/t_x509a.c"
|
||||
"crypto/x509/x509.c"
|
||||
"crypto/x509/x509_att.c"
|
||||
"crypto/x509/x509_cmp.c"
|
||||
"crypto/x509/x509_d2.c"
|
||||
"crypto/x509/x509_def.c"
|
||||
"crypto/x509/x509_ext.c"
|
||||
"crypto/x509/x509_lu.c"
|
||||
"crypto/x509/x509_obj.c"
|
||||
"crypto/x509/x509_req.c"
|
||||
"crypto/x509/x509_set.c"
|
||||
"crypto/x509/x509_trs.c"
|
||||
"crypto/x509/x509_txt.c"
|
||||
"crypto/x509/x509_v3.c"
|
||||
"crypto/x509/x509_vfy.c"
|
||||
"crypto/x509/x509_vpm.c"
|
||||
"crypto/x509/x509cset.c"
|
||||
"crypto/x509/x509name.c"
|
||||
"crypto/x509/x509rset.c"
|
||||
"crypto/x509/x509spki.c"
|
||||
"crypto/x509/x_algor.c"
|
||||
"crypto/x509/x_all.c"
|
||||
"crypto/x509/x_attrib.c"
|
||||
"crypto/x509/x_crl.c"
|
||||
"crypto/x509/x_exten.c"
|
||||
"crypto/x509/x_info.c"
|
||||
"crypto/x509/x_name.c"
|
||||
"crypto/x509/x_pkey.c"
|
||||
"crypto/x509/x_pubkey.c"
|
||||
"crypto/x509/x_req.c"
|
||||
"crypto/x509/x_sig.c"
|
||||
"crypto/x509/x_spki.c"
|
||||
"crypto/x509/x_val.c"
|
||||
"crypto/x509/x_x509.c"
|
||||
"crypto/x509/x_x509a.c"
|
||||
"crypto/x509v3/pcy_cache.c"
|
||||
"crypto/x509v3/pcy_data.c"
|
||||
"crypto/x509v3/pcy_lib.c"
|
||||
"crypto/x509v3/pcy_map.c"
|
||||
"crypto/x509v3/pcy_node.c"
|
||||
"crypto/x509v3/pcy_tree.c"
|
||||
"crypto/x509v3/v3_akey.c"
|
||||
"crypto/x509v3/v3_akeya.c"
|
||||
"crypto/x509v3/v3_alt.c"
|
||||
"crypto/x509v3/v3_bcons.c"
|
||||
"crypto/x509v3/v3_bitst.c"
|
||||
"crypto/x509v3/v3_conf.c"
|
||||
"crypto/x509v3/v3_cpols.c"
|
||||
"crypto/x509v3/v3_crld.c"
|
||||
"crypto/x509v3/v3_enum.c"
|
||||
"crypto/x509v3/v3_extku.c"
|
||||
"crypto/x509v3/v3_genn.c"
|
||||
"crypto/x509v3/v3_ia5.c"
|
||||
"crypto/x509v3/v3_info.c"
|
||||
"crypto/x509v3/v3_int.c"
|
||||
"crypto/x509v3/v3_lib.c"
|
||||
"crypto/x509v3/v3_ncons.c"
|
||||
"crypto/x509v3/v3_ocsp.c"
|
||||
"crypto/x509v3/v3_pci.c"
|
||||
"crypto/x509v3/v3_pcia.c"
|
||||
"crypto/x509v3/v3_pcons.c"
|
||||
"crypto/x509v3/v3_pmaps.c"
|
||||
"crypto/x509v3/v3_prn.c"
|
||||
"crypto/x509v3/v3_purp.c"
|
||||
"crypto/x509v3/v3_skey.c"
|
||||
"crypto/x509v3/v3_utl.c")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-x86_64.mac.x86_64.S
|
||||
crypto/cipher_extra/aes128gcmsiv-x86_64.mac.x86_64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/aesni-gcm-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/aesni-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/ghash-ssse3-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/ghash-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/md5-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/p256-x86_64-asm.mac.x86_64.S
|
||||
crypto/fipsmodule/p256_beeu-x86_64-asm.mac.x86_64.S
|
||||
crypto/fipsmodule/rdrand-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/rsaz-avx2.mac.x86_64.S
|
||||
crypto/fipsmodule/sha1-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/sha256-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/sha512-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/vpaes-x86_64.mac.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont.mac.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont5.mac.x86_64.S)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-x86_64.linux.x86_64.S
|
||||
crypto/cipher_extra/aes128gcmsiv-x86_64.linux.x86_64.S
|
||||
crypto/cipher_extra/chacha20_poly1305_x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/aesni-gcm-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/aesni-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/ghash-ssse3-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/ghash-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/md5-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/p256-x86_64-asm.linux.x86_64.S
|
||||
crypto/fipsmodule/p256_beeu-x86_64-asm.linux.x86_64.S
|
||||
crypto/fipsmodule/rdrand-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/rsaz-avx2.linux.x86_64.S
|
||||
crypto/fipsmodule/sha1-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/sha256-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/sha512-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/vpaes-x86_64.linux.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont.linux.x86_64.S
|
||||
crypto/fipsmodule/x86_64-mont5.linux.x86_64.S)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/aesv8-armx64.ios.aarch64.S
|
||||
crypto/fipsmodule/armv8-mont.ios.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armx64.ios.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8.ios.aarch64.S
|
||||
crypto/fipsmodule/vpaes-armv8.ios.aarch64.S)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||
target_sources(CCryptoBoringSSL PRIVATE
|
||||
crypto/chacha/chacha-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/aesv8-armx64.linux.aarch64.S
|
||||
crypto/fipsmodule/armv8-mont.linux.aarch64.S
|
||||
crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S
|
||||
crypto/fipsmodule/sha1-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/sha256-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/sha512-armv8.linux.aarch64.S
|
||||
crypto/fipsmodule/vpaes-armv8.linux.aarch64.S)
|
||||
endif()
|
||||
|
||||
target_include_directories(CCryptoBoringSSL PUBLIC
|
||||
include)
|
||||
|
||||
target_compile_definitions(CCryptoBoringSSL PRIVATE
|
||||
$<$<PLATFORM_ID:Windows>:WIN32_LEAN_AND_MEAN>)
|
||||
set_target_properties(CCryptoBoringSSL PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_Swift_MODULE_DIRECTORY}")
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CCryptoBoringSSL)
|
||||
@@ -223,6 +223,15 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
break;
|
||||
|
||||
case ASN1_ITYPE_MSTRING:
|
||||
/*
|
||||
* It never makes sense for multi-strings to have implicit tagging, so
|
||||
* if tag != -1, then this looks like an error in the template.
|
||||
*/
|
||||
if (tag != -1) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
p = *in;
|
||||
/* Just read in tag and class */
|
||||
ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,
|
||||
@@ -256,6 +265,15 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx);
|
||||
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
/*
|
||||
* It never makes sense for CHOICE types to have implicit tagging, so if
|
||||
* tag != -1, then this looks like an error in the template.
|
||||
*/
|
||||
if (tag != -1) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
|
||||
goto auxerr;
|
||||
|
||||
|
||||
@@ -145,9 +145,25 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
break;
|
||||
|
||||
case ASN1_ITYPE_MSTRING:
|
||||
/*
|
||||
* It never makes sense for multi-strings to have implicit tagging, so
|
||||
* if tag != -1, then this looks like an error in the template.
|
||||
*/
|
||||
if (tag != -1) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
return -1;
|
||||
}
|
||||
return asn1_i2d_ex_primitive(pval, out, it, -1, aclass);
|
||||
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
/*
|
||||
* It never makes sense for CHOICE types to have implicit tagging, so if
|
||||
* tag != -1, then this looks like an error in the template.
|
||||
*/
|
||||
if (tag != -1) {
|
||||
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
|
||||
return -1;
|
||||
}
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
|
||||
return 0;
|
||||
i = asn1_get_choice_selector(pval, it);
|
||||
|
||||
@@ -55,7 +55,11 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock,
|
||||
ret = getaddrinfo(hostname, port_str, &hint, &result);
|
||||
if (ret != 0) {
|
||||
OPENSSL_PUT_ERROR(SYS, 0);
|
||||
#if defined(OPENSSL_WINDOWS)
|
||||
ERR_add_error_data(1, gai_strerrorA(ret));
|
||||
#else
|
||||
ERR_add_error_data(1, gai_strerror(ret));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#include <CCryptoBoringSSL_blake2.h>
|
||||
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
// https://tools.ietf.org/html/rfc7693#section-2.6
|
||||
static const uint64_t kIV[8] = {
|
||||
UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b),
|
||||
UINT64_C(0x3c6ef372fe94f82b), UINT64_C(0xa54ff53a5f1d36f1),
|
||||
UINT64_C(0x510e527fade682d1), UINT64_C(0x9b05688c2b3e6c1f),
|
||||
UINT64_C(0x1f83d9abfb41bd6b), UINT64_C(0x5be0cd19137e2179),
|
||||
};
|
||||
|
||||
// https://tools.ietf.org/html/rfc7693#section-2.7
|
||||
static const uint8_t kSigma[10 * 16] = {
|
||||
// clang-format off
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
|
||||
11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
|
||||
7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
|
||||
9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
|
||||
2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
|
||||
12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,
|
||||
13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,
|
||||
6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,
|
||||
10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
#define RIGHT_ROTATE(v, n) (((v) >> (n)) | ((v) << (64 - (n))))
|
||||
|
||||
// https://tools.ietf.org/html/rfc7693#section-3.1
|
||||
static void blake2b_mix(uint64_t v[16], int a, int b, int c, int d, uint64_t x,
|
||||
uint64_t y) {
|
||||
v[a] = v[a] + v[b] + x;
|
||||
v[d] = RIGHT_ROTATE(v[d] ^ v[a], 32);
|
||||
v[c] = v[c] + v[d];
|
||||
v[b] = RIGHT_ROTATE(v[b] ^ v[c], 24);
|
||||
v[a] = v[a] + v[b] + y;
|
||||
v[d] = RIGHT_ROTATE(v[d] ^ v[a], 16);
|
||||
v[c] = v[c] + v[d];
|
||||
v[b] = RIGHT_ROTATE(v[b] ^ v[c], 63);
|
||||
}
|
||||
|
||||
static void blake2b_transform(
|
||||
BLAKE2B_CTX *b2b,
|
||||
const uint64_t block_words[BLAKE2B_CBLOCK / sizeof(uint64_t)],
|
||||
size_t num_bytes, int is_final_block) {
|
||||
// https://tools.ietf.org/html/rfc7693#section-3.2
|
||||
uint64_t v[16];
|
||||
OPENSSL_STATIC_ASSERT(sizeof(v) == sizeof(b2b->h) + sizeof(kIV), "");
|
||||
OPENSSL_memcpy(v, b2b->h, sizeof(b2b->h));
|
||||
OPENSSL_memcpy(&v[8], kIV, sizeof(kIV));
|
||||
|
||||
b2b->t_low += num_bytes;
|
||||
if (b2b->t_low < num_bytes) {
|
||||
b2b->t_high++;
|
||||
}
|
||||
v[12] ^= b2b->t_low;
|
||||
v[13] ^= b2b->t_high;
|
||||
|
||||
if (is_final_block) {
|
||||
v[14] = ~v[14];
|
||||
}
|
||||
|
||||
for (int round = 0; round < 12; round++) {
|
||||
const uint8_t *const s = &kSigma[16 * (round % 10)];
|
||||
blake2b_mix(v, 0, 4, 8, 12, block_words[s[0]], block_words[s[1]]);
|
||||
blake2b_mix(v, 1, 5, 9, 13, block_words[s[2]], block_words[s[3]]);
|
||||
blake2b_mix(v, 2, 6, 10, 14, block_words[s[4]], block_words[s[5]]);
|
||||
blake2b_mix(v, 3, 7, 11, 15, block_words[s[6]], block_words[s[7]]);
|
||||
blake2b_mix(v, 0, 5, 10, 15, block_words[s[8]], block_words[s[9]]);
|
||||
blake2b_mix(v, 1, 6, 11, 12, block_words[s[10]], block_words[s[11]]);
|
||||
blake2b_mix(v, 2, 7, 8, 13, block_words[s[12]], block_words[s[13]]);
|
||||
blake2b_mix(v, 3, 4, 9, 14, block_words[s[14]], block_words[s[15]]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(b2b->h); i++) {
|
||||
b2b->h[i] ^= v[i];
|
||||
b2b->h[i] ^= v[i + 8];
|
||||
}
|
||||
}
|
||||
|
||||
void BLAKE2B256_Init(BLAKE2B_CTX *b2b) {
|
||||
OPENSSL_memset(b2b, 0, sizeof(BLAKE2B_CTX));
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(kIV) == sizeof(b2b->h), "");
|
||||
OPENSSL_memcpy(&b2b->h, kIV, sizeof(kIV));
|
||||
|
||||
// https://tools.ietf.org/html/rfc7693#section-2.5
|
||||
b2b->h[0] ^= 0x01010000 | BLAKE2B256_DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *in_data, size_t len) {
|
||||
const uint8_t *data = (const uint8_t *)in_data;
|
||||
|
||||
size_t todo = sizeof(b2b->block.bytes) - b2b->block_used;
|
||||
if (todo > len) {
|
||||
todo = len;
|
||||
}
|
||||
OPENSSL_memcpy(&b2b->block.bytes[b2b->block_used], data, todo);
|
||||
b2b->block_used += todo;
|
||||
data += todo;
|
||||
len -= todo;
|
||||
|
||||
if (!len) {
|
||||
return;
|
||||
}
|
||||
|
||||
// More input remains therefore we must have filled |b2b->block|.
|
||||
assert(b2b->block_used == BLAKE2B_CBLOCK);
|
||||
blake2b_transform(b2b, b2b->block.words, BLAKE2B_CBLOCK,
|
||||
/*is_final_block=*/0);
|
||||
b2b->block_used = 0;
|
||||
|
||||
while (len > BLAKE2B_CBLOCK) {
|
||||
uint64_t block_words[BLAKE2B_CBLOCK / sizeof(uint64_t)];
|
||||
OPENSSL_memcpy(block_words, data, sizeof(block_words));
|
||||
blake2b_transform(b2b, block_words, BLAKE2B_CBLOCK, /*is_final_block=*/0);
|
||||
data += BLAKE2B_CBLOCK;
|
||||
len -= BLAKE2B_CBLOCK;
|
||||
}
|
||||
|
||||
OPENSSL_memcpy(b2b->block.bytes, data, len);
|
||||
b2b->block_used = len;
|
||||
}
|
||||
|
||||
void BLAKE2B256_Final(uint8_t out[BLAKE2B256_DIGEST_LENGTH], BLAKE2B_CTX *b2b) {
|
||||
OPENSSL_memset(&b2b->block.bytes[b2b->block_used], 0,
|
||||
sizeof(b2b->block.bytes) - b2b->block_used);
|
||||
blake2b_transform(b2b, b2b->block.words, b2b->block_used,
|
||||
/*is_final_block=*/1);
|
||||
OPENSSL_STATIC_ASSERT(BLAKE2B256_DIGEST_LENGTH <= sizeof(b2b->h), "");
|
||||
memcpy(out, b2b->h, BLAKE2B256_DIGEST_LENGTH);
|
||||
}
|
||||
|
||||
void BLAKE2B256(const uint8_t *data, size_t len,
|
||||
uint8_t out[BLAKE2B256_DIGEST_LENGTH]) {
|
||||
BLAKE2B_CTX ctx;
|
||||
BLAKE2B256_Init(&ctx);
|
||||
BLAKE2B256_Update(&ctx, data, len);
|
||||
BLAKE2B256_Final(out, &ctx);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ static int is_string_type(unsigned tag) {
|
||||
// depending on whether an indefinite length element or constructed string was
|
||||
// found. The value of |orig_in| is not changed. It returns one on success (i.e.
|
||||
// |*ber_found| was set) and zero on error.
|
||||
static int cbs_find_ber(const CBS *orig_in, char *ber_found, unsigned depth) {
|
||||
static int cbs_find_ber(const CBS *orig_in, int *ber_found, unsigned depth) {
|
||||
CBS in;
|
||||
|
||||
if (depth > kMaxDepth) {
|
||||
@@ -68,14 +68,11 @@ static int cbs_find_ber(const CBS *orig_in, char *ber_found, unsigned depth) {
|
||||
unsigned tag;
|
||||
size_t header_len;
|
||||
|
||||
if (!CBS_get_any_ber_asn1_element(&in, &contents, &tag, &header_len)) {
|
||||
if (!CBS_get_any_ber_asn1_element(&in, &contents, &tag, &header_len,
|
||||
ber_found)) {
|
||||
return 0;
|
||||
}
|
||||
if (CBS_len(&contents) == header_len &&
|
||||
header_len > 0 &&
|
||||
CBS_data(&contents)[header_len-1] == 0x80) {
|
||||
// Found an indefinite-length element.
|
||||
*ber_found = 1;
|
||||
if (*ber_found) {
|
||||
return 1;
|
||||
}
|
||||
if (tag & CBS_ASN1_CONSTRUCTED) {
|
||||
@@ -120,9 +117,11 @@ static int cbs_convert_ber(CBS *in, CBB *out, unsigned string_tag,
|
||||
CBS contents;
|
||||
unsigned tag, child_string_tag = string_tag;
|
||||
size_t header_len;
|
||||
int ber_found;
|
||||
CBB *out_contents, out_contents_storage;
|
||||
|
||||
if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len)) {
|
||||
if (!CBS_get_any_ber_asn1_element(in, &contents, &tag, &header_len,
|
||||
&ber_found)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -194,7 +193,7 @@ int CBS_asn1_ber_to_der(CBS *in, CBS *out, uint8_t **out_storage) {
|
||||
|
||||
// First, do a quick walk to find any indefinite-length elements. Most of the
|
||||
// time we hope that there aren't any and thus we can quickly return.
|
||||
char conversion_needed;
|
||||
int conversion_needed;
|
||||
if (!cbs_find_ber(in, &conversion_needed, 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -254,8 +254,7 @@ static int parse_asn1_tag(CBS *cbs, unsigned *out) {
|
||||
//
|
||||
// If the number portion is 31 (0x1f, the largest value that fits in the
|
||||
// allotted bits), then the tag is more than one byte long and the
|
||||
// continuation bytes contain the tag number. This parser only supports tag
|
||||
// numbers less than 31 (and thus single-byte tags).
|
||||
// continuation bytes contain the tag number.
|
||||
unsigned tag = ((unsigned)tag_byte & 0xe0) << CBS_ASN1_TAG_SHIFT;
|
||||
unsigned tag_number = tag_byte & 0x1f;
|
||||
if (tag_number == 0x1f) {
|
||||
@@ -263,7 +262,7 @@ static int parse_asn1_tag(CBS *cbs, unsigned *out) {
|
||||
if (!parse_base128_integer(cbs, &v) ||
|
||||
// Check the tag number is within our supported bounds.
|
||||
v > CBS_ASN1_TAG_NUMBER_MASK ||
|
||||
// Small tag numbers should have used low tag number form.
|
||||
// Small tag numbers should have used low tag number form, even in BER.
|
||||
v < 0x1f) {
|
||||
return 0;
|
||||
}
|
||||
@@ -277,13 +276,17 @@ static int parse_asn1_tag(CBS *cbs, unsigned *out) {
|
||||
}
|
||||
|
||||
static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
|
||||
size_t *out_header_len, int ber_ok) {
|
||||
size_t *out_header_len, int *out_ber_found,
|
||||
int ber_ok) {
|
||||
CBS header = *cbs;
|
||||
CBS throwaway;
|
||||
|
||||
if (out == NULL) {
|
||||
out = &throwaway;
|
||||
}
|
||||
if (ber_ok) {
|
||||
*out_ber_found = 0;
|
||||
}
|
||||
|
||||
unsigned tag;
|
||||
if (!parse_asn1_tag(&header, &tag)) {
|
||||
@@ -321,27 +324,38 @@ static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
|
||||
if (out_header_len != NULL) {
|
||||
*out_header_len = header_len;
|
||||
}
|
||||
*out_ber_found = 1;
|
||||
return CBS_get_bytes(cbs, out, header_len);
|
||||
}
|
||||
|
||||
// ITU-T X.690 clause 8.1.3.5.c specifies that the value 0xff shall not be
|
||||
// used as the first byte of the length. If this parser encounters that
|
||||
// value, num_bytes will be parsed as 127, which will fail the check below.
|
||||
// value, num_bytes will be parsed as 127, which will fail this check.
|
||||
if (num_bytes == 0 || num_bytes > 4) {
|
||||
return 0;
|
||||
}
|
||||
if (!cbs_get_u(&header, &len64, num_bytes)) {
|
||||
return 0;
|
||||
}
|
||||
// ITU-T X.690 section 10.1 (DER length forms) requires encoding the length
|
||||
// with the minimum number of octets.
|
||||
// ITU-T X.690 section 10.1 (DER length forms) requires encoding the
|
||||
// length with the minimum number of octets. BER could, technically, have
|
||||
// 125 superfluous zero bytes. We do not attempt to handle that and still
|
||||
// require that the length fit in a |uint32_t| for BER.
|
||||
if (len64 < 128) {
|
||||
// Length should have used short-form encoding.
|
||||
return 0;
|
||||
if (ber_ok) {
|
||||
*out_ber_found = 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((len64 >> ((num_bytes-1)*8)) == 0) {
|
||||
if ((len64 >> ((num_bytes - 1) * 8)) == 0) {
|
||||
// Length should have been at least one byte shorter.
|
||||
return 0;
|
||||
if (ber_ok) {
|
||||
*out_ber_found = 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
len = len64;
|
||||
if (len + header_len + num_bytes < len) {
|
||||
@@ -374,13 +388,15 @@ int CBS_get_any_asn1(CBS *cbs, CBS *out, unsigned *out_tag) {
|
||||
int CBS_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
|
||||
size_t *out_header_len) {
|
||||
return cbs_get_any_asn1_element(cbs, out, out_tag, out_header_len,
|
||||
0 /* DER only */);
|
||||
NULL, 0 /* DER only */);
|
||||
}
|
||||
|
||||
int CBS_get_any_ber_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
|
||||
size_t *out_header_len) {
|
||||
return cbs_get_any_asn1_element(cbs, out, out_tag, out_header_len,
|
||||
1 /* BER allowed */);
|
||||
size_t *out_header_len, int *out_ber_found) {
|
||||
int ber_found_temp;
|
||||
return cbs_get_any_asn1_element(
|
||||
cbs, out, out_tag, out_header_len,
|
||||
out_ber_found ? out_ber_found : &ber_found_temp, 1 /* BER allowed */);
|
||||
}
|
||||
|
||||
static int cbs_get_asn1(CBS *cbs, CBS *out, unsigned tag_value,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
|
||||
.section __TEXT,__const
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
|
||||
.hidden OPENSSL_armcap_P
|
||||
|
||||
.section .rodata
|
||||
|
||||
|
||||
+1915
-1980
File diff suppressed because it is too large.
Load diff
+1870
-1977
File diff suppressed because it is too large.
Load diff
@@ -18,18 +18,15 @@
|
||||
|
||||
#include <CCryptoBoringSSL_chacha.h>
|
||||
#include <CCryptoBoringSSL_cipher.h>
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_poly1305.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "../chacha/internal.h"
|
||||
#include "../fipsmodule/cipher/internal.h"
|
||||
#include "../internal.h"
|
||||
#include "../chacha/internal.h"
|
||||
|
||||
|
||||
#define POLY1305_TAG_LEN 16
|
||||
|
||||
struct aead_chacha20_poly1305_ctx {
|
||||
uint8_t key[32];
|
||||
@@ -44,78 +41,6 @@ OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
|
||||
"AEAD state has insufficient alignment");
|
||||
#endif
|
||||
|
||||
// For convenience (the x86_64 calling convention allows only six parameters in
|
||||
// registers), the final parameter for the assembly functions is both an input
|
||||
// and output parameter.
|
||||
union open_data {
|
||||
struct {
|
||||
alignas(16) uint8_t key[32];
|
||||
uint32_t counter;
|
||||
uint8_t nonce[12];
|
||||
} in;
|
||||
struct {
|
||||
uint8_t tag[POLY1305_TAG_LEN];
|
||||
} out;
|
||||
};
|
||||
|
||||
union seal_data {
|
||||
struct {
|
||||
alignas(16) uint8_t key[32];
|
||||
uint32_t counter;
|
||||
uint8_t nonce[12];
|
||||
const uint8_t *extra_ciphertext;
|
||||
size_t extra_ciphertext_len;
|
||||
} in;
|
||||
struct {
|
||||
uint8_t tag[POLY1305_TAG_LEN];
|
||||
} out;
|
||||
};
|
||||
|
||||
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) && \
|
||||
!defined(OPENSSL_WINDOWS)
|
||||
static int asm_capable(void) {
|
||||
const int sse41_capable = (OPENSSL_ia32cap_P[1] & (1 << 19)) != 0;
|
||||
return sse41_capable;
|
||||
}
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(union open_data) == 48, "wrong open_data size");
|
||||
OPENSSL_STATIC_ASSERT(sizeof(union seal_data) == 48 + 8 + 8,
|
||||
"wrong seal_data size");
|
||||
|
||||
// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It decrypts
|
||||
// |plaintext_len| bytes from |ciphertext| and writes them to |out_plaintext|.
|
||||
// Additional input parameters are passed in |aead_data->in|. On exit, it will
|
||||
// write calculated tag value to |aead_data->out.tag|, which the caller must
|
||||
// check.
|
||||
extern void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len, union open_data *aead_data);
|
||||
|
||||
// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It encrypts
|
||||
// |plaintext_len| bytes from |plaintext| and writes them to |out_ciphertext|.
|
||||
// Additional input parameters are passed in |aead_data->in|. The calculated tag
|
||||
// value is over the computed ciphertext concatenated with |extra_ciphertext|
|
||||
// and written to |aead_data->out.tag|.
|
||||
extern void chacha20_poly1305_seal(uint8_t *out_ciphertext,
|
||||
const uint8_t *plaintext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len, union seal_data *aead_data);
|
||||
#else
|
||||
static int asm_capable(void) { return 0; }
|
||||
|
||||
|
||||
static void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len, union open_data *aead_data) {}
|
||||
|
||||
static void chacha20_poly1305_seal(uint8_t *out_ciphertext,
|
||||
const uint8_t *plaintext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len, union seal_data *aead_data) {}
|
||||
#endif
|
||||
|
||||
static int aead_chacha20_poly1305_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
|
||||
size_t key_len, size_t tag_len) {
|
||||
struct aead_chacha20_poly1305_ctx *c20_ctx =
|
||||
@@ -238,8 +163,8 @@ static int chacha20_poly1305_seal_scatter(
|
||||
}
|
||||
}
|
||||
|
||||
union seal_data data;
|
||||
if (asm_capable()) {
|
||||
union chacha20_poly1305_seal_data data;
|
||||
if (chacha20_poly1305_asm_capable()) {
|
||||
OPENSSL_memcpy(data.in.key, key, 32);
|
||||
data.in.counter = 0;
|
||||
OPENSSL_memcpy(data.in.nonce, nonce, 12);
|
||||
@@ -321,8 +246,8 @@ static int chacha20_poly1305_open_gather(
|
||||
return 0;
|
||||
}
|
||||
|
||||
union open_data data;
|
||||
if (asm_capable()) {
|
||||
union chacha20_poly1305_open_data data;
|
||||
if (chacha20_poly1305_asm_capable()) {
|
||||
OPENSSL_memcpy(data.in.key, key, 32);
|
||||
data.in.counter = 0;
|
||||
OPENSSL_memcpy(data.in.nonce, nonce, 12);
|
||||
|
||||
@@ -57,7 +57,11 @@
|
||||
#ifndef OPENSSL_HEADER_CIPHER_EXTRA_INTERNAL_H
|
||||
#define OPENSSL_HEADER_CIPHER_EXTRA_INTERNAL_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
@@ -120,6 +124,89 @@ int EVP_tls_cbc_digest_record(const EVP_MD *md, uint8_t *md_out,
|
||||
const uint8_t *mac_secret,
|
||||
unsigned mac_secret_length);
|
||||
|
||||
#define POLY1305_TAG_LEN 16
|
||||
|
||||
// For convenience (the x86_64 calling convention allows only six parameters in
|
||||
// registers), the final parameter for the assembly functions is both an input
|
||||
// and output parameter.
|
||||
union chacha20_poly1305_open_data {
|
||||
struct {
|
||||
alignas(16) uint8_t key[32];
|
||||
uint32_t counter;
|
||||
uint8_t nonce[12];
|
||||
} in;
|
||||
struct {
|
||||
uint8_t tag[POLY1305_TAG_LEN];
|
||||
} out;
|
||||
};
|
||||
|
||||
union chacha20_poly1305_seal_data {
|
||||
struct {
|
||||
alignas(16) uint8_t key[32];
|
||||
uint32_t counter;
|
||||
uint8_t nonce[12];
|
||||
const uint8_t *extra_ciphertext;
|
||||
size_t extra_ciphertext_len;
|
||||
} in;
|
||||
struct {
|
||||
uint8_t tag[POLY1305_TAG_LEN];
|
||||
} out;
|
||||
};
|
||||
|
||||
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM)
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(union chacha20_poly1305_open_data) == 48,
|
||||
"wrong chacha20_poly1305_open_data size");
|
||||
OPENSSL_STATIC_ASSERT(sizeof(union chacha20_poly1305_seal_data) == 48 + 8 + 8,
|
||||
"wrong chacha20_poly1305_seal_data size");
|
||||
|
||||
OPENSSL_INLINE int chacha20_poly1305_asm_capable(void) {
|
||||
const int sse41_capable = (OPENSSL_ia32cap_P[1] & (1 << 19)) != 0;
|
||||
return sse41_capable;
|
||||
}
|
||||
|
||||
// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It decrypts
|
||||
// |plaintext_len| bytes from |ciphertext| and writes them to |out_plaintext|.
|
||||
// Additional input parameters are passed in |aead_data->in|. On exit, it will
|
||||
// write calculated tag value to |aead_data->out.tag|, which the caller must
|
||||
// check.
|
||||
extern void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_open_data *data);
|
||||
|
||||
// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It encrypts
|
||||
// |plaintext_len| bytes from |plaintext| and writes them to |out_ciphertext|.
|
||||
// Additional input parameters are passed in |aead_data->in|. The calculated tag
|
||||
// value is over the computed ciphertext concatenated with |extra_ciphertext|
|
||||
// and written to |aead_data->out.tag|.
|
||||
extern void chacha20_poly1305_seal(uint8_t *out_ciphertext,
|
||||
const uint8_t *plaintext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_seal_data *data);
|
||||
#else
|
||||
|
||||
OPENSSL_INLINE int chacha20_poly1305_asm_capable(void) { return 0; }
|
||||
|
||||
OPENSSL_INLINE void chacha20_poly1305_open(uint8_t *out_plaintext,
|
||||
const uint8_t *ciphertext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_open_data *data) {
|
||||
abort();
|
||||
}
|
||||
|
||||
OPENSSL_INLINE void chacha20_poly1305_seal(uint8_t *out_ciphertext,
|
||||
const uint8_t *plaintext,
|
||||
size_t plaintext_len, const uint8_t *ad,
|
||||
size_t ad_len,
|
||||
union chacha20_poly1305_seal_data *data) {
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright (c) 2018, Google Inc.
|
||||
* Copyright (c) 2020, Arm Ltd.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
|
||||
#if defined(OPENSSL_AARCH64) && defined(OPENSSL_WINDOWS) && \
|
||||
!defined(OPENSSL_STATIC_ARMCAP)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <CCryptoBoringSSL_arm_arch.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
extern uint32_t OPENSSL_armcap_P;
|
||||
void OPENSSL_cpuid_setup(void) {
|
||||
// We do not need to check for the presence of NEON, as Armv8-A always has it
|
||||
OPENSSL_armcap_P |= ARMV7_NEON;
|
||||
|
||||
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)) {
|
||||
// These are all covered by one call in Windows
|
||||
OPENSSL_armcap_P |= ARMV8_AES;
|
||||
OPENSSL_armcap_P |= ARMV8_PMULL;
|
||||
OPENSSL_armcap_P |= ARMV8_SHA1;
|
||||
OPENSSL_armcap_P |= ARMV8_SHA256;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -175,7 +175,13 @@ void OPENSSL_cpuid_setup(void) {
|
||||
hwcap = crypto_get_arm_hwcap_from_cpuinfo(&cpuinfo);
|
||||
}
|
||||
|
||||
// Clear NEON support if known broken.
|
||||
// Clear NEON support if known broken. Note, if NEON is available statically,
|
||||
// the non-NEON code is dropped and this workaround is a no-op.
|
||||
//
|
||||
// TODO(davidben): The Android NDK now builds with NEON statically available
|
||||
// by default. Cronet still has some consumers that support NEON-less devices
|
||||
// (b/150371744). Get metrics on whether they still see this CPU and, if not,
|
||||
// remove this check entirely.
|
||||
g_has_broken_neon = crypto_cpuinfo_has_broken_neon(&cpuinfo);
|
||||
if (g_has_broken_neon) {
|
||||
hwcap &= ~HWCAP_NEON;
|
||||
@@ -186,7 +192,10 @@ void OPENSSL_cpuid_setup(void) {
|
||||
OPENSSL_armcap_P |= ARMV7_NEON;
|
||||
|
||||
// Some ARMv8 Android devices don't expose AT_HWCAP2. Fall back to
|
||||
// /proc/cpuinfo. See https://crbug.com/596156.
|
||||
// /proc/cpuinfo. See https://crbug.com/boringssl/46. As of February 2021,
|
||||
// this is now rare (see Chrome's Net.NeedsHWCAP2Workaround metric), but AES
|
||||
// and PMULL extensions are very useful, so we still carry the workaround
|
||||
// for now.
|
||||
unsigned long hwcap2 = 0;
|
||||
if (getauxval != NULL) {
|
||||
hwcap2 = getauxval(AT_HWCAP2);
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
|
||||
extern uint32_t OPENSSL_armcap_P;
|
||||
|
||||
char CRYPTO_is_NEON_capable_at_runtime(void) {
|
||||
int CRYPTO_is_NEON_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV7_NEON) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_AES_capable(void) {
|
||||
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_AES) != 0;
|
||||
}
|
||||
|
||||
int CRYPTO_is_ARMv8_PMULL_capable(void) {
|
||||
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void) {
|
||||
return (OPENSSL_armcap_P & ARMV8_PMULL) != 0;
|
||||
}
|
||||
|
||||
|
||||
File renamed without changes.
+179
@@ -53,6 +53,8 @@
|
||||
#include <CCryptoBoringSSL_dh.h>
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
#include "../fipsmodule/bn/internal.h"
|
||||
|
||||
@@ -91,3 +93,180 @@ BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *ret) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_bits, int generator,
|
||||
BN_GENCB *cb) {
|
||||
// We generate DH parameters as follows
|
||||
// find a prime q which is prime_bits/2 bits long.
|
||||
// p=(2*q)+1 or (p-1)/2 = q
|
||||
// For this case, g is a generator if
|
||||
// g^((p-1)/q) mod p != 1 for values of q which are the factors of p-1.
|
||||
// Since the factors of p-1 are q and 2, we just need to check
|
||||
// g^2 mod p != 1 and g^q mod p != 1.
|
||||
//
|
||||
// Having said all that,
|
||||
// there is another special case method for the generators 2, 3 and 5.
|
||||
// for 2, p mod 24 == 11
|
||||
// for 3, p mod 12 == 5 <<<<< does not work for safe primes.
|
||||
// for 5, p mod 10 == 3 or 7
|
||||
//
|
||||
// Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the
|
||||
// special generators and for answering some of my questions.
|
||||
//
|
||||
// I've implemented the second simple method :-).
|
||||
// Since DH should be using a safe prime (both p and q are prime),
|
||||
// this generator function can take a very very long time to run.
|
||||
|
||||
// Actually there is no reason to insist that 'generator' be a generator.
|
||||
// It's just as OK (and in some sense better) to use a generator of the
|
||||
// order-q subgroup.
|
||||
|
||||
BIGNUM *t1, *t2;
|
||||
int g, ok = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
goto err;
|
||||
}
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
t2 = BN_CTX_get(ctx);
|
||||
if (t1 == NULL || t2 == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// Make sure |dh| has the necessary elements
|
||||
if (dh->p == NULL) {
|
||||
dh->p = BN_new();
|
||||
if (dh->p == NULL) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (dh->g == NULL) {
|
||||
dh->g = BN_new();
|
||||
if (dh->g == NULL) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (generator <= 1) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
|
||||
goto err;
|
||||
}
|
||||
if (generator == DH_GENERATOR_2) {
|
||||
if (!BN_set_word(t1, 24)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 11)) {
|
||||
goto err;
|
||||
}
|
||||
g = 2;
|
||||
} else if (generator == DH_GENERATOR_5) {
|
||||
if (!BN_set_word(t1, 10)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 3)) {
|
||||
goto err;
|
||||
}
|
||||
// BN_set_word(t3,7); just have to miss
|
||||
// out on these ones :-(
|
||||
g = 5;
|
||||
} else {
|
||||
// in the general case, don't worry if 'generator' is a
|
||||
// generator or not: since we are using safe primes,
|
||||
// it will generate either an order-q or an order-2q group,
|
||||
// which both is OK
|
||||
if (!BN_set_word(t1, 2)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 1)) {
|
||||
goto err;
|
||||
}
|
||||
g = generator;
|
||||
}
|
||||
|
||||
if (!BN_generate_prime_ex(dh->p, prime_bits, 1, t1, t2, cb)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_GENCB_call(cb, 3, 0)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(dh->g, g)) {
|
||||
goto err;
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
OPENSSL_PUT_ERROR(DH, ERR_R_BN_LIB);
|
||||
}
|
||||
|
||||
if (ctx != NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src) {
|
||||
BIGNUM *a = NULL;
|
||||
|
||||
if (src) {
|
||||
a = BN_dup(src);
|
||||
if (!a) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
BN_free(*dst);
|
||||
*dst = a;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int int_dh_param_copy(DH *to, const DH *from, int is_x942) {
|
||||
if (is_x942 == -1) {
|
||||
is_x942 = !!from->q;
|
||||
}
|
||||
if (!int_dh_bn_cpy(&to->p, from->p) ||
|
||||
!int_dh_bn_cpy(&to->g, from->g)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!is_x942) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!int_dh_bn_cpy(&to->q, from->q) ||
|
||||
!int_dh_bn_cpy(&to->j, from->j)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OPENSSL_free(to->seed);
|
||||
to->seed = NULL;
|
||||
to->seedlen = 0;
|
||||
|
||||
if (from->seed) {
|
||||
to->seed = OPENSSL_memdup(from->seed, from->seedlen);
|
||||
if (!to->seed) {
|
||||
return 0;
|
||||
}
|
||||
to->seedlen = from->seedlen;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
DH *DHparams_dup(const DH *dh) {
|
||||
DH *ret = DH_new();
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!int_dh_param_copy(ret, dh, -1)) {
|
||||
DH_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -59,10 +59,12 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_asn1.h>
|
||||
#include <CCryptoBoringSSL_blake2.h>
|
||||
#include <CCryptoBoringSSL_bytestring.h>
|
||||
#include <CCryptoBoringSSL_nid.h>
|
||||
|
||||
#include "../internal.h"
|
||||
#include "../fipsmodule/digest/internal.h"
|
||||
|
||||
|
||||
struct nid_to_digest {
|
||||
@@ -238,3 +240,26 @@ const EVP_MD *EVP_get_digestbyname(const char *name) {
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void blake2b256_init(EVP_MD_CTX *ctx) { BLAKE2B256_Init(ctx->md_data); }
|
||||
|
||||
static void blake2b256_update(EVP_MD_CTX *ctx, const void *data, size_t len) {
|
||||
BLAKE2B256_Update(ctx->md_data, data, len);
|
||||
}
|
||||
|
||||
static void blake2b256_final(EVP_MD_CTX *ctx, uint8_t *md) {
|
||||
BLAKE2B256_Final(md, ctx->md_data);
|
||||
}
|
||||
|
||||
static const EVP_MD evp_md_blake2b256 = {
|
||||
NID_undef,
|
||||
BLAKE2B256_DIGEST_LENGTH,
|
||||
0,
|
||||
blake2b256_init,
|
||||
blake2b256_update,
|
||||
blake2b256_final,
|
||||
BLAKE2B_CBLOCK,
|
||||
sizeof(BLAKE2B_CTX),
|
||||
};
|
||||
|
||||
const EVP_MD *EVP_blake2b256(void) { return &evp_md_blake2b256; }
|
||||
File diff suppressed because it is too large.
Load diff
@@ -632,20 +632,34 @@ _aes_hw_ctr32_encrypt_blocks:
|
||||
add r7,r3,#32
|
||||
mov r6,r5
|
||||
movlo r12,#0
|
||||
|
||||
@ ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are
|
||||
@ affected by silicon errata #1742098 [0] and #1655431 [1],
|
||||
@ respectively, where the second instruction of an aese/aesmc
|
||||
@ instruction pair may execute twice if an interrupt is taken right
|
||||
@ after the first instruction consumes an input register of which a
|
||||
@ single 32-bit lane has been updated the last time it was modified.
|
||||
@
|
||||
@ This function uses a counter in one 32-bit lane. The
|
||||
@ could write to q1 and q10 directly, but that trips this bugs.
|
||||
@ We write to q6 and copy to the final register as a workaround.
|
||||
@
|
||||
@ [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice
|
||||
@ [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice
|
||||
#ifndef __ARMEB__
|
||||
rev r8, r8
|
||||
#endif
|
||||
vorr q1,q0,q0
|
||||
add r10, r8, #1
|
||||
vorr q10,q0,q0
|
||||
add r8, r8, #2
|
||||
vorr q6,q0,q0
|
||||
rev r10, r10
|
||||
vmov.32 d3[1],r10
|
||||
vmov.32 d13[1],r10
|
||||
add r8, r8, #2
|
||||
vorr q1,q6,q6
|
||||
bls Lctr32_tail
|
||||
rev r12, r8
|
||||
vmov.32 d13[1],r12
|
||||
sub r2,r2,#3 @ bias
|
||||
vmov.32 d21[1],r12
|
||||
vorr q10,q6,q6
|
||||
b Loop3x_ctr32
|
||||
|
||||
.align 4
|
||||
@@ -672,11 +686,11 @@ Loop3x_ctr32:
|
||||
.byte 0x20,0x23,0xb0,0xf3 @ aese q1,q8
|
||||
.byte 0x82,0xa3,0xb0,0xf3 @ aesmc q5,q1
|
||||
vld1.8 {q2},[r0]!
|
||||
vorr q0,q6,q6
|
||||
add r9,r8,#1
|
||||
.byte 0x20,0x43,0xf0,0xf3 @ aese q10,q8
|
||||
.byte 0xa4,0x43,0xf0,0xf3 @ aesmc q10,q10
|
||||
vld1.8 {q3},[r0]!
|
||||
vorr q1,q6,q6
|
||||
rev r9,r9
|
||||
.byte 0x22,0x83,0xb0,0xf3 @ aese q4,q9
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x22,0xa3,0xb0,0xf3 @ aese q5,q9
|
||||
@@ -685,8 +699,6 @@ Loop3x_ctr32:
|
||||
mov r7,r3
|
||||
.byte 0x22,0x43,0xf0,0xf3 @ aese q10,q9
|
||||
.byte 0xa4,0x23,0xf0,0xf3 @ aesmc q9,q10
|
||||
vorr q10,q6,q6
|
||||
add r9,r8,#1
|
||||
.byte 0x28,0x83,0xb0,0xf3 @ aese q4,q12
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x28,0xa3,0xb0,0xf3 @ aese q5,q12
|
||||
@@ -701,21 +713,26 @@ Loop3x_ctr32:
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x2a,0xa3,0xb0,0xf3 @ aese q5,q13
|
||||
.byte 0x8a,0xa3,0xb0,0xf3 @ aesmc q5,q5
|
||||
@ Note the logic to update q0, q1, and q1 is written to work
|
||||
@ around a bug in ARM Cortex-A57 and Cortex-A72 cores running in
|
||||
@ 32-bit mode. See the comment above.
|
||||
veor q11,q11,q7
|
||||
rev r9,r9
|
||||
vmov.32 d13[1], r9
|
||||
.byte 0x2a,0x23,0xf0,0xf3 @ aese q9,q13
|
||||
.byte 0xa2,0x23,0xf0,0xf3 @ aesmc q9,q9
|
||||
vmov.32 d1[1], r9
|
||||
vorr q0,q6,q6
|
||||
rev r10,r10
|
||||
.byte 0x2c,0x83,0xb0,0xf3 @ aese q4,q14
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
vmov.32 d13[1], r10
|
||||
rev r12,r8
|
||||
.byte 0x2c,0xa3,0xb0,0xf3 @ aese q5,q14
|
||||
.byte 0x8a,0xa3,0xb0,0xf3 @ aesmc q5,q5
|
||||
vmov.32 d3[1], r10
|
||||
rev r12,r8
|
||||
vorr q1,q6,q6
|
||||
vmov.32 d13[1], r12
|
||||
.byte 0x2c,0x23,0xf0,0xf3 @ aese q9,q14
|
||||
.byte 0xa2,0x23,0xf0,0xf3 @ aesmc q9,q9
|
||||
vmov.32 d21[1], r12
|
||||
vorr q10,q6,q6
|
||||
subs r2,r2,#3
|
||||
.byte 0x2e,0x83,0xb0,0xf3 @ aese q4,q15
|
||||
.byte 0x2e,0xa3,0xb0,0xf3 @ aese q5,q15
|
||||
|
||||
@@ -621,20 +621,34 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
add r7,r3,#32
|
||||
mov r6,r5
|
||||
movlo r12,#0
|
||||
|
||||
@ ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are
|
||||
@ affected by silicon errata #1742098 [0] and #1655431 [1],
|
||||
@ respectively, where the second instruction of an aese/aesmc
|
||||
@ instruction pair may execute twice if an interrupt is taken right
|
||||
@ after the first instruction consumes an input register of which a
|
||||
@ single 32-bit lane has been updated the last time it was modified.
|
||||
@
|
||||
@ This function uses a counter in one 32-bit lane. The
|
||||
@ could write to q1 and q10 directly, but that trips this bugs.
|
||||
@ We write to q6 and copy to the final register as a workaround.
|
||||
@
|
||||
@ [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice
|
||||
@ [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice
|
||||
#ifndef __ARMEB__
|
||||
rev r8, r8
|
||||
#endif
|
||||
vorr q1,q0,q0
|
||||
add r10, r8, #1
|
||||
vorr q10,q0,q0
|
||||
add r8, r8, #2
|
||||
vorr q6,q0,q0
|
||||
rev r10, r10
|
||||
vmov.32 d3[1],r10
|
||||
vmov.32 d13[1],r10
|
||||
add r8, r8, #2
|
||||
vorr q1,q6,q6
|
||||
bls .Lctr32_tail
|
||||
rev r12, r8
|
||||
vmov.32 d13[1],r12
|
||||
sub r2,r2,#3 @ bias
|
||||
vmov.32 d21[1],r12
|
||||
vorr q10,q6,q6
|
||||
b .Loop3x_ctr32
|
||||
|
||||
.align 4
|
||||
@@ -661,11 +675,11 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
.byte 0x20,0x23,0xb0,0xf3 @ aese q1,q8
|
||||
.byte 0x82,0xa3,0xb0,0xf3 @ aesmc q5,q1
|
||||
vld1.8 {q2},[r0]!
|
||||
vorr q0,q6,q6
|
||||
add r9,r8,#1
|
||||
.byte 0x20,0x43,0xf0,0xf3 @ aese q10,q8
|
||||
.byte 0xa4,0x43,0xf0,0xf3 @ aesmc q10,q10
|
||||
vld1.8 {q3},[r0]!
|
||||
vorr q1,q6,q6
|
||||
rev r9,r9
|
||||
.byte 0x22,0x83,0xb0,0xf3 @ aese q4,q9
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x22,0xa3,0xb0,0xf3 @ aese q5,q9
|
||||
@@ -674,8 +688,6 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
mov r7,r3
|
||||
.byte 0x22,0x43,0xf0,0xf3 @ aese q10,q9
|
||||
.byte 0xa4,0x23,0xf0,0xf3 @ aesmc q9,q10
|
||||
vorr q10,q6,q6
|
||||
add r9,r8,#1
|
||||
.byte 0x28,0x83,0xb0,0xf3 @ aese q4,q12
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x28,0xa3,0xb0,0xf3 @ aese q5,q12
|
||||
@@ -690,21 +702,26 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
.byte 0x2a,0xa3,0xb0,0xf3 @ aese q5,q13
|
||||
.byte 0x8a,0xa3,0xb0,0xf3 @ aesmc q5,q5
|
||||
@ Note the logic to update q0, q1, and q1 is written to work
|
||||
@ around a bug in ARM Cortex-A57 and Cortex-A72 cores running in
|
||||
@ 32-bit mode. See the comment above.
|
||||
veor q11,q11,q7
|
||||
rev r9,r9
|
||||
vmov.32 d13[1], r9
|
||||
.byte 0x2a,0x23,0xf0,0xf3 @ aese q9,q13
|
||||
.byte 0xa2,0x23,0xf0,0xf3 @ aesmc q9,q9
|
||||
vmov.32 d1[1], r9
|
||||
vorr q0,q6,q6
|
||||
rev r10,r10
|
||||
.byte 0x2c,0x83,0xb0,0xf3 @ aese q4,q14
|
||||
.byte 0x88,0x83,0xb0,0xf3 @ aesmc q4,q4
|
||||
vmov.32 d13[1], r10
|
||||
rev r12,r8
|
||||
.byte 0x2c,0xa3,0xb0,0xf3 @ aese q5,q14
|
||||
.byte 0x8a,0xa3,0xb0,0xf3 @ aesmc q5,q5
|
||||
vmov.32 d3[1], r10
|
||||
rev r12,r8
|
||||
vorr q1,q6,q6
|
||||
vmov.32 d13[1], r12
|
||||
.byte 0x2c,0x23,0xf0,0xf3 @ aese q9,q14
|
||||
.byte 0xa2,0x23,0xf0,0xf3 @ aesmc q9,q9
|
||||
vmov.32 d21[1], r12
|
||||
vorr q10,q6,q6
|
||||
subs r2,r2,#3
|
||||
.byte 0x2e,0x83,0xb0,0xf3 @ aese q4,q15
|
||||
.byte 0x2e,0xa3,0xb0,0xf3 @ aese q5,q15
|
||||
|
||||
@@ -622,20 +622,34 @@ _aes_hw_ctr32_encrypt_blocks:
|
||||
add x7,x3,#32
|
||||
mov w6,w5
|
||||
csel x12,xzr,x12,lo
|
||||
|
||||
// ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are
|
||||
// affected by silicon errata #1742098 [0] and #1655431 [1],
|
||||
// respectively, where the second instruction of an aese/aesmc
|
||||
// instruction pair may execute twice if an interrupt is taken right
|
||||
// after the first instruction consumes an input register of which a
|
||||
// single 32-bit lane has been updated the last time it was modified.
|
||||
//
|
||||
// This function uses a counter in one 32-bit lane. The vmov lines
|
||||
// could write to v1.16b and v18.16b directly, but that trips this bugs.
|
||||
// We write to v6.16b and copy to the final register as a workaround.
|
||||
//
|
||||
// [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice
|
||||
// [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice
|
||||
#ifndef __ARMEB__
|
||||
rev w8, w8
|
||||
#endif
|
||||
orr v1.16b,v0.16b,v0.16b
|
||||
add w10, w8, #1
|
||||
orr v18.16b,v0.16b,v0.16b
|
||||
add w8, w8, #2
|
||||
orr v6.16b,v0.16b,v0.16b
|
||||
rev w10, w10
|
||||
mov v1.s[3],w10
|
||||
mov v6.s[3],w10
|
||||
add w8, w8, #2
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
b.ls Lctr32_tail
|
||||
rev w12, w8
|
||||
mov v6.s[3],w12
|
||||
sub x2,x2,#3 // bias
|
||||
mov v18.s[3],w12
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
b Loop3x_ctr32
|
||||
|
||||
.align 4
|
||||
@@ -662,11 +676,11 @@ Loop3x_ctr32:
|
||||
aese v1.16b,v16.16b
|
||||
aesmc v5.16b,v1.16b
|
||||
ld1 {v2.16b},[x0],#16
|
||||
orr v0.16b,v6.16b,v6.16b
|
||||
add w9,w8,#1
|
||||
aese v18.16b,v16.16b
|
||||
aesmc v18.16b,v18.16b
|
||||
ld1 {v3.16b},[x0],#16
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
rev w9,w9
|
||||
aese v4.16b,v17.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v17.16b
|
||||
@@ -675,8 +689,6 @@ Loop3x_ctr32:
|
||||
mov x7,x3
|
||||
aese v18.16b,v17.16b
|
||||
aesmc v17.16b,v18.16b
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
add w9,w8,#1
|
||||
aese v4.16b,v20.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v20.16b
|
||||
@@ -691,21 +703,26 @@ Loop3x_ctr32:
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v21.16b
|
||||
aesmc v5.16b,v5.16b
|
||||
// Note the logic to update v0.16b, v1.16b, and v1.16b is written to work
|
||||
// around a bug in ARM Cortex-A57 and Cortex-A72 cores running in
|
||||
// 32-bit mode. See the comment above.
|
||||
eor v19.16b,v19.16b,v7.16b
|
||||
rev w9,w9
|
||||
mov v6.s[3], w9
|
||||
aese v17.16b,v21.16b
|
||||
aesmc v17.16b,v17.16b
|
||||
mov v0.s[3], w9
|
||||
orr v0.16b,v6.16b,v6.16b
|
||||
rev w10,w10
|
||||
aese v4.16b,v22.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
mov v6.s[3], w10
|
||||
rev w12,w8
|
||||
aese v5.16b,v22.16b
|
||||
aesmc v5.16b,v5.16b
|
||||
mov v1.s[3], w10
|
||||
rev w12,w8
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
mov v6.s[3], w12
|
||||
aese v17.16b,v22.16b
|
||||
aesmc v17.16b,v17.16b
|
||||
mov v18.s[3], w12
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
subs x2,x2,#3
|
||||
aese v4.16b,v23.16b
|
||||
aese v5.16b,v23.16b
|
||||
|
||||
@@ -623,20 +623,34 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
add x7,x3,#32
|
||||
mov w6,w5
|
||||
csel x12,xzr,x12,lo
|
||||
|
||||
// ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are
|
||||
// affected by silicon errata #1742098 [0] and #1655431 [1],
|
||||
// respectively, where the second instruction of an aese/aesmc
|
||||
// instruction pair may execute twice if an interrupt is taken right
|
||||
// after the first instruction consumes an input register of which a
|
||||
// single 32-bit lane has been updated the last time it was modified.
|
||||
//
|
||||
// This function uses a counter in one 32-bit lane. The vmov lines
|
||||
// could write to v1.16b and v18.16b directly, but that trips this bugs.
|
||||
// We write to v6.16b and copy to the final register as a workaround.
|
||||
//
|
||||
// [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice
|
||||
// [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice
|
||||
#ifndef __ARMEB__
|
||||
rev w8, w8
|
||||
#endif
|
||||
orr v1.16b,v0.16b,v0.16b
|
||||
add w10, w8, #1
|
||||
orr v18.16b,v0.16b,v0.16b
|
||||
add w8, w8, #2
|
||||
orr v6.16b,v0.16b,v0.16b
|
||||
rev w10, w10
|
||||
mov v1.s[3],w10
|
||||
mov v6.s[3],w10
|
||||
add w8, w8, #2
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
b.ls .Lctr32_tail
|
||||
rev w12, w8
|
||||
mov v6.s[3],w12
|
||||
sub x2,x2,#3 // bias
|
||||
mov v18.s[3],w12
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
b .Loop3x_ctr32
|
||||
|
||||
.align 4
|
||||
@@ -663,11 +677,11 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
aese v1.16b,v16.16b
|
||||
aesmc v5.16b,v1.16b
|
||||
ld1 {v2.16b},[x0],#16
|
||||
orr v0.16b,v6.16b,v6.16b
|
||||
add w9,w8,#1
|
||||
aese v18.16b,v16.16b
|
||||
aesmc v18.16b,v18.16b
|
||||
ld1 {v3.16b},[x0],#16
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
rev w9,w9
|
||||
aese v4.16b,v17.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v17.16b
|
||||
@@ -676,8 +690,6 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
mov x7,x3
|
||||
aese v18.16b,v17.16b
|
||||
aesmc v17.16b,v18.16b
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
add w9,w8,#1
|
||||
aese v4.16b,v20.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v20.16b
|
||||
@@ -692,21 +704,26 @@ aes_hw_ctr32_encrypt_blocks:
|
||||
aesmc v4.16b,v4.16b
|
||||
aese v5.16b,v21.16b
|
||||
aesmc v5.16b,v5.16b
|
||||
// Note the logic to update v0.16b, v1.16b, and v1.16b is written to work
|
||||
// around a bug in ARM Cortex-A57 and Cortex-A72 cores running in
|
||||
// 32-bit mode. See the comment above.
|
||||
eor v19.16b,v19.16b,v7.16b
|
||||
rev w9,w9
|
||||
mov v6.s[3], w9
|
||||
aese v17.16b,v21.16b
|
||||
aesmc v17.16b,v17.16b
|
||||
mov v0.s[3], w9
|
||||
orr v0.16b,v6.16b,v6.16b
|
||||
rev w10,w10
|
||||
aese v4.16b,v22.16b
|
||||
aesmc v4.16b,v4.16b
|
||||
mov v6.s[3], w10
|
||||
rev w12,w8
|
||||
aese v5.16b,v22.16b
|
||||
aesmc v5.16b,v5.16b
|
||||
mov v1.s[3], w10
|
||||
rev w12,w8
|
||||
orr v1.16b,v6.16b,v6.16b
|
||||
mov v6.s[3], w12
|
||||
aese v17.16b,v22.16b
|
||||
aesmc v17.16b,v17.16b
|
||||
mov v18.s[3], w12
|
||||
orr v18.16b,v6.16b,v6.16b
|
||||
subs x2,x2,#3
|
||||
aese v4.16b,v23.16b
|
||||
aese v5.16b,v23.16b
|
||||
|
||||
@@ -101,26 +101,7 @@ void BN_free(BIGNUM *bn) {
|
||||
}
|
||||
|
||||
void BN_clear_free(BIGNUM *bn) {
|
||||
char should_free;
|
||||
|
||||
if (bn == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bn->d != NULL) {
|
||||
if ((bn->flags & BN_FLG_STATIC_DATA) == 0) {
|
||||
OPENSSL_free(bn->d);
|
||||
} else {
|
||||
OPENSSL_cleanse(bn->d, bn->dmax * sizeof(bn->d[0]));
|
||||
}
|
||||
}
|
||||
|
||||
should_free = (bn->flags & BN_FLG_MALLOCED) != 0;
|
||||
if (should_free) {
|
||||
OPENSSL_free(bn);
|
||||
} else {
|
||||
OPENSSL_cleanse(bn, sizeof(BIGNUM));
|
||||
}
|
||||
BN_free(bn);
|
||||
}
|
||||
|
||||
BIGNUM *BN_dup(const BIGNUM *src) {
|
||||
@@ -302,6 +283,18 @@ int bn_set_words(BIGNUM *bn, const BN_ULONG *words, size_t num) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bn_set_static_words(BIGNUM *bn, const BN_ULONG *words, size_t num) {
|
||||
if ((bn->flags & BN_FLG_STATIC_DATA) == 0) {
|
||||
OPENSSL_free(bn->d);
|
||||
}
|
||||
bn->d = (BN_ULONG *)words;
|
||||
|
||||
bn->width = num;
|
||||
bn->dmax = num;
|
||||
bn->neg = 0;
|
||||
bn->flags |= BN_FLG_STATIC_DATA;
|
||||
}
|
||||
|
||||
int bn_fits_in_words(const BIGNUM *bn, size_t num) {
|
||||
// All words beyond |num| must be zero.
|
||||
BN_ULONG mask = 0;
|
||||
|
||||
@@ -64,10 +64,10 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
#if !defined(BN_CAN_DIVIDE_ULLONG) && !defined(BN_CAN_USE_INLINE_ASM)
|
||||
// bn_div_words divides a double-width |h|,|l| by |d| and returns the result,
|
||||
// which must fit in a |BN_ULONG|.
|
||||
static BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) {
|
||||
OPENSSL_UNUSED static BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l,
|
||||
BN_ULONG d) {
|
||||
BN_ULONG dh, dl, q, ret = 0, th, tl, t;
|
||||
int i, count = 2;
|
||||
|
||||
@@ -135,7 +135,6 @@ static BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) {
|
||||
ret |= q;
|
||||
return ret;
|
||||
}
|
||||
#endif // !defined(BN_CAN_DIVIDE_ULLONG) && !defined(BN_CAN_USE_INLINE_ASM)
|
||||
|
||||
static inline void bn_div_rem_words(BN_ULONG *quotient_out, BN_ULONG *rem_out,
|
||||
BN_ULONG n0, BN_ULONG n1, BN_ULONG d0) {
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
#ifndef OPENSSL_HEADER_BN_INTERNAL_H
|
||||
#define OPENSSL_HEADER_BN_INTERNAL_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
|
||||
#if defined(OPENSSL_X86_64) && defined(_MSC_VER)
|
||||
OPENSSL_MSVC_PRAGMA(warning(push, 3))
|
||||
@@ -241,6 +241,14 @@ void bn_select_words(BN_ULONG *r, BN_ULONG mask, const BN_ULONG *a,
|
||||
// least significant word first.
|
||||
int bn_set_words(BIGNUM *bn, const BN_ULONG *words, size_t num);
|
||||
|
||||
// bn_set_static_words acts like |bn_set_words|, but doesn't copy the data. A
|
||||
// flag is set on |bn| so that |BN_free| won't attempt to free the data.
|
||||
//
|
||||
// The |STATIC_BIGNUM| macro is probably a better solution for this outside of
|
||||
// the FIPS module. Inside of the FIPS module that macro generates rel.ro data,
|
||||
// which doesn't work with FIPS requirements.
|
||||
void bn_set_static_words(BIGNUM *bn, const BN_ULONG *words, size_t num);
|
||||
|
||||
// bn_fits_in_words returns one if |bn| may be represented in |num| words, plus
|
||||
// a sign bit, and zero otherwise.
|
||||
int bn_fits_in_words(const BIGNUM *bn, size_t num);
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <CCryptoBoringSSL_cipher.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
@@ -224,7 +225,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
|
||||
ctx->buf_len = 0;
|
||||
ctx->final_used = 0;
|
||||
ctx->block_mask = ctx->cipher->block_size - 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -238,16 +238,31 @@ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
|
||||
}
|
||||
|
||||
// block_remainder returns the number of bytes to remove from |len| to get a
|
||||
// multiple of |ctx|'s block size.
|
||||
static int block_remainder(const EVP_CIPHER_CTX *ctx, int len) {
|
||||
// |block_size| must be a power of two.
|
||||
assert(ctx->cipher->block_size != 0);
|
||||
assert((ctx->cipher->block_size & (ctx->cipher->block_size - 1)) == 0);
|
||||
return len & (ctx->cipher->block_size - 1);
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
const uint8_t *in, int in_len) {
|
||||
int i, j, bl;
|
||||
// Ciphers that use blocks may write up to |bl| extra bytes. Ensure the output
|
||||
// does not overflow |*out_len|.
|
||||
int bl = ctx->cipher->block_size;
|
||||
if (bl > 1 && in_len > INT_MAX - bl) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
i = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
if (i < 0) {
|
||||
int ret = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
if (ret < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
*out_len = i;
|
||||
*out_len = ret;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -257,7 +272,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
return in_len == 0;
|
||||
}
|
||||
|
||||
if (ctx->buf_len == 0 && (in_len & ctx->block_mask) == 0) {
|
||||
if (ctx->buf_len == 0 && block_remainder(ctx, in_len) == 0) {
|
||||
if (ctx->cipher->cipher(ctx, out, in, in_len)) {
|
||||
*out_len = in_len;
|
||||
return 1;
|
||||
@@ -267,8 +282,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
}
|
||||
}
|
||||
|
||||
i = ctx->buf_len;
|
||||
bl = ctx->cipher->block_size;
|
||||
int i = ctx->buf_len;
|
||||
assert(bl <= (int)sizeof(ctx->buf));
|
||||
if (i != 0) {
|
||||
if (bl - i > in_len) {
|
||||
@@ -277,7 +291,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
*out_len = 0;
|
||||
return 1;
|
||||
} else {
|
||||
j = bl - i;
|
||||
int j = bl - i;
|
||||
OPENSSL_memcpy(&ctx->buf[i], in, j);
|
||||
if (!ctx->cipher->cipher(ctx, out, ctx->buf, bl)) {
|
||||
return 0;
|
||||
@@ -291,7 +305,7 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
*out_len = 0;
|
||||
}
|
||||
|
||||
i = in_len & ctx->block_mask;
|
||||
i = block_remainder(ctx, in_len);
|
||||
in_len -= i;
|
||||
if (in_len > 0) {
|
||||
if (!ctx->cipher->cipher(ctx, out, in, in_len)) {
|
||||
@@ -353,8 +367,13 @@ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len) {
|
||||
|
||||
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
const uint8_t *in, int in_len) {
|
||||
int fix_len;
|
||||
unsigned int b;
|
||||
// Ciphers that use blocks may write up to |bl| extra bytes. Ensure the output
|
||||
// does not overflow |*out_len|.
|
||||
unsigned int b = ctx->cipher->block_size;
|
||||
if (b > 1 && in_len > INT_MAX - (int)b) {
|
||||
OPENSSL_PUT_ERROR(CIPHER, ERR_R_OVERFLOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
int r = ctx->cipher->cipher(ctx, out, in, in_len);
|
||||
@@ -376,15 +395,12 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len,
|
||||
return EVP_EncryptUpdate(ctx, out, out_len, in, in_len);
|
||||
}
|
||||
|
||||
b = ctx->cipher->block_size;
|
||||
assert(b <= sizeof(ctx->final));
|
||||
|
||||
int fix_len = 0;
|
||||
if (ctx->final_used) {
|
||||
OPENSSL_memcpy(out, ctx->final, b);
|
||||
out += b;
|
||||
fix_len = 1;
|
||||
} else {
|
||||
fix_len = 0;
|
||||
}
|
||||
|
||||
if (!EVP_EncryptUpdate(ctx, out, out_len, in, in_len)) {
|
||||
|
||||
File renamed without changes.
+146
-223
@@ -60,17 +60,16 @@
|
||||
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_ex_data.h>
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_thread.h>
|
||||
|
||||
#include "../internal.h"
|
||||
#include "../../internal.h"
|
||||
#include "../bn/internal.h"
|
||||
|
||||
|
||||
#define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
|
||||
static CRYPTO_EX_DATA_CLASS g_ex_data_class = CRYPTO_EX_DATA_CLASS_INIT;
|
||||
|
||||
DH *DH_new(void) {
|
||||
DH *dh = OPENSSL_malloc(sizeof(DH));
|
||||
if (dh == NULL) {
|
||||
@@ -83,7 +82,6 @@ DH *DH_new(void) {
|
||||
CRYPTO_MUTEX_init(&dh->method_mont_p_lock);
|
||||
|
||||
dh->references = 1;
|
||||
CRYPTO_new_ex_data(&dh->ex_data);
|
||||
|
||||
return dh;
|
||||
}
|
||||
@@ -97,8 +95,6 @@ void DH_free(DH *dh) {
|
||||
return;
|
||||
}
|
||||
|
||||
CRYPTO_free_ex_data(&g_ex_data_class, dh, &dh->ex_data);
|
||||
|
||||
BN_MONT_CTX_free(dh->method_mont_p);
|
||||
BN_clear_free(dh->p);
|
||||
BN_clear_free(dh->g);
|
||||
@@ -189,120 +185,6 @@ int DH_set_length(DH *dh, unsigned priv_length) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DH_generate_parameters_ex(DH *dh, int prime_bits, int generator, BN_GENCB *cb) {
|
||||
// We generate DH parameters as follows
|
||||
// find a prime q which is prime_bits/2 bits long.
|
||||
// p=(2*q)+1 or (p-1)/2 = q
|
||||
// For this case, g is a generator if
|
||||
// g^((p-1)/q) mod p != 1 for values of q which are the factors of p-1.
|
||||
// Since the factors of p-1 are q and 2, we just need to check
|
||||
// g^2 mod p != 1 and g^q mod p != 1.
|
||||
//
|
||||
// Having said all that,
|
||||
// there is another special case method for the generators 2, 3 and 5.
|
||||
// for 2, p mod 24 == 11
|
||||
// for 3, p mod 12 == 5 <<<<< does not work for safe primes.
|
||||
// for 5, p mod 10 == 3 or 7
|
||||
//
|
||||
// Thanks to Phil Karn <karn@qualcomm.com> for the pointers about the
|
||||
// special generators and for answering some of my questions.
|
||||
//
|
||||
// I've implemented the second simple method :-).
|
||||
// Since DH should be using a safe prime (both p and q are prime),
|
||||
// this generator function can take a very very long time to run.
|
||||
|
||||
// Actually there is no reason to insist that 'generator' be a generator.
|
||||
// It's just as OK (and in some sense better) to use a generator of the
|
||||
// order-q subgroup.
|
||||
|
||||
BIGNUM *t1, *t2;
|
||||
int g, ok = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
goto err;
|
||||
}
|
||||
BN_CTX_start(ctx);
|
||||
t1 = BN_CTX_get(ctx);
|
||||
t2 = BN_CTX_get(ctx);
|
||||
if (t1 == NULL || t2 == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// Make sure |dh| has the necessary elements
|
||||
if (dh->p == NULL) {
|
||||
dh->p = BN_new();
|
||||
if (dh->p == NULL) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (dh->g == NULL) {
|
||||
dh->g = BN_new();
|
||||
if (dh->g == NULL) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (generator <= 1) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_BAD_GENERATOR);
|
||||
goto err;
|
||||
}
|
||||
if (generator == DH_GENERATOR_2) {
|
||||
if (!BN_set_word(t1, 24)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 11)) {
|
||||
goto err;
|
||||
}
|
||||
g = 2;
|
||||
} else if (generator == DH_GENERATOR_5) {
|
||||
if (!BN_set_word(t1, 10)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 3)) {
|
||||
goto err;
|
||||
}
|
||||
// BN_set_word(t3,7); just have to miss
|
||||
// out on these ones :-(
|
||||
g = 5;
|
||||
} else {
|
||||
// in the general case, don't worry if 'generator' is a
|
||||
// generator or not: since we are using safe primes,
|
||||
// it will generate either an order-q or an order-2q group,
|
||||
// which both is OK
|
||||
if (!BN_set_word(t1, 2)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(t2, 1)) {
|
||||
goto err;
|
||||
}
|
||||
g = generator;
|
||||
}
|
||||
|
||||
if (!BN_generate_prime_ex(dh->p, prime_bits, 1, t1, t2, cb)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_GENCB_call(cb, 3, 0)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_set_word(dh->g, g)) {
|
||||
goto err;
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
OPENSSL_PUT_ERROR(DH, ERR_R_BN_LIB);
|
||||
}
|
||||
|
||||
if (ctx != NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
int DH_generate_key(DH *dh) {
|
||||
int ok = 0;
|
||||
int generate_new_key = 0;
|
||||
@@ -390,56 +272,127 @@ err:
|
||||
return ok;
|
||||
}
|
||||
|
||||
int DH_compute_key(unsigned char *out, const BIGNUM *peers_key, DH *dh) {
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *shared_key;
|
||||
int ret = -1;
|
||||
int check_result;
|
||||
|
||||
static int dh_compute_key(DH *dh, BIGNUM *out_shared_key,
|
||||
const BIGNUM *peers_key, BN_CTX *ctx) {
|
||||
if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_MODULUS_TOO_LARGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
goto err;
|
||||
}
|
||||
BN_CTX_start(ctx);
|
||||
shared_key = BN_CTX_get(ctx);
|
||||
if (shared_key == NULL) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dh->priv_key == NULL) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_NO_PRIVATE_VALUE);
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!BN_MONT_CTX_set_locked(&dh->method_mont_p, &dh->method_mont_p_lock,
|
||||
int check_result;
|
||||
if (!DH_check_pub_key(dh, peers_key, &check_result) || check_result) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_INVALID_PUBKEY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
BN_CTX_start(ctx);
|
||||
BIGNUM *p_minus_1 = BN_CTX_get(ctx);
|
||||
|
||||
if (!p_minus_1 ||
|
||||
!BN_MONT_CTX_set_locked(&dh->method_mont_p, &dh->method_mont_p_lock,
|
||||
dh->p, ctx)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!DH_check_pub_key(dh, peers_key, &check_result) || check_result) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_INVALID_PUBKEY);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!BN_mod_exp_mont_consttime(shared_key, peers_key, dh->priv_key, dh->p,
|
||||
ctx, dh->method_mont_p)) {
|
||||
if (!BN_mod_exp_mont_consttime(out_shared_key, peers_key, dh->priv_key, dh->p,
|
||||
ctx, dh->method_mont_p) ||
|
||||
!BN_copy(p_minus_1, dh->p) ||
|
||||
!BN_sub_word(p_minus_1, 1)) {
|
||||
OPENSSL_PUT_ERROR(DH, ERR_R_BN_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = BN_bn2bin(shared_key, out);
|
||||
|
||||
err:
|
||||
if (ctx != NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
// This performs the check required by SP 800-56Ar3 section 5.7.1.1 step two.
|
||||
if (BN_cmp_word(out_shared_key, 1) <= 0 ||
|
||||
BN_cmp(out_shared_key, p_minus_1) == 0) {
|
||||
OPENSSL_PUT_ERROR(DH, DH_R_INVALID_PUBKEY);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DH_compute_key_padded(unsigned char *out, const BIGNUM *peers_key, DH *dh) {
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
int dh_size = DH_size(dh);
|
||||
int ret = -1;
|
||||
BIGNUM *shared_key = BN_CTX_get(ctx);
|
||||
if (shared_key &&
|
||||
dh_compute_key(dh, shared_key, peers_key, ctx) &&
|
||||
BN_bn2bin_padded(out, dh_size, shared_key)) {
|
||||
ret = dh_size;
|
||||
}
|
||||
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DH_compute_key(unsigned char *out, const BIGNUM *peers_key, DH *dh) {
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
int ret = -1;
|
||||
BIGNUM *shared_key = BN_CTX_get(ctx);
|
||||
if (shared_key && dh_compute_key(dh, shared_key, peers_key, ctx)) {
|
||||
ret = BN_bn2bin(shared_key, out);
|
||||
}
|
||||
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DH_compute_key_hashed(DH *dh, uint8_t *out, size_t *out_len,
|
||||
size_t max_out_len, const BIGNUM *peers_key,
|
||||
const EVP_MD *digest) {
|
||||
*out_len = (size_t)-1;
|
||||
|
||||
const size_t digest_len = EVP_MD_size(digest);
|
||||
if (digest_len > max_out_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
const size_t dh_len = DH_size(dh);
|
||||
uint8_t *shared_bytes = OPENSSL_malloc(dh_len);
|
||||
unsigned out_len_unsigned;
|
||||
if (!shared_bytes ||
|
||||
// SP 800-56A is ambiguous about whether the output should be padded prior
|
||||
// to revision three. But revision three, section C.1, awkwardly specifies
|
||||
// padding to the length of p.
|
||||
//
|
||||
// Also, padded output avoids side-channels, so is always strongly
|
||||
// advisable.
|
||||
DH_compute_key_padded(shared_bytes, peers_key, dh) != (int)dh_len ||
|
||||
!EVP_Digest(shared_bytes, dh_len, out, &out_len_unsigned, digest, NULL) ||
|
||||
out_len_unsigned != digest_len) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
*out_len = digest_len;
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
OPENSSL_free(shared_bytes);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -452,82 +405,52 @@ int DH_up_ref(DH *dh) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src) {
|
||||
BIGNUM *a = NULL;
|
||||
DH *DH_get_rfc7919_2048(void) {
|
||||
// This is the prime from https://tools.ietf.org/html/rfc7919#appendix-A.1,
|
||||
// which is specifically approved for FIPS in appendix D of SP 800-56Ar3.
|
||||
static const BN_ULONG kFFDHE2048Data[] = {
|
||||
TOBN(0xffffffff, 0xffffffff), TOBN(0x886b4238, 0x61285c97),
|
||||
TOBN(0xc6f34a26, 0xc1b2effa), TOBN(0xc58ef183, 0x7d1683b2),
|
||||
TOBN(0x3bb5fcbc, 0x2ec22005), TOBN(0xc3fe3b1b, 0x4c6fad73),
|
||||
TOBN(0x8e4f1232, 0xeef28183), TOBN(0x9172fe9c, 0xe98583ff),
|
||||
TOBN(0xc03404cd, 0x28342f61), TOBN(0x9e02fce1, 0xcdf7e2ec),
|
||||
TOBN(0x0b07a7c8, 0xee0a6d70), TOBN(0xae56ede7, 0x6372bb19),
|
||||
TOBN(0x1d4f42a3, 0xde394df4), TOBN(0xb96adab7, 0x60d7f468),
|
||||
TOBN(0xd108a94b, 0xb2c8e3fb), TOBN(0xbc0ab182, 0xb324fb61),
|
||||
TOBN(0x30acca4f, 0x483a797a), TOBN(0x1df158a1, 0x36ade735),
|
||||
TOBN(0xe2a689da, 0xf3efe872), TOBN(0x984f0c70, 0xe0e68b77),
|
||||
TOBN(0xb557135e, 0x7f57c935), TOBN(0x85636555, 0x3ded1af3),
|
||||
TOBN(0x2433f51f, 0x5f066ed0), TOBN(0xd3df1ed5, 0xd5fd6561),
|
||||
TOBN(0xf681b202, 0xaec4617a), TOBN(0x7d2fe363, 0x630c75d8),
|
||||
TOBN(0xcc939dce, 0x249b3ef9), TOBN(0xa9e13641, 0x146433fb),
|
||||
TOBN(0xd8b9c583, 0xce2d3695), TOBN(0xafdc5620, 0x273d3cf1),
|
||||
TOBN(0xadf85458, 0xa2bb4a9a), TOBN(0xffffffff, 0xffffffff),
|
||||
};
|
||||
|
||||
if (src) {
|
||||
a = BN_dup(src);
|
||||
if (!a) {
|
||||
return 0;
|
||||
}
|
||||
BIGNUM *const ffdhe2048_p = BN_new();
|
||||
BIGNUM *const ffdhe2048_q = BN_new();
|
||||
BIGNUM *const ffdhe2048_g = BN_new();
|
||||
DH *const dh = DH_new();
|
||||
|
||||
if (!ffdhe2048_p || !ffdhe2048_q || !ffdhe2048_g || !dh) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
BN_free(*dst);
|
||||
*dst = a;
|
||||
return 1;
|
||||
}
|
||||
bn_set_static_words(ffdhe2048_p, kFFDHE2048Data,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048Data));
|
||||
|
||||
static int int_dh_param_copy(DH *to, const DH *from, int is_x942) {
|
||||
if (is_x942 == -1) {
|
||||
is_x942 = !!from->q;
|
||||
}
|
||||
if (!int_dh_bn_cpy(&to->p, from->p) ||
|
||||
!int_dh_bn_cpy(&to->g, from->g)) {
|
||||
return 0;
|
||||
if (!BN_rshift1(ffdhe2048_q, ffdhe2048_p) ||
|
||||
!BN_set_word(ffdhe2048_g, 2) ||
|
||||
!DH_set0_pqg(dh, ffdhe2048_p, ffdhe2048_q, ffdhe2048_g)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!is_x942) {
|
||||
return 1;
|
||||
}
|
||||
return dh;
|
||||
|
||||
if (!int_dh_bn_cpy(&to->q, from->q) ||
|
||||
!int_dh_bn_cpy(&to->j, from->j)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
OPENSSL_free(to->seed);
|
||||
to->seed = NULL;
|
||||
to->seedlen = 0;
|
||||
|
||||
if (from->seed) {
|
||||
to->seed = OPENSSL_memdup(from->seed, from->seedlen);
|
||||
if (!to->seed) {
|
||||
return 0;
|
||||
}
|
||||
to->seedlen = from->seedlen;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
DH *DHparams_dup(const DH *dh) {
|
||||
DH *ret = DH_new();
|
||||
if (!ret) {
|
||||
err:
|
||||
BN_free(ffdhe2048_p);
|
||||
BN_free(ffdhe2048_q);
|
||||
BN_free(ffdhe2048_g);
|
||||
DH_free(dh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!int_dh_param_copy(ret, dh, -1)) {
|
||||
DH_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
|
||||
CRYPTO_EX_dup *dup_unused, CRYPTO_EX_free *free_func) {
|
||||
int index;
|
||||
if (!CRYPTO_get_ex_new_index(&g_ex_data_class, &index, argl, argp,
|
||||
free_func)) {
|
||||
return -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int DH_set_ex_data(DH *d, int idx, void *arg) {
|
||||
return CRYPTO_set_ex_data(&d->ex_data, idx, arg);
|
||||
}
|
||||
|
||||
void *DH_get_ex_data(DH *d, int idx) {
|
||||
return CRYPTO_get_ex_data(&d->ex_data, idx);
|
||||
}
|
||||
@@ -797,6 +797,12 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EC_POINT_get_affine_coordinates(const EC_GROUP *group,
|
||||
const EC_POINT *point, BIGNUM *x, BIGNUM *y,
|
||||
BN_CTX *ctx) {
|
||||
return EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx);
|
||||
}
|
||||
|
||||
void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out,
|
||||
const EC_AFFINE *p) {
|
||||
out->X = p->X;
|
||||
@@ -879,6 +885,12 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
|
||||
const BIGNUM *x, const BIGNUM *y,
|
||||
BN_CTX *ctx) {
|
||||
return EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx);
|
||||
}
|
||||
|
||||
int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
||||
const EC_POINT *b, BN_CTX *ctx) {
|
||||
if (EC_GROUP_cmp(group, r->group, NULL) != 0 ||
|
||||
@@ -1220,6 +1232,10 @@ void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out) {
|
||||
|
||||
void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) {}
|
||||
|
||||
int EC_GROUP_get_asn1_flag(const EC_GROUP *group) {
|
||||
return OPENSSL_EC_NAMED_CURVE;
|
||||
}
|
||||
|
||||
const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group) {
|
||||
// This function exists purely to give callers a way to call
|
||||
// |EC_METHOD_get_field_type|. cryptography.io crashes if |EC_GROUP_method_of|
|
||||
|
||||
@@ -171,7 +171,6 @@ void EC_KEY_free(EC_KEY *r) {
|
||||
EC_GROUP_free(r->group);
|
||||
EC_POINT_free(r->pub_key);
|
||||
ec_wrapped_scalar_free(r->priv_key);
|
||||
BN_free(r->fixed_k);
|
||||
|
||||
CRYPTO_free_ex_data(g_ec_ex_data_class_bss_get(), r, &r->ex_data);
|
||||
|
||||
@@ -440,7 +439,15 @@ int EC_KEY_generate_key(EC_KEY *key) {
|
||||
}
|
||||
|
||||
int EC_KEY_generate_key_fips(EC_KEY *eckey) {
|
||||
return EC_KEY_generate_key(eckey) && EC_KEY_check_fips(eckey);
|
||||
if (EC_KEY_generate_key(eckey) && EC_KEY_check_fips(eckey)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
EC_POINT_free(eckey->pub_key);
|
||||
ec_wrapped_scalar_free(eckey->priv_key);
|
||||
eckey->pub_key = NULL;
|
||||
eckey->priv_key = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EC_KEY_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
|
||||
|
||||
@@ -729,10 +729,6 @@ struct ec_key_st {
|
||||
EC_POINT *pub_key;
|
||||
EC_WRAPPED_SCALAR *priv_key;
|
||||
|
||||
// fixed_k may contain a specific value of 'k', to be used in ECDSA signing.
|
||||
// This is only for the FIPS power-on tests.
|
||||
BIGNUM *fixed_k;
|
||||
|
||||
unsigned int enc_flag;
|
||||
point_conversion_form_t conv_form;
|
||||
|
||||
|
||||
@@ -61,9 +61,10 @@
|
||||
#include <CCryptoBoringSSL_sha.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../bn/internal.h"
|
||||
#include "../ec/internal.h"
|
||||
#include "../../internal.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
// digest_to_scalar interprets |digest_len| bytes from |digest| as a scalar for
|
||||
@@ -198,68 +199,104 @@ int ECDSA_do_verify(const uint8_t *digest, size_t digest_len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ecdsa_sign_setup(const EC_KEY *eckey, EC_SCALAR *out_kinv_mont,
|
||||
EC_SCALAR *out_r, const uint8_t *digest,
|
||||
size_t digest_len, const EC_SCALAR *priv_key) {
|
||||
static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry,
|
||||
const EC_SCALAR *priv_key, const EC_SCALAR *k,
|
||||
const uint8_t *digest, size_t digest_len) {
|
||||
*out_retry = 0;
|
||||
|
||||
// Check that the size of the group order is FIPS compliant (FIPS 186-4
|
||||
// B.5.2).
|
||||
const EC_GROUP *group = EC_KEY_get0_group(eckey);
|
||||
const BIGNUM *order = EC_GROUP_get0_order(group);
|
||||
if (BN_num_bits(order) < 160) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, EC_R_INVALID_GROUP_ORDER);
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
EC_SCALAR k;
|
||||
// Compute r, the x-coordinate of k * generator.
|
||||
EC_RAW_POINT tmp_point;
|
||||
do {
|
||||
// Include the private key and message digest in the k generation.
|
||||
if (eckey->fixed_k != NULL) {
|
||||
if (!ec_bignum_to_scalar(group, &k, eckey->fixed_k)) {
|
||||
goto err;
|
||||
}
|
||||
if (ec_scalar_is_zero(group, &k)) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
// Pass a SHA512 hash of the private key and digest as additional data
|
||||
// into the RBG. This is a hardening measure against entropy failure.
|
||||
OPENSSL_STATIC_ASSERT(SHA512_DIGEST_LENGTH >= 32,
|
||||
"additional_data is too large for SHA-512");
|
||||
SHA512_CTX sha;
|
||||
uint8_t additional_data[SHA512_DIGEST_LENGTH];
|
||||
SHA512_Init(&sha);
|
||||
SHA512_Update(&sha, priv_key->words, order->width * sizeof(BN_ULONG));
|
||||
SHA512_Update(&sha, digest, digest_len);
|
||||
SHA512_Final(additional_data, &sha);
|
||||
if (!ec_random_nonzero_scalar(group, &k, additional_data)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
EC_SCALAR r;
|
||||
if (!ec_point_mul_scalar_base(group, &tmp_point, k) ||
|
||||
!ec_get_x_coordinate_as_scalar(group, &r, &tmp_point)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute k^-1 in the Montgomery domain. This is |ec_scalar_to_montgomery|
|
||||
// followed by |ec_scalar_inv0_montgomery|, but |ec_scalar_inv0_montgomery|
|
||||
// followed by |ec_scalar_from_montgomery| is equivalent and slightly more
|
||||
// efficient. Note k is non-zero, so the inverse must exist.
|
||||
ec_scalar_inv0_montgomery(group, out_kinv_mont, &k);
|
||||
ec_scalar_from_montgomery(group, out_kinv_mont, out_kinv_mont);
|
||||
if (ec_scalar_is_zero(group, &r)) {
|
||||
*out_retry = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute r, the x-coordinate of generator * k.
|
||||
if (!ec_point_mul_scalar_base(group, &tmp_point, &k) ||
|
||||
!ec_get_x_coordinate_as_scalar(group, out_r, &tmp_point)) {
|
||||
goto err;
|
||||
}
|
||||
} while (ec_scalar_is_zero(group, out_r));
|
||||
// s = priv_key * r. Note if only one parameter is in the Montgomery domain,
|
||||
// |ec_scalar_mod_mul_montgomery| will compute the answer in the normal
|
||||
// domain.
|
||||
EC_SCALAR s;
|
||||
ec_scalar_to_montgomery(group, &s, &r);
|
||||
ec_scalar_mul_montgomery(group, &s, priv_key, &s);
|
||||
|
||||
ret = 1;
|
||||
// s = m + priv_key * r.
|
||||
EC_SCALAR tmp;
|
||||
digest_to_scalar(group, &tmp, digest, digest_len);
|
||||
ec_scalar_add(group, &s, &s, &tmp);
|
||||
|
||||
err:
|
||||
OPENSSL_cleanse(&k, sizeof(k));
|
||||
// s = k^-1 * (m + priv_key * r). First, we compute k^-1 in the Montgomery
|
||||
// domain. This is |ec_scalar_to_montgomery| followed by
|
||||
// |ec_scalar_inv0_montgomery|, but |ec_scalar_inv0_montgomery| followed by
|
||||
// |ec_scalar_from_montgomery| is equivalent and slightly more efficient.
|
||||
// Then, as above, only one parameter is in the Montgomery domain, so the
|
||||
// result is in the normal domain. Finally, note k is non-zero (or computing r
|
||||
// would fail), so the inverse must exist.
|
||||
ec_scalar_inv0_montgomery(group, &tmp, k); // tmp = k^-1 R^2
|
||||
ec_scalar_from_montgomery(group, &tmp, &tmp); // tmp = k^-1 R
|
||||
ec_scalar_mul_montgomery(group, &s, &s, &tmp);
|
||||
if (ec_scalar_is_zero(group, &s)) {
|
||||
*out_retry = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ECDSA_SIG *ret = ECDSA_SIG_new();
|
||||
if (ret == NULL || //
|
||||
!bn_set_words(ret->r, r.words, order->width) ||
|
||||
!bn_set_words(ret->s, s.words, order->width)) {
|
||||
ECDSA_SIG_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ECDSA_SIG *ecdsa_sign_with_nonce_for_known_answer_test(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len) {
|
||||
if (eckey->ecdsa_meth && eckey->ecdsa_meth->sign) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ECDSA_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const EC_GROUP *group = EC_KEY_get0_group(eckey);
|
||||
if (group == NULL || eckey->priv_key == NULL) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
const EC_SCALAR *priv_key = &eckey->priv_key->scalar;
|
||||
|
||||
EC_SCALAR k;
|
||||
if (!ec_scalar_from_bytes(group, &k, nonce, nonce_len)) {
|
||||
return NULL;
|
||||
}
|
||||
int retry_ignored;
|
||||
return ecdsa_sign_impl(group, &retry_ignored, priv_key, &k, digest,
|
||||
digest_len);
|
||||
}
|
||||
|
||||
// This function is only exported for testing and is not called in production
|
||||
// code.
|
||||
ECDSA_SIG *ECDSA_sign_with_nonce_and_leak_private_key_for_testing(
|
||||
const uint8_t *digest, size_t digest_len, const EC_KEY *eckey,
|
||||
const uint8_t *nonce, size_t nonce_len) {
|
||||
return ecdsa_sign_with_nonce_for_known_answer_test(digest, digest_len, eckey,
|
||||
nonce, nonce_len);
|
||||
}
|
||||
|
||||
ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len,
|
||||
const EC_KEY *eckey) {
|
||||
if (eckey->ecdsa_meth && eckey->ecdsa_meth->sign) {
|
||||
@@ -275,54 +312,28 @@ ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len,
|
||||
const BIGNUM *order = EC_GROUP_get0_order(group);
|
||||
const EC_SCALAR *priv_key = &eckey->priv_key->scalar;
|
||||
|
||||
int ok = 0;
|
||||
ECDSA_SIG *ret = ECDSA_SIG_new();
|
||||
EC_SCALAR kinv_mont, r_mont, s, m, tmp;
|
||||
if (ret == NULL) {
|
||||
OPENSSL_PUT_ERROR(ECDSA, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
// Pass a SHA512 hash of the private key and digest as additional data
|
||||
// into the RBG. This is a hardening measure against entropy failure.
|
||||
OPENSSL_STATIC_ASSERT(SHA512_DIGEST_LENGTH >= 32,
|
||||
"additional_data is too large for SHA-512");
|
||||
SHA512_CTX sha;
|
||||
uint8_t additional_data[SHA512_DIGEST_LENGTH];
|
||||
SHA512_Init(&sha);
|
||||
SHA512_Update(&sha, priv_key->words, order->width * sizeof(BN_ULONG));
|
||||
SHA512_Update(&sha, digest, digest_len);
|
||||
SHA512_Final(additional_data, &sha);
|
||||
|
||||
digest_to_scalar(group, &m, digest, digest_len);
|
||||
for (;;) {
|
||||
if (!ecdsa_sign_setup(eckey, &kinv_mont, &r_mont, digest, digest_len,
|
||||
priv_key) ||
|
||||
!bn_set_words(ret->r, r_mont.words, order->width)) {
|
||||
goto err;
|
||||
EC_SCALAR k;
|
||||
if (!ec_random_nonzero_scalar(group, &k, additional_data)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Compute priv_key * r (mod order). Note if only one parameter is in the
|
||||
// Montgomery domain, |ec_scalar_mod_mul_montgomery| will compute the answer
|
||||
// in the normal domain.
|
||||
ec_scalar_to_montgomery(group, &r_mont, &r_mont);
|
||||
ec_scalar_mul_montgomery(group, &s, priv_key, &r_mont);
|
||||
|
||||
// Compute tmp = m + priv_key * r.
|
||||
ec_scalar_add(group, &tmp, &m, &s);
|
||||
|
||||
// Finally, multiply s by k^-1. That was retained in Montgomery form, so the
|
||||
// same technique as the previous multiplication works.
|
||||
ec_scalar_mul_montgomery(group, &s, &tmp, &kinv_mont);
|
||||
if (!bn_set_words(ret->s, s.words, order->width)) {
|
||||
goto err;
|
||||
}
|
||||
if (!BN_is_zero(ret->s)) {
|
||||
// s != 0 => we have a valid signature
|
||||
break;
|
||||
int retry;
|
||||
ECDSA_SIG *sig =
|
||||
ecdsa_sign_impl(group, &retry, priv_key, &k, digest, digest_len);
|
||||
if (sig != NULL || !retry) {
|
||||
return sig;
|
||||
}
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
if (!ok) {
|
||||
ECDSA_SIG_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
OPENSSL_cleanse(&kinv_mont, sizeof(kinv_mont));
|
||||
OPENSSL_cleanse(&r_mont, sizeof(r_mont));
|
||||
OPENSSL_cleanse(&s, sizeof(s));
|
||||
OPENSSL_cleanse(&tmp, sizeof(tmp));
|
||||
OPENSSL_cleanse(&m, sizeof(m));
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
#define OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// ecdsa_sign_with_nonce_for_known_answer_test behaves like |ECDSA_do_sign| but
|
||||
// takes a fixed nonce. This function is used as part of known-answer tests in
|
||||
// the FIPS module.
|
||||
ECDSA_SIG *ecdsa_sign_with_nonce_for_known_answer_test(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_CRYPTO_FIPSMODULE_ECDSA_INTERNAL_H
|
||||
@@ -36,6 +36,34 @@ extern "C" {
|
||||
void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
const uint8_t user_additional_data[32]);
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
|
||||
// We overread from /dev/urandom or RDRAND by a factor of 10 and XOR to whiten.
|
||||
#define BORINGSSL_FIPS_OVERREAD 10
|
||||
|
||||
// CRYPTO_get_seed_entropy writes |out_entropy_len| bytes of entropy, suitable
|
||||
// for seeding a DRBG, to |out_entropy|. It sets |*out_used_cpu| to one if the
|
||||
// entropy came directly from the CPU and zero if it came from the OS. It
|
||||
// actively obtains entropy from the CPU/OS and so should not be called from
|
||||
// within the FIPS module if |BORINGSSL_FIPS_PASSIVE_ENTROPY| is defined.
|
||||
void CRYPTO_get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
||||
int *out_used_cpu);
|
||||
|
||||
#if defined(BORINGSSL_FIPS_PASSIVE_ENTROPY)
|
||||
|
||||
// RAND_load_entropy supplies |entropy_len| bytes of entropy to the module. The
|
||||
// |from_cpu| parameter is true iff the entropy was obtained directly from the
|
||||
// CPU.
|
||||
void RAND_load_entropy(const uint8_t *entropy, size_t entropy_len,
|
||||
int from_cpu);
|
||||
|
||||
// RAND_need_entropy is implemented outside of the FIPS module and is called
|
||||
// when the module has stopped because it has run out of entropy.
|
||||
void RAND_need_entropy(size_t bytes_needed);
|
||||
|
||||
#endif // BORINGSSL_FIPS_PASSIVE_ENTROPY
|
||||
#endif // BORINGSSL_FIPS
|
||||
|
||||
// CRYPTO_sysrand fills |len| bytes at |buf| with entropy from the operating
|
||||
// system.
|
||||
void CRYPTO_sysrand(uint8_t *buf, size_t len);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <CCryptoBoringSSL_chacha.h>
|
||||
#include <CCryptoBoringSSL_cpu.h>
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
#include <CCryptoBoringSSL_type_check.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "fork_detect.h"
|
||||
@@ -63,11 +64,11 @@ struct rand_thread_state {
|
||||
// (re)seeded. This is bound by |kReseedInterval|.
|
||||
unsigned calls;
|
||||
// last_block_valid is non-zero iff |last_block| contains data from
|
||||
// |CRYPTO_sysrand_for_seed|.
|
||||
// |get_seed_entropy|.
|
||||
int last_block_valid;
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
// last_block contains the previous block from |CRYPTO_sysrand_for_seed|.
|
||||
// last_block contains the previous block from |get_seed_entropy|.
|
||||
uint8_t last_block[CRNGT_BLOCK_SIZE];
|
||||
// next and prev form a NULL-terminated, double-linked list of all states in
|
||||
// a process.
|
||||
@@ -82,16 +83,18 @@ struct rand_thread_state {
|
||||
// called when the whole process is exiting.
|
||||
DEFINE_BSS_GET(struct rand_thread_state *, thread_states_list);
|
||||
DEFINE_STATIC_MUTEX(thread_states_list_lock);
|
||||
DEFINE_STATIC_MUTEX(state_clear_all_lock);
|
||||
|
||||
static void rand_thread_state_clear_all(void) __attribute__((destructor));
|
||||
static void rand_thread_state_clear_all(void) {
|
||||
CRYPTO_STATIC_MUTEX_lock_write(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_write(state_clear_all_lock_bss_get());
|
||||
for (struct rand_thread_state *cur = *thread_states_list_bss_get();
|
||||
cur != NULL; cur = cur->next) {
|
||||
CTR_DRBG_clear(&cur->drbg);
|
||||
}
|
||||
// |thread_states_list_lock is deliberately left locked so that any threads
|
||||
// that are still running will hang if they try to call |RAND_bytes|.
|
||||
// The locks are deliberately left locked so that any threads that are still
|
||||
// running will hang if they try to call |RAND_bytes|.
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,12 +149,6 @@ static int rdrand(uint8_t *buf, const size_t len) {
|
||||
OPENSSL_memcpy(buf + len_multiple8, rand_buf, remainder);
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS_BREAK_CRNG)
|
||||
// This breaks the "continuous random number generator test" defined in FIPS
|
||||
// 140-2, section 4.9.2, and implemented in rand_get_seed().
|
||||
OPENSSL_memset(buf, 0, len);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -165,25 +162,110 @@ static int rdrand(uint8_t *buf, size_t len) {
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
|
||||
void CRYPTO_get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
||||
int *out_used_cpu) {
|
||||
*out_used_cpu = 0;
|
||||
if (have_rdrand() && rdrand(out_entropy, out_entropy_len)) {
|
||||
*out_used_cpu = 1;
|
||||
} else {
|
||||
CRYPTO_sysrand_for_seed(out_entropy, out_entropy_len);
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS_BREAK_CRNG)
|
||||
// This breaks the "continuous random number generator test" defined in FIPS
|
||||
// 140-2, section 4.9.2, and implemented in |rand_get_seed|.
|
||||
OPENSSL_memset(out_entropy, 0, out_entropy_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS_PASSIVE_ENTROPY)
|
||||
|
||||
// In passive entropy mode, entropy is supplied from outside of the module via
|
||||
// |RAND_load_entropy| and is stored in global instance of the following
|
||||
// structure.
|
||||
|
||||
struct entropy_buffer {
|
||||
// bytes contains entropy suitable for seeding a DRBG.
|
||||
uint8_t bytes[CTR_DRBG_ENTROPY_LEN * BORINGSSL_FIPS_OVERREAD];
|
||||
// bytes_valid indicates the number of bytes of |bytes| that contain valid
|
||||
// data.
|
||||
size_t bytes_valid;
|
||||
// from_cpu is true if any of the contents of |bytes| were obtained directly
|
||||
// from the CPU.
|
||||
int from_cpu;
|
||||
};
|
||||
|
||||
DEFINE_BSS_GET(struct entropy_buffer, entropy_buffer);
|
||||
DEFINE_STATIC_MUTEX(entropy_buffer_lock);
|
||||
|
||||
void RAND_load_entropy(const uint8_t *entropy, size_t entropy_len,
|
||||
int from_cpu) {
|
||||
struct entropy_buffer *const buffer = entropy_buffer_bss_get();
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get());
|
||||
const size_t space = sizeof(buffer->bytes) - buffer->bytes_valid;
|
||||
if (entropy_len > space) {
|
||||
entropy_len = space;
|
||||
}
|
||||
|
||||
OPENSSL_memcpy(&buffer->bytes[buffer->bytes_valid], entropy, entropy_len);
|
||||
buffer->bytes_valid += entropy_len;
|
||||
buffer->from_cpu |= from_cpu && (entropy_len != 0);
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get());
|
||||
}
|
||||
|
||||
// get_seed_entropy fills |out_entropy_len| bytes of |out_entropy| from the
|
||||
// global |entropy_buffer|.
|
||||
static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
||||
int *out_used_cpu) {
|
||||
struct entropy_buffer *const buffer = entropy_buffer_bss_get();
|
||||
if (out_entropy_len > sizeof(buffer->bytes)) {
|
||||
abort();
|
||||
}
|
||||
|
||||
CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get());
|
||||
while (buffer->bytes_valid < out_entropy_len) {
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get());
|
||||
RAND_need_entropy(out_entropy_len - buffer->bytes_valid);
|
||||
CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get());
|
||||
}
|
||||
|
||||
*out_used_cpu = buffer->from_cpu;
|
||||
OPENSSL_memcpy(out_entropy, buffer->bytes, out_entropy_len);
|
||||
OPENSSL_memmove(buffer->bytes, &buffer->bytes[out_entropy_len],
|
||||
buffer->bytes_valid - out_entropy_len);
|
||||
buffer->bytes_valid -= out_entropy_len;
|
||||
if (buffer->bytes_valid == 0) {
|
||||
buffer->from_cpu = 0;
|
||||
}
|
||||
|
||||
CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// In the active case, |get_seed_entropy| simply calls |CRYPTO_get_seed_entropy|
|
||||
// in order to obtain entropy from the CPU or OS.
|
||||
static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len,
|
||||
int *out_used_cpu) {
|
||||
CRYPTO_get_seed_entropy(out_entropy, out_entropy_len, out_used_cpu);
|
||||
}
|
||||
|
||||
#endif // !BORINGSSL_FIPS_PASSIVE_ENTROPY
|
||||
|
||||
// rand_get_seed fills |seed| with entropy and sets |*out_used_cpu| to one if
|
||||
// that entropy came directly from the CPU and zero otherwise.
|
||||
static void rand_get_seed(struct rand_thread_state *state,
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN]) {
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN],
|
||||
int *out_used_cpu) {
|
||||
if (!state->last_block_valid) {
|
||||
if (!have_rdrand() ||
|
||||
!rdrand(state->last_block, sizeof(state->last_block))) {
|
||||
CRYPTO_sysrand_for_seed(state->last_block, sizeof(state->last_block));
|
||||
}
|
||||
int unused;
|
||||
get_seed_entropy(state->last_block, sizeof(state->last_block), &unused);
|
||||
state->last_block_valid = 1;
|
||||
}
|
||||
|
||||
// We overread from /dev/urandom or RDRAND by a factor of 10 and XOR to
|
||||
// whiten.
|
||||
#define FIPS_OVERREAD 10
|
||||
uint8_t entropy[CTR_DRBG_ENTROPY_LEN * FIPS_OVERREAD];
|
||||
|
||||
int used_rdrand = have_rdrand() && rdrand(entropy, sizeof(entropy));
|
||||
if (!used_rdrand) {
|
||||
CRYPTO_sysrand_for_seed(entropy, sizeof(entropy));
|
||||
}
|
||||
uint8_t entropy[CTR_DRBG_ENTROPY_LEN * BORINGSSL_FIPS_OVERREAD];
|
||||
get_seed_entropy(entropy, sizeof(entropy), out_used_cpu);
|
||||
|
||||
// See FIPS 140-2, section 4.9.2. This is the “continuous random number
|
||||
// generator test” which causes the program to randomly abort. Hopefully the
|
||||
@@ -193,6 +275,7 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
BORINGSSL_FIPS_abort();
|
||||
}
|
||||
|
||||
OPENSSL_STATIC_ASSERT(sizeof(entropy) % CRNGT_BLOCK_SIZE == 0, "");
|
||||
for (size_t i = CRNGT_BLOCK_SIZE; i < sizeof(entropy);
|
||||
i += CRNGT_BLOCK_SIZE) {
|
||||
if (CRYPTO_memcmp(entropy + i - CRNGT_BLOCK_SIZE, entropy + i,
|
||||
@@ -207,31 +290,24 @@ static void rand_get_seed(struct rand_thread_state *state,
|
||||
|
||||
OPENSSL_memcpy(seed, entropy, CTR_DRBG_ENTROPY_LEN);
|
||||
|
||||
for (size_t i = 1; i < FIPS_OVERREAD; i++) {
|
||||
for (size_t i = 1; i < BORINGSSL_FIPS_OVERREAD; i++) {
|
||||
for (size_t j = 0; j < CTR_DRBG_ENTROPY_LEN; j++) {
|
||||
seed[j] ^= entropy[CTR_DRBG_ENTROPY_LEN * i + j];
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
// If we used RDRAND, also opportunistically read from the system. This avoids
|
||||
// solely relying on the hardware once the entropy pool has been initialized.
|
||||
if (used_rdrand) {
|
||||
CRYPTO_sysrand_if_available(entropy, CTR_DRBG_ENTROPY_LEN);
|
||||
for (size_t i = 0; i < CTR_DRBG_ENTROPY_LEN; i++) {
|
||||
seed[i] ^= entropy[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// rand_get_seed fills |seed| with entropy and sets |*out_used_cpu| to one if
|
||||
// that entropy came directly from the CPU and zero otherwise.
|
||||
static void rand_get_seed(struct rand_thread_state *state,
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN]) {
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN],
|
||||
int *out_used_cpu) {
|
||||
// If not in FIPS mode, we don't overread from the system entropy source and
|
||||
// we don't depend only on the hardware RDRAND.
|
||||
CRYPTO_sysrand(seed, CTR_DRBG_ENTROPY_LEN);
|
||||
*out_used_cpu = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -290,8 +366,23 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
|
||||
state->last_block_valid = 0;
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN];
|
||||
rand_get_seed(state, seed);
|
||||
if (!CTR_DRBG_init(&state->drbg, seed, NULL, 0)) {
|
||||
int used_cpu;
|
||||
rand_get_seed(state, seed, &used_cpu);
|
||||
|
||||
uint8_t personalization[CTR_DRBG_ENTROPY_LEN];
|
||||
size_t personalization_len = 0;
|
||||
#if defined(OPENSSL_URANDOM)
|
||||
// If we used RDRAND, also opportunistically read from the system. This
|
||||
// avoids solely relying on the hardware once the entropy pool has been
|
||||
// initialized.
|
||||
if (used_cpu &&
|
||||
CRYPTO_sysrand_if_available(personalization, sizeof(personalization))) {
|
||||
personalization_len = sizeof(personalization);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!CTR_DRBG_init(&state->drbg, seed, personalization,
|
||||
personalization_len)) {
|
||||
abort();
|
||||
}
|
||||
state->calls = 0;
|
||||
@@ -315,7 +406,8 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
if (state->calls >= kReseedInterval ||
|
||||
state->fork_generation != fork_generation) {
|
||||
uint8_t seed[CTR_DRBG_ENTROPY_LEN];
|
||||
rand_get_seed(state, seed);
|
||||
int used_cpu;
|
||||
rand_get_seed(state, seed, &used_cpu);
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
// Take a read lock around accesses to |state->drbg|. This is needed to
|
||||
// avoid returning bad entropy if we race with
|
||||
@@ -325,7 +417,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
// bug on ppc64le. glibc may implement pthread locks by wrapping user code
|
||||
// in a hardware transaction, but, on some older versions of glibc and the
|
||||
// kernel, syscalls made with |syscall| did not abort the transaction.
|
||||
CRYPTO_STATIC_MUTEX_lock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
if (!CTR_DRBG_reseed(&state->drbg, seed, NULL, 0)) {
|
||||
abort();
|
||||
@@ -334,7 +426,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
state->fork_generation = fork_generation;
|
||||
} else {
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
CRYPTO_STATIC_MUTEX_lock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -363,7 +455,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(thread_states_list_lock_bss_get());
|
||||
CRYPTO_STATIC_MUTEX_unlock_read(state_clear_all_lock_bss_get());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -366,14 +366,7 @@ void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
||||
perror("entropy fill failed");
|
||||
abort();
|
||||
}
|
||||
|
||||
#if defined(BORINGSSL_FIPS_BREAK_CRNG)
|
||||
// This breaks the "continuous random number generator test" defined in FIPS
|
||||
// 140-2, section 4.9.2, and implemented in rand_get_seed().
|
||||
OPENSSL_memset(out, 0, requested);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // BORINGSSL_FIPS
|
||||
|
||||
int CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
||||
|
||||
@@ -1316,52 +1316,72 @@ static void replace_bn_mont_ctx(BN_MONT_CTX **out, BN_MONT_CTX **in) {
|
||||
*in = NULL;
|
||||
}
|
||||
|
||||
int RSA_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e_value,
|
||||
BN_GENCB *cb) {
|
||||
static int RSA_generate_key_ex_maybe_fips(RSA *rsa, int bits,
|
||||
const BIGNUM *e_value, BN_GENCB *cb,
|
||||
int check_fips) {
|
||||
RSA *tmp = NULL;
|
||||
uint32_t err;
|
||||
int ret = 0;
|
||||
|
||||
// |rsa_generate_key_impl|'s 2^-20 failure probability is too high at scale,
|
||||
// so we run the FIPS algorithm four times, bringing it down to 2^-80. We
|
||||
// should just adjust the retry limit, but FIPS 186-4 prescribes that value
|
||||
// and thus results in unnecessary complexity.
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int failures = 0;
|
||||
do {
|
||||
ERR_clear_error();
|
||||
// Generate into scratch space, to avoid leaving partial work on failure.
|
||||
RSA *tmp = RSA_new();
|
||||
tmp = RSA_new();
|
||||
if (tmp == NULL) {
|
||||
return 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (rsa_generate_key_impl(tmp, bits, e_value, cb)) {
|
||||
replace_bignum(&rsa->n, &tmp->n);
|
||||
replace_bignum(&rsa->e, &tmp->e);
|
||||
replace_bignum(&rsa->d, &tmp->d);
|
||||
replace_bignum(&rsa->p, &tmp->p);
|
||||
replace_bignum(&rsa->q, &tmp->q);
|
||||
replace_bignum(&rsa->dmp1, &tmp->dmp1);
|
||||
replace_bignum(&rsa->dmq1, &tmp->dmq1);
|
||||
replace_bignum(&rsa->iqmp, &tmp->iqmp);
|
||||
replace_bn_mont_ctx(&rsa->mont_n, &tmp->mont_n);
|
||||
replace_bn_mont_ctx(&rsa->mont_p, &tmp->mont_p);
|
||||
replace_bn_mont_ctx(&rsa->mont_q, &tmp->mont_q);
|
||||
replace_bignum(&rsa->d_fixed, &tmp->d_fixed);
|
||||
replace_bignum(&rsa->dmp1_fixed, &tmp->dmp1_fixed);
|
||||
replace_bignum(&rsa->dmq1_fixed, &tmp->dmq1_fixed);
|
||||
replace_bignum(&rsa->inv_small_mod_large_mont,
|
||||
&tmp->inv_small_mod_large_mont);
|
||||
rsa->private_key_frozen = tmp->private_key_frozen;
|
||||
RSA_free(tmp);
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
uint32_t err = ERR_peek_error();
|
||||
|
||||
err = ERR_peek_error();
|
||||
RSA_free(tmp);
|
||||
tmp = NULL;
|
||||
failures++;
|
||||
|
||||
// Only retry on |RSA_R_TOO_MANY_ITERATIONS|. This is so a caller-induced
|
||||
// failure in |BN_GENCB_call| is still fatal.
|
||||
if (ERR_GET_LIB(err) != ERR_LIB_RSA ||
|
||||
ERR_GET_REASON(err) != RSA_R_TOO_MANY_ITERATIONS) {
|
||||
return 0;
|
||||
}
|
||||
} while (failures < 4 && ERR_GET_LIB(err) == ERR_LIB_RSA &&
|
||||
ERR_GET_REASON(err) == RSA_R_TOO_MANY_ITERATIONS);
|
||||
|
||||
if (tmp == NULL || (check_fips && !RSA_check_fips(tmp))) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
replace_bignum(&rsa->n, &tmp->n);
|
||||
replace_bignum(&rsa->e, &tmp->e);
|
||||
replace_bignum(&rsa->d, &tmp->d);
|
||||
replace_bignum(&rsa->p, &tmp->p);
|
||||
replace_bignum(&rsa->q, &tmp->q);
|
||||
replace_bignum(&rsa->dmp1, &tmp->dmp1);
|
||||
replace_bignum(&rsa->dmq1, &tmp->dmq1);
|
||||
replace_bignum(&rsa->iqmp, &tmp->iqmp);
|
||||
replace_bn_mont_ctx(&rsa->mont_n, &tmp->mont_n);
|
||||
replace_bn_mont_ctx(&rsa->mont_p, &tmp->mont_p);
|
||||
replace_bn_mont_ctx(&rsa->mont_q, &tmp->mont_q);
|
||||
replace_bignum(&rsa->d_fixed, &tmp->d_fixed);
|
||||
replace_bignum(&rsa->dmp1_fixed, &tmp->dmp1_fixed);
|
||||
replace_bignum(&rsa->dmq1_fixed, &tmp->dmq1_fixed);
|
||||
replace_bignum(&rsa->inv_small_mod_large_mont,
|
||||
&tmp->inv_small_mod_large_mont);
|
||||
rsa->private_key_frozen = tmp->private_key_frozen;
|
||||
ret = 1;
|
||||
|
||||
out:
|
||||
RSA_free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int RSA_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e_value,
|
||||
BN_GENCB *cb) {
|
||||
return RSA_generate_key_ex_maybe_fips(rsa, bits, e_value, cb,
|
||||
/*check_fips=*/0);
|
||||
}
|
||||
|
||||
int RSA_generate_key_fips(RSA *rsa, int bits, BN_GENCB *cb) {
|
||||
@@ -1377,8 +1397,7 @@ int RSA_generate_key_fips(RSA *rsa, int bits, BN_GENCB *cb) {
|
||||
BIGNUM *e = BN_new();
|
||||
int ret = e != NULL &&
|
||||
BN_set_word(e, RSA_F4) &&
|
||||
RSA_generate_key_ex(rsa, bits, e, cb) &&
|
||||
RSA_check_fips(rsa);
|
||||
RSA_generate_key_ex_maybe_fips(rsa, bits, e, cb, /*check_fips=*/1);
|
||||
BN_free(e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <CCryptoBoringSSL_aes.h>
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_des.h>
|
||||
#include <CCryptoBoringSSL_dh.h>
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
#include <CCryptoBoringSSL_ec.h>
|
||||
#include <CCryptoBoringSSL_ecdsa.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
|
||||
#include "../../internal.h"
|
||||
#include "../ec/internal.h"
|
||||
#include "../ecdsa/internal.h"
|
||||
#include "../rand/internal.h"
|
||||
#include "../tls/internal.h"
|
||||
|
||||
@@ -246,6 +248,41 @@ static EC_KEY *self_test_ecdsa_key(void) {
|
||||
return ec_key;
|
||||
}
|
||||
|
||||
static DH *self_test_dh(void) {
|
||||
DH *dh = DH_get_rfc7919_2048();
|
||||
if (!dh) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BIGNUM *priv = BN_new();
|
||||
if (!priv) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
// kFFDHE2048PrivateKeyData is a 225-bit value. (225 because that's the
|
||||
// minimum private key size in
|
||||
// https://tools.ietf.org/html/rfc7919#appendix-A.1.)
|
||||
static const BN_ULONG kFFDHE2048PrivateKeyData[] = {
|
||||
TOBN(0x187be36b, 0xd38a4fa1),
|
||||
TOBN(0x0a152f39, 0x6458f3b8),
|
||||
TOBN(0x0570187e, 0xc422eeb7),
|
||||
TOBN(0x00000001, 0x91173f2a),
|
||||
};
|
||||
|
||||
bn_set_static_words(priv, kFFDHE2048PrivateKeyData,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048PrivateKeyData));
|
||||
|
||||
if (!DH_set0_key(dh, NULL, priv)) {
|
||||
goto err;
|
||||
}
|
||||
return dh;
|
||||
|
||||
err:
|
||||
BN_free(priv);
|
||||
DH_free(dh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_ANDROID)
|
||||
static const size_t kModuleDigestSize = SHA256_DIGEST_LENGTH;
|
||||
#else
|
||||
@@ -487,6 +524,57 @@ int boringssl_fips_self_test(
|
||||
0x31, 0x1e, 0x2b, 0x21, 0x41, 0x8d, 0x32, 0x81,
|
||||
};
|
||||
|
||||
// kFFDHE2048PublicValueData is an arbitrary public value, mod
|
||||
// kFFDHE2048Data. (The private key happens to be 4096.)
|
||||
static const BN_ULONG kFFDHE2048PublicValueData[] = {
|
||||
TOBN(0x187be36b, 0xd38a4fa1), TOBN(0x0a152f39, 0x6458f3b8),
|
||||
TOBN(0x0570187e, 0xc422eeb7), TOBN(0x18af7482, 0x91173f2a),
|
||||
TOBN(0xe9fdac6a, 0xcff4eaaa), TOBN(0xf6afebb7, 0x6e589d6c),
|
||||
TOBN(0xf92f8e9a, 0xb7e33fb0), TOBN(0x70acf2aa, 0x4cf36ddd),
|
||||
TOBN(0x561ab426, 0xd07137fd), TOBN(0x5f57d037, 0x430ee91e),
|
||||
TOBN(0xe3e768c8, 0x60d10b8a), TOBN(0xb14884d8, 0xa18af8ce),
|
||||
TOBN(0xf8a98014, 0xa12b74e4), TOBN(0x748d407c, 0x3437b7a8),
|
||||
TOBN(0x627588c4, 0x9875d5a7), TOBN(0xdd24a127, 0x53c8f09d),
|
||||
TOBN(0x85a997d5, 0x0cd51aec), TOBN(0x44f0c619, 0xce348458),
|
||||
TOBN(0x9b894b24, 0x5f6b69a1), TOBN(0xae1302f2, 0xf6d4777e),
|
||||
TOBN(0xe6678eeb, 0x375db18e), TOBN(0x2674e1d6, 0x4fbcbdc8),
|
||||
TOBN(0xb297a823, 0x6fa93d28), TOBN(0x6a12fb70, 0x7c8c0510),
|
||||
TOBN(0x5c6d1aeb, 0xdb06f65b), TOBN(0xe8c2954e, 0x4c1804ca),
|
||||
TOBN(0x06bdeac1, 0xf5500fa7), TOBN(0x6a315604, 0x189cd76b),
|
||||
TOBN(0xbae7b0b3, 0x6e362dc0), TOBN(0xa57c73bd, 0xdc70fb82),
|
||||
TOBN(0xfaff50d2, 0x9d573457), TOBN(0x352bd399, 0xbe84058e),
|
||||
};
|
||||
|
||||
const uint8_t kDHOutput[2048 / 8] = {
|
||||
0x2a, 0xe6, 0xd3, 0xa6, 0x13, 0x58, 0x8e, 0xce, 0x53, 0xaa, 0xf6, 0x5d,
|
||||
0x9a, 0xae, 0x02, 0x12, 0xf5, 0x80, 0x3d, 0x06, 0x09, 0x76, 0xac, 0x57,
|
||||
0x37, 0x9e, 0xab, 0x38, 0x62, 0x25, 0x05, 0x1d, 0xf3, 0xa9, 0x39, 0x60,
|
||||
0xf6, 0xae, 0x90, 0xed, 0x1e, 0xad, 0x6e, 0xe9, 0xe3, 0xba, 0x27, 0xf6,
|
||||
0xdb, 0x54, 0xdf, 0xe2, 0xbd, 0xbb, 0x7f, 0xf1, 0x81, 0xac, 0x1a, 0xfa,
|
||||
0xdb, 0x87, 0x07, 0x98, 0x76, 0x90, 0x21, 0xf2, 0xae, 0xda, 0x0d, 0x84,
|
||||
0x97, 0x64, 0x0b, 0xbf, 0xb8, 0x8d, 0x10, 0x46, 0xe2, 0xd5, 0xca, 0x1b,
|
||||
0xbb, 0xe5, 0x37, 0xb2, 0x3b, 0x35, 0xd3, 0x1b, 0x65, 0xea, 0xae, 0xf2,
|
||||
0x03, 0xe2, 0xb6, 0xde, 0x22, 0xb7, 0x86, 0x49, 0x79, 0xfe, 0xd7, 0x16,
|
||||
0xf7, 0xdc, 0x9c, 0x59, 0xf5, 0xb7, 0x70, 0xc0, 0x53, 0x42, 0x6f, 0xb1,
|
||||
0xd2, 0x4e, 0x00, 0x25, 0x4b, 0x2d, 0x5a, 0x9b, 0xd0, 0xe9, 0x27, 0x43,
|
||||
0xcc, 0x00, 0x66, 0xea, 0x94, 0x7a, 0x0b, 0xb9, 0x89, 0x0c, 0x5e, 0x94,
|
||||
0xb8, 0x3a, 0x78, 0x9c, 0x4d, 0x84, 0xe6, 0x32, 0x2c, 0x38, 0x7c, 0xf7,
|
||||
0x43, 0x9c, 0xd8, 0xb8, 0x1c, 0xce, 0x24, 0x91, 0x20, 0x67, 0x7a, 0x54,
|
||||
0x1f, 0x7e, 0x86, 0x7f, 0xa1, 0xc1, 0x03, 0x4e, 0x2c, 0x26, 0x71, 0xb2,
|
||||
0x06, 0x30, 0xb3, 0x6c, 0x15, 0xcc, 0xac, 0x25, 0xe5, 0x37, 0x3f, 0x24,
|
||||
0x8f, 0x2a, 0x89, 0x5e, 0x3d, 0x43, 0x94, 0xc9, 0x36, 0xae, 0x40, 0x00,
|
||||
0x6a, 0x0d, 0xb0, 0x6e, 0x8b, 0x2e, 0x70, 0x57, 0xe1, 0x88, 0x53, 0xd6,
|
||||
0x06, 0x80, 0x2a, 0x4e, 0x5a, 0xf0, 0x1e, 0xaa, 0xcb, 0xab, 0x06, 0x0e,
|
||||
0x27, 0x0f, 0xd9, 0x88, 0xd9, 0x01, 0xe3, 0x07, 0xeb, 0xdf, 0xc3, 0x12,
|
||||
0xe3, 0x40, 0x88, 0x7b, 0x5f, 0x59, 0x78, 0x6e, 0x26, 0x20, 0xc3, 0xdf,
|
||||
0xc8, 0xe4, 0x5e,
|
||||
#if !defined(BORINGSSL_FIPS_BREAK_FFC_DH)
|
||||
0xb8,
|
||||
#else
|
||||
0x00,
|
||||
#endif
|
||||
};
|
||||
|
||||
EVP_AEAD_CTX aead_ctx;
|
||||
EVP_AEAD_CTX_zero(&aead_ctx);
|
||||
RSA *rsa_key = NULL;
|
||||
@@ -640,14 +728,12 @@ int boringssl_fips_self_test(
|
||||
// ECDSA Sign/Verify KAT
|
||||
|
||||
// The 'k' value for ECDSA is fixed to avoid an entropy draw.
|
||||
ec_key->fixed_k = BN_new();
|
||||
if (ec_key->fixed_k == NULL ||
|
||||
!BN_set_word(ec_key->fixed_k, 42)) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
goto err;
|
||||
}
|
||||
uint8_t ecdsa_k[32] = {0};
|
||||
ecdsa_k[31] = 42;
|
||||
|
||||
sig = ECDSA_do_sign(kPlaintextSHA256, sizeof(kPlaintextSHA256), ec_key);
|
||||
sig = ecdsa_sign_with_nonce_for_known_answer_test(
|
||||
kPlaintextSHA256, sizeof(kPlaintextSHA256), ec_key, ecdsa_k,
|
||||
sizeof(ecdsa_k));
|
||||
|
||||
uint8_t ecdsa_r_bytes[sizeof(kECDSASigR)];
|
||||
uint8_t ecdsa_s_bytes[sizeof(kECDSASigS)];
|
||||
@@ -692,6 +778,29 @@ int boringssl_fips_self_test(
|
||||
goto err;
|
||||
}
|
||||
|
||||
// FFC Diffie-Hellman KAT
|
||||
|
||||
BIGNUM *const ffdhe2048_value = BN_new();
|
||||
DH *const dh = self_test_dh();
|
||||
int dh_ok = 0;
|
||||
if (ffdhe2048_value && dh) {
|
||||
bn_set_static_words(ffdhe2048_value, kFFDHE2048PublicValueData,
|
||||
OPENSSL_ARRAY_SIZE(kFFDHE2048PublicValueData));
|
||||
|
||||
uint8_t dh_out[sizeof(kDHOutput)];
|
||||
dh_ok =
|
||||
sizeof(dh_out) == DH_size(dh) &&
|
||||
DH_compute_key_padded(dh_out, ffdhe2048_value, dh) == sizeof(dh_out) &&
|
||||
check_test(kDHOutput, dh_out, sizeof(dh_out), "FFC DH");
|
||||
}
|
||||
|
||||
BN_free(ffdhe2048_value);
|
||||
DH_free(dh);
|
||||
if (!dh_ok) {
|
||||
fprintf(stderr, "FFDH failed.\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
// DBRG KAT
|
||||
CTR_DRBG_STATE drbg;
|
||||
if (!CTR_DRBG_init(&drbg, kDRBGEntropy, kDRBGPersonalization,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
.globl _sha1_block_data_order
|
||||
.private_extern _sha1_block_data_order
|
||||
|
||||
@@ -1233,8 +1234,6 @@ Lconst:
|
||||
.byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
.align 2
|
||||
.align 2
|
||||
.comm _OPENSSL_armcap_P,4,4
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.hidden OPENSSL_armcap_P
|
||||
.globl sha1_block_data_order
|
||||
.hidden sha1_block_data_order
|
||||
.type sha1_block_data_order,%function
|
||||
@@ -1234,8 +1235,6 @@ sha1_block_armv8:
|
||||
.byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
.align 2
|
||||
.align 2
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
.hidden OPENSSL_armcap_P
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
.globl _sha256_block_data_order
|
||||
.private_extern _sha256_block_data_order
|
||||
|
||||
@@ -1208,10 +1209,6 @@ Loop_hw:
|
||||
ldr x29,[sp],#16
|
||||
ret
|
||||
|
||||
#endif
|
||||
#ifndef __KERNEL__
|
||||
.comm _OPENSSL_armcap_P,4,4
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.hidden OPENSSL_armcap_P
|
||||
.globl sha256_block_data_order
|
||||
.hidden sha256_block_data_order
|
||||
.type sha256_block_data_order,%function
|
||||
@@ -1210,10 +1211,6 @@ sha256_block_armv8:
|
||||
ret
|
||||
.size sha256_block_armv8,.-sha256_block_armv8
|
||||
#endif
|
||||
#ifndef __KERNEL__
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
.hidden OPENSSL_armcap_P
|
||||
#endif
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
.globl _sha512_block_data_order
|
||||
.private_extern _sha512_block_data_order
|
||||
|
||||
@@ -1079,10 +1080,6 @@ LK512:
|
||||
.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
.align 2
|
||||
.align 2
|
||||
#ifndef __KERNEL__
|
||||
.comm _OPENSSL_armcap_P,4,4
|
||||
.private_extern _OPENSSL_armcap_P
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
#endif // defined(__aarch64__) && defined(__APPLE__)
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
.text
|
||||
|
||||
|
||||
.hidden OPENSSL_armcap_P
|
||||
.globl sha512_block_data_order
|
||||
.hidden sha512_block_data_order
|
||||
.type sha512_block_data_order,%function
|
||||
@@ -1080,10 +1081,6 @@ sha512_block_data_order:
|
||||
.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
||||
.align 2
|
||||
.align 2
|
||||
#ifndef __KERNEL__
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
.hidden OPENSSL_armcap_P
|
||||
#endif
|
||||
#endif
|
||||
#endif // !OPENSSL_NO_ASM
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
|
||||
@@ -1010,7 +1010,7 @@ Lschedule_mangle_dec:
|
||||
|
||||
Lschedule_mangle_both:
|
||||
tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3
|
||||
add x8, x8, #64-16 // add $-16, %r8
|
||||
add x8, x8, #48 // add $-16, %r8
|
||||
and x8, x8, #~(1<<6) // and $0x30, %r8
|
||||
st1 {v3.2d}, [x2] // vmovdqu %xmm3, (%rdx)
|
||||
ret
|
||||
|
||||
@@ -1011,7 +1011,7 @@ _vpaes_schedule_mangle:
|
||||
|
||||
.Lschedule_mangle_both:
|
||||
tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3
|
||||
add x8, x8, #64-16 // add $-16, %r8
|
||||
add x8, x8, #48 // add $-16, %r8
|
||||
and x8, x8, #~(1<<6) // and $0x30, %r8
|
||||
st1 {v3.2d}, [x2] // vmovdqu %xmm3, (%rdx)
|
||||
ret
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
// This file implements draft-irtf-cfrg-hpke-05.
|
||||
// This file implements draft-irtf-cfrg-hpke-07.
|
||||
|
||||
#define KEM_CONTEXT_LEN (2 * X25519_PUBLIC_VALUE_LEN)
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#define HPKE_MODE_BASE 0
|
||||
#define HPKE_MODE_PSK 1
|
||||
|
||||
static const char kHpkeRfcId[] = "HPKE-05 ";
|
||||
static const char kHpkeRfcId[] = "HPKE-07";
|
||||
|
||||
static int add_label_string(CBB *cbb, const char *label) {
|
||||
return CBB_add_bytes(cbb, (const uint8_t *)label, strlen(label));
|
||||
@@ -125,7 +125,7 @@ static int hpke_extract_and_expand(const EVP_MD *hkdf_md, uint8_t *out_key,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_AEAD *hpke_get_aead(uint16_t aead_id) {
|
||||
const EVP_AEAD *EVP_HPKE_get_aead(uint16_t aead_id) {
|
||||
switch (aead_id) {
|
||||
case EVP_HPKE_AEAD_AES_GCM_128:
|
||||
return EVP_aead_aes_128_gcm();
|
||||
@@ -138,7 +138,7 @@ static const EVP_AEAD *hpke_get_aead(uint16_t aead_id) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const EVP_MD *hpke_get_kdf(uint16_t kdf_id) {
|
||||
const EVP_MD *EVP_HPKE_get_hkdf_md(uint16_t kdf_id) {
|
||||
switch (kdf_id) {
|
||||
case EVP_HPKE_HKDF_SHA256:
|
||||
return EVP_sha256();
|
||||
@@ -174,7 +174,7 @@ static int hpke_key_schedule(EVP_HPKE_CTX *hpke, uint8_t mode,
|
||||
}
|
||||
|
||||
// Attempt to get an EVP_AEAD*.
|
||||
const EVP_AEAD *aead = hpke_get_aead(hpke->aead_id);
|
||||
const EVP_AEAD *aead = EVP_HPKE_get_aead(hpke->aead_id);
|
||||
if (aead == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -216,24 +216,13 @@ static int hpke_key_schedule(EVP_HPKE_CTX *hpke, uint8_t mode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// psk_hash = LabeledExtract("", "psk_hash", psk)
|
||||
static const char kPskHashLabel[] = "psk_hash";
|
||||
uint8_t psk_hash[EVP_MAX_MD_SIZE];
|
||||
size_t psk_hash_len;
|
||||
if (!hpke_labeled_extract(hpke->hkdf_md, psk_hash, &psk_hash_len, NULL, 0,
|
||||
suite_id, sizeof(suite_id), kPskHashLabel, psk,
|
||||
psk_len)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// secret = LabeledExtract(psk_hash, "secret", shared_secret)
|
||||
// secret = LabeledExtract(shared_secret, "secret", psk)
|
||||
static const char kSecretExtractLabel[] = "secret";
|
||||
uint8_t secret[EVP_MAX_MD_SIZE];
|
||||
size_t secret_len;
|
||||
if (!hpke_labeled_extract(hpke->hkdf_md, secret, &secret_len, psk_hash,
|
||||
psk_hash_len, suite_id, sizeof(suite_id),
|
||||
kSecretExtractLabel, shared_secret,
|
||||
shared_secret_len)) {
|
||||
if (!hpke_labeled_extract(hpke->hkdf_md, secret, &secret_len, shared_secret,
|
||||
shared_secret_len, suite_id, sizeof(suite_id),
|
||||
kSecretExtractLabel, psk, psk_len)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -252,9 +241,9 @@ static int hpke_key_schedule(EVP_HPKE_CTX *hpke, uint8_t mode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// nonce = LabeledExpand(secret, "nonce", key_schedule_context, Nn)
|
||||
static const char kNonceExpandLabel[] = "nonce";
|
||||
if (!hpke_labeled_expand(hpke->hkdf_md, hpke->nonce,
|
||||
// base_nonce = LabeledExpand(secret, "base_nonce", key_schedule_context, Nn)
|
||||
static const char kNonceExpandLabel[] = "base_nonce";
|
||||
if (!hpke_labeled_expand(hpke->hkdf_md, hpke->base_nonce,
|
||||
EVP_AEAD_nonce_length(aead), secret, secret_len,
|
||||
suite_id, sizeof(suite_id), kNonceExpandLabel,
|
||||
context, context_len)) {
|
||||
@@ -351,7 +340,7 @@ int EVP_HPKE_CTX_setup_base_s_x25519_for_test(
|
||||
hpke->is_sender = 1;
|
||||
hpke->kdf_id = kdf_id;
|
||||
hpke->aead_id = aead_id;
|
||||
hpke->hkdf_md = hpke_get_kdf(kdf_id);
|
||||
hpke->hkdf_md = EVP_HPKE_get_hkdf_md(kdf_id);
|
||||
if (hpke->hkdf_md == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -375,7 +364,7 @@ int EVP_HPKE_CTX_setup_base_r_x25519(
|
||||
hpke->is_sender = 0;
|
||||
hpke->kdf_id = kdf_id;
|
||||
hpke->aead_id = aead_id;
|
||||
hpke->hkdf_md = hpke_get_kdf(kdf_id);
|
||||
hpke->hkdf_md = EVP_HPKE_get_hkdf_md(kdf_id);
|
||||
if (hpke->hkdf_md == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -415,7 +404,7 @@ int EVP_HPKE_CTX_setup_psk_s_x25519_for_test(
|
||||
hpke->is_sender = 1;
|
||||
hpke->kdf_id = kdf_id;
|
||||
hpke->aead_id = aead_id;
|
||||
hpke->hkdf_md = hpke_get_kdf(kdf_id);
|
||||
hpke->hkdf_md = EVP_HPKE_get_hkdf_md(kdf_id);
|
||||
if (hpke->hkdf_md == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -440,7 +429,7 @@ int EVP_HPKE_CTX_setup_psk_r_x25519(
|
||||
hpke->is_sender = 0;
|
||||
hpke->kdf_id = kdf_id;
|
||||
hpke->aead_id = aead_id;
|
||||
hpke->hkdf_md = hpke_get_kdf(kdf_id);
|
||||
hpke->hkdf_md = EVP_HPKE_get_hkdf_md(kdf_id);
|
||||
if (hpke->hkdf_md == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -466,9 +455,9 @@ static void hpke_nonce(const EVP_HPKE_CTX *hpke, uint8_t *out_nonce,
|
||||
seq_copy >>= 8;
|
||||
}
|
||||
|
||||
// XOR the encoded sequence with the |hpke->nonce|.
|
||||
// XOR the encoded sequence with the |hpke->base_nonce|.
|
||||
for (size_t i = 0; i < nonce_len; i++) {
|
||||
out_nonce[i] ^= hpke->nonce[i];
|
||||
out_nonce[i] ^= hpke->base_nonce[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <CCryptoBoringSSL_aead.h>
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
#include <CCryptoBoringSSL_curve25519.h>
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
@@ -30,7 +31,7 @@ extern "C" {
|
||||
// receiver with a public key. Optionally, the sender may authenticate its
|
||||
// possession of a pre-shared key to the recipient.
|
||||
//
|
||||
// See https://tools.ietf.org/html/draft-irtf-cfrg-hpke-05.
|
||||
// See https://tools.ietf.org/html/draft-irtf-cfrg-hpke-07.
|
||||
|
||||
// EVP_HPKE_AEAD_* are AEAD identifiers.
|
||||
#define EVP_HPKE_AEAD_AES_GCM_128 0x0001
|
||||
@@ -55,7 +56,7 @@ typedef struct evp_hpke_ctx_st {
|
||||
EVP_AEAD_CTX aead_ctx;
|
||||
uint16_t kdf_id;
|
||||
uint16_t aead_id;
|
||||
uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH];
|
||||
uint8_t base_nonce[EVP_AEAD_MAX_NONCE_LENGTH];
|
||||
uint8_t exporter_secret[EVP_MAX_MD_SIZE];
|
||||
uint64_t seq;
|
||||
int is_sender;
|
||||
@@ -77,8 +78,8 @@ OPENSSL_EXPORT void EVP_HPKE_CTX_cleanup(EVP_HPKE_CTX *ctx);
|
||||
// In each of the following functions, |hpke| must have been initialized with
|
||||
// |EVP_HPKE_CTX_init|. |kdf_id| selects the KDF for non-KEM HPKE operations and
|
||||
// must be one of the |EVP_HPKE_HKDF_*| constants. |aead_id| selects the AEAD
|
||||
// for the "open" and "seal" operations and must be one of the |EVP_HPKE_AEAD_*"
|
||||
// constants."
|
||||
// for the "open" and "seal" operations and must be one of the |EVP_HPKE_AEAD_*|
|
||||
// constants.
|
||||
|
||||
// EVP_HPKE_CTX_setup_base_s_x25519 sets up |hpke| as a sender context that can
|
||||
// encrypt for the private key corresponding to |peer_public_value| (the
|
||||
@@ -215,6 +216,14 @@ OPENSSL_EXPORT int EVP_HPKE_CTX_export(const EVP_HPKE_CTX *hpke, uint8_t *out,
|
||||
// set up as a sender.
|
||||
OPENSSL_EXPORT size_t EVP_HPKE_CTX_max_overhead(const EVP_HPKE_CTX *hpke);
|
||||
|
||||
// EVP_HPKE_get_aead returns the AEAD corresponding to |aead_id|, or NULL if
|
||||
// |aead_id| is not a known AEAD identifier.
|
||||
OPENSSL_EXPORT const EVP_AEAD *EVP_HPKE_get_aead(uint16_t aead_id);
|
||||
|
||||
// EVP_HPKE_get_hkdf_md returns the hash function associated with |kdf_id|, or
|
||||
// NULL if |kdf_id| is not a known KDF identifier that uses HKDF.
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_HPKE_get_hkdf_md(uint16_t kdf_id);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
|
||||
@@ -943,11 +943,6 @@ int PKCS12_parse(const PKCS12 *p12, const char *password, EVP_PKEY **out_pkey,
|
||||
|
||||
// OpenSSL selects the last certificate which matches the private key as
|
||||
// |out_cert|.
|
||||
//
|
||||
// TODO(davidben): OpenSSL additionally reverses the order of the
|
||||
// certificates, which was likely originally a bug, but may be a feature by
|
||||
// now. See https://crbug.com/boringssl/250 and
|
||||
// https://github.com/openssl/openssl/issues/6698.
|
||||
*out_cert = NULL;
|
||||
size_t num_certs = sk_X509_num(ca_certs);
|
||||
if (*out_pkey != NULL && num_certs > 0) {
|
||||
@@ -1074,31 +1069,24 @@ static int add_cert_bag(CBB *cbb, X509 *cert, const char *name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int make_cert_safe_contents(uint8_t **out_data, size_t *out_len,
|
||||
X509 *cert, const STACK_OF(X509) *chain,
|
||||
const char *name, const uint8_t *key_id,
|
||||
size_t key_id_len) {
|
||||
int ret = 0;
|
||||
CBB cbb, safe_contents;
|
||||
if (!CBB_init(&cbb, 0) ||
|
||||
!CBB_add_asn1(&cbb, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
static int add_cert_safe_contents(CBB *cbb, X509 *cert,
|
||||
const STACK_OF(X509) *chain, const char *name,
|
||||
const uint8_t *key_id, size_t key_id_len) {
|
||||
CBB safe_contents;
|
||||
if (!CBB_add_asn1(cbb, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
(cert != NULL &&
|
||||
!add_cert_bag(&safe_contents, cert, name, key_id, key_id_len))) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sk_X509_num(chain); i++) {
|
||||
// Only the leaf certificate gets attributes.
|
||||
if (!add_cert_bag(&safe_contents, sk_X509_value(chain, i), NULL, NULL, 0)) {
|
||||
goto err;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ret = CBB_finish(&cbb, out_data, out_len);
|
||||
|
||||
err:
|
||||
CBB_cleanup(&cbb);
|
||||
return ret;
|
||||
return CBB_flush(cbb);
|
||||
}
|
||||
|
||||
static int add_encrypted_data(CBB *out, int pbe_nid, const char *password,
|
||||
@@ -1181,9 +1169,6 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
if (// In OpenSSL, this specifies a non-standard Microsoft key usage extension
|
||||
// which we do not currently support.
|
||||
key_type != 0 ||
|
||||
// In OpenSSL, -1 here means to use no encryption, which we do not
|
||||
// currently support.
|
||||
key_nid < 0 || cert_nid < 0 ||
|
||||
// In OpenSSL, -1 here means to omit the MAC, which we do not
|
||||
// currently support. Omitting it is also invalid for a password-based
|
||||
// PKCS#12 file.
|
||||
@@ -1194,6 +1179,36 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// PKCS#12 is a very confusing recursive data format, built out of another
|
||||
// recursive data format. Section 5.1 of RFC7292 describes the encoding
|
||||
// algorithm, but there is no clear overview. A quick summary:
|
||||
//
|
||||
// PKCS#7 defines a ContentInfo structure, which is a overgeneralized typed
|
||||
// combinator structure for applying cryptography. We care about two types. A
|
||||
// data ContentInfo contains an OCTET STRING and is a leaf node of the
|
||||
// combinator tree. An encrypted-data ContentInfo contains encryption
|
||||
// parameters (key derivation and encryption) and wraps another ContentInfo,
|
||||
// usually data.
|
||||
//
|
||||
// A PKCS#12 file is a PFX structure (section 4), which contains a single data
|
||||
// ContentInfo and a MAC over it. This root ContentInfo is the
|
||||
// AuthenticatedSafe and its payload is a SEQUENCE of other ContentInfos, so
|
||||
// that different parts of the PKCS#12 file can by differently protected.
|
||||
//
|
||||
// Each ContentInfo in the AuthenticatedSafe, after undoing all the PKCS#7
|
||||
// combinators, has SafeContents payload. A SafeContents is a SEQUENCE of
|
||||
// SafeBag. SafeBag is PKCS#12's typed structure, with subtypes such as KeyBag
|
||||
// and CertBag. Confusingly, there is a SafeContents bag type which itself
|
||||
// recursively contains more SafeBags, but we do not implement this. Bags also
|
||||
// can have attributes.
|
||||
//
|
||||
// The grouping of SafeBags into intermediate ContentInfos does not appear to
|
||||
// be significant, except that all SafeBags sharing a ContentInfo have the
|
||||
// same level of protection. Additionally, while keys may be encrypted by
|
||||
// placing a KeyBag in an encrypted-data ContentInfo, PKCS#12 also defines a
|
||||
// key-specific encryption container, PKCS8ShroudedKeyBag, which is used
|
||||
// instead.
|
||||
|
||||
// Note that |password| may be NULL to specify no password, rather than the
|
||||
// empty string. They are encoded differently in PKCS#12. (One is the empty
|
||||
// byte array and the other is NUL-terminated UCS-2.)
|
||||
@@ -1236,24 +1251,43 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
// If there are any certificates, place them in CertBags wrapped in a single
|
||||
// encrypted ContentInfo.
|
||||
if (cert != NULL || sk_X509_num(chain) > 0) {
|
||||
uint8_t *data;
|
||||
size_t len;
|
||||
if (!make_cert_safe_contents(&data, &len, cert, chain, name, key_id,
|
||||
key_id_len)) {
|
||||
goto err;
|
||||
}
|
||||
int ok = add_encrypted_data(&content_infos, cert_nid, password,
|
||||
password_len, iterations, data, len);
|
||||
OPENSSL_free(data);
|
||||
if (!ok) {
|
||||
goto err;
|
||||
if (cert_nid < 0) {
|
||||
// Place the certificates in an unencrypted ContentInfo. This could be
|
||||
// more compactly-encoded by reusing the same ContentInfo as the key, but
|
||||
// OpenSSL does not do this. We keep them separate for consistency. (Keys,
|
||||
// even when encrypted, are always placed in unencrypted ContentInfos.
|
||||
// PKCS#12 defines bag-level encryption for keys.)
|
||||
CBB content_info, oid, wrapper, data;
|
||||
if (!CBB_add_asn1(&content_infos, &content_info, CBS_ASN1_SEQUENCE) ||
|
||||
!CBB_add_asn1(&content_info, &oid, CBS_ASN1_OBJECT) ||
|
||||
!CBB_add_bytes(&oid, kPKCS7Data, sizeof(kPKCS7Data)) ||
|
||||
!CBB_add_asn1(&content_info, &wrapper,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!CBB_add_asn1(&wrapper, &data, CBS_ASN1_OCTETSTRING) ||
|
||||
!add_cert_safe_contents(&data, cert, chain, name, key_id,
|
||||
key_id_len) ||
|
||||
!CBB_flush(&content_infos)) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
CBB plaintext_cbb;
|
||||
int ok = CBB_init(&plaintext_cbb, 0) &&
|
||||
add_cert_safe_contents(&plaintext_cbb, cert, chain, name, key_id,
|
||||
key_id_len) &&
|
||||
add_encrypted_data(
|
||||
&content_infos, cert_nid, password, password_len, iterations,
|
||||
CBB_data(&plaintext_cbb), CBB_len(&plaintext_cbb));
|
||||
CBB_cleanup(&plaintext_cbb);
|
||||
if (!ok) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a key, place it in a single PKCS8ShroudedKeyBag wrapped in an
|
||||
// unencrypted ContentInfo. (One could also place it in a KeyBag inside an
|
||||
// encrypted ContentInfo, but OpenSSL does not do this and some PKCS#12
|
||||
// consumers do not support KeyBags.)
|
||||
// If there is a key, place it in a single KeyBag or PKCS8ShroudedKeyBag
|
||||
// wrapped in an unencrypted ContentInfo. (One could also place it in a KeyBag
|
||||
// inside an encrypted ContentInfo, but OpenSSL does not do this and some
|
||||
// PKCS#12 consumers do not support KeyBags.)
|
||||
if (pkey != NULL) {
|
||||
CBB content_info, oid, wrapper, data, safe_contents, bag, bag_oid,
|
||||
bag_contents;
|
||||
@@ -1267,16 +1301,29 @@ PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
!CBB_add_asn1(&data, &safe_contents, CBS_ASN1_SEQUENCE) ||
|
||||
// Add a SafeBag containing a PKCS8ShroudedKeyBag.
|
||||
!CBB_add_asn1(&safe_contents, &bag, CBS_ASN1_SEQUENCE) ||
|
||||
!CBB_add_asn1(&bag, &bag_oid, CBS_ASN1_OBJECT) ||
|
||||
!CBB_add_bytes(&bag_oid, kPKCS8ShroudedKeyBag,
|
||||
sizeof(kPKCS8ShroudedKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!PKCS8_marshal_encrypted_private_key(
|
||||
&bag_contents, key_nid, NULL, password, password_len,
|
||||
NULL /* generate a random salt */, 0 /* use default salt length */,
|
||||
iterations, pkey) ||
|
||||
!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
!CBB_add_asn1(&bag, &bag_oid, CBS_ASN1_OBJECT)) {
|
||||
goto err;
|
||||
}
|
||||
if (key_nid < 0) {
|
||||
if (!CBB_add_bytes(&bag_oid, kKeyBag, sizeof(kKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!EVP_marshal_private_key(&bag_contents, pkey)) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
if (!CBB_add_bytes(&bag_oid, kPKCS8ShroudedKeyBag,
|
||||
sizeof(kPKCS8ShroudedKeyBag)) ||
|
||||
!CBB_add_asn1(&bag, &bag_contents,
|
||||
CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 0) ||
|
||||
!PKCS8_marshal_encrypted_private_key(
|
||||
&bag_contents, key_nid, NULL, password, password_len,
|
||||
NULL /* generate a random salt */,
|
||||
0 /* use default salt length */, iterations, pkey)) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!add_bag_attributes(&bag, name, key_id, key_id_len) ||
|
||||
!CBB_flush(&content_infos)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -46,10 +46,14 @@ struct poly1305_state_st {
|
||||
uint32_t s1, s2, s3, s4;
|
||||
uint32_t h0, h1, h2, h3, h4;
|
||||
uint8_t buf[16];
|
||||
unsigned int buf_used;
|
||||
size_t buf_used;
|
||||
uint8_t key[16];
|
||||
};
|
||||
|
||||
OPENSSL_STATIC_ASSERT(
|
||||
sizeof(struct poly1305_state_st) + 63 <= sizeof(poly1305_state),
|
||||
"poly1305_state isn't large enough to hold aligned poly1305_state_st");
|
||||
|
||||
static inline struct poly1305_state_st *poly1305_aligned_state(
|
||||
poly1305_state *state) {
|
||||
return (struct poly1305_state_st *)(((uintptr_t)state + 63) & ~63);
|
||||
@@ -200,7 +204,6 @@ void CRYPTO_poly1305_init(poly1305_state *statep, const uint8_t key[32]) {
|
||||
|
||||
void CRYPTO_poly1305_update(poly1305_state *statep, const uint8_t *in,
|
||||
size_t in_len) {
|
||||
unsigned int i;
|
||||
struct poly1305_state_st *state = poly1305_aligned_state(statep);
|
||||
|
||||
#if defined(OPENSSL_POLY1305_NEON)
|
||||
@@ -211,11 +214,11 @@ void CRYPTO_poly1305_update(poly1305_state *statep, const uint8_t *in,
|
||||
#endif
|
||||
|
||||
if (state->buf_used) {
|
||||
unsigned todo = 16 - state->buf_used;
|
||||
size_t todo = 16 - state->buf_used;
|
||||
if (todo > in_len) {
|
||||
todo = (unsigned)in_len;
|
||||
todo = in_len;
|
||||
}
|
||||
for (i = 0; i < todo; i++) {
|
||||
for (size_t i = 0; i < todo; i++) {
|
||||
state->buf[state->buf_used + i] = in[i];
|
||||
}
|
||||
state->buf_used += todo;
|
||||
@@ -236,10 +239,10 @@ void CRYPTO_poly1305_update(poly1305_state *statep, const uint8_t *in,
|
||||
}
|
||||
|
||||
if (in_len) {
|
||||
for (i = 0; i < in_len; i++) {
|
||||
for (size_t i = 0; i < in_len; i++) {
|
||||
state->buf[i] = in[i];
|
||||
}
|
||||
state->buf_used = (unsigned)in_len;
|
||||
state->buf_used = in_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ extern void addmulmod(fe1305x2 *r, const fe1305x2 *x, const fe1305x2 *y,
|
||||
const fe1305x2 *c);
|
||||
|
||||
extern int blocks(fe1305x2 *h, const fe1305x2 *precomp, const uint8_t *in,
|
||||
unsigned int inlen);
|
||||
size_t inlen);
|
||||
|
||||
static void freeze(fe1305x2 *r) {
|
||||
int i;
|
||||
@@ -136,7 +136,7 @@ static void fe1305x2_tobytearray(uint8_t r[16], fe1305x2 *x) {
|
||||
}
|
||||
|
||||
static void fe1305x2_frombytearray(fe1305x2 *r, const uint8_t *x, size_t xlen) {
|
||||
unsigned i;
|
||||
size_t i;
|
||||
uint8_t t[17];
|
||||
|
||||
for (i = 0; (i < 16) && (i < xlen); i++) {
|
||||
@@ -179,17 +179,20 @@ static const alignas(16) fe1305x2 zero;
|
||||
struct poly1305_state_st {
|
||||
uint8_t data[sizeof(fe1305x2[5]) + 128];
|
||||
uint8_t buf[32];
|
||||
unsigned int buf_used;
|
||||
size_t buf_used;
|
||||
uint8_t key[16];
|
||||
};
|
||||
|
||||
OPENSSL_STATIC_ASSERT(
|
||||
sizeof(struct poly1305_state_st) + 63 <= sizeof(poly1305_state),
|
||||
"poly1305_state isn't large enough to hold aligned poly1305_state_st.");
|
||||
|
||||
void CRYPTO_poly1305_init_neon(poly1305_state *state, const uint8_t key[32]) {
|
||||
struct poly1305_state_st *st = (struct poly1305_state_st *)(state);
|
||||
fe1305x2 *const r = (fe1305x2 *)(st->data + (15 & (-(int)st->data)));
|
||||
fe1305x2 *const h = r + 1;
|
||||
fe1305x2 *const c = h + 1;
|
||||
fe1305x2 *const precomp = c + 1;
|
||||
unsigned int j;
|
||||
|
||||
r->v[1] = r->v[0] = 0x3ffffff & load32(key);
|
||||
r->v[3] = r->v[2] = 0x3ffff03 & (load32(key + 3) >> 2);
|
||||
@@ -197,7 +200,7 @@ void CRYPTO_poly1305_init_neon(poly1305_state *state, const uint8_t key[32]) {
|
||||
r->v[7] = r->v[6] = 0x3f03fff & (load32(key + 9) >> 6);
|
||||
r->v[9] = r->v[8] = 0x00fffff & (load32(key + 12) >> 8);
|
||||
|
||||
for (j = 0; j < 10; j++) {
|
||||
for (size_t j = 0; j < 10; j++) {
|
||||
h->v[j] = 0; // XXX: should fast-forward a bit
|
||||
}
|
||||
|
||||
@@ -215,14 +218,13 @@ void CRYPTO_poly1305_update_neon(poly1305_state *state, const uint8_t *in,
|
||||
fe1305x2 *const h = r + 1;
|
||||
fe1305x2 *const c = h + 1;
|
||||
fe1305x2 *const precomp = c + 1;
|
||||
unsigned int i;
|
||||
|
||||
if (st->buf_used) {
|
||||
unsigned int todo = 32 - st->buf_used;
|
||||
size_t todo = 32 - st->buf_used;
|
||||
if (todo > in_len) {
|
||||
todo = in_len;
|
||||
}
|
||||
for (i = 0; i < todo; i++) {
|
||||
for (size_t i = 0; i < todo; i++) {
|
||||
st->buf[st->buf_used + i] = in[i];
|
||||
}
|
||||
st->buf_used += todo;
|
||||
@@ -232,7 +234,7 @@ void CRYPTO_poly1305_update_neon(poly1305_state *state, const uint8_t *in,
|
||||
if (st->buf_used == sizeof(st->buf) && in_len) {
|
||||
addmulmod(h, h, precomp, &zero);
|
||||
fe1305x2_frombytearray(c, st->buf, sizeof(st->buf));
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (size_t i = 0; i < 10; i++) {
|
||||
h->v[i] += c->v[i];
|
||||
}
|
||||
st->buf_used = 0;
|
||||
@@ -240,7 +242,7 @@ void CRYPTO_poly1305_update_neon(poly1305_state *state, const uint8_t *in,
|
||||
}
|
||||
|
||||
while (in_len > 32) {
|
||||
unsigned int tlen = 1048576;
|
||||
size_t tlen = 1048576;
|
||||
if (in_len < tlen) {
|
||||
tlen = in_len;
|
||||
}
|
||||
@@ -250,7 +252,7 @@ void CRYPTO_poly1305_update_neon(poly1305_state *state, const uint8_t *in,
|
||||
}
|
||||
|
||||
if (in_len) {
|
||||
for (i = 0; i < in_len; i++) {
|
||||
for (size_t i = 0; i < in_len; i++) {
|
||||
st->buf[i] = in[i];
|
||||
}
|
||||
st->buf_used = in_len;
|
||||
|
||||
@@ -92,6 +92,10 @@ typedef struct poly1305_state_internal_t {
|
||||
} poly1305_state_internal; /* 448 bytes total + 63 bytes for
|
||||
alignment = 511 bytes raw */
|
||||
|
||||
OPENSSL_STATIC_ASSERT(
|
||||
sizeof(struct poly1305_state_internal_t) + 63 <= sizeof(poly1305_state),
|
||||
"poly1305_state isn't large enough to hold aligned poly1305_state_internal_t");
|
||||
|
||||
static inline poly1305_state_internal *poly1305_aligned_state(
|
||||
poly1305_state *state) {
|
||||
return (poly1305_state_internal *)(((uint64_t)state + 63) & ~63);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright (c) 2020, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#include <CCryptoBoringSSL_base.h>
|
||||
#include "../fipsmodule/rand/internal.h"
|
||||
|
||||
#if defined(BORINGSSL_FIPS_PASSIVE_ENTROPY)
|
||||
|
||||
// RAND_need_entropy is called by the FIPS module when it has blocked because of
|
||||
// a lack of entropy. This signal is used as an indication to feed it more.
|
||||
void RAND_need_entropy(size_t bytes_needed) {
|
||||
uint8_t buf[CTR_DRBG_ENTROPY_LEN * BORINGSSL_FIPS_OVERREAD];
|
||||
size_t todo = sizeof(buf);
|
||||
if (todo > bytes_needed) {
|
||||
todo = bytes_needed;
|
||||
}
|
||||
|
||||
int used_cpu;
|
||||
CRYPTO_get_seed_entropy(buf, todo, &used_cpu);
|
||||
RAND_load_entropy(buf, todo, used_cpu);
|
||||
}
|
||||
|
||||
#endif // BORINGSSL_FIPS_PASSIVE_ENTROPY
|
||||
@@ -63,8 +63,12 @@ RAND_METHOD *RAND_SSLeay(void) {
|
||||
return (RAND_METHOD*) &kSSLeayMethod;
|
||||
}
|
||||
|
||||
RAND_METHOD *RAND_OpenSSL(void) {
|
||||
return RAND_SSLeay();
|
||||
}
|
||||
|
||||
const RAND_METHOD *RAND_get_rand_method(void) { return RAND_SSLeay(); }
|
||||
|
||||
void RAND_set_rand_method(const RAND_METHOD *method) {}
|
||||
int RAND_set_rand_method(const RAND_METHOD *method) { return 1; }
|
||||
|
||||
void RAND_cleanup(void) {}
|
||||
@@ -57,7 +57,6 @@
|
||||
#include <CCryptoBoringSSL_stack.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <CCryptoBoringSSL_mem.h>
|
||||
|
||||
@@ -69,11 +68,9 @@
|
||||
static const size_t kMinSize = 4;
|
||||
|
||||
_STACK *sk_new(stack_cmp_func comp) {
|
||||
_STACK *ret;
|
||||
|
||||
ret = OPENSSL_malloc(sizeof(_STACK));
|
||||
_STACK *ret = OPENSSL_malloc(sizeof(_STACK));
|
||||
if (ret == NULL) {
|
||||
goto err;
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(_STACK));
|
||||
|
||||
@@ -331,23 +328,20 @@ void *sk_pop(_STACK *sk) {
|
||||
}
|
||||
|
||||
_STACK *sk_dup(const _STACK *sk) {
|
||||
_STACK *ret;
|
||||
void **s;
|
||||
|
||||
if (sk == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = sk_new(sk->comp);
|
||||
_STACK *ret = OPENSSL_malloc(sizeof(_STACK));
|
||||
if (ret == NULL) {
|
||||
goto err;
|
||||
return NULL;
|
||||
}
|
||||
OPENSSL_memset(ret, 0, sizeof(_STACK));
|
||||
|
||||
s = (void **)OPENSSL_realloc(ret->data, sizeof(void *) * sk->num_alloc);
|
||||
if (s == NULL) {
|
||||
ret->data = OPENSSL_malloc(sizeof(void *) * sk->num_alloc);
|
||||
if (ret->data == NULL) {
|
||||
goto err;
|
||||
}
|
||||
ret->data = s;
|
||||
|
||||
ret->num = sk->num;
|
||||
OPENSSL_memcpy(ret->data, sk->data, sizeof(void *) * sk->num);
|
||||
|
||||
@@ -24,6 +24,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Internal structures. */
|
||||
|
||||
struct X509_val_st {
|
||||
ASN1_TIME *notBefore;
|
||||
ASN1_TIME *notAfter;
|
||||
} /* X509_VAL */;
|
||||
|
||||
|
||||
/* RSA-PSS functions. */
|
||||
|
||||
/* x509_rsa_pss_to_ctx configures |ctx| for an RSA-PSS operation based on
|
||||
|
||||
@@ -83,34 +83,6 @@ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b)
|
||||
return (X509_NAME_cmp(ai->issuer, bi->issuer));
|
||||
}
|
||||
|
||||
unsigned long X509_issuer_and_serial_hash(X509 *a)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
EVP_MD_CTX ctx;
|
||||
unsigned char md[16];
|
||||
char *f;
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
f = X509_NAME_oneline(a->cert_info->issuer, NULL, 0);
|
||||
if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL))
|
||||
goto err;
|
||||
if (!EVP_DigestUpdate(&ctx, (unsigned char *)f, strlen(f)))
|
||||
goto err;
|
||||
OPENSSL_free(f);
|
||||
if (!EVP_DigestUpdate
|
||||
(&ctx, (unsigned char *)a->cert_info->serialNumber->data,
|
||||
(unsigned long)a->cert_info->serialNumber->length))
|
||||
goto err;
|
||||
if (!EVP_DigestFinal_ex(&ctx, &(md[0]), NULL))
|
||||
goto err;
|
||||
ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
|
||||
((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
|
||||
) & 0xffffffffL;
|
||||
err:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int X509_issuer_name_cmp(const X509 *a, const X509 *b)
|
||||
{
|
||||
return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer));
|
||||
@@ -411,7 +383,7 @@ int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
|
||||
} else
|
||||
i = 0;
|
||||
|
||||
if (X509_get_version(x) != 2) {
|
||||
if (X509_get_version(x) != X509V3_VERSION) {
|
||||
rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
|
||||
/* Correct error depth */
|
||||
i = 0;
|
||||
@@ -429,7 +401,7 @@ int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
|
||||
for (; i < sk_X509_num(chain); i++) {
|
||||
sign_nid = X509_get_signature_nid(x);
|
||||
x = sk_X509_value(chain, i);
|
||||
if (X509_get_version(x) != 2) {
|
||||
if (X509_get_version(x) != X509V3_VERSION) {
|
||||
rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.] */
|
||||
|
||||
#include <CCryptoBoringSSL_asn1.h>
|
||||
#include <CCryptoBoringSSL_bn.h>
|
||||
#include <CCryptoBoringSSL_digest.h>
|
||||
#include <CCryptoBoringSSL_err.h>
|
||||
#include <CCryptoBoringSSL_evp.h>
|
||||
#include <CCryptoBoringSSL_obj.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
|
||||
{
|
||||
X509 *ret = NULL;
|
||||
X509_CINF *xi = NULL;
|
||||
X509_NAME *xn;
|
||||
EVP_PKEY *pubkey = NULL;
|
||||
int res;
|
||||
|
||||
if ((ret = X509_new()) == NULL) {
|
||||
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* duplicate the request */
|
||||
xi = ret->cert_info;
|
||||
|
||||
if (sk_X509_ATTRIBUTE_num(r->req_info->attributes) != 0) {
|
||||
if ((xi->version = ASN1_INTEGER_new()) == NULL)
|
||||
goto err;
|
||||
if (!ASN1_INTEGER_set(xi->version, 2))
|
||||
goto err;
|
||||
/*
|
||||
* xi->extensions=ri->attributes; <- bad, should not ever be done
|
||||
* ri->attributes=NULL;
|
||||
*/
|
||||
}
|
||||
|
||||
xn = X509_REQ_get_subject_name(r);
|
||||
if (X509_set_subject_name(ret, xn) == 0)
|
||||
goto err;
|
||||
if (X509_set_issuer_name(ret, xn) == 0)
|
||||
goto err;
|
||||
|
||||
if (X509_gmtime_adj(xi->validity->notBefore, 0) == NULL)
|
||||
goto err;
|
||||
if (X509_gmtime_adj(xi->validity->notAfter, (long)60 * 60 * 24 * days) ==
|
||||
NULL)
|
||||
goto err;
|
||||
|
||||
pubkey = X509_REQ_get_pubkey(r);
|
||||
res = X509_set_pubkey(ret, pubkey);
|
||||
EVP_PKEY_free(pubkey);
|
||||
|
||||
if (!res || !X509_sign(ret, pkey, EVP_md5()))
|
||||
goto err;
|
||||
if (0) {
|
||||
err:
|
||||
X509_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
@@ -60,8 +60,15 @@
|
||||
#include <CCryptoBoringSSL_obj.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
long X509_get_version(const X509 *x509)
|
||||
{
|
||||
// The default version is v1(0).
|
||||
if (x509->cert_info->version == NULL) {
|
||||
return X509V1_VERSION;
|
||||
}
|
||||
return ASN1_INTEGER_get(x509->cert_info->version);
|
||||
}
|
||||
|
||||
@@ -72,6 +79,7 @@ X509_CINF *X509_get_cert_info(const X509 *x509)
|
||||
|
||||
int X509_set_version(X509 *x, long version)
|
||||
{
|
||||
// TODO(davidben): Reject invalid version numbers.
|
||||
if (x == NULL)
|
||||
return (0);
|
||||
if (version == 0) {
|
||||
@@ -86,7 +94,7 @@ int X509_set_version(X509 *x, long version)
|
||||
return (ASN1_INTEGER_set(x->cert_info->version, version));
|
||||
}
|
||||
|
||||
int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
|
||||
int X509_set_serialNumber(X509 *x, const ASN1_INTEGER *serial)
|
||||
{
|
||||
ASN1_INTEGER *in;
|
||||
|
||||
|
||||
@@ -2052,7 +2052,7 @@ X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
|
||||
}
|
||||
/* Create new CRL */
|
||||
crl = X509_CRL_new();
|
||||
if (!crl || !X509_CRL_set_version(crl, 1))
|
||||
if (!crl || !X509_CRL_set_version(crl, X509V2_VERSION))
|
||||
goto memerr;
|
||||
/* Set issuer name */
|
||||
if (!X509_CRL_set_issuer_name(crl, X509_CRL_get_issuer(newer)))
|
||||
|
||||
@@ -85,27 +85,32 @@ IMPLEMENT_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
|
||||
|
||||
X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value)
|
||||
{
|
||||
X509_ATTRIBUTE *ret = NULL;
|
||||
ASN1_TYPE *val = NULL;
|
||||
const ASN1_OBJECT *obj = OBJ_nid2obj(nid);
|
||||
if (obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ret = X509_ATTRIBUTE_new()) == NULL)
|
||||
return (NULL);
|
||||
/* TODO(fork): const correctness. */
|
||||
ret->object = (ASN1_OBJECT *)OBJ_nid2obj(nid);
|
||||
X509_ATTRIBUTE *ret = X509_ATTRIBUTE_new();
|
||||
ASN1_TYPE *val = ASN1_TYPE_new();
|
||||
if (ret == NULL || val == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* TODO(fork): const correctness. |ASN1_OBJECT| is messy because static
|
||||
* objects are const but freeable with a no-op |ASN1_OBJECT_free|. */
|
||||
ret->object = (ASN1_OBJECT *)obj;
|
||||
ret->single = 0;
|
||||
if ((ret->value.set = sk_ASN1_TYPE_new_null()) == NULL)
|
||||
goto err;
|
||||
if ((val = ASN1_TYPE_new()) == NULL)
|
||||
goto err;
|
||||
if (!sk_ASN1_TYPE_push(ret->value.set, val))
|
||||
ret->value.set = sk_ASN1_TYPE_new_null();
|
||||
if (ret->value.set == NULL ||
|
||||
!sk_ASN1_TYPE_push(ret->value.set, val)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
ASN1_TYPE_set(val, atrtype, value);
|
||||
return (ret);
|
||||
return ret;
|
||||
|
||||
err:
|
||||
if (ret != NULL)
|
||||
X509_ATTRIBUTE_free(ret);
|
||||
if (val != NULL)
|
||||
ASN1_TYPE_free(val);
|
||||
return (NULL);
|
||||
X509_ATTRIBUTE_free(ret);
|
||||
ASN1_TYPE_free(val);
|
||||
return NULL;
|
||||
}
|
||||
@@ -436,6 +436,11 @@ int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
|
||||
|
||||
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
|
||||
{
|
||||
if (X509_ALGOR_cmp(crl->sig_alg, crl->crl->sig_alg) != 0) {
|
||||
OPENSSL_PUT_ERROR(X509, X509_R_SIGNATURE_ALGORITHM_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CRL_INFO),
|
||||
crl->sig_alg, crl->signature, crl->crl, r));
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#include <CCryptoBoringSSL_asn1t.h>
|
||||
#include <CCryptoBoringSSL_x509.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
ASN1_SEQUENCE(X509_VAL) = {
|
||||
ASN1_SIMPLE(X509_VAL, notBefore, ASN1_TIME),
|
||||
|
||||
@@ -136,7 +136,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
}
|
||||
|
||||
/* Per RFC5280, section 4.1.2.9, extensions require v3. */
|
||||
/* Check disabled. TODO re-enable in Jan 2021.
|
||||
/* Check disabled. TODO re-enable in April 2021.
|
||||
https://crbug.com/boringssl/375
|
||||
if (version != 2 && ret->cert_info->extensions != NULL) {
|
||||
OPENSSL_PUT_ERROR(X509, X509_R_INVALID_FIELD_FOR_VERSION);
|
||||
|
||||
@@ -72,8 +72,9 @@ ASN1_SEQUENCE(OTHERNAME) = {
|
||||
IMPLEMENT_ASN1_FUNCTIONS(OTHERNAME)
|
||||
|
||||
ASN1_SEQUENCE(EDIPARTYNAME) = {
|
||||
ASN1_IMP_OPT(EDIPARTYNAME, nameAssigner, DIRECTORYSTRING, 0),
|
||||
ASN1_IMP_OPT(EDIPARTYNAME, partyName, DIRECTORYSTRING, 1)
|
||||
/* DirectoryString is a CHOICE type, so use explicit tagging. */
|
||||
ASN1_EXP_OPT(EDIPARTYNAME, nameAssigner, DIRECTORYSTRING, 0),
|
||||
ASN1_EXP(EDIPARTYNAME, partyName, DIRECTORYSTRING, 1)
|
||||
} ASN1_SEQUENCE_END(EDIPARTYNAME)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(EDIPARTYNAME)
|
||||
@@ -102,42 +103,56 @@ IMPLEMENT_ASN1_FUNCTIONS(GENERAL_NAMES)
|
||||
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(GENERAL_NAME)
|
||||
|
||||
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||
int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
|
||||
static int edipartyname_cmp(const EDIPARTYNAME *a, const EDIPARTYNAME *b)
|
||||
{
|
||||
int result = -1;
|
||||
/* nameAssigner is optional and may be NULL. */
|
||||
if (a->nameAssigner == NULL) {
|
||||
if (b->nameAssigner != NULL) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (b->nameAssigner == NULL ||
|
||||
ASN1_STRING_cmp(a->nameAssigner, b->nameAssigner) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* partyName may not be NULL. */
|
||||
return ASN1_STRING_cmp(a->partyName, b->partyName);
|
||||
}
|
||||
|
||||
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||
int GENERAL_NAME_cmp(const GENERAL_NAME *a, const GENERAL_NAME *b)
|
||||
{
|
||||
if (!a || !b || a->type != b->type)
|
||||
return -1;
|
||||
|
||||
switch (a->type) {
|
||||
case GEN_X400:
|
||||
return ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
|
||||
|
||||
case GEN_EDIPARTY:
|
||||
result = ASN1_TYPE_cmp(a->d.other, b->d.other);
|
||||
break;
|
||||
return edipartyname_cmp(a->d.ediPartyName, b->d.ediPartyName);
|
||||
|
||||
case GEN_OTHERNAME:
|
||||
result = OTHERNAME_cmp(a->d.otherName, b->d.otherName);
|
||||
break;
|
||||
return OTHERNAME_cmp(a->d.otherName, b->d.otherName);
|
||||
|
||||
case GEN_EMAIL:
|
||||
case GEN_DNS:
|
||||
case GEN_URI:
|
||||
result = ASN1_STRING_cmp(a->d.ia5, b->d.ia5);
|
||||
break;
|
||||
return ASN1_STRING_cmp(a->d.ia5, b->d.ia5);
|
||||
|
||||
case GEN_DIRNAME:
|
||||
result = X509_NAME_cmp(a->d.dirn, b->d.dirn);
|
||||
break;
|
||||
return X509_NAME_cmp(a->d.dirn, b->d.dirn);
|
||||
|
||||
case GEN_IPADD:
|
||||
result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip);
|
||||
break;
|
||||
return ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip);
|
||||
|
||||
case GEN_RID:
|
||||
result = OBJ_cmp(a->d.rid, b->d.rid);
|
||||
break;
|
||||
return OBJ_cmp(a->d.rid, b->d.rid);
|
||||
}
|
||||
return result;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||
@@ -159,8 +174,11 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value)
|
||||
{
|
||||
switch (type) {
|
||||
case GEN_X400:
|
||||
a->d.x400Address = value;
|
||||
break;
|
||||
|
||||
case GEN_EDIPARTY:
|
||||
a->d.other = value;
|
||||
a->d.ediPartyName = value;
|
||||
break;
|
||||
|
||||
case GEN_OTHERNAME:
|
||||
@@ -194,8 +212,10 @@ void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype)
|
||||
*ptype = a->type;
|
||||
switch (a->type) {
|
||||
case GEN_X400:
|
||||
return a->d.x400Address;
|
||||
|
||||
case GEN_EDIPARTY:
|
||||
return a->d.other;
|
||||
return a->d.ediPartyName;
|
||||
|
||||
case GEN_OTHERNAME:
|
||||
return a->d.otherName;
|
||||
|
||||
@@ -440,7 +440,7 @@ int x509v3_cache_extensions(X509 *x)
|
||||
if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL))
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
/* V1 should mean no extensions ... */
|
||||
if (!X509_get_version(x))
|
||||
if (X509_get_version(x) == X509V1_VERSION)
|
||||
x->ex_flags |= EXFLAG_V1;
|
||||
/* Handle basic constraints */
|
||||
if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &j, NULL))) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 9dae0ac4f0ae18ebed988d36bfb4c4e4023fc574
|
||||
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 04b3213d43492b6c9e0434d8e2a4530a9938f958
|
||||
@@ -1,6 +1,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwitCrypto open source project
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) 2019 Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "CCryptoBoringSSL_asn1t.h"
|
||||
#include "CCryptoBoringSSL_base.h"
|
||||
#include "CCryptoBoringSSL_bio.h"
|
||||
#include "CCryptoBoringSSL_blake2.h"
|
||||
#include "CCryptoBoringSSL_blowfish.h"
|
||||
#include "CCryptoBoringSSL_boringssl_prefix_symbols.h"
|
||||
#include "CCryptoBoringSSL_boringssl_prefix_symbols_asm.h"
|
||||
|
||||
@@ -1012,5 +1012,6 @@ BSSL_NAMESPACE_END
|
||||
#define ASN1_R_WRONG_TAG 190
|
||||
#define ASN1_R_WRONG_TYPE 191
|
||||
#define ASN1_R_NESTED_TOO_DEEP 192
|
||||
#define ASN1_R_BAD_TEMPLATE 193
|
||||
|
||||
#endif
|
||||
@@ -98,21 +98,25 @@ extern "C" {
|
||||
#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_X86
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#elif defined(__AARCH64EL__) || defined(_M_ARM64)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_AARCH64
|
||||
#elif defined(__arm) || defined(__arm__) || defined(_M_ARM)
|
||||
#elif defined(__ARMEL__) || defined(_M_ARM)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_ARM
|
||||
#elif (defined(__PPC64__) || defined(__powerpc64__)) && defined(_LITTLE_ENDIAN)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_PPC64LE
|
||||
#elif defined(__mips__) && !defined(__LP64__)
|
||||
#elif defined(__MIPSEL__) && !defined(__LP64__)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_MIPS
|
||||
#elif defined(__mips__) && defined(__LP64__)
|
||||
#elif defined(__MIPSEL__) && defined(__LP64__)
|
||||
#define OPENSSL_64_BIT
|
||||
#define OPENSSL_MIPS64
|
||||
#elif defined(__riscv) && __SIZEOF_POINTER__ == 8
|
||||
#define OPENSSL_64_BIT
|
||||
#elif defined(__riscv) && __SIZEOF_POINTER__ == 4
|
||||
#define OPENSSL_32_BIT
|
||||
#elif defined(__pnacl__)
|
||||
#define OPENSSL_32_BIT
|
||||
#define OPENSSL_PNACL
|
||||
@@ -164,6 +168,10 @@ extern "C" {
|
||||
|
||||
#if defined(__ANDROID_API__)
|
||||
#define OPENSSL_ANDROID
|
||||
#if defined(BORINGSSL_FIPS)
|
||||
// The FIPS module on Android passively receives entropy.
|
||||
#define BORINGSSL_FIPS_PASSIVE_ENTROPY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// BoringSSL requires platform's locking APIs to make internal global state
|
||||
@@ -195,7 +203,7 @@ extern "C" {
|
||||
// A consumer may use this symbol in the preprocessor to temporarily build
|
||||
// against multiple revisions of BoringSSL at the same time. It is not
|
||||
// recommended to do so for longer than is necessary.
|
||||
#define BORINGSSL_API_VERSION 12
|
||||
#define BORINGSSL_API_VERSION 14
|
||||
|
||||
#if defined(BORINGSSL_SHARED_LIBRARY)
|
||||
|
||||
@@ -380,6 +388,7 @@ typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct bio_method_st BIO_METHOD;
|
||||
typedef struct bio_st BIO;
|
||||
typedef struct blake2b_state_st BLAKE2B_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct buf_mem_st BUF_MEM;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/* Copyright (c) 2021, Google Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#ifndef OPENSSL_HEADER_BLAKE2_H
|
||||
#define OPENSSL_HEADER_BLAKE2_H
|
||||
|
||||
#include "CCryptoBoringSSL_base.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define BLAKE2B256_DIGEST_LENGTH (256 / 8)
|
||||
#define BLAKE2B_CBLOCK 128
|
||||
|
||||
struct blake2b_state_st {
|
||||
uint64_t h[8];
|
||||
uint64_t t_low, t_high;
|
||||
union {
|
||||
uint8_t bytes[BLAKE2B_CBLOCK];
|
||||
uint64_t words[16];
|
||||
} block;
|
||||
size_t block_used;
|
||||
};
|
||||
|
||||
// BLAKE2B256_Init initialises |b2b| to perform a BLAKE2b-256 hash. There are no
|
||||
// pointers inside |b2b| thus release of |b2b| is purely managed by the caller.
|
||||
OPENSSL_EXPORT void BLAKE2B256_Init(BLAKE2B_CTX *b2b);
|
||||
|
||||
// BLAKE2B256_Update appends |len| bytes from |data| to the digest being
|
||||
// calculated by |b2b|.
|
||||
OPENSSL_EXPORT void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *data,
|
||||
size_t len);
|
||||
|
||||
// BLAKE2B256_Final completes the digest calculated by |b2b| and writes
|
||||
// |BLAKE2B256_DIGEST_LENGTH| bytes to |out|.
|
||||
OPENSSL_EXPORT void BLAKE2B256_Final(uint8_t out[BLAKE2B256_DIGEST_LENGTH],
|
||||
BLAKE2B_CTX *b2b);
|
||||
|
||||
// BLAKE2B256 writes the BLAKE2b-256 digset of |len| bytes from |data| to
|
||||
// |out|.
|
||||
OPENSSL_EXPORT void BLAKE2B256(const uint8_t *data, size_t len,
|
||||
uint8_t out[BLAKE2B256_DIGEST_LENGTH]);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern C
|
||||
#endif
|
||||
|
||||
#endif // OPENSSL_HEADER_BLAKE2_H
|
||||
@@ -300,6 +300,10 @@
|
||||
#define BIO_write BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BIO_write)
|
||||
#define BIO_write_all BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BIO_write_all)
|
||||
#define BIO_write_filename BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BIO_write_filename)
|
||||
#define BLAKE2B256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BLAKE2B256)
|
||||
#define BLAKE2B256_Final BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BLAKE2B256_Final)
|
||||
#define BLAKE2B256_Init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BLAKE2B256_Init)
|
||||
#define BLAKE2B256_Update BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BLAKE2B256_Update)
|
||||
#define BN_BLINDING_convert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_convert)
|
||||
#define BN_BLINDING_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_free)
|
||||
#define BN_BLINDING_invalidate BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, BN_BLINDING_invalidate)
|
||||
@@ -592,8 +596,8 @@
|
||||
#define CRYPTO_has_asm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#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_ARMv8_AES_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable_at_runtime)
|
||||
#define CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable_at_runtime)
|
||||
#define CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
#define CRYPTO_is_confidential_build BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_is_confidential_build)
|
||||
#define CRYPTO_library_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_library_init)
|
||||
@@ -640,6 +644,8 @@
|
||||
#define DH_check BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_check)
|
||||
#define DH_check_pub_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_check_pub_key)
|
||||
#define DH_compute_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_compute_key)
|
||||
#define DH_compute_key_hashed BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_compute_key_hashed)
|
||||
#define DH_compute_key_padded BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_compute_key_padded)
|
||||
#define DH_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_free)
|
||||
#define DH_generate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_generate_key)
|
||||
#define DH_generate_parameters_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_generate_parameters_ex)
|
||||
@@ -650,15 +656,13 @@
|
||||
#define DH_get0_priv_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define DH_get0_pub_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define DH_get0_q BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define DH_get_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_ex_data)
|
||||
#define DH_get_ex_new_index BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_ex_new_index)
|
||||
#define DH_get_rfc7919_2048 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_get_rfc7919_2048)
|
||||
#define DH_marshal_parameters BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
#define DH_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_new)
|
||||
#define DH_num_bits BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_num_bits)
|
||||
#define DH_parse_parameters BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_parse_parameters)
|
||||
#define DH_set0_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set0_key)
|
||||
#define DH_set0_pqg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set0_pqg)
|
||||
#define DH_set_ex_data BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set_ex_data)
|
||||
#define DH_set_length BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_set_length)
|
||||
#define DH_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_size)
|
||||
#define DH_up_ref BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, DH_up_ref)
|
||||
@@ -728,6 +732,7 @@
|
||||
#define ECDSA_do_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_do_sign)
|
||||
#define ECDSA_do_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_do_verify)
|
||||
#define ECDSA_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_sign)
|
||||
#define ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_sign_with_nonce_and_leak_private_key_for_testing)
|
||||
#define ECDSA_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_size)
|
||||
#define ECDSA_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ECDSA_verify)
|
||||
#define EC_GFp_mont_method BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GFp_mont_method)
|
||||
@@ -739,6 +744,7 @@
|
||||
#define EC_GROUP_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_free)
|
||||
#define EC_GROUP_get0_generator BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get0_generator)
|
||||
#define EC_GROUP_get0_order BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get0_order)
|
||||
#define EC_GROUP_get_asn1_flag BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_asn1_flag)
|
||||
#define EC_GROUP_get_cofactor BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_cofactor)
|
||||
#define EC_GROUP_get_curve_GFp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_curve_GFp)
|
||||
#define EC_GROUP_get_curve_name BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_GROUP_get_curve_name)
|
||||
@@ -792,6 +798,7 @@
|
||||
#define EC_POINT_dbl BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_dbl)
|
||||
#define EC_POINT_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_dup)
|
||||
#define EC_POINT_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_free)
|
||||
#define EC_POINT_get_affine_coordinates BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_get_affine_coordinates)
|
||||
#define EC_POINT_get_affine_coordinates_GFp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_get_affine_coordinates_GFp)
|
||||
#define EC_POINT_invert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_invert)
|
||||
#define EC_POINT_is_at_infinity BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_is_at_infinity)
|
||||
@@ -801,6 +808,7 @@
|
||||
#define EC_POINT_oct2point BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_oct2point)
|
||||
#define EC_POINT_point2cbb BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_point2cbb)
|
||||
#define EC_POINT_point2oct BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_point2oct)
|
||||
#define EC_POINT_set_affine_coordinates BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_set_affine_coordinates)
|
||||
#define EC_POINT_set_affine_coordinates_GFp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_set_affine_coordinates_GFp)
|
||||
#define EC_POINT_set_compressed_coordinates_GFp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_set_compressed_coordinates_GFp)
|
||||
#define EC_POINT_set_to_infinity BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_POINT_set_to_infinity)
|
||||
@@ -952,6 +960,8 @@
|
||||
#define EVP_HPKE_CTX_setup_psk_r_x25519 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_r_x25519)
|
||||
#define EVP_HPKE_CTX_setup_psk_s_x25519 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_s_x25519)
|
||||
#define EVP_HPKE_CTX_setup_psk_s_x25519_for_test BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_s_x25519_for_test)
|
||||
#define EVP_HPKE_get_aead BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_get_aead)
|
||||
#define EVP_HPKE_get_hkdf_md BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_get_hkdf_md)
|
||||
#define EVP_MD_CTX_block_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_MD_CTX_block_size)
|
||||
#define EVP_MD_CTX_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_MD_CTX_cleanup)
|
||||
#define EVP_MD_CTX_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_MD_CTX_copy)
|
||||
@@ -1106,6 +1116,7 @@
|
||||
#define EVP_aes_256_ecb BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aes_256_ecb)
|
||||
#define EVP_aes_256_gcm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aes_256_gcm)
|
||||
#define EVP_aes_256_ofb BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aes_256_ofb)
|
||||
#define EVP_blake2b256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_blake2b256)
|
||||
#define EVP_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_cleanup)
|
||||
#define EVP_des_cbc BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_des_cbc)
|
||||
#define EVP_des_ecb BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_des_ecb)
|
||||
@@ -1433,6 +1444,7 @@
|
||||
#define PROXY_POLICY_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PROXY_POLICY_free)
|
||||
#define PROXY_POLICY_it BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PROXY_POLICY_it)
|
||||
#define PROXY_POLICY_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, PROXY_POLICY_new)
|
||||
#define RAND_OpenSSL BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_OpenSSL)
|
||||
#define RAND_SSLeay BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_SSLeay)
|
||||
#define RAND_add BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_add)
|
||||
#define RAND_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RAND_bytes)
|
||||
@@ -1838,7 +1850,6 @@
|
||||
#define X509_REQ_set_version BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_set_version)
|
||||
#define X509_REQ_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_sign)
|
||||
#define X509_REQ_sign_ctx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_sign_ctx)
|
||||
#define X509_REQ_to_X509 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_to_X509)
|
||||
#define X509_REQ_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REQ_verify)
|
||||
#define X509_REVOKED_add1_ext_i2d BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REVOKED_add1_ext_i2d)
|
||||
#define X509_REVOKED_add_ext BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_REVOKED_add_ext)
|
||||
@@ -2057,7 +2068,6 @@
|
||||
#define X509_getm_notBefore BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_getm_notBefore)
|
||||
#define X509_gmtime_adj BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_gmtime_adj)
|
||||
#define X509_issuer_and_serial_cmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_and_serial_cmp)
|
||||
#define X509_issuer_and_serial_hash BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_and_serial_hash)
|
||||
#define X509_issuer_name_cmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_cmp)
|
||||
#define X509_issuer_name_hash BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_hash)
|
||||
#define X509_issuer_name_hash_old BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_issuer_name_hash_old)
|
||||
@@ -2245,6 +2255,7 @@
|
||||
#define bn_scatter5 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_scatter5)
|
||||
#define bn_select_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_select_words)
|
||||
#define bn_set_minimal_width BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_set_minimal_width)
|
||||
#define bn_set_static_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_set_static_words)
|
||||
#define bn_set_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_set_words)
|
||||
#define bn_sqr8x_internal BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_sqr8x_internal)
|
||||
#define bn_sqr_comba4 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_sqr_comba4)
|
||||
@@ -2481,6 +2492,7 @@
|
||||
#define ec_set_to_safe_point BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecdsa_sign_with_nonce_for_known_answer_test)
|
||||
#define ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define ecp_nistz256_mul_mont BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_mul_mont)
|
||||
#define ecp_nistz256_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_neg)
|
||||
|
||||
@@ -305,6 +305,10 @@
|
||||
#define _BIO_write BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BIO_write)
|
||||
#define _BIO_write_all BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BIO_write_all)
|
||||
#define _BIO_write_filename BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BIO_write_filename)
|
||||
#define _BLAKE2B256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BLAKE2B256)
|
||||
#define _BLAKE2B256_Final BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BLAKE2B256_Final)
|
||||
#define _BLAKE2B256_Init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BLAKE2B256_Init)
|
||||
#define _BLAKE2B256_Update BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BLAKE2B256_Update)
|
||||
#define _BN_BLINDING_convert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_convert)
|
||||
#define _BN_BLINDING_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_free)
|
||||
#define _BN_BLINDING_invalidate BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, BN_BLINDING_invalidate)
|
||||
@@ -597,8 +601,8 @@
|
||||
#define _CRYPTO_has_asm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_has_asm)
|
||||
#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_ARMv8_AES_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable)
|
||||
#define _CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable)
|
||||
#define _CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_AES_capable_at_runtime)
|
||||
#define _CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_ARMv8_PMULL_capable_at_runtime)
|
||||
#define _CRYPTO_is_NEON_capable_at_runtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_NEON_capable_at_runtime)
|
||||
#define _CRYPTO_is_confidential_build BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_is_confidential_build)
|
||||
#define _CRYPTO_library_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_library_init)
|
||||
@@ -645,6 +649,8 @@
|
||||
#define _DH_check BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_check)
|
||||
#define _DH_check_pub_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_check_pub_key)
|
||||
#define _DH_compute_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_compute_key)
|
||||
#define _DH_compute_key_hashed BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_compute_key_hashed)
|
||||
#define _DH_compute_key_padded BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_compute_key_padded)
|
||||
#define _DH_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_free)
|
||||
#define _DH_generate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_generate_key)
|
||||
#define _DH_generate_parameters_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_generate_parameters_ex)
|
||||
@@ -655,15 +661,13 @@
|
||||
#define _DH_get0_priv_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_priv_key)
|
||||
#define _DH_get0_pub_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_pub_key)
|
||||
#define _DH_get0_q BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get0_q)
|
||||
#define _DH_get_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_ex_data)
|
||||
#define _DH_get_ex_new_index BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_ex_new_index)
|
||||
#define _DH_get_rfc7919_2048 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_get_rfc7919_2048)
|
||||
#define _DH_marshal_parameters BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_marshal_parameters)
|
||||
#define _DH_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_new)
|
||||
#define _DH_num_bits BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_num_bits)
|
||||
#define _DH_parse_parameters BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_parse_parameters)
|
||||
#define _DH_set0_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set0_key)
|
||||
#define _DH_set0_pqg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set0_pqg)
|
||||
#define _DH_set_ex_data BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set_ex_data)
|
||||
#define _DH_set_length BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_set_length)
|
||||
#define _DH_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_size)
|
||||
#define _DH_up_ref BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, DH_up_ref)
|
||||
@@ -733,6 +737,7 @@
|
||||
#define _ECDSA_do_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_do_sign)
|
||||
#define _ECDSA_do_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_do_verify)
|
||||
#define _ECDSA_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_sign)
|
||||
#define _ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_sign_with_nonce_and_leak_private_key_for_testing)
|
||||
#define _ECDSA_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_size)
|
||||
#define _ECDSA_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ECDSA_verify)
|
||||
#define _EC_GFp_mont_method BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GFp_mont_method)
|
||||
@@ -744,6 +749,7 @@
|
||||
#define _EC_GROUP_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_free)
|
||||
#define _EC_GROUP_get0_generator BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get0_generator)
|
||||
#define _EC_GROUP_get0_order BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get0_order)
|
||||
#define _EC_GROUP_get_asn1_flag BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_asn1_flag)
|
||||
#define _EC_GROUP_get_cofactor BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_cofactor)
|
||||
#define _EC_GROUP_get_curve_GFp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_curve_GFp)
|
||||
#define _EC_GROUP_get_curve_name BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_GROUP_get_curve_name)
|
||||
@@ -797,6 +803,7 @@
|
||||
#define _EC_POINT_dbl BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_dbl)
|
||||
#define _EC_POINT_dup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_dup)
|
||||
#define _EC_POINT_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_free)
|
||||
#define _EC_POINT_get_affine_coordinates BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_get_affine_coordinates)
|
||||
#define _EC_POINT_get_affine_coordinates_GFp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_get_affine_coordinates_GFp)
|
||||
#define _EC_POINT_invert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_invert)
|
||||
#define _EC_POINT_is_at_infinity BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_is_at_infinity)
|
||||
@@ -806,6 +813,7 @@
|
||||
#define _EC_POINT_oct2point BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_oct2point)
|
||||
#define _EC_POINT_point2cbb BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_point2cbb)
|
||||
#define _EC_POINT_point2oct BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_point2oct)
|
||||
#define _EC_POINT_set_affine_coordinates BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_set_affine_coordinates)
|
||||
#define _EC_POINT_set_affine_coordinates_GFp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_set_affine_coordinates_GFp)
|
||||
#define _EC_POINT_set_compressed_coordinates_GFp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_set_compressed_coordinates_GFp)
|
||||
#define _EC_POINT_set_to_infinity BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_POINT_set_to_infinity)
|
||||
@@ -957,6 +965,8 @@
|
||||
#define _EVP_HPKE_CTX_setup_psk_r_x25519 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_r_x25519)
|
||||
#define _EVP_HPKE_CTX_setup_psk_s_x25519 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_s_x25519)
|
||||
#define _EVP_HPKE_CTX_setup_psk_s_x25519_for_test BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_psk_s_x25519_for_test)
|
||||
#define _EVP_HPKE_get_aead BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_get_aead)
|
||||
#define _EVP_HPKE_get_hkdf_md BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_get_hkdf_md)
|
||||
#define _EVP_MD_CTX_block_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_MD_CTX_block_size)
|
||||
#define _EVP_MD_CTX_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_MD_CTX_cleanup)
|
||||
#define _EVP_MD_CTX_copy BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_MD_CTX_copy)
|
||||
@@ -1111,6 +1121,7 @@
|
||||
#define _EVP_aes_256_ecb BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aes_256_ecb)
|
||||
#define _EVP_aes_256_gcm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aes_256_gcm)
|
||||
#define _EVP_aes_256_ofb BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aes_256_ofb)
|
||||
#define _EVP_blake2b256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_blake2b256)
|
||||
#define _EVP_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_cleanup)
|
||||
#define _EVP_des_cbc BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_des_cbc)
|
||||
#define _EVP_des_ecb BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_des_ecb)
|
||||
@@ -1438,6 +1449,7 @@
|
||||
#define _PROXY_POLICY_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PROXY_POLICY_free)
|
||||
#define _PROXY_POLICY_it BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PROXY_POLICY_it)
|
||||
#define _PROXY_POLICY_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, PROXY_POLICY_new)
|
||||
#define _RAND_OpenSSL BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_OpenSSL)
|
||||
#define _RAND_SSLeay BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_SSLeay)
|
||||
#define _RAND_add BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_add)
|
||||
#define _RAND_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RAND_bytes)
|
||||
@@ -1843,7 +1855,6 @@
|
||||
#define _X509_REQ_set_version BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_set_version)
|
||||
#define _X509_REQ_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_sign)
|
||||
#define _X509_REQ_sign_ctx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_sign_ctx)
|
||||
#define _X509_REQ_to_X509 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_to_X509)
|
||||
#define _X509_REQ_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REQ_verify)
|
||||
#define _X509_REVOKED_add1_ext_i2d BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REVOKED_add1_ext_i2d)
|
||||
#define _X509_REVOKED_add_ext BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_REVOKED_add_ext)
|
||||
@@ -2062,7 +2073,6 @@
|
||||
#define _X509_getm_notBefore BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_getm_notBefore)
|
||||
#define _X509_gmtime_adj BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_gmtime_adj)
|
||||
#define _X509_issuer_and_serial_cmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_and_serial_cmp)
|
||||
#define _X509_issuer_and_serial_hash BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_and_serial_hash)
|
||||
#define _X509_issuer_name_cmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_cmp)
|
||||
#define _X509_issuer_name_hash BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_hash)
|
||||
#define _X509_issuer_name_hash_old BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_issuer_name_hash_old)
|
||||
@@ -2250,6 +2260,7 @@
|
||||
#define _bn_scatter5 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_scatter5)
|
||||
#define _bn_select_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_select_words)
|
||||
#define _bn_set_minimal_width BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_set_minimal_width)
|
||||
#define _bn_set_static_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_set_static_words)
|
||||
#define _bn_set_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_set_words)
|
||||
#define _bn_sqr8x_internal BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_sqr8x_internal)
|
||||
#define _bn_sqr_comba4 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_sqr_comba4)
|
||||
@@ -2486,6 +2497,7 @@
|
||||
#define _ec_set_to_safe_point BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_set_to_safe_point)
|
||||
#define _ec_simple_scalar_inv0_montgomery BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_inv0_montgomery)
|
||||
#define _ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_simple_scalar_to_montgomery_inv_vartime)
|
||||
#define _ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecdsa_sign_with_nonce_for_known_answer_test)
|
||||
#define _ecp_nistz256_avx2_select_w7 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_avx2_select_w7)
|
||||
#define _ecp_nistz256_mul_mont BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_mul_mont)
|
||||
#define _ecp_nistz256_neg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_neg)
|
||||
|
||||
@@ -252,12 +252,16 @@ OPENSSL_EXPORT int CBS_get_any_asn1_element(CBS *cbs, CBS *out,
|
||||
size_t *out_header_len);
|
||||
|
||||
// CBS_get_any_ber_asn1_element acts the same as |CBS_get_any_asn1_element| but
|
||||
// also allows indefinite-length elements to be returned. In that case,
|
||||
// |*out_header_len| and |CBS_len(out)| will both be two as only the header is
|
||||
// returned, otherwise it behaves the same as the previous function.
|
||||
// also allows indefinite-length elements to be returned and does not enforce
|
||||
// that lengths are minimal. For indefinite-lengths, |*out_header_len| and
|
||||
// |CBS_len(out)| will be equal as only the header is returned (although this is
|
||||
// also true for empty elements so the length must be checked too). If
|
||||
// |out_ber_found| is not NULL then it is set to one if any case of invalid DER
|
||||
// but valid BER is found, and to zero otherwise.
|
||||
OPENSSL_EXPORT int CBS_get_any_ber_asn1_element(CBS *cbs, CBS *out,
|
||||
unsigned *out_tag,
|
||||
size_t *out_header_len);
|
||||
size_t *out_header_len,
|
||||
int *out_ber_found);
|
||||
|
||||
// CBS_get_asn1_uint64 gets an ASN.1 INTEGER from |cbs| using |CBS_get_asn1|
|
||||
// and sets |*out| to its value. It returns one on success and zero on error,
|
||||
|
||||
@@ -431,9 +431,24 @@ OPENSSL_EXPORT const EVP_CIPHER *EVP_des_ede3_ecb(void);
|
||||
// EVP_aes_128_cfb128 is only available in decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_cfb128(void);
|
||||
|
||||
// EVP_aes_128_cfb is an alias for |EVP_aes_128_cfb128| and is only available in
|
||||
// decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_128_cfb(void);
|
||||
|
||||
// EVP_aes_192_cfb128 is only available in decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_cfb128(void);
|
||||
|
||||
// EVP_aes_192_cfb is an alias for |EVP_aes_192_cfb128| and is only available in
|
||||
// decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_192_cfb(void);
|
||||
|
||||
// EVP_aes_256_cfb128 is only available in decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_cfb128(void);
|
||||
|
||||
// EVP_aes_256_cfb is an alias for |EVP_aes_256_cfb128| and is only available in
|
||||
// decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_aes_256_cfb(void);
|
||||
|
||||
// EVP_bf_ecb is Blowfish in ECB mode and is only available in decrepit.
|
||||
OPENSSL_EXPORT const EVP_CIPHER *EVP_bf_ecb(void);
|
||||
|
||||
@@ -541,10 +556,6 @@ struct evp_cipher_ctx_st {
|
||||
// final_used is non-zero if the |final| buffer contains plaintext.
|
||||
int final_used;
|
||||
|
||||
// block_mask contains |cipher->block_size| minus one. (The block size
|
||||
// assumed to be a power of two.)
|
||||
int block_mask;
|
||||
|
||||
uint8_t final[EVP_MAX_BLOCK_LENGTH]; // possible final block
|
||||
} /* EVP_CIPHER_CTX */;
|
||||
|
||||
|
||||
@@ -111,26 +111,18 @@ OPENSSL_INLINE const uint32_t *OPENSSL_ia32cap_get(void) {
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_STATIC_ARMCAP)
|
||||
|
||||
// CRYPTO_is_NEON_capable_at_runtime returns true if the current CPU has a NEON
|
||||
// unit. Note that |OPENSSL_armcap_P| also exists and contains the same
|
||||
// information in a form that's easier for assembly to use.
|
||||
OPENSSL_EXPORT char CRYPTO_is_NEON_capable_at_runtime(void);
|
||||
OPENSSL_EXPORT int CRYPTO_is_NEON_capable_at_runtime(void);
|
||||
|
||||
// CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
|
||||
// this is known statically then it returns one immediately.
|
||||
OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
|
||||
// Only statically skip the runtime lookup on aarch64. On arm, one CPU is
|
||||
// known to have a broken NEON unit which is known to fail with on some
|
||||
// hand-written NEON assembly. For now, continue to apply the workaround even
|
||||
// when the compiler is instructed to freely emit NEON code. See
|
||||
// https://crbug.com/341598 and https://crbug.com/606629.
|
||||
#if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && !defined(OPENSSL_ARM)
|
||||
return 1;
|
||||
#else
|
||||
return CRYPTO_is_NEON_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
// CRYPTO_is_ARMv8_AES_capable_at_runtime returns true if the current CPU
|
||||
// supports the ARMv8 AES instruction.
|
||||
int CRYPTO_is_ARMv8_AES_capable_at_runtime(void);
|
||||
|
||||
// CRYPTO_is_ARMv8_PMULL_capable_at_runtime returns true if the current CPU
|
||||
// supports the ARMv8 PMULL instruction.
|
||||
int CRYPTO_is_ARMv8_PMULL_capable_at_runtime(void);
|
||||
|
||||
#if defined(OPENSSL_ARM)
|
||||
// CRYPTO_has_broken_NEON returns one if the current CPU is known to have a
|
||||
@@ -141,43 +133,41 @@ OPENSSL_EXPORT int CRYPTO_has_broken_NEON(void);
|
||||
// workaround was needed. See https://crbug.com/boringssl/46.
|
||||
OPENSSL_EXPORT int CRYPTO_needs_hwcap2_workaround(void);
|
||||
#endif
|
||||
#endif // !OPENSSL_STATIC_ARMCAP
|
||||
|
||||
// CRYPTO_is_ARMv8_AES_capable returns true if the current CPU supports the
|
||||
// ARMv8 AES instruction.
|
||||
int CRYPTO_is_ARMv8_AES_capable(void);
|
||||
|
||||
// CRYPTO_is_ARMv8_PMULL_capable returns true if the current CPU supports the
|
||||
// ARMv8 PMULL instruction.
|
||||
int CRYPTO_is_ARMv8_PMULL_capable(void);
|
||||
|
||||
#else
|
||||
|
||||
// CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
|
||||
// this is known statically, it is a constant inline function.
|
||||
OPENSSL_INLINE int CRYPTO_is_NEON_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_NEON) || \
|
||||
(defined(__ARM_NEON__) || defined(__ARM_NEON))
|
||||
#if defined(__ARM_NEON__) || defined(__ARM_NEON) || \
|
||||
defined(OPENSSL_STATIC_ARMCAP_NEON)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_NEON_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int CRYPTO_is_ARMv8_AES_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_AES) || defined(__ARM_FEATURE_CRYPTO)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_ARMv8_AES_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENSSL_INLINE int CRYPTO_is_ARMv8_PMULL_capable(void) {
|
||||
#if defined(OPENSSL_STATIC_ARMCAP_PMULL) || defined(__ARM_FEATURE_CRYPTO)
|
||||
return 1;
|
||||
#else
|
||||
#elif defined(OPENSSL_STATIC_ARMCAP)
|
||||
return 0;
|
||||
#else
|
||||
return CRYPTO_is_ARMv8_PMULL_capable_at_runtime();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // OPENSSL_STATIC_ARMCAP
|
||||
#endif // OPENSSL_ARM || OPENSSL_AARCH64
|
||||
|
||||
#if defined(OPENSSL_PPC64LE)
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
|
||||
#include "CCryptoBoringSSL_base.h"
|
||||
|
||||
#include "CCryptoBoringSSL_ex_data.h"
|
||||
#include "CCryptoBoringSSL_thread.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -140,6 +139,11 @@ OPENSSL_EXPORT int DH_set_length(DH *dh, unsigned priv_length);
|
||||
// and returned. It returns NULL on allocation failure.
|
||||
OPENSSL_EXPORT BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *ret);
|
||||
|
||||
// DH_get_rfc7919_2048 returns the group `ffdhe2048` from
|
||||
// https://tools.ietf.org/html/rfc7919#appendix-A.1. It returns NULL if out
|
||||
// of memory.
|
||||
OPENSSL_EXPORT DH *DH_get_rfc7919_2048(void);
|
||||
|
||||
|
||||
// Parameter generation.
|
||||
|
||||
@@ -164,20 +168,37 @@ OPENSSL_EXPORT int DH_generate_parameters_ex(DH *dh, int prime_bits,
|
||||
// |dh|. It returns one on success and zero on error.
|
||||
OPENSSL_EXPORT int DH_generate_key(DH *dh);
|
||||
|
||||
// DH_compute_key calculates the shared key between |dh| and |peers_key| and
|
||||
// writes it as a big-endian integer into |out|, which must have |DH_size|
|
||||
// bytes of space. It returns the number of bytes written, or a negative number
|
||||
// on error.
|
||||
// DH_compute_key_padded calculates the shared key between |dh| and |peers_key|
|
||||
// and writes it as a big-endian integer into |out|, padded up to |DH_size|
|
||||
// bytes. It returns the number of bytes written, which is always |DH_size|, or
|
||||
// a negative number on error. |out| must have |DH_size| bytes of space.
|
||||
//
|
||||
// Note the output may be shorter than |DH_size| bytes. Contrary to PKCS #3,
|
||||
// this function returns a variable-length shared key with leading zeros
|
||||
// removed. This may result in sporadic key mismatch and, if |dh| is reused,
|
||||
// side channel attacks such as https://raccoon-attack.com/.
|
||||
// WARNING: this differs from the usual BoringSSL return-value convention.
|
||||
//
|
||||
// This is a legacy algorithm, so we do not provide a fixed-width variant. Use
|
||||
// X25519 or ECDH with P-256 instead.
|
||||
OPENSSL_EXPORT int DH_compute_key(uint8_t *out, const BIGNUM *peers_key,
|
||||
DH *dh);
|
||||
// Note this function differs from |DH_compute_key| in that it preserves leading
|
||||
// zeros in the secret. This function is the preferred variant. It matches PKCS
|
||||
// #3 and avoids some side channel attacks. However, the two functions are not
|
||||
// drop-in replacements for each other. Using a different variant than the
|
||||
// application expects will result in sporadic key mismatches.
|
||||
//
|
||||
// Callers that expect a fixed-width secret should use this function over
|
||||
// |DH_compute_key|. Callers that use either function should migrate to a modern
|
||||
// primitive such as X25519 or ECDH with P-256 instead.
|
||||
OPENSSL_EXPORT int DH_compute_key_padded(uint8_t *out, const BIGNUM *peers_key,
|
||||
DH *dh);
|
||||
|
||||
// DH_compute_key_hashed calculates the shared key between |dh| and |peers_key|
|
||||
// and hashes it with the given |digest|. If the hash output is less than
|
||||
// |max_out_len| bytes then it writes the hash output to |out| and sets
|
||||
// |*out_len| to the number of bytes written. Otherwise it signals an error. It
|
||||
// returns one on success or zero on error.
|
||||
//
|
||||
// NOTE: this follows the usual BoringSSL return-value convention, but that's
|
||||
// different from |DH_compute_key| and |DH_compute_key_padded|.
|
||||
OPENSSL_EXPORT int DH_compute_key_hashed(DH *dh, uint8_t *out, size_t *out_len,
|
||||
size_t max_out_len,
|
||||
const BIGNUM *peers_key,
|
||||
const EVP_MD *digest);
|
||||
|
||||
|
||||
// Utility functions.
|
||||
@@ -237,18 +258,6 @@ OPENSSL_EXPORT DH *DH_parse_parameters(CBS *cbs);
|
||||
OPENSSL_EXPORT int DH_marshal_parameters(CBB *cbb, const DH *dh);
|
||||
|
||||
|
||||
// ex_data functions.
|
||||
//
|
||||
// See |ex_data.h| for details.
|
||||
|
||||
OPENSSL_EXPORT int DH_get_ex_new_index(long argl, void *argp,
|
||||
CRYPTO_EX_unused *unused,
|
||||
CRYPTO_EX_dup *dup_unused,
|
||||
CRYPTO_EX_free *free_func);
|
||||
OPENSSL_EXPORT int DH_set_ex_data(DH *d, int idx, void *arg);
|
||||
OPENSSL_EXPORT void *DH_get_ex_data(DH *d, int idx);
|
||||
|
||||
|
||||
// Deprecated functions.
|
||||
|
||||
// DH_generate_parameters behaves like |DH_generate_parameters_ex|, which is
|
||||
@@ -278,6 +287,28 @@ OPENSSL_EXPORT DH *d2i_DHparams(DH **ret, const unsigned char **inp, long len);
|
||||
// Use |DH_marshal_parameters| instead.
|
||||
OPENSSL_EXPORT int i2d_DHparams(const DH *in, unsigned char **outp);
|
||||
|
||||
// DH_compute_key behaves like |DH_compute_key_padded| but, contrary to PKCS #3,
|
||||
// returns a variable-length shared key with leading zeros. It returns the
|
||||
// number of bytes written, or a negative number on error. |out| must have
|
||||
// |DH_size| bytes of space.
|
||||
//
|
||||
// WARNING: this differs from the usual BoringSSL return-value convention.
|
||||
//
|
||||
// Note this function's running time and memory access pattern leaks information
|
||||
// about the shared secret. Particularly if |dh| is reused, this may result in
|
||||
// side channel attacks such as https://raccoon-attack.com/.
|
||||
//
|
||||
// |DH_compute_key_padded| is the preferred variant and avoids the above
|
||||
// attacks. However, the two functions are not drop-in replacements for each
|
||||
// other. Using a different variant than the application expects will result in
|
||||
// sporadic key mismatches.
|
||||
//
|
||||
// Callers that expect a fixed-width secret should use |DH_compute_key_padded|
|
||||
// instead. Callers that use either function should migrate to a modern
|
||||
// primitive such as X25519 or ECDH with P-256 instead.
|
||||
OPENSSL_EXPORT int DH_compute_key(uint8_t *out, const BIGNUM *peers_key,
|
||||
DH *dh);
|
||||
|
||||
|
||||
struct dh_st {
|
||||
BIGNUM *p;
|
||||
@@ -301,7 +332,6 @@ struct dh_st {
|
||||
|
||||
int flags;
|
||||
CRYPTO_refcount_t references;
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ OPENSSL_EXPORT const EVP_MD *EVP_sha256(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha384(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha512(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_sha512_256(void);
|
||||
OPENSSL_EXPORT const EVP_MD *EVP_blake2b256(void);
|
||||
|
||||
// EVP_md5_sha1 is a TLS-specific |EVP_MD| which computes the concatenation of
|
||||
// MD5 and SHA-1, as used in TLS 1.1 and below.
|
||||
|
||||
@@ -221,6 +221,13 @@ OPENSSL_EXPORT int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
BIGNUM *x, BIGNUM *y,
|
||||
BN_CTX *ctx);
|
||||
|
||||
// EC_POINT_get_affine_coordinates is an alias of
|
||||
// |EC_POINT_get_affine_coordinates_GFp|.
|
||||
OPENSSL_EXPORT int EC_POINT_get_affine_coordinates(const EC_GROUP *group,
|
||||
const EC_POINT *point,
|
||||
BIGNUM *x, BIGNUM *y,
|
||||
BN_CTX *ctx);
|
||||
|
||||
// EC_POINT_set_affine_coordinates_GFp sets the value of |point| to be
|
||||
// (|x|, |y|). The |ctx| argument may be used if not NULL. It returns one
|
||||
// on success or zero on error. It's considered an error if the point is not on
|
||||
@@ -237,6 +244,14 @@ OPENSSL_EXPORT int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
|
||||
const BIGNUM *y,
|
||||
BN_CTX *ctx);
|
||||
|
||||
// EC_POINT_set_affine_coordinates is an alias of
|
||||
// |EC_POINT_set_affine_coordinates_GFp|.
|
||||
OPENSSL_EXPORT int EC_POINT_set_affine_coordinates(const EC_GROUP *group,
|
||||
EC_POINT *point,
|
||||
const BIGNUM *x,
|
||||
const BIGNUM *y,
|
||||
BN_CTX *ctx);
|
||||
|
||||
// EC_POINT_point2oct serialises |point| into the X9.62 form given by |form|
|
||||
// into, at most, |len| bytes at |buf|. It returns the number of bytes written
|
||||
// or zero on error if |buf| is non-NULL, else the number of bytes needed. The
|
||||
@@ -328,11 +343,14 @@ OPENSSL_EXPORT int EC_GROUP_set_generator(EC_GROUP *group,
|
||||
OPENSSL_EXPORT int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order,
|
||||
BN_CTX *ctx);
|
||||
|
||||
#define OPENSSL_EC_EXPLICIT_CURVE 0
|
||||
#define OPENSSL_EC_NAMED_CURVE 1
|
||||
|
||||
// EC_GROUP_set_asn1_flag does nothing.
|
||||
OPENSSL_EXPORT void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
|
||||
|
||||
#define OPENSSL_EC_NAMED_CURVE 0
|
||||
#define OPENSSL_EC_EXPLICIT_CURVE 1
|
||||
// EC_GROUP_get_asn1_flag returns |OPENSSL_EC_NAMED_CURVE|.
|
||||
OPENSSL_EXPORT int EC_GROUP_get_asn1_flag(const EC_GROUP *group);
|
||||
|
||||
typedef struct ec_method_st EC_METHOD;
|
||||
|
||||
|
||||
@@ -162,6 +162,25 @@ OPENSSL_EXPORT int ECDSA_SIG_to_bytes(uint8_t **out_bytes, size_t *out_len,
|
||||
OPENSSL_EXPORT size_t ECDSA_SIG_max_len(size_t order_len);
|
||||
|
||||
|
||||
// Testing-only functions.
|
||||
|
||||
// ECDSA_sign_with_nonce_and_leak_private_key_for_testing behaves like
|
||||
// |ECDSA_do_sign| but uses |nonce| for the ECDSA nonce 'k', instead of a random
|
||||
// value. |nonce| is interpreted as a big-endian integer. It must be reduced
|
||||
// modulo the group order and padded with zeros up to |BN_num_bytes(order)|
|
||||
// bytes.
|
||||
//
|
||||
// WARNING: This function is only exported for testing purposes, when using test
|
||||
// vectors or fuzzing strategies. It must not be used outside tests and may leak
|
||||
// any private keys it is used with.
|
||||
OPENSSL_EXPORT ECDSA_SIG *
|
||||
ECDSA_sign_with_nonce_and_leak_private_key_for_testing(const uint8_t *digest,
|
||||
size_t digest_len,
|
||||
const EC_KEY *eckey,
|
||||
const uint8_t *nonce,
|
||||
size_t nonce_len);
|
||||
|
||||
|
||||
// Deprecated functions.
|
||||
|
||||
// d2i_ECDSA_SIG parses an ASN.1, DER-encoded, signature from |len| bytes at
|
||||
|
||||
@@ -101,6 +101,7 @@ typedef struct {
|
||||
typedef void PKCS7_ENVELOPE;
|
||||
typedef void PKCS7_DIGEST;
|
||||
typedef void PKCS7_ENCRYPT;
|
||||
typedef void PKCS7_SIGNER_INFO;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *ber_bytes;
|
||||
@@ -183,6 +184,7 @@ OPENSSL_EXPORT int PKCS7_type_is_signedAndEnveloped(const PKCS7 *p7);
|
||||
#define PKCS7_NOATTR 0x100
|
||||
#define PKCS7_NOSMIMECAP 0x200
|
||||
#define PKCS7_STREAM 0x1000
|
||||
#define PKCS7_PARTIAL 0x4000
|
||||
|
||||
// PKCS7_sign assembles |certs| into a PKCS#7 signed data ContentInfo with
|
||||
// external data and no signatures. It returns a newly-allocated |PKCS7| on
|
||||
|
||||
@@ -175,7 +175,9 @@ OPENSSL_EXPORT int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12);
|
||||
//
|
||||
// Note if |p12| does not contain a private key, both |*out_pkey| and
|
||||
// |*out_cert| will be set to NULL and all certificates will be returned via
|
||||
// |*out_ca_certs|.
|
||||
// |*out_ca_certs|. Also note this function differs from OpenSSL in that extra
|
||||
// certificates are returned in the order they appear in the file. OpenSSL 1.1.1
|
||||
// returns them in reverse order, but this will be fixed in OpenSSL 3.0.
|
||||
//
|
||||
// It returns one on success and zero on error.
|
||||
//
|
||||
@@ -206,6 +208,12 @@ OPENSSL_EXPORT int PKCS12_verify_mac(const PKCS12 *p12, const char *password,
|
||||
// Each of |key_nid|, |cert_nid|, |iterations|, and |mac_iterations| may be zero
|
||||
// to use defaults, which are |NID_pbe_WithSHA1And3_Key_TripleDES_CBC|,
|
||||
// |NID_pbe_WithSHA1And40BitRC2_CBC|, 2048, and one, respectively.
|
||||
//
|
||||
// |key_nid| or |cert_nid| may also be -1 to disable encryption of the key or
|
||||
// certificate, respectively. This option is not recommended and is only
|
||||
// implemented for compatibility with external packages. Note the output still
|
||||
// requires a password for the MAC. Unencrypted keys in PKCS#12 are also not
|
||||
// widely supported and may not open in other implementations.
|
||||
OPENSSL_EXPORT PKCS12 *PKCS12_create(const char *password, const char *name,
|
||||
const EVP_PKEY *pkey, X509 *cert,
|
||||
const STACK_OF(X509) *chain, int key_nid,
|
||||
|
||||
@@ -97,11 +97,14 @@ struct rand_meth_st {
|
||||
// RAND_SSLeay returns a pointer to a dummy |RAND_METHOD|.
|
||||
OPENSSL_EXPORT RAND_METHOD *RAND_SSLeay(void);
|
||||
|
||||
// RAND_OpenSSL returns a pointer to a dummy |RAND_METHOD|.
|
||||
OPENSSL_EXPORT RAND_METHOD *RAND_OpenSSL(void);
|
||||
|
||||
// RAND_get_rand_method returns |RAND_SSLeay()|.
|
||||
OPENSSL_EXPORT const RAND_METHOD *RAND_get_rand_method(void);
|
||||
|
||||
// RAND_set_rand_method does nothing.
|
||||
OPENSSL_EXPORT void RAND_set_rand_method(const RAND_METHOD *);
|
||||
// RAND_set_rand_method returns one.
|
||||
OPENSSL_EXPORT int RAND_set_rand_method(const RAND_METHOD *);
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
|
||||
extern "C++" {
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
|
||||
BSSL_NAMESPACE_BEGIN
|
||||
|
||||
@@ -115,11 +115,6 @@ DECLARE_ASN1_SET_OF(X509_ALGOR)
|
||||
|
||||
typedef STACK_OF(X509_ALGOR) X509_ALGORS;
|
||||
|
||||
struct X509_val_st {
|
||||
ASN1_TIME *notBefore;
|
||||
ASN1_TIME *notAfter;
|
||||
} /* X509_VAL */;
|
||||
|
||||
struct X509_pubkey_st {
|
||||
X509_ALGOR *algor;
|
||||
ASN1_BIT_STRING *public_key;
|
||||
@@ -475,16 +470,34 @@ extern "C" {
|
||||
// it is safe to call mutating functions is a little tricky due to various
|
||||
// internal caches.
|
||||
|
||||
// X509_get_version returns the numerical value of |x509|'s version. That is,
|
||||
// it returns zero for X.509v1, one for X.509v2, and two for X.509v3. Unknown
|
||||
// versions are rejected by the parser, but a manually-created |X509| object may
|
||||
// encode invalid versions. In that case, the function will return the invalid
|
||||
// version, or -1 on overflow.
|
||||
// The following constants are version numbers of X.509-related structures. Note
|
||||
// APIs typically return the numerical value of X.509 versions, which are one
|
||||
// less than the named version.
|
||||
#define X509V1_VERSION 0
|
||||
#define X509V2_VERSION 1
|
||||
#define X509V3_VERSION 2
|
||||
|
||||
// X509_get_version returns the numerical value of |x509|'s version. Callers may
|
||||
// compare the result to the |X509V*_VERSION| constants. Unknown versions are
|
||||
// rejected by the parser, but a manually-created |X509| object may encode
|
||||
// invalid versions. In that case, the function will return the invalid version,
|
||||
// or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_get_version(const X509 *x509);
|
||||
|
||||
// X509_set_version sets |x509|'s version to |version|, which should be one of
|
||||
// the |X509V*_VERSION| constants. It returns one on success and zero on error.
|
||||
//
|
||||
// If unsure, use |X509V3_VERSION|.
|
||||
OPENSSL_EXPORT int X509_set_version(X509 *x509, long version);
|
||||
|
||||
// X509_get0_serialNumber returns |x509|'s serial number.
|
||||
OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x509);
|
||||
|
||||
// X509_set_serialNumber sets |x509|'s serial number to |serial|. It returns one
|
||||
// on success and zero on error.
|
||||
OPENSSL_EXPORT int X509_set_serialNumber(X509 *x509,
|
||||
const ASN1_INTEGER *serial);
|
||||
|
||||
// X509_get0_notBefore returns |x509|'s notBefore time.
|
||||
OPENSSL_EXPORT const ASN1_TIME *X509_get0_notBefore(const X509 *x509);
|
||||
|
||||
@@ -550,9 +563,9 @@ OPENSSL_EXPORT X509_CINF *X509_get_cert_info(const X509 *x509);
|
||||
// |EXFLAG_INVALID| bit.
|
||||
OPENSSL_EXPORT long X509_get_pathlen(X509 *x509);
|
||||
|
||||
// X509_REQ_get_version returns the numerical value of |req|'s version. That is,
|
||||
// it returns zero for a v1 request. If |req| is invalid, it may return another
|
||||
// value, or -1 on overflow.
|
||||
// X509_REQ_get_version returns the numerical value of |req|'s version. Callers
|
||||
// may compare the result to |X509V*_VERSION| constants. If |req| is invalid, it
|
||||
// may return another value, or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_REQ_get_version(const X509_REQ *req);
|
||||
|
||||
// X509_REQ_get_subject_name returns |req|'s subject name. Note this function is
|
||||
@@ -565,9 +578,9 @@ OPENSSL_EXPORT X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
|
||||
// X509_name_cmp is a legacy alias for |X509_NAME_cmp|.
|
||||
#define X509_name_cmp(a, b) X509_NAME_cmp((a), (b))
|
||||
|
||||
// X509_REQ_get_version returns the numerical value of |crl|'s version. That is,
|
||||
// it returns zero for a v1 CRL and one for a v2 CRL. If |crl| is invalid, it
|
||||
// may return another value, or -1 on overflow.
|
||||
// X509_CRL_get_version returns the numerical value of |crl|'s version. Callers
|
||||
// may compare the result to |X509V*_VERSION| constants. If |crl| is invalid,
|
||||
// it may return another value, or -1 on overflow.
|
||||
OPENSSL_EXPORT long X509_CRL_get_version(const X509_CRL *crl);
|
||||
|
||||
// X509_CRL_get0_lastUpdate returns |crl|'s lastUpdate time.
|
||||
@@ -923,7 +936,6 @@ OPENSSL_EXPORT const char *X509_get_default_private_dir(void);
|
||||
|
||||
OPENSSL_EXPORT X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey,
|
||||
const EVP_MD *md);
|
||||
OPENSSL_EXPORT X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
|
||||
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
|
||||
DECLARE_ASN1_FUNCTIONS(X509_VAL)
|
||||
@@ -955,8 +967,8 @@ DECLARE_ASN1_FUNCTIONS(X509_CINF)
|
||||
DECLARE_ASN1_FUNCTIONS(X509)
|
||||
DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
|
||||
|
||||
// X509_up_ref adds one to the reference count of |x| and returns one.
|
||||
OPENSSL_EXPORT int X509_up_ref(X509 *x);
|
||||
// X509_up_ref adds one to the reference count of |x509| and returns one.
|
||||
OPENSSL_EXPORT int X509_up_ref(X509 *x509);
|
||||
|
||||
OPENSSL_EXPORT int X509_get_ex_new_index(long argl, void *argp,
|
||||
CRYPTO_EX_unused *unused,
|
||||
@@ -1014,9 +1026,22 @@ OPENSSL_EXPORT int X509_set1_signature_algo(X509 *x509, const X509_ALGOR *algo);
|
||||
OPENSSL_EXPORT int X509_set1_signature_value(X509 *x509, const uint8_t *sig,
|
||||
size_t sig_len);
|
||||
|
||||
OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg, const X509 *x);
|
||||
OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x);
|
||||
// X509_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |x509|, respectively. Either output pointer may be
|
||||
// NULL to ignore the value.
|
||||
//
|
||||
// This function outputs the outer signature algorithm. For the one in the
|
||||
// TBSCertificate, see |X509_get0_tbs_sigalg|. Certificates with mismatched
|
||||
// signature algorithms will successfully parse, but they will be rejected when
|
||||
// verifying.
|
||||
OPENSSL_EXPORT void X509_get0_signature(const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg,
|
||||
const X509 *x509);
|
||||
|
||||
// X509_get_signature_nid returns the NID corresponding to |x509|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x509);
|
||||
|
||||
OPENSSL_EXPORT int X509_alias_set1(X509 *x, const unsigned char *name, int len);
|
||||
OPENSSL_EXPORT int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
|
||||
@@ -1071,8 +1096,6 @@ OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
|
||||
ASN1_BIT_STRING *signature, void *asn,
|
||||
EVP_MD_CTX *ctx);
|
||||
|
||||
OPENSSL_EXPORT int X509_set_version(X509 *x, long version);
|
||||
OPENSSL_EXPORT int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
|
||||
OPENSSL_EXPORT ASN1_INTEGER *X509_get_serialNumber(X509 *x);
|
||||
OPENSSL_EXPORT int X509_set_issuer_name(X509 *x, X509_NAME *name);
|
||||
OPENSSL_EXPORT X509_NAME *X509_get_issuer_name(const X509 *a);
|
||||
@@ -1083,14 +1106,33 @@ OPENSSL_EXPORT EVP_PKEY *X509_get_pubkey(X509 *x);
|
||||
OPENSSL_EXPORT ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
|
||||
OPENSSL_EXPORT const STACK_OF(X509_EXTENSION) *X509_get0_extensions(
|
||||
const X509 *x);
|
||||
OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
|
||||
|
||||
OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *x, long version);
|
||||
// X509_get0_tbs_sigalg returns the signature algorithm in |x509|'s
|
||||
// TBSCertificate. For the outer signature algorithm, see |X509_get0_signature|.
|
||||
//
|
||||
// Certificates with mismatched signature algorithms will successfully parse,
|
||||
// but they will be rejected when verifying.
|
||||
OPENSSL_EXPORT const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x509);
|
||||
|
||||
// X509_REQ_set_version sets |req|'s version to |version|, which should be
|
||||
// |X509V1_VERSION|. It returns one on success and zero on error.
|
||||
//
|
||||
// Note no versions other than |X509V1_VERSION| are defined for CSRs.
|
||||
OPENSSL_EXPORT int X509_REQ_set_version(X509_REQ *req, long version);
|
||||
OPENSSL_EXPORT int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
|
||||
|
||||
// X509_REQ_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |req|, respectively. Either output pointer may be NULL
|
||||
// to ignore the value.
|
||||
OPENSSL_EXPORT void X509_REQ_get0_signature(const X509_REQ *req,
|
||||
const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg);
|
||||
const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg);
|
||||
|
||||
// X509_REQ_get_signature_nid returns the NID corresponding to |req|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_REQ_get_signature_nid(const X509_REQ *req);
|
||||
|
||||
OPENSSL_EXPORT int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
|
||||
OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
|
||||
OPENSSL_EXPORT EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
|
||||
@@ -1123,14 +1165,33 @@ OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
|
||||
const unsigned char *bytes,
|
||||
int len);
|
||||
|
||||
OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *x, long version);
|
||||
// X509_CRL_set_version sets |crl|'s version to |version|, which should be one
|
||||
// of the |X509V*_VERSION| constants. It returns one on success and zero on
|
||||
// error.
|
||||
//
|
||||
// If unsure, use |X509V2_VERSION|. Note |X509V3_VERSION| is not defined for
|
||||
// CRLs.
|
||||
OPENSSL_EXPORT int X509_CRL_set_version(X509_CRL *crl, long version);
|
||||
OPENSSL_EXPORT int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
|
||||
OPENSSL_EXPORT int X509_CRL_sort(X509_CRL *crl);
|
||||
|
||||
// X509_CRL_up_ref adds one to the reference count of |crl| and returns one.
|
||||
OPENSSL_EXPORT int X509_CRL_up_ref(X509_CRL *crl);
|
||||
|
||||
// X509_CRL_get0_signature sets |*out_sig| and |*out_alg| to the signature and
|
||||
// signature algorithm of |crl|, respectively. Either output pointer may be NULL
|
||||
// to ignore the value.
|
||||
//
|
||||
// This function outputs the outer signature algorithm, not the one in the
|
||||
// TBSCertList. CRLs with mismatched signature algorithms will successfully
|
||||
// parse, but they will be rejected when verifying.
|
||||
OPENSSL_EXPORT void X509_CRL_get0_signature(const X509_CRL *crl,
|
||||
const ASN1_BIT_STRING **psig,
|
||||
const X509_ALGOR **palg);
|
||||
const ASN1_BIT_STRING **out_sig,
|
||||
const X509_ALGOR **out_alg);
|
||||
|
||||
// X509_CRL_get_signature_nid returns the NID corresponding to |crl|'s signature
|
||||
// algorithm, or |NID_undef| if the signature algorithm does not correspond to
|
||||
// a known NID.
|
||||
OPENSSL_EXPORT int X509_CRL_get_signature_nid(const X509_CRL *crl);
|
||||
|
||||
// i2d_re_X509_CRL_tbs serializes the TBSCertList portion of |crl|. If |outp| is
|
||||
@@ -1198,10 +1259,14 @@ OPENSSL_EXPORT int X509_chain_check_suiteb(int *perror_depth, X509 *x,
|
||||
unsigned long flags);
|
||||
OPENSSL_EXPORT int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk,
|
||||
unsigned long flags);
|
||||
|
||||
// X509_chain_up_ref returns a newly-allocated |STACK_OF(X509)| containing a
|
||||
// shallow copy of |chain|, or NULL on error. That is, the return value has the
|
||||
// same contents as |chain|, and each |X509|'s reference count is incremented by
|
||||
// one.
|
||||
OPENSSL_EXPORT STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
|
||||
|
||||
OPENSSL_EXPORT int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
|
||||
OPENSSL_EXPORT unsigned long X509_issuer_and_serial_hash(X509 *a);
|
||||
|
||||
OPENSSL_EXPORT int X509_issuer_name_cmp(const X509 *a, const X509 *b);
|
||||
OPENSSL_EXPORT unsigned long X509_issuer_name_hash(X509 *a);
|
||||
|
||||
@@ -474,7 +474,12 @@ DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
|
||||
OPENSSL_EXPORT GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
|
||||
OPENSSL_EXPORT int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);
|
||||
|
||||
// GENERAL_NAME_cmp returns zero if |a| and |b| are equal and a non-zero
|
||||
// value otherwise. Note this function does not provide a comparison suitable
|
||||
// for sorting.
|
||||
OPENSSL_EXPORT int GENERAL_NAME_cmp(const GENERAL_NAME *a,
|
||||
const GENERAL_NAME *b);
|
||||
|
||||
|
||||
|
||||
@@ -905,6 +910,8 @@ BORINGSSL_MAKE_DELETER(AUTHORITY_KEYID, AUTHORITY_KEYID_free)
|
||||
BORINGSSL_MAKE_DELETER(BASIC_CONSTRAINTS, BASIC_CONSTRAINTS_free)
|
||||
BORINGSSL_MAKE_DELETER(DIST_POINT, DIST_POINT_free)
|
||||
BORINGSSL_MAKE_DELETER(GENERAL_NAME, GENERAL_NAME_free)
|
||||
BORINGSSL_MAKE_DELETER(NAME_CONSTRAINTS, NAME_CONSTRAINTS_free)
|
||||
BORINGSSL_MAKE_DELETER(POLICY_MAPPING, POLICY_MAPPING_free)
|
||||
BORINGSSL_MAKE_DELETER(POLICYINFO, POLICYINFO_free)
|
||||
|
||||
BSSL_NAMESPACE_END
|
||||
|
||||
@@ -297,6 +297,10 @@
|
||||
%xdefine _BIO_write _ %+ BORINGSSL_PREFIX %+ _BIO_write
|
||||
%xdefine _BIO_write_all _ %+ BORINGSSL_PREFIX %+ _BIO_write_all
|
||||
%xdefine _BIO_write_filename _ %+ BORINGSSL_PREFIX %+ _BIO_write_filename
|
||||
%xdefine _BLAKE2B256 _ %+ BORINGSSL_PREFIX %+ _BLAKE2B256
|
||||
%xdefine _BLAKE2B256_Final _ %+ BORINGSSL_PREFIX %+ _BLAKE2B256_Final
|
||||
%xdefine _BLAKE2B256_Init _ %+ BORINGSSL_PREFIX %+ _BLAKE2B256_Init
|
||||
%xdefine _BLAKE2B256_Update _ %+ BORINGSSL_PREFIX %+ _BLAKE2B256_Update
|
||||
%xdefine _BN_BLINDING_convert _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_convert
|
||||
%xdefine _BN_BLINDING_free _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_free
|
||||
%xdefine _BN_BLINDING_invalidate _ %+ BORINGSSL_PREFIX %+ _BN_BLINDING_invalidate
|
||||
@@ -589,8 +593,8 @@
|
||||
%xdefine _CRYPTO_has_asm _ %+ BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine _CRYPTO_hchacha20 _ %+ BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine _CRYPTO_init_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine _CRYPTO_is_ARMv8_AES_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine _CRYPTO_is_ARMv8_PMULL_capable _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine _CRYPTO_is_ARMv8_AES_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_ARMv8_PMULL_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_NEON_capable_at_runtime _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
%xdefine _CRYPTO_is_confidential_build _ %+ BORINGSSL_PREFIX %+ _CRYPTO_is_confidential_build
|
||||
%xdefine _CRYPTO_library_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_library_init
|
||||
@@ -637,6 +641,8 @@
|
||||
%xdefine _DH_check _ %+ BORINGSSL_PREFIX %+ _DH_check
|
||||
%xdefine _DH_check_pub_key _ %+ BORINGSSL_PREFIX %+ _DH_check_pub_key
|
||||
%xdefine _DH_compute_key _ %+ BORINGSSL_PREFIX %+ _DH_compute_key
|
||||
%xdefine _DH_compute_key_hashed _ %+ BORINGSSL_PREFIX %+ _DH_compute_key_hashed
|
||||
%xdefine _DH_compute_key_padded _ %+ BORINGSSL_PREFIX %+ _DH_compute_key_padded
|
||||
%xdefine _DH_free _ %+ BORINGSSL_PREFIX %+ _DH_free
|
||||
%xdefine _DH_generate_key _ %+ BORINGSSL_PREFIX %+ _DH_generate_key
|
||||
%xdefine _DH_generate_parameters_ex _ %+ BORINGSSL_PREFIX %+ _DH_generate_parameters_ex
|
||||
@@ -647,15 +653,13 @@
|
||||
%xdefine _DH_get0_priv_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine _DH_get0_pub_key _ %+ BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine _DH_get0_q _ %+ BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine _DH_get_ex_data _ %+ BORINGSSL_PREFIX %+ _DH_get_ex_data
|
||||
%xdefine _DH_get_ex_new_index _ %+ BORINGSSL_PREFIX %+ _DH_get_ex_new_index
|
||||
%xdefine _DH_get_rfc7919_2048 _ %+ BORINGSSL_PREFIX %+ _DH_get_rfc7919_2048
|
||||
%xdefine _DH_marshal_parameters _ %+ BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
%xdefine _DH_new _ %+ BORINGSSL_PREFIX %+ _DH_new
|
||||
%xdefine _DH_num_bits _ %+ BORINGSSL_PREFIX %+ _DH_num_bits
|
||||
%xdefine _DH_parse_parameters _ %+ BORINGSSL_PREFIX %+ _DH_parse_parameters
|
||||
%xdefine _DH_set0_key _ %+ BORINGSSL_PREFIX %+ _DH_set0_key
|
||||
%xdefine _DH_set0_pqg _ %+ BORINGSSL_PREFIX %+ _DH_set0_pqg
|
||||
%xdefine _DH_set_ex_data _ %+ BORINGSSL_PREFIX %+ _DH_set_ex_data
|
||||
%xdefine _DH_set_length _ %+ BORINGSSL_PREFIX %+ _DH_set_length
|
||||
%xdefine _DH_size _ %+ BORINGSSL_PREFIX %+ _DH_size
|
||||
%xdefine _DH_up_ref _ %+ BORINGSSL_PREFIX %+ _DH_up_ref
|
||||
@@ -725,6 +729,7 @@
|
||||
%xdefine _ECDSA_do_sign _ %+ BORINGSSL_PREFIX %+ _ECDSA_do_sign
|
||||
%xdefine _ECDSA_do_verify _ %+ BORINGSSL_PREFIX %+ _ECDSA_do_verify
|
||||
%xdefine _ECDSA_sign _ %+ BORINGSSL_PREFIX %+ _ECDSA_sign
|
||||
%xdefine _ECDSA_sign_with_nonce_and_leak_private_key_for_testing _ %+ BORINGSSL_PREFIX %+ _ECDSA_sign_with_nonce_and_leak_private_key_for_testing
|
||||
%xdefine _ECDSA_size _ %+ BORINGSSL_PREFIX %+ _ECDSA_size
|
||||
%xdefine _ECDSA_verify _ %+ BORINGSSL_PREFIX %+ _ECDSA_verify
|
||||
%xdefine _EC_GFp_mont_method _ %+ BORINGSSL_PREFIX %+ _EC_GFp_mont_method
|
||||
@@ -736,6 +741,7 @@
|
||||
%xdefine _EC_GROUP_free _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_free
|
||||
%xdefine _EC_GROUP_get0_generator _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get0_generator
|
||||
%xdefine _EC_GROUP_get0_order _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get0_order
|
||||
%xdefine _EC_GROUP_get_asn1_flag _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_asn1_flag
|
||||
%xdefine _EC_GROUP_get_cofactor _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_cofactor
|
||||
%xdefine _EC_GROUP_get_curve_GFp _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_GFp
|
||||
%xdefine _EC_GROUP_get_curve_name _ %+ BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_name
|
||||
@@ -789,6 +795,7 @@
|
||||
%xdefine _EC_POINT_dbl _ %+ BORINGSSL_PREFIX %+ _EC_POINT_dbl
|
||||
%xdefine _EC_POINT_dup _ %+ BORINGSSL_PREFIX %+ _EC_POINT_dup
|
||||
%xdefine _EC_POINT_free _ %+ BORINGSSL_PREFIX %+ _EC_POINT_free
|
||||
%xdefine _EC_POINT_get_affine_coordinates _ %+ BORINGSSL_PREFIX %+ _EC_POINT_get_affine_coordinates
|
||||
%xdefine _EC_POINT_get_affine_coordinates_GFp _ %+ BORINGSSL_PREFIX %+ _EC_POINT_get_affine_coordinates_GFp
|
||||
%xdefine _EC_POINT_invert _ %+ BORINGSSL_PREFIX %+ _EC_POINT_invert
|
||||
%xdefine _EC_POINT_is_at_infinity _ %+ BORINGSSL_PREFIX %+ _EC_POINT_is_at_infinity
|
||||
@@ -798,6 +805,7 @@
|
||||
%xdefine _EC_POINT_oct2point _ %+ BORINGSSL_PREFIX %+ _EC_POINT_oct2point
|
||||
%xdefine _EC_POINT_point2cbb _ %+ BORINGSSL_PREFIX %+ _EC_POINT_point2cbb
|
||||
%xdefine _EC_POINT_point2oct _ %+ BORINGSSL_PREFIX %+ _EC_POINT_point2oct
|
||||
%xdefine _EC_POINT_set_affine_coordinates _ %+ BORINGSSL_PREFIX %+ _EC_POINT_set_affine_coordinates
|
||||
%xdefine _EC_POINT_set_affine_coordinates_GFp _ %+ BORINGSSL_PREFIX %+ _EC_POINT_set_affine_coordinates_GFp
|
||||
%xdefine _EC_POINT_set_compressed_coordinates_GFp _ %+ BORINGSSL_PREFIX %+ _EC_POINT_set_compressed_coordinates_GFp
|
||||
%xdefine _EC_POINT_set_to_infinity _ %+ BORINGSSL_PREFIX %+ _EC_POINT_set_to_infinity
|
||||
@@ -949,6 +957,8 @@
|
||||
%xdefine _EVP_HPKE_CTX_setup_psk_r_x25519 _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_r_x25519
|
||||
%xdefine _EVP_HPKE_CTX_setup_psk_s_x25519 _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_s_x25519
|
||||
%xdefine _EVP_HPKE_CTX_setup_psk_s_x25519_for_test _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_s_x25519_for_test
|
||||
%xdefine _EVP_HPKE_get_aead _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_get_aead
|
||||
%xdefine _EVP_HPKE_get_hkdf_md _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_get_hkdf_md
|
||||
%xdefine _EVP_MD_CTX_block_size _ %+ BORINGSSL_PREFIX %+ _EVP_MD_CTX_block_size
|
||||
%xdefine _EVP_MD_CTX_cleanup _ %+ BORINGSSL_PREFIX %+ _EVP_MD_CTX_cleanup
|
||||
%xdefine _EVP_MD_CTX_copy _ %+ BORINGSSL_PREFIX %+ _EVP_MD_CTX_copy
|
||||
@@ -1103,6 +1113,7 @@
|
||||
%xdefine _EVP_aes_256_ecb _ %+ BORINGSSL_PREFIX %+ _EVP_aes_256_ecb
|
||||
%xdefine _EVP_aes_256_gcm _ %+ BORINGSSL_PREFIX %+ _EVP_aes_256_gcm
|
||||
%xdefine _EVP_aes_256_ofb _ %+ BORINGSSL_PREFIX %+ _EVP_aes_256_ofb
|
||||
%xdefine _EVP_blake2b256 _ %+ BORINGSSL_PREFIX %+ _EVP_blake2b256
|
||||
%xdefine _EVP_cleanup _ %+ BORINGSSL_PREFIX %+ _EVP_cleanup
|
||||
%xdefine _EVP_des_cbc _ %+ BORINGSSL_PREFIX %+ _EVP_des_cbc
|
||||
%xdefine _EVP_des_ecb _ %+ BORINGSSL_PREFIX %+ _EVP_des_ecb
|
||||
@@ -1430,6 +1441,7 @@
|
||||
%xdefine _PROXY_POLICY_free _ %+ BORINGSSL_PREFIX %+ _PROXY_POLICY_free
|
||||
%xdefine _PROXY_POLICY_it _ %+ BORINGSSL_PREFIX %+ _PROXY_POLICY_it
|
||||
%xdefine _PROXY_POLICY_new _ %+ BORINGSSL_PREFIX %+ _PROXY_POLICY_new
|
||||
%xdefine _RAND_OpenSSL _ %+ BORINGSSL_PREFIX %+ _RAND_OpenSSL
|
||||
%xdefine _RAND_SSLeay _ %+ BORINGSSL_PREFIX %+ _RAND_SSLeay
|
||||
%xdefine _RAND_add _ %+ BORINGSSL_PREFIX %+ _RAND_add
|
||||
%xdefine _RAND_bytes _ %+ BORINGSSL_PREFIX %+ _RAND_bytes
|
||||
@@ -1835,7 +1847,6 @@
|
||||
%xdefine _X509_REQ_set_version _ %+ BORINGSSL_PREFIX %+ _X509_REQ_set_version
|
||||
%xdefine _X509_REQ_sign _ %+ BORINGSSL_PREFIX %+ _X509_REQ_sign
|
||||
%xdefine _X509_REQ_sign_ctx _ %+ BORINGSSL_PREFIX %+ _X509_REQ_sign_ctx
|
||||
%xdefine _X509_REQ_to_X509 _ %+ BORINGSSL_PREFIX %+ _X509_REQ_to_X509
|
||||
%xdefine _X509_REQ_verify _ %+ BORINGSSL_PREFIX %+ _X509_REQ_verify
|
||||
%xdefine _X509_REVOKED_add1_ext_i2d _ %+ BORINGSSL_PREFIX %+ _X509_REVOKED_add1_ext_i2d
|
||||
%xdefine _X509_REVOKED_add_ext _ %+ BORINGSSL_PREFIX %+ _X509_REVOKED_add_ext
|
||||
@@ -2054,7 +2065,6 @@
|
||||
%xdefine _X509_getm_notBefore _ %+ BORINGSSL_PREFIX %+ _X509_getm_notBefore
|
||||
%xdefine _X509_gmtime_adj _ %+ BORINGSSL_PREFIX %+ _X509_gmtime_adj
|
||||
%xdefine _X509_issuer_and_serial_cmp _ %+ BORINGSSL_PREFIX %+ _X509_issuer_and_serial_cmp
|
||||
%xdefine _X509_issuer_and_serial_hash _ %+ BORINGSSL_PREFIX %+ _X509_issuer_and_serial_hash
|
||||
%xdefine _X509_issuer_name_cmp _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_cmp
|
||||
%xdefine _X509_issuer_name_hash _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_hash
|
||||
%xdefine _X509_issuer_name_hash_old _ %+ BORINGSSL_PREFIX %+ _X509_issuer_name_hash_old
|
||||
@@ -2242,6 +2252,7 @@
|
||||
%xdefine _bn_scatter5 _ %+ BORINGSSL_PREFIX %+ _bn_scatter5
|
||||
%xdefine _bn_select_words _ %+ BORINGSSL_PREFIX %+ _bn_select_words
|
||||
%xdefine _bn_set_minimal_width _ %+ BORINGSSL_PREFIX %+ _bn_set_minimal_width
|
||||
%xdefine _bn_set_static_words _ %+ BORINGSSL_PREFIX %+ _bn_set_static_words
|
||||
%xdefine _bn_set_words _ %+ BORINGSSL_PREFIX %+ _bn_set_words
|
||||
%xdefine _bn_sqr8x_internal _ %+ BORINGSSL_PREFIX %+ _bn_sqr8x_internal
|
||||
%xdefine _bn_sqr_comba4 _ %+ BORINGSSL_PREFIX %+ _bn_sqr_comba4
|
||||
@@ -2478,6 +2489,7 @@
|
||||
%xdefine _ec_set_to_safe_point _ %+ BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine _ec_simple_scalar_inv0_montgomery _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine _ec_simple_scalar_to_montgomery_inv_vartime _ %+ BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine _ecdsa_sign_with_nonce_for_known_answer_test _ %+ BORINGSSL_PREFIX %+ _ecdsa_sign_with_nonce_for_known_answer_test
|
||||
%xdefine _ecp_nistz256_avx2_select_w7 _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine _ecp_nistz256_mul_mont _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine _ecp_nistz256_neg _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
@@ -3094,6 +3106,10 @@
|
||||
%xdefine BIO_write BORINGSSL_PREFIX %+ _BIO_write
|
||||
%xdefine BIO_write_all BORINGSSL_PREFIX %+ _BIO_write_all
|
||||
%xdefine BIO_write_filename BORINGSSL_PREFIX %+ _BIO_write_filename
|
||||
%xdefine BLAKE2B256 BORINGSSL_PREFIX %+ _BLAKE2B256
|
||||
%xdefine BLAKE2B256_Final BORINGSSL_PREFIX %+ _BLAKE2B256_Final
|
||||
%xdefine BLAKE2B256_Init BORINGSSL_PREFIX %+ _BLAKE2B256_Init
|
||||
%xdefine BLAKE2B256_Update BORINGSSL_PREFIX %+ _BLAKE2B256_Update
|
||||
%xdefine BN_BLINDING_convert BORINGSSL_PREFIX %+ _BN_BLINDING_convert
|
||||
%xdefine BN_BLINDING_free BORINGSSL_PREFIX %+ _BN_BLINDING_free
|
||||
%xdefine BN_BLINDING_invalidate BORINGSSL_PREFIX %+ _BN_BLINDING_invalidate
|
||||
@@ -3386,8 +3402,8 @@
|
||||
%xdefine CRYPTO_has_asm BORINGSSL_PREFIX %+ _CRYPTO_has_asm
|
||||
%xdefine CRYPTO_hchacha20 BORINGSSL_PREFIX %+ _CRYPTO_hchacha20
|
||||
%xdefine CRYPTO_init_sysrand BORINGSSL_PREFIX %+ _CRYPTO_init_sysrand
|
||||
%xdefine CRYPTO_is_ARMv8_AES_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable
|
||||
%xdefine CRYPTO_is_ARMv8_PMULL_capable BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable
|
||||
%xdefine CRYPTO_is_ARMv8_AES_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_AES_capable_at_runtime
|
||||
%xdefine CRYPTO_is_ARMv8_PMULL_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_ARMv8_PMULL_capable_at_runtime
|
||||
%xdefine CRYPTO_is_NEON_capable_at_runtime BORINGSSL_PREFIX %+ _CRYPTO_is_NEON_capable_at_runtime
|
||||
%xdefine CRYPTO_is_confidential_build BORINGSSL_PREFIX %+ _CRYPTO_is_confidential_build
|
||||
%xdefine CRYPTO_library_init BORINGSSL_PREFIX %+ _CRYPTO_library_init
|
||||
@@ -3434,6 +3450,8 @@
|
||||
%xdefine DH_check BORINGSSL_PREFIX %+ _DH_check
|
||||
%xdefine DH_check_pub_key BORINGSSL_PREFIX %+ _DH_check_pub_key
|
||||
%xdefine DH_compute_key BORINGSSL_PREFIX %+ _DH_compute_key
|
||||
%xdefine DH_compute_key_hashed BORINGSSL_PREFIX %+ _DH_compute_key_hashed
|
||||
%xdefine DH_compute_key_padded BORINGSSL_PREFIX %+ _DH_compute_key_padded
|
||||
%xdefine DH_free BORINGSSL_PREFIX %+ _DH_free
|
||||
%xdefine DH_generate_key BORINGSSL_PREFIX %+ _DH_generate_key
|
||||
%xdefine DH_generate_parameters_ex BORINGSSL_PREFIX %+ _DH_generate_parameters_ex
|
||||
@@ -3444,15 +3462,13 @@
|
||||
%xdefine DH_get0_priv_key BORINGSSL_PREFIX %+ _DH_get0_priv_key
|
||||
%xdefine DH_get0_pub_key BORINGSSL_PREFIX %+ _DH_get0_pub_key
|
||||
%xdefine DH_get0_q BORINGSSL_PREFIX %+ _DH_get0_q
|
||||
%xdefine DH_get_ex_data BORINGSSL_PREFIX %+ _DH_get_ex_data
|
||||
%xdefine DH_get_ex_new_index BORINGSSL_PREFIX %+ _DH_get_ex_new_index
|
||||
%xdefine DH_get_rfc7919_2048 BORINGSSL_PREFIX %+ _DH_get_rfc7919_2048
|
||||
%xdefine DH_marshal_parameters BORINGSSL_PREFIX %+ _DH_marshal_parameters
|
||||
%xdefine DH_new BORINGSSL_PREFIX %+ _DH_new
|
||||
%xdefine DH_num_bits BORINGSSL_PREFIX %+ _DH_num_bits
|
||||
%xdefine DH_parse_parameters BORINGSSL_PREFIX %+ _DH_parse_parameters
|
||||
%xdefine DH_set0_key BORINGSSL_PREFIX %+ _DH_set0_key
|
||||
%xdefine DH_set0_pqg BORINGSSL_PREFIX %+ _DH_set0_pqg
|
||||
%xdefine DH_set_ex_data BORINGSSL_PREFIX %+ _DH_set_ex_data
|
||||
%xdefine DH_set_length BORINGSSL_PREFIX %+ _DH_set_length
|
||||
%xdefine DH_size BORINGSSL_PREFIX %+ _DH_size
|
||||
%xdefine DH_up_ref BORINGSSL_PREFIX %+ _DH_up_ref
|
||||
@@ -3522,6 +3538,7 @@
|
||||
%xdefine ECDSA_do_sign BORINGSSL_PREFIX %+ _ECDSA_do_sign
|
||||
%xdefine ECDSA_do_verify BORINGSSL_PREFIX %+ _ECDSA_do_verify
|
||||
%xdefine ECDSA_sign BORINGSSL_PREFIX %+ _ECDSA_sign
|
||||
%xdefine ECDSA_sign_with_nonce_and_leak_private_key_for_testing BORINGSSL_PREFIX %+ _ECDSA_sign_with_nonce_and_leak_private_key_for_testing
|
||||
%xdefine ECDSA_size BORINGSSL_PREFIX %+ _ECDSA_size
|
||||
%xdefine ECDSA_verify BORINGSSL_PREFIX %+ _ECDSA_verify
|
||||
%xdefine EC_GFp_mont_method BORINGSSL_PREFIX %+ _EC_GFp_mont_method
|
||||
@@ -3533,6 +3550,7 @@
|
||||
%xdefine EC_GROUP_free BORINGSSL_PREFIX %+ _EC_GROUP_free
|
||||
%xdefine EC_GROUP_get0_generator BORINGSSL_PREFIX %+ _EC_GROUP_get0_generator
|
||||
%xdefine EC_GROUP_get0_order BORINGSSL_PREFIX %+ _EC_GROUP_get0_order
|
||||
%xdefine EC_GROUP_get_asn1_flag BORINGSSL_PREFIX %+ _EC_GROUP_get_asn1_flag
|
||||
%xdefine EC_GROUP_get_cofactor BORINGSSL_PREFIX %+ _EC_GROUP_get_cofactor
|
||||
%xdefine EC_GROUP_get_curve_GFp BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_GFp
|
||||
%xdefine EC_GROUP_get_curve_name BORINGSSL_PREFIX %+ _EC_GROUP_get_curve_name
|
||||
@@ -3586,6 +3604,7 @@
|
||||
%xdefine EC_POINT_dbl BORINGSSL_PREFIX %+ _EC_POINT_dbl
|
||||
%xdefine EC_POINT_dup BORINGSSL_PREFIX %+ _EC_POINT_dup
|
||||
%xdefine EC_POINT_free BORINGSSL_PREFIX %+ _EC_POINT_free
|
||||
%xdefine EC_POINT_get_affine_coordinates BORINGSSL_PREFIX %+ _EC_POINT_get_affine_coordinates
|
||||
%xdefine EC_POINT_get_affine_coordinates_GFp BORINGSSL_PREFIX %+ _EC_POINT_get_affine_coordinates_GFp
|
||||
%xdefine EC_POINT_invert BORINGSSL_PREFIX %+ _EC_POINT_invert
|
||||
%xdefine EC_POINT_is_at_infinity BORINGSSL_PREFIX %+ _EC_POINT_is_at_infinity
|
||||
@@ -3595,6 +3614,7 @@
|
||||
%xdefine EC_POINT_oct2point BORINGSSL_PREFIX %+ _EC_POINT_oct2point
|
||||
%xdefine EC_POINT_point2cbb BORINGSSL_PREFIX %+ _EC_POINT_point2cbb
|
||||
%xdefine EC_POINT_point2oct BORINGSSL_PREFIX %+ _EC_POINT_point2oct
|
||||
%xdefine EC_POINT_set_affine_coordinates BORINGSSL_PREFIX %+ _EC_POINT_set_affine_coordinates
|
||||
%xdefine EC_POINT_set_affine_coordinates_GFp BORINGSSL_PREFIX %+ _EC_POINT_set_affine_coordinates_GFp
|
||||
%xdefine EC_POINT_set_compressed_coordinates_GFp BORINGSSL_PREFIX %+ _EC_POINT_set_compressed_coordinates_GFp
|
||||
%xdefine EC_POINT_set_to_infinity BORINGSSL_PREFIX %+ _EC_POINT_set_to_infinity
|
||||
@@ -3746,6 +3766,8 @@
|
||||
%xdefine EVP_HPKE_CTX_setup_psk_r_x25519 BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_r_x25519
|
||||
%xdefine EVP_HPKE_CTX_setup_psk_s_x25519 BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_s_x25519
|
||||
%xdefine EVP_HPKE_CTX_setup_psk_s_x25519_for_test BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_psk_s_x25519_for_test
|
||||
%xdefine EVP_HPKE_get_aead BORINGSSL_PREFIX %+ _EVP_HPKE_get_aead
|
||||
%xdefine EVP_HPKE_get_hkdf_md BORINGSSL_PREFIX %+ _EVP_HPKE_get_hkdf_md
|
||||
%xdefine EVP_MD_CTX_block_size BORINGSSL_PREFIX %+ _EVP_MD_CTX_block_size
|
||||
%xdefine EVP_MD_CTX_cleanup BORINGSSL_PREFIX %+ _EVP_MD_CTX_cleanup
|
||||
%xdefine EVP_MD_CTX_copy BORINGSSL_PREFIX %+ _EVP_MD_CTX_copy
|
||||
@@ -3900,6 +3922,7 @@
|
||||
%xdefine EVP_aes_256_ecb BORINGSSL_PREFIX %+ _EVP_aes_256_ecb
|
||||
%xdefine EVP_aes_256_gcm BORINGSSL_PREFIX %+ _EVP_aes_256_gcm
|
||||
%xdefine EVP_aes_256_ofb BORINGSSL_PREFIX %+ _EVP_aes_256_ofb
|
||||
%xdefine EVP_blake2b256 BORINGSSL_PREFIX %+ _EVP_blake2b256
|
||||
%xdefine EVP_cleanup BORINGSSL_PREFIX %+ _EVP_cleanup
|
||||
%xdefine EVP_des_cbc BORINGSSL_PREFIX %+ _EVP_des_cbc
|
||||
%xdefine EVP_des_ecb BORINGSSL_PREFIX %+ _EVP_des_ecb
|
||||
@@ -4227,6 +4250,7 @@
|
||||
%xdefine PROXY_POLICY_free BORINGSSL_PREFIX %+ _PROXY_POLICY_free
|
||||
%xdefine PROXY_POLICY_it BORINGSSL_PREFIX %+ _PROXY_POLICY_it
|
||||
%xdefine PROXY_POLICY_new BORINGSSL_PREFIX %+ _PROXY_POLICY_new
|
||||
%xdefine RAND_OpenSSL BORINGSSL_PREFIX %+ _RAND_OpenSSL
|
||||
%xdefine RAND_SSLeay BORINGSSL_PREFIX %+ _RAND_SSLeay
|
||||
%xdefine RAND_add BORINGSSL_PREFIX %+ _RAND_add
|
||||
%xdefine RAND_bytes BORINGSSL_PREFIX %+ _RAND_bytes
|
||||
@@ -4632,7 +4656,6 @@
|
||||
%xdefine X509_REQ_set_version BORINGSSL_PREFIX %+ _X509_REQ_set_version
|
||||
%xdefine X509_REQ_sign BORINGSSL_PREFIX %+ _X509_REQ_sign
|
||||
%xdefine X509_REQ_sign_ctx BORINGSSL_PREFIX %+ _X509_REQ_sign_ctx
|
||||
%xdefine X509_REQ_to_X509 BORINGSSL_PREFIX %+ _X509_REQ_to_X509
|
||||
%xdefine X509_REQ_verify BORINGSSL_PREFIX %+ _X509_REQ_verify
|
||||
%xdefine X509_REVOKED_add1_ext_i2d BORINGSSL_PREFIX %+ _X509_REVOKED_add1_ext_i2d
|
||||
%xdefine X509_REVOKED_add_ext BORINGSSL_PREFIX %+ _X509_REVOKED_add_ext
|
||||
@@ -4851,7 +4874,6 @@
|
||||
%xdefine X509_getm_notBefore BORINGSSL_PREFIX %+ _X509_getm_notBefore
|
||||
%xdefine X509_gmtime_adj BORINGSSL_PREFIX %+ _X509_gmtime_adj
|
||||
%xdefine X509_issuer_and_serial_cmp BORINGSSL_PREFIX %+ _X509_issuer_and_serial_cmp
|
||||
%xdefine X509_issuer_and_serial_hash BORINGSSL_PREFIX %+ _X509_issuer_and_serial_hash
|
||||
%xdefine X509_issuer_name_cmp BORINGSSL_PREFIX %+ _X509_issuer_name_cmp
|
||||
%xdefine X509_issuer_name_hash BORINGSSL_PREFIX %+ _X509_issuer_name_hash
|
||||
%xdefine X509_issuer_name_hash_old BORINGSSL_PREFIX %+ _X509_issuer_name_hash_old
|
||||
@@ -5039,6 +5061,7 @@
|
||||
%xdefine bn_scatter5 BORINGSSL_PREFIX %+ _bn_scatter5
|
||||
%xdefine bn_select_words BORINGSSL_PREFIX %+ _bn_select_words
|
||||
%xdefine bn_set_minimal_width BORINGSSL_PREFIX %+ _bn_set_minimal_width
|
||||
%xdefine bn_set_static_words BORINGSSL_PREFIX %+ _bn_set_static_words
|
||||
%xdefine bn_set_words BORINGSSL_PREFIX %+ _bn_set_words
|
||||
%xdefine bn_sqr8x_internal BORINGSSL_PREFIX %+ _bn_sqr8x_internal
|
||||
%xdefine bn_sqr_comba4 BORINGSSL_PREFIX %+ _bn_sqr_comba4
|
||||
@@ -5275,6 +5298,7 @@
|
||||
%xdefine ec_set_to_safe_point BORINGSSL_PREFIX %+ _ec_set_to_safe_point
|
||||
%xdefine ec_simple_scalar_inv0_montgomery BORINGSSL_PREFIX %+ _ec_simple_scalar_inv0_montgomery
|
||||
%xdefine ec_simple_scalar_to_montgomery_inv_vartime BORINGSSL_PREFIX %+ _ec_simple_scalar_to_montgomery_inv_vartime
|
||||
%xdefine ecdsa_sign_with_nonce_for_known_answer_test BORINGSSL_PREFIX %+ _ecdsa_sign_with_nonce_for_known_answer_test
|
||||
%xdefine ecp_nistz256_avx2_select_w7 BORINGSSL_PREFIX %+ _ecp_nistz256_avx2_select_w7
|
||||
%xdefine ecp_nistz256_mul_mont BORINGSSL_PREFIX %+ _ecp_nistz256_mul_mont
|
||||
%xdefine ecp_nistz256_neg BORINGSSL_PREFIX %+ _ecp_nistz256_neg
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
module CCryptoBoringSSL {
|
||||
header "CCryptoBoringSSL.h"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
add_library(CCryptoBoringSSLShims STATIC
|
||||
"shims.c")
|
||||
|
||||
target_include_directories(CCryptoBoringSSLShims PUBLIC
|
||||
include
|
||||
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>)
|
||||
|
||||
target_link_libraries(CCryptoBoringSSLShims PUBLIC
|
||||
CCryptoBoringSSL)
|
||||
|
||||
set_target_properties(CCryptoBoringSSLShims PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CCryptoBoringSSLShims)
|
||||
@@ -0,0 +1,4 @@
|
||||
module CCryptoBoringSSLShims {
|
||||
header "CCryptoBoringSSLShims.h"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
add_subdirectory(CCryptoBoringSSL)
|
||||
add_subdirectory(CCryptoBoringSSLShims)
|
||||
add_subdirectory(Crypto)
|
||||
@@ -0,0 +1,91 @@
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2021 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
add_library(Crypto
|
||||
"AEADs/AES/GCM/AES-GCM.swift"
|
||||
"AEADs/AES/GCM/BoringSSL/AES-GCM_boring.swift"
|
||||
"AEADs/ChachaPoly/BoringSSL/ChaChaPoly_boring.swift"
|
||||
"AEADs/ChachaPoly/ChaChaPoly.swift"
|
||||
"AEADs/Cipher.swift"
|
||||
"AEADs/Nonces.swift"
|
||||
"ASN1/ASN1.swift"
|
||||
"ASN1/Basic ASN1 Types/ASN1BitString.swift"
|
||||
"ASN1/Basic ASN1 Types/ASN1Identifier.swift"
|
||||
"ASN1/Basic ASN1 Types/ASN1Integer.swift"
|
||||
"ASN1/Basic ASN1 Types/ASN1OctetString.swift"
|
||||
"ASN1/Basic ASN1 Types/ArraySliceBigint.swift"
|
||||
"ASN1/Basic ASN1 Types/ObjectIdentifier.swift"
|
||||
"ASN1/ECDSASignature.swift"
|
||||
"ASN1/PEMDocument.swift"
|
||||
"ASN1/PKCS8PrivateKey.swift"
|
||||
"ASN1/SEC1PrivateKey.swift"
|
||||
"ASN1/SubjectPublicKeyInfo.swift"
|
||||
"CryptoKitErrors.swift"
|
||||
"Digests/BoringSSL/Digest_boring.swift"
|
||||
"Digests/Digest.swift"
|
||||
"Digests/Digests.swift"
|
||||
"Digests/HashFunctions.swift"
|
||||
"Digests/HashFunctions_SHA2.swift"
|
||||
"Insecure/Insecure.swift"
|
||||
"Insecure/Insecure_HashFunctions.swift"
|
||||
"Key Agreement/BoringSSL/ECDH_boring.swift"
|
||||
"Key Agreement/DH.swift"
|
||||
"Key Agreement/ECDH.swift"
|
||||
"Key Derivation/HKDF.swift"
|
||||
"Keys/EC/BoringSSL/Ed25519_boring.swift"
|
||||
"Keys/EC/BoringSSL/EllipticCurvePoint_boring.swift"
|
||||
"Keys/EC/BoringSSL/EllipticCurve_boring.swift"
|
||||
"Keys/EC/BoringSSL/NISTCurvesKeys_boring.swift"
|
||||
"Keys/EC/BoringSSL/X25519Keys_boring.swift"
|
||||
"Keys/EC/Curve25519.swift"
|
||||
"Keys/EC/Ed25519.swift"
|
||||
"Keys/EC/NISTCurvesKeys.swift"
|
||||
"Keys/EC/X25519Keys.swift"
|
||||
"Keys/Symmetric/SymmetricKeys.swift"
|
||||
"Message Authentication Codes/HMAC/HMAC.swift"
|
||||
"Message Authentication Codes/MACFunctions.swift"
|
||||
"Message Authentication Codes/MessageAuthenticationCode.swift"
|
||||
"PRF/AES.swift"
|
||||
"Signatures/BoringSSL/ECDSASignature_boring.swift"
|
||||
"Signatures/BoringSSL/ECDSA_boring.swift"
|
||||
"Signatures/BoringSSL/EdDSA_boring.swift"
|
||||
"Signatures/ECDSA.swift"
|
||||
"Signatures/EdDSA.swift"
|
||||
"Signatures/Signature.swift"
|
||||
"Util/BoringSSL/ArbitraryPrecisionInteger_boring.swift"
|
||||
"Util/BoringSSL/CryptoKitErrors_boring.swift"
|
||||
"Util/BoringSSL/FiniteFieldArithmeticContext_boring.swift"
|
||||
"Util/BoringSSL/RNG_boring.swift"
|
||||
"Util/BoringSSL/SafeCompare_boring.swift"
|
||||
"Util/BoringSSL/Zeroization_boring.swift"
|
||||
"Util/PrettyBytes.swift"
|
||||
"Util/SafeCompare.swift"
|
||||
"Util/SecureBytes.swift"
|
||||
"Util/Zeroization.swift")
|
||||
|
||||
target_compile_definitions(Crypto PRIVATE
|
||||
CRYPTO_IN_SWIFTPM_FORCE_BUILD_API)
|
||||
target_include_directories(Crypto PRIVATE
|
||||
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:CCryptoBoringSSLShims,INCLUDE_DIRECTORIES>)
|
||||
target_link_libraries(Crypto PUBLIC
|
||||
$<$<NOT:$<PLATFORM_ID:Darwin>>:dispatch>
|
||||
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
|
||||
CCryptoBoringSSL
|
||||
CCryptoBoringSSLShims)
|
||||
set_target_properties(Crypto PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
|
||||
|
||||
_install_target(Crypto)
|
||||
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS Crypto)
|
||||
@@ -25,7 +25,7 @@ public struct SymmetricKeySize {
|
||||
return self.init(bitCount: 128)
|
||||
}
|
||||
|
||||
/// Symmetric key size of 128 bits
|
||||
/// Symmetric key size of 192 bits
|
||||
public static var bits192: SymmetricKeySize {
|
||||
return self.init(bitCount: 192)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class DERTests: XCTestCase {
|
||||
}
|
||||
|
||||
func randomBytes(count: Int) -> [UInt8] {
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) || os(Linux) || os(Android)
|
||||
#if (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) || os(Linux) || os(Android) || os(Windows)
|
||||
var rng = SystemRandomNumberGenerator()
|
||||
return (0..<count).map { _ in rng.next() }
|
||||
#else
|
||||
|
||||
Loaded 100 of 111 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user