visaljs 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +393 -62
- package/node/include/js_node.h +28 -5
- package/node/include/js_uv.h +36 -0
- package/node/prelude/crypto.js +7 -10
- package/node/prelude/dns.js +99 -0
- package/node/prelude/dns_promises.js +10 -0
- package/node/prelude/http.js +1039 -195
- package/node/prelude/internal/crypto/asym.js +39 -12
- package/node/prelude/internal/crypto/dh_groups.js +12 -0
- package/node/prelude/internal/crypto/diffiehellman.js +354 -0
- package/node/prelude/internal/crypto/hash.js +1 -1
- package/node/prelude/internal/crypto/key_type.js +3 -0
- package/node/prelude/internal/crypto/keys.js +39 -9
- package/node/prelude/internal/http_agent.js +249 -0
- package/node/prelude/internal/net.js +33 -0
- package/node/prelude/internal/socketaddress.js +249 -0
- package/node/prelude/internal/tls/common.js +306 -0
- package/node/prelude/internal/tls/wrap.js +1217 -0
- package/node/prelude/internal/tls/x509.js +394 -0
- package/node/prelude/net.js +1083 -50
- package/node/prelude/stream.js +6 -0
- package/node/prelude/tls.js +141 -0
- package/node/prelude/util.js +5 -2
- package/node/prelude/util_types.js +85 -0
- package/node/src/host_http.c +268 -270
- package/node/src/host_loop.c +84 -0
- package/node/src/host_net.c +495 -0
- package/node/src/host_sys.c +16 -0
- package/package.json +1 -1
- package/runtime/include/js_builtins.h +16 -0
- package/runtime/include/js_console.h +2 -0
- package/runtime/include/js_core.def +23 -0
- package/runtime/include/js_crypto.h +23 -0
- package/runtime/include/js_generator.h +2 -3
- package/runtime/include/js_promise.h +0 -2
- package/runtime/src/async_iter.c +4 -1
- package/runtime/src/boringssl_support.cc +34 -0
- package/runtime/src/builtin_table.c +8 -0
- package/runtime/src/components.c +10 -0
- package/runtime/src/console.c +6 -18
- package/runtime/src/core_all.c +1 -0
- package/runtime/src/crypto_asym.c +450 -241
- package/runtime/src/crypto_bn.c +91 -0
- package/runtime/src/crypto_cipher.c +153 -75
- package/runtime/src/crypto_hash.c +68 -53
- package/runtime/src/crypto_internal.h +55 -26
- package/runtime/src/crypto_pkey.c +198 -61
- package/runtime/src/crypto_subtle.c +42 -16
- package/runtime/src/crypto_tls.c +678 -0
- package/runtime/src/generator.c +8 -1
- package/runtime/src/global.c +2 -4
- package/runtime/src/internal.h +0 -1
- package/runtime/src/jobs.c +2 -1
- package/runtime/src/promise.c +4 -1
- package/runtime/src/tls_roots.gen.h +3215 -0
- package/runtime/src/util_types.c +52 -0
- package/runtime/src/weak.c +2 -1
- package/runtime/third_party/boringssl/LICENSE +238 -0
- package/runtime/third_party/boringssl/README.md +46 -0
- package/runtime/third_party/boringssl/VERSION +1 -0
- package/runtime/third_party/boringssl/crypto/aes/aes.cc +44 -0
- package/runtime/third_party/boringssl/crypto/armv8_feature_parsing.h +67 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_bitstr.cc +297 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_bool.cc +50 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_d2i_fp.cc +47 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_dup.cc +42 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_gentm.cc +130 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_i2d_fp.cc +44 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_int.cc +467 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_mbstr.cc +242 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_object.cc +191 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_octet.cc +32 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_strex.cc +411 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_strnid.cc +208 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_time.cc +248 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_type.cc +467 -0
- package/runtime/third_party/boringssl/crypto/asn1/a_utctm.cc +128 -0
- package/runtime/third_party/boringssl/crypto/asn1/asn1_lib.cc +453 -0
- package/runtime/third_party/boringssl/crypto/asn1/asn1_par.cc +61 -0
- package/runtime/third_party/boringssl/crypto/asn1/asn_pack.cc +56 -0
- package/runtime/third_party/boringssl/crypto/asn1/f_int.cc +63 -0
- package/runtime/third_party/boringssl/crypto/asn1/f_string.cc +52 -0
- package/runtime/third_party/boringssl/crypto/asn1/internal.h +430 -0
- package/runtime/third_party/boringssl/crypto/asn1/posix_time.cc +244 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_dec.cc +611 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_enc.cc +348 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_fre.cc +163 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_new.cc +274 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_typ.cc +92 -0
- package/runtime/third_party/boringssl/crypto/asn1/tasn_utl.cc +218 -0
- package/runtime/third_party/boringssl/crypto/base64/base64.cc +433 -0
- package/runtime/third_party/boringssl/crypto/bcm_support.h +62 -0
- package/runtime/third_party/boringssl/crypto/bio/bio.cc +715 -0
- package/runtime/third_party/boringssl/crypto/bio/bio_mem.cc +260 -0
- package/runtime/third_party/boringssl/crypto/bio/connect.cc +463 -0
- package/runtime/third_party/boringssl/crypto/bio/errno.cc +52 -0
- package/runtime/third_party/boringssl/crypto/bio/fd.cc +193 -0
- package/runtime/third_party/boringssl/crypto/bio/file.cc +283 -0
- package/runtime/third_party/boringssl/crypto/bio/hexdump.cc +154 -0
- package/runtime/third_party/boringssl/crypto/bio/internal.h +128 -0
- package/runtime/third_party/boringssl/crypto/bio/pair.cc +426 -0
- package/runtime/third_party/boringssl/crypto/bio/printf.cc +59 -0
- package/runtime/third_party/boringssl/crypto/bio/socket.cc +210 -0
- package/runtime/third_party/boringssl/crypto/bio/socket_helper.cc +179 -0
- package/runtime/third_party/boringssl/crypto/blake2/blake2.cc +173 -0
- package/runtime/third_party/boringssl/crypto/bn/bn_asn1.cc +57 -0
- package/runtime/third_party/boringssl/crypto/bn/convert.cc +409 -0
- package/runtime/third_party/boringssl/crypto/bn/div.cc +102 -0
- package/runtime/third_party/boringssl/crypto/bn/exponentiation.cc +168 -0
- package/runtime/third_party/boringssl/crypto/bn/sqrt.cc +93 -0
- package/runtime/third_party/boringssl/crypto/buf/buf.cc +119 -0
- package/runtime/third_party/boringssl/crypto/bytestring/asn1_compat.cc +54 -0
- package/runtime/third_party/boringssl/crypto/bytestring/ber.cc +268 -0
- package/runtime/third_party/boringssl/crypto/bytestring/cbb.cc +787 -0
- package/runtime/third_party/boringssl/crypto/bytestring/cbs.cc +977 -0
- package/runtime/third_party/boringssl/crypto/bytestring/internal.h +134 -0
- package/runtime/third_party/boringssl/crypto/bytestring/unicode.cc +156 -0
- package/runtime/third_party/boringssl/crypto/chacha/chacha.cc +226 -0
- package/runtime/third_party/boringssl/crypto/chacha/internal.h +103 -0
- package/runtime/third_party/boringssl/crypto/cipher/derive_key.cc +106 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_aesctrhmac.cc +294 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_aeseax.cc +351 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_aesgcmsiv.cc +918 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_chacha20poly1305.cc +404 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_des.cc +214 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_null.cc +55 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_rc2.cc +432 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_rc4.cc +56 -0
- package/runtime/third_party/boringssl/crypto/cipher/e_tls.cc +615 -0
- package/runtime/third_party/boringssl/crypto/cipher/get_cipher.cc +85 -0
- package/runtime/third_party/boringssl/crypto/cipher/internal.h +399 -0
- package/runtime/third_party/boringssl/crypto/cipher/tls_cbc.cc +476 -0
- package/runtime/third_party/boringssl/crypto/cms/cms.cc +178 -0
- package/runtime/third_party/boringssl/crypto/conf/conf.cc +637 -0
- package/runtime/third_party/boringssl/crypto/conf/internal.h +54 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_apple.cc +76 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_fuchsia.cc +58 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_linux.cc +66 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_openbsd.cc +45 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_sysreg.cc +66 -0
- package/runtime/third_party/boringssl/crypto/cpu_aarch64_win.cc +52 -0
- package/runtime/third_party/boringssl/crypto/cpu_arm_freebsd.cc +55 -0
- package/runtime/third_party/boringssl/crypto/cpu_arm_linux.cc +173 -0
- package/runtime/third_party/boringssl/crypto/cpu_arm_linux.h +141 -0
- package/runtime/third_party/boringssl/crypto/cpu_intel.cc +287 -0
- package/runtime/third_party/boringssl/crypto/crypto.cc +152 -0
- package/runtime/third_party/boringssl/crypto/curve25519/asm/x25519-asm-arm.S +2124 -0
- package/runtime/third_party/boringssl/crypto/curve25519/cpace.cc +227 -0
- package/runtime/third_party/boringssl/crypto/curve25519/curve25519.cc +2436 -0
- package/runtime/third_party/boringssl/crypto/curve25519/curve25519_64_adx.cc +18 -0
- package/runtime/third_party/boringssl/crypto/curve25519/curve25519_tables.h +3264 -0
- package/runtime/third_party/boringssl/crypto/curve25519/internal.h +202 -0
- package/runtime/third_party/boringssl/crypto/curve25519/spake25519.cc +532 -0
- package/runtime/third_party/boringssl/crypto/des/des.cc +837 -0
- package/runtime/third_party/boringssl/crypto/des/internal.h +144 -0
- package/runtime/third_party/boringssl/crypto/dh/dh_asn1.cc +109 -0
- package/runtime/third_party/boringssl/crypto/dh/params.cc +411 -0
- package/runtime/third_party/boringssl/crypto/digest/digest_extra.cc +361 -0
- package/runtime/third_party/boringssl/crypto/dsa/dsa.cc +922 -0
- package/runtime/third_party/boringssl/crypto/dsa/dsa_asn1.cc +306 -0
- package/runtime/third_party/boringssl/crypto/dsa/internal.h +56 -0
- package/runtime/third_party/boringssl/crypto/ec/ec_asn1.cc +542 -0
- package/runtime/third_party/boringssl/crypto/ec/ec_derive.cc +94 -0
- package/runtime/third_party/boringssl/crypto/ec/hash_to_curve.cc +773 -0
- package/runtime/third_party/boringssl/crypto/ec/internal.h +114 -0
- package/runtime/third_party/boringssl/crypto/ecdh/ecdh.cc +75 -0
- package/runtime/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.cc +337 -0
- package/runtime/third_party/boringssl/crypto/ecdsa/ecdsa_p1363.cc +54 -0
- package/runtime/third_party/boringssl/crypto/engine/engine.cc +95 -0
- package/runtime/third_party/boringssl/crypto/err/err.cc +820 -0
- package/runtime/third_party/boringssl/crypto/err/internal.h +45 -0
- package/runtime/third_party/boringssl/crypto/evp/evp.cc +454 -0
- package/runtime/third_party/boringssl/crypto/evp/evp_asn1.cc +439 -0
- package/runtime/third_party/boringssl/crypto/evp/evp_ctx.cc +541 -0
- package/runtime/third_party/boringssl/crypto/evp/evp_kem.cc +101 -0
- package/runtime/third_party/boringssl/crypto/evp/internal.h +427 -0
- package/runtime/third_party/boringssl/crypto/evp/p_dh.cc +326 -0
- package/runtime/third_party/boringssl/crypto/evp/p_dsa.cc +333 -0
- package/runtime/third_party/boringssl/crypto/evp/p_ec.cc +736 -0
- package/runtime/third_party/boringssl/crypto/evp/p_ed25519.cc +359 -0
- package/runtime/third_party/boringssl/crypto/evp/p_hkdf.cc +204 -0
- package/runtime/third_party/boringssl/crypto/evp/p_mldsa.cc +549 -0
- package/runtime/third_party/boringssl/crypto/evp/p_mlkem.cc +510 -0
- package/runtime/third_party/boringssl/crypto/evp/p_rsa.cc +1185 -0
- package/runtime/third_party/boringssl/crypto/evp/p_x25519.cc +371 -0
- package/runtime/third_party/boringssl/crypto/evp/p_xwing.cc +300 -0
- package/runtime/third_party/boringssl/crypto/evp/pbkdf.cc +105 -0
- package/runtime/third_party/boringssl/crypto/evp/print.cc +287 -0
- package/runtime/third_party/boringssl/crypto/evp/scrypt.cc +218 -0
- package/runtime/third_party/boringssl/crypto/evp/sign.cc +95 -0
- package/runtime/third_party/boringssl/crypto/ex_data.cc +140 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/aes.cc.inc +208 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/aes_nohw.cc.inc +1279 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/cbc.cc.inc +132 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/cfb.cc.inc +168 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/ctr.cc.inc +102 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/gcm.cc.inc +614 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/gcm_nohw.cc.inc +304 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/internal.h +590 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.cc.inc +211 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.cc.inc +97 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/aes/ofb.cc.inc +55 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bcm.cc +288 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bcm_interface.h +953 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/add.cc.inc +276 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/asm/x86_64-gcc.cc.inc +573 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/bn.cc.inc +377 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/bytes.cc.inc +230 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/cmp.cc.inc +161 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/ctx.cc.inc +127 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/div.cc.inc +738 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/div_extra.cc.inc +90 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.cc.inc +743 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/gcd.cc.inc +281 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.cc.inc +327 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/generic.cc.inc +579 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/internal.h +810 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/jacobi.cc.inc +101 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/montgomery.cc.inc +408 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.cc.inc +179 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/mul.cc.inc +347 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/prime.cc.inc +931 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/random.cc.inc +261 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.cc.inc +144 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +109 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/shift.cc.inc +317 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/bn/sqrt.cc.inc +370 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cipher/aead.cc.inc +619 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cipher/cipher.cc.inc +837 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.cc.inc +1240 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cipher/e_aesccm.cc.inc +440 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cipher/internal.h +461 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/cmac/cmac.cc.inc +293 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/delocate.h +95 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/dh/check.cc.inc +198 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/dh/dh.cc.inc +401 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/dh/internal.h +63 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/digest/digest.cc.inc +221 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/digest/digests.cc.inc +184 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/digest/internal.h +72 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/digest/md32_common.h +166 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/digestsign/digestsign.cc.inc +230 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/builtin_curves.h +277 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/ec.cc.inc +1024 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/ec_key.cc.inc +536 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.cc.inc +379 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/felem.cc.inc +250 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/internal.h +752 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/oct.cc.inc +174 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/p256-nistz-table.h +9502 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/p256-nistz.cc.inc +740 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/p256-nistz.h +207 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/p256.cc.inc +578 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/p256_table.h +297 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/scalar.cc.inc +184 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/simple.cc.inc +246 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/simple_mul.cc.inc +274 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/util.cc.inc +258 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ec/wnaf.cc.inc +224 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.cc.inc +91 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.cc.inc +288 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/ecdsa/internal.h +57 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/entropy/internal.h +38 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/entropy/jitter.cc.inc +487 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/entropy/sha512.cc.inc +329 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/fips_shared_support.cc +28 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/hkdf/hkdf.cc.inc +114 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/hmac/hmac.cc.inc +218 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/keccak/internal.h +165 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/keccak/keccak.cc.inc +647 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/mldsa/fips_known_values.inc +1345 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/mldsa/mldsa.cc.inc +3323 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/mlkem/fips_known_values.inc +411 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/mlkem/mlkem.cc.inc +1856 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rand/android_entropy_client.cc.inc +82 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.cc.inc +401 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rand/internal.h +99 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rand/rand.cc.inc +486 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rsa/internal.h +167 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rsa/padding.cc.inc +371 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rsa/rsa.cc.inc +996 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.cc.inc +1000 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/self_check/fips.cc.inc +129 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/self_check/self_check.cc.inc +1093 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/service_indicator/internal.h +112 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/service_indicator/service_indicator.cc.inc +330 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/sha/internal.h +205 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/sha/sha1.cc.inc +404 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/sha/sha256.cc.inc +315 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/sha/sha512.cc.inc +473 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/address.h +144 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/fips_known_values.inc +674 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/fors.cc.inc +179 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/fors.h +48 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/merkle.cc.inc +164 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/merkle.h +58 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/params.h +178 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/slhdsa.cc.inc +690 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/thash.cc.inc +326 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/thash.h +71 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/wots.cc.inc +172 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/slhdsa/wots.h +40 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/tls/internal.h +33 -0
- package/runtime/third_party/boringssl/crypto/fipsmodule/tls/kdf.cc.inc +180 -0
- package/runtime/third_party/boringssl/crypto/fuzzer_mode.cc +30 -0
- package/runtime/third_party/boringssl/crypto/hpke/hpke.cc +1514 -0
- package/runtime/third_party/boringssl/crypto/hrss/asm/poly_rq_mul.S +8489 -0
- package/runtime/third_party/boringssl/crypto/hrss/hrss.cc +2189 -0
- package/runtime/third_party/boringssl/crypto/hrss/internal.h +64 -0
- package/runtime/third_party/boringssl/crypto/internal.h +1767 -0
- package/runtime/third_party/boringssl/crypto/lhash/internal.h +222 -0
- package/runtime/third_party/boringssl/crypto/lhash/lhash.cc +312 -0
- package/runtime/third_party/boringssl/crypto/md4/md4.cc +207 -0
- package/runtime/third_party/boringssl/crypto/md5/internal.h +34 -0
- package/runtime/third_party/boringssl/crypto/md5/md5.cc +255 -0
- package/runtime/third_party/boringssl/crypto/mem.cc +577 -0
- package/runtime/third_party/boringssl/crypto/mem_internal.h +706 -0
- package/runtime/third_party/boringssl/crypto/mldsa/mldsa.cc +296 -0
- package/runtime/third_party/boringssl/crypto/mlkem/mlkem.cc +108 -0
- package/runtime/third_party/boringssl/crypto/obj/obj.cc +494 -0
- package/runtime/third_party/boringssl/crypto/obj/obj_dat.h +11722 -0
- package/runtime/third_party/boringssl/crypto/obj/obj_xref.cc +83 -0
- package/runtime/third_party/boringssl/crypto/params_internal.h +30 -0
- package/runtime/third_party/boringssl/crypto/pem/internal.h +135 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_all.cc +153 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_info.cc +250 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_lib.cc +707 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_oth.cc +45 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_pk8.cc +211 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_pkey.cc +147 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_x509.cc +25 -0
- package/runtime/third_party/boringssl/crypto/pem/pem_xaux.cc +25 -0
- package/runtime/third_party/boringssl/crypto/pkcs7/internal.h +67 -0
- package/runtime/third_party/boringssl/crypto/pkcs7/pkcs7.cc +198 -0
- package/runtime/third_party/boringssl/crypto/pkcs7/pkcs7_x509.cc +527 -0
- package/runtime/third_party/boringssl/crypto/pkcs8/internal.h +98 -0
- package/runtime/third_party/boringssl/crypto/pkcs8/p5_pbev2.cc +286 -0
- package/runtime/third_party/boringssl/crypto/pkcs8/pkcs8.cc +473 -0
- package/runtime/third_party/boringssl/crypto/pkcs8/pkcs8_x509.cc +1328 -0
- package/runtime/third_party/boringssl/crypto/poly1305/internal.h +54 -0
- package/runtime/third_party/boringssl/crypto/poly1305/poly1305.cc +315 -0
- package/runtime/third_party/boringssl/crypto/poly1305/poly1305_arm.cc +294 -0
- package/runtime/third_party/boringssl/crypto/poly1305/poly1305_arm_asm.S +2017 -0
- package/runtime/third_party/boringssl/crypto/poly1305/poly1305_vec.cc +853 -0
- package/runtime/third_party/boringssl/crypto/pool/internal.h +95 -0
- package/runtime/third_party/boringssl/crypto/pool/pool.cc +282 -0
- package/runtime/third_party/boringssl/crypto/rand/deterministic.cc +58 -0
- package/runtime/third_party/boringssl/crypto/rand/fork_detect.cc +222 -0
- package/runtime/third_party/boringssl/crypto/rand/forkunsafe.cc +44 -0
- package/runtime/third_party/boringssl/crypto/rand/getentropy.cc +53 -0
- package/runtime/third_party/boringssl/crypto/rand/internal.h +67 -0
- package/runtime/third_party/boringssl/crypto/rand/ios.cc +35 -0
- package/runtime/third_party/boringssl/crypto/rand/rand.cc +79 -0
- package/runtime/third_party/boringssl/crypto/rand/trusty.cc +39 -0
- package/runtime/third_party/boringssl/crypto/rand/urandom.cc +149 -0
- package/runtime/third_party/boringssl/crypto/rand/windows.cc +91 -0
- package/runtime/third_party/boringssl/crypto/rc4/rc4.cc +56 -0
- package/runtime/third_party/boringssl/crypto/refcount.cc +49 -0
- package/runtime/third_party/boringssl/crypto/rsa/internal.h +51 -0
- package/runtime/third_party/boringssl/crypto/rsa/rsa_asn1.cc +404 -0
- package/runtime/third_party/boringssl/crypto/rsa/rsa_crypt.cc +530 -0
- package/runtime/third_party/boringssl/crypto/rsa/rsa_extra.cc +30 -0
- package/runtime/third_party/boringssl/crypto/rsa/rsa_print.cc +25 -0
- package/runtime/third_party/boringssl/crypto/sha/sha1.cc +55 -0
- package/runtime/third_party/boringssl/crypto/sha/sha256.cc +89 -0
- package/runtime/third_party/boringssl/crypto/sha/sha512.cc +106 -0
- package/runtime/third_party/boringssl/crypto/siphash/siphash.cc +81 -0
- package/runtime/third_party/boringssl/crypto/slhdsa/slhdsa.cc +167 -0
- package/runtime/third_party/boringssl/crypto/spake2plus/internal.h +204 -0
- package/runtime/third_party/boringssl/crypto/spake2plus/spake2plus.cc +501 -0
- package/runtime/third_party/boringssl/crypto/stack/stack.cc +462 -0
- package/runtime/third_party/boringssl/crypto/thread.cc +68 -0
- package/runtime/third_party/boringssl/crypto/thread_none.cc +48 -0
- package/runtime/third_party/boringssl/crypto/thread_pthread.cc +138 -0
- package/runtime/third_party/boringssl/crypto/thread_win.cc +227 -0
- package/runtime/third_party/boringssl/crypto/trust_token/internal.h +405 -0
- package/runtime/third_party/boringssl/crypto/trust_token/pmbtoken.cc +1672 -0
- package/runtime/third_party/boringssl/crypto/trust_token/trust_token.cc +701 -0
- package/runtime/third_party/boringssl/crypto/trust_token/voprf.cc +1266 -0
- package/runtime/third_party/boringssl/crypto/x509/a_digest.cc +52 -0
- package/runtime/third_party/boringssl/crypto/x509/a_sign.cc +100 -0
- package/runtime/third_party/boringssl/crypto/x509/a_verify.cc +77 -0
- package/runtime/third_party/boringssl/crypto/x509/algorithm.cc +167 -0
- package/runtime/third_party/boringssl/crypto/x509/asn1_gen.cc +540 -0
- package/runtime/third_party/boringssl/crypto/x509/by_dir.cc +301 -0
- package/runtime/third_party/boringssl/crypto/x509/by_file.cc +226 -0
- package/runtime/third_party/boringssl/crypto/x509/i2d_pr.cc +37 -0
- package/runtime/third_party/boringssl/crypto/x509/internal.h +697 -0
- package/runtime/third_party/boringssl/crypto/x509/name_print.cc +187 -0
- package/runtime/third_party/boringssl/crypto/x509/policy.cc +686 -0
- package/runtime/third_party/boringssl/crypto/x509/rsa_pss.cc +187 -0
- package/runtime/third_party/boringssl/crypto/x509/t_crl.cc +106 -0
- package/runtime/third_party/boringssl/crypto/x509/t_req.cc +206 -0
- package/runtime/third_party/boringssl/crypto/x509/t_x509.cc +292 -0
- package/runtime/third_party/boringssl/crypto/x509/t_x509a.cc +81 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_akey.cc +174 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_akeya.cc +31 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_alt.cc +636 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_bcons.cc +96 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_bitst.cc +100 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_conf.cc +369 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_cpols.cc +417 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_crld.cc +471 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_enum.cc +74 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_extku.cc +97 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_genn.cc +238 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_ia5.cc +83 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_info.cc +162 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_int.cc +83 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_lib.cc +349 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_ncons.cc +798 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_ocsp.cc +92 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_pcons.cc +102 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_pmaps.cc +110 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_prn.cc +183 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_purp.cc +580 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_skey.cc +128 -0
- package/runtime/third_party/boringssl/crypto/x509/v3_utl.cc +1311 -0
- package/runtime/third_party/boringssl/crypto/x509/x509.cc +47 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_att.cc +188 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_cmp.cc +243 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_d2.cc +66 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_def.cc +42 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_ext.cc +161 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_lu.cc +570 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_mtc.cc +598 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_obj.cc +169 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_req.cc +248 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_set.cc +166 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_trs.cc +123 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_txt.cc +147 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_v3.cc +249 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_vfy.cc +1531 -0
- package/runtime/third_party/boringssl/crypto/x509/x509_vpm.cc +449 -0
- package/runtime/third_party/boringssl/crypto/x509/x509cset.cc +222 -0
- package/runtime/third_party/boringssl/crypto/x509/x509name.cc +377 -0
- package/runtime/third_party/boringssl/crypto/x509/x509rset.cc +55 -0
- package/runtime/third_party/boringssl/crypto/x509/x509spki.cc +91 -0
- package/runtime/third_party/boringssl/crypto/x509/x_algor.cc +223 -0
- package/runtime/third_party/boringssl/crypto/x509/x_all.cc +352 -0
- package/runtime/third_party/boringssl/crypto/x509/x_attrib.cc +61 -0
- package/runtime/third_party/boringssl/crypto/x509/x_crl.cc +325 -0
- package/runtime/third_party/boringssl/crypto/x509/x_exten.cc +42 -0
- package/runtime/third_party/boringssl/crypto/x509/x_name.cc +407 -0
- package/runtime/third_party/boringssl/crypto/x509/x_pubkey.cc +199 -0
- package/runtime/third_party/boringssl/crypto/x509/x_req.cc +80 -0
- package/runtime/third_party/boringssl/crypto/x509/x_sig.cc +51 -0
- package/runtime/third_party/boringssl/crypto/x509/x_spki.cc +44 -0
- package/runtime/third_party/boringssl/crypto/x509/x_x509.cc +495 -0
- package/runtime/third_party/boringssl/crypto/x509/x_x509a.cc +169 -0
- package/runtime/third_party/boringssl/crypto/xwing/xwing.cc +257 -0
- package/runtime/third_party/boringssl/gen/bcm/aes-gcm-avx2-x86_64-apple.S +1326 -0
- package/runtime/third_party/boringssl/gen/bcm/aes-gcm-avx2-x86_64-linux.S +1327 -0
- package/runtime/third_party/boringssl/gen/bcm/aes-gcm-avx512-x86_64-apple.S +1252 -0
- package/runtime/third_party/boringssl/gen/bcm/aes-gcm-avx512-x86_64-linux.S +1253 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-gcm-x86_64-apple.S +873 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-gcm-x86_64-linux.S +885 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-x86-apple.S +2490 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-x86-linux.S +2530 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-x86_64-apple.S +2413 -0
- package/runtime/third_party/boringssl/gen/bcm/aesni-x86_64-linux.S +2397 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-armv7-linux.S +784 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-armv8-apple.S +792 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-armv8-linux.S +786 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-armv8-win.S +798 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-gcm-armv8-apple.S +2912 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-gcm-armv8-linux.S +2907 -0
- package/runtime/third_party/boringssl/gen/bcm/aesv8-gcm-armv8-win.S +2915 -0
- package/runtime/third_party/boringssl/gen/bcm/armv4-mont-linux.S +932 -0
- package/runtime/third_party/boringssl/gen/bcm/armv8-mont-apple.S +1440 -0
- package/runtime/third_party/boringssl/gen/bcm/armv8-mont-linux.S +1440 -0
- package/runtime/third_party/boringssl/gen/bcm/armv8-mont-win.S +1446 -0
- package/runtime/third_party/boringssl/gen/bcm/bn-586-apple.S +530 -0
- package/runtime/third_party/boringssl/gen/bcm/bn-586-linux.S +540 -0
- package/runtime/third_party/boringssl/gen/bcm/bn-armv8-apple.S +88 -0
- package/runtime/third_party/boringssl/gen/bcm/bn-armv8-linux.S +87 -0
- package/runtime/third_party/boringssl/gen/bcm/bn-armv8-win.S +87 -0
- package/runtime/third_party/boringssl/gen/bcm/bsaes-armv7-linux.S +1520 -0
- package/runtime/third_party/boringssl/gen/bcm/co-586-apple.S +1256 -0
- package/runtime/third_party/boringssl/gen/bcm/co-586-linux.S +1264 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-armv4-linux.S +242 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-neon-armv8-apple.S +337 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-neon-armv8-linux.S +335 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-neon-armv8-win.S +341 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-ssse3-x86-apple.S +288 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-ssse3-x86-linux.S +292 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-ssse3-x86_64-apple.S +426 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-ssse3-x86_64-linux.S +425 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-x86-apple.S +322 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-x86-linux.S +328 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-x86_64-apple.S +1134 -0
- package/runtime/third_party/boringssl/gen/bcm/ghash-x86_64-linux.S +1129 -0
- package/runtime/third_party/boringssl/gen/bcm/ghashv8-armv7-linux.S +244 -0
- package/runtime/third_party/boringssl/gen/bcm/ghashv8-armv8-apple.S +567 -0
- package/runtime/third_party/boringssl/gen/bcm/ghashv8-armv8-linux.S +563 -0
- package/runtime/third_party/boringssl/gen/bcm/ghashv8-armv8-win.S +571 -0
- package/runtime/third_party/boringssl/gen/bcm/p256-armv8-asm-apple.S +1744 -0
- package/runtime/third_party/boringssl/gen/bcm/p256-armv8-asm-linux.S +1725 -0
- package/runtime/third_party/boringssl/gen/bcm/p256-armv8-asm-win.S +1765 -0
- package/runtime/third_party/boringssl/gen/bcm/p256-x86_64-asm-apple.S +4544 -0
- package/runtime/third_party/boringssl/gen/bcm/p256-x86_64-asm-linux.S +4600 -0
- package/runtime/third_party/boringssl/gen/bcm/p256_beeu-armv8-asm-apple.S +310 -0
- package/runtime/third_party/boringssl/gen/bcm/p256_beeu-armv8-asm-linux.S +310 -0
- package/runtime/third_party/boringssl/gen/bcm/p256_beeu-armv8-asm-win.S +310 -0
- package/runtime/third_party/boringssl/gen/bcm/p256_beeu-x86_64-asm-apple.S +321 -0
- package/runtime/third_party/boringssl/gen/bcm/p256_beeu-x86_64-asm-linux.S +335 -0
- package/runtime/third_party/boringssl/gen/bcm/rdrand-x86_64-apple.S +58 -0
- package/runtime/third_party/boringssl/gen/bcm/rdrand-x86_64-linux.S +57 -0
- package/runtime/third_party/boringssl/gen/bcm/rsaz-avx2-apple.S +1756 -0
- package/runtime/third_party/boringssl/gen/bcm/rsaz-avx2-linux.S +1751 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-586-apple.S +3782 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-586-linux.S +3788 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-armv4-large-linux.S +1479 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-armv8-apple.S +1219 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-armv8-linux.S +1218 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-armv8-win.S +1222 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-x86_64-apple.S +5454 -0
- package/runtime/third_party/boringssl/gen/bcm/sha1-x86_64-linux.S +5450 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-586-apple.S +5593 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-586-linux.S +5599 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-armv4-linux.S +2840 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-armv8-apple.S +1195 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-armv8-linux.S +1194 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-armv8-win.S +1198 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-x86_64-apple.S +4173 -0
- package/runtime/third_party/boringssl/gen/bcm/sha256-x86_64-linux.S +4170 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-586-apple.S +2406 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-586-linux.S +2410 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-armv4-linux.S +1857 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-armv8-apple.S +1598 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-armv8-linux.S +1597 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-armv8-win.S +1601 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-x86_64-apple.S +2979 -0
- package/runtime/third_party/boringssl/gen/bcm/sha512-x86_64-linux.S +2978 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-armv7-linux.S +1225 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-armv8-apple.S +1238 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-armv8-linux.S +1220 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-armv8-win.S +1256 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-x86-apple.S +680 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-x86-linux.S +706 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-x86_64-apple.S +1146 -0
- package/runtime/third_party/boringssl/gen/bcm/vpaes-x86_64-linux.S +1133 -0
- package/runtime/third_party/boringssl/gen/bcm/x86-mont-apple.S +216 -0
- package/runtime/third_party/boringssl/gen/bcm/x86-mont-linux.S +218 -0
- package/runtime/third_party/boringssl/gen/bcm/x86_64-mont-apple.S +1238 -0
- package/runtime/third_party/boringssl/gen/bcm/x86_64-mont-linux.S +1237 -0
- package/runtime/third_party/boringssl/gen/bcm/x86_64-mont5-apple.S +3644 -0
- package/runtime/third_party/boringssl/gen/bcm/x86_64-mont5-linux.S +3628 -0
- package/runtime/third_party/boringssl/gen/boringssl_prefix_symbols_internal_x86_64_win_asm.inc +325 -0
- package/runtime/third_party/boringssl/gen/boringssl_prefix_symbols_internal_x86_win_asm.inc +325 -0
- package/runtime/third_party/boringssl/gen/crypto/aes128gcmsiv-x86_64-apple.S +3113 -0
- package/runtime/third_party/boringssl/gen/crypto/aes128gcmsiv-x86_64-linux.S +3091 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-armv4-linux.S +1450 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-armv8-apple.S +1969 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-armv8-linux.S +1967 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-armv8-win.S +1973 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-x86-apple.S +957 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-x86-linux.S +961 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-x86_64-apple.S +1608 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha-x86_64-linux.S +1611 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha20_poly1305_armv8-apple.S +3010 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha20_poly1305_armv8-linux.S +3008 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha20_poly1305_armv8-win.S +3014 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha20_poly1305_x86_64-apple.S +8903 -0
- package/runtime/third_party/boringssl/gen/crypto/chacha20_poly1305_x86_64-linux.S +8940 -0
- package/runtime/third_party/boringssl/gen/crypto/err_data.cc +1578 -0
- package/runtime/third_party/boringssl/gen/crypto/md5-586-apple.S +684 -0
- package/runtime/third_party/boringssl/gen/crypto/md5-586-linux.S +686 -0
- package/runtime/third_party/boringssl/gen/crypto/md5-x86_64-apple.S +690 -0
- package/runtime/third_party/boringssl/gen/crypto/md5-x86_64-linux.S +695 -0
- package/runtime/third_party/boringssl/include/openssl/aead.h +650 -0
- package/runtime/third_party/boringssl/include/openssl/aes.h +173 -0
- package/runtime/third_party/boringssl/include/openssl/arm_arch.h +24 -0
- package/runtime/third_party/boringssl/include/openssl/asm_base.h +219 -0
- package/runtime/third_party/boringssl/include/openssl/asn1.h +2002 -0
- package/runtime/third_party/boringssl/include/openssl/asn1_mac.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/asn1t.h +584 -0
- package/runtime/third_party/boringssl/include/openssl/base.h +548 -0
- package/runtime/third_party/boringssl/include/openssl/base64.h +156 -0
- package/runtime/third_party/boringssl/include/openssl/bio.h +1061 -0
- package/runtime/third_party/boringssl/include/openssl/blake2.h +63 -0
- package/runtime/third_party/boringssl/include/openssl/blowfish.h +58 -0
- package/runtime/third_party/boringssl/include/openssl/bn.h +986 -0
- package/runtime/third_party/boringssl/include/openssl/buf.h +95 -0
- package/runtime/third_party/boringssl/include/openssl/buffer.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/bytestring.h +798 -0
- package/runtime/third_party/boringssl/include/openssl/cast.h +91 -0
- package/runtime/third_party/boringssl/include/openssl/chacha.h +47 -0
- package/runtime/third_party/boringssl/include/openssl/cipher.h +819 -0
- package/runtime/third_party/boringssl/include/openssl/cmac.h +91 -0
- package/runtime/third_party/boringssl/include/openssl/cms.h +147 -0
- package/runtime/third_party/boringssl/include/openssl/conf.h +136 -0
- package/runtime/third_party/boringssl/include/openssl/configuration.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/cpu.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/crypto.h +235 -0
- package/runtime/third_party/boringssl/include/openssl/ctrdrbg.h +116 -0
- package/runtime/third_party/boringssl/include/openssl/curve25519.h +309 -0
- package/runtime/third_party/boringssl/include/openssl/des.h +134 -0
- package/runtime/third_party/boringssl/include/openssl/dh.h +336 -0
- package/runtime/third_party/boringssl/include/openssl/digest.h +399 -0
- package/runtime/third_party/boringssl/include/openssl/dsa.h +392 -0
- package/runtime/third_party/boringssl/include/openssl/dtls1.h +16 -0
- package/runtime/third_party/boringssl/include/openssl/e_os2.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/ec.h +530 -0
- package/runtime/third_party/boringssl/include/openssl/ec_key.h +358 -0
- package/runtime/third_party/boringssl/include/openssl/ecdh.h +67 -0
- package/runtime/third_party/boringssl/include/openssl/ecdsa.h +242 -0
- package/runtime/third_party/boringssl/include/openssl/engine.h +109 -0
- package/runtime/third_party/boringssl/include/openssl/err.h +416 -0
- package/runtime/third_party/boringssl/include/openssl/evp.h +1645 -0
- package/runtime/third_party/boringssl/include/openssl/evp_errors.h +66 -0
- package/runtime/third_party/boringssl/include/openssl/ex_data.h +117 -0
- package/runtime/third_party/boringssl/include/openssl/hkdf.h +68 -0
- package/runtime/third_party/boringssl/include/openssl/hmac.h +151 -0
- package/runtime/third_party/boringssl/include/openssl/hpke.h +456 -0
- package/runtime/third_party/boringssl/include/openssl/hrss.h +108 -0
- package/runtime/third_party/boringssl/include/openssl/is_boringssl.h +16 -0
- package/runtime/third_party/boringssl/include/openssl/kdf.h +92 -0
- package/runtime/third_party/boringssl/include/openssl/lhash.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/md4.h +73 -0
- package/runtime/third_party/boringssl/include/openssl/md5.h +67 -0
- package/runtime/third_party/boringssl/include/openssl/mem.h +215 -0
- package/runtime/third_party/boringssl/include/openssl/mldsa.h +486 -0
- package/runtime/third_party/boringssl/include/openssl/mlkem.h +222 -0
- package/runtime/third_party/boringssl/include/openssl/nid.h +5561 -0
- package/runtime/third_party/boringssl/include/openssl/obj.h +225 -0
- package/runtime/third_party/boringssl/include/openssl/obj_mac.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/objects.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/opensslconf.h +108 -0
- package/runtime/third_party/boringssl/include/openssl/opensslv.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/ossl_typ.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/params.h +42 -0
- package/runtime/third_party/boringssl/include/openssl/pem.h +769 -0
- package/runtime/third_party/boringssl/include/openssl/pkcs12.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/pkcs7.h +239 -0
- package/runtime/third_party/boringssl/include/openssl/pkcs8.h +267 -0
- package/runtime/third_party/boringssl/include/openssl/poly1305.h +52 -0
- package/runtime/third_party/boringssl/include/openssl/pool.h +137 -0
- package/runtime/third_party/boringssl/include/openssl/posix_time.h +51 -0
- package/runtime/third_party/boringssl/include/openssl/prefix_symbols.h +8000 -0
- package/runtime/third_party/boringssl/include/openssl/prefix_symbols_internal_S.h +633 -0
- package/runtime/third_party/boringssl/include/openssl/prefix_symbols_internal_c.h +329 -0
- package/runtime/third_party/boringssl/include/openssl/rand.h +138 -0
- package/runtime/third_party/boringssl/include/openssl/rc4.h +54 -0
- package/runtime/third_party/boringssl/include/openssl/ripemd.h +71 -0
- package/runtime/third_party/boringssl/include/openssl/rsa.h +893 -0
- package/runtime/third_party/boringssl/include/openssl/safestack.h +16 -0
- package/runtime/third_party/boringssl/include/openssl/service_indicator.h +19 -0
- package/runtime/third_party/boringssl/include/openssl/sha.h +108 -0
- package/runtime/third_party/boringssl/include/openssl/sha2.h +201 -0
- package/runtime/third_party/boringssl/include/openssl/siphash.h +37 -0
- package/runtime/third_party/boringssl/include/openssl/slhdsa.h +250 -0
- package/runtime/third_party/boringssl/include/openssl/span.h +376 -0
- package/runtime/third_party/boringssl/include/openssl/srtp.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/ssl.h +7211 -0
- package/runtime/third_party/boringssl/include/openssl/ssl3.h +171 -0
- package/runtime/third_party/boringssl/include/openssl/stack.h +688 -0
- package/runtime/third_party/boringssl/include/openssl/target.h +246 -0
- package/runtime/third_party/boringssl/include/openssl/thread.h +114 -0
- package/runtime/third_party/boringssl/include/openssl/time.h +22 -0
- package/runtime/third_party/boringssl/include/openssl/tls1.h +263 -0
- package/runtime/third_party/boringssl/include/openssl/tls_prf.h +47 -0
- package/runtime/third_party/boringssl/include/openssl/trust_token.h +349 -0
- package/runtime/third_party/boringssl/include/openssl/type_check.h +37 -0
- package/runtime/third_party/boringssl/include/openssl/types.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/x509.h +5404 -0
- package/runtime/third_party/boringssl/include/openssl/x509_vfy.h +18 -0
- package/runtime/third_party/boringssl/include/openssl/x509v3.h +63 -0
- package/runtime/third_party/boringssl/include/openssl/x509v3_errors.h +84 -0
- package/runtime/third_party/boringssl/include/openssl/xwing.h +115 -0
- package/runtime/third_party/boringssl/sources.json +696 -0
- package/runtime/third_party/boringssl/ssl/bio_ssl.cc +196 -0
- package/runtime/third_party/boringssl/ssl/d1_both.cc +1137 -0
- package/runtime/third_party/boringssl/ssl/d1_lib.cc +245 -0
- package/runtime/third_party/boringssl/ssl/d1_pkt.cc +322 -0
- package/runtime/third_party/boringssl/ssl/d1_srtp.cc +128 -0
- package/runtime/third_party/boringssl/ssl/dtls_method.cc +216 -0
- package/runtime/third_party/boringssl/ssl/dtls_record.cc +586 -0
- package/runtime/third_party/boringssl/ssl/encrypted_client_hello.cc +1110 -0
- package/runtime/third_party/boringssl/ssl/extensions.cc +5368 -0
- package/runtime/third_party/boringssl/ssl/handoff.cc +625 -0
- package/runtime/third_party/boringssl/ssl/handshake.cc +694 -0
- package/runtime/third_party/boringssl/ssl/handshake_client.cc +1958 -0
- package/runtime/third_party/boringssl/ssl/handshake_server.cc +1875 -0
- package/runtime/third_party/boringssl/ssl/internal.h +4506 -0
- package/runtime/third_party/boringssl/ssl/s3_both.cc +555 -0
- package/runtime/third_party/boringssl/ssl/s3_lib.cc +88 -0
- package/runtime/third_party/boringssl/ssl/s3_pkt.cc +396 -0
- package/runtime/third_party/boringssl/ssl/ssl_aead_ctx.cc +416 -0
- package/runtime/third_party/boringssl/ssl/ssl_asn1.cc +851 -0
- package/runtime/third_party/boringssl/ssl/ssl_buffer.cc +304 -0
- package/runtime/third_party/boringssl/ssl/ssl_cert.cc +723 -0
- package/runtime/third_party/boringssl/ssl/ssl_cipher.cc +1762 -0
- package/runtime/third_party/boringssl/ssl/ssl_credential.cc +913 -0
- package/runtime/third_party/boringssl/ssl/ssl_file.cc +375 -0
- package/runtime/third_party/boringssl/ssl/ssl_key_share.cc +445 -0
- package/runtime/third_party/boringssl/ssl/ssl_lib.cc +4132 -0
- package/runtime/third_party/boringssl/ssl/ssl_privkey.cc +973 -0
- package/runtime/third_party/boringssl/ssl/ssl_session.cc +1273 -0
- package/runtime/third_party/boringssl/ssl/ssl_stat.cc +162 -0
- package/runtime/third_party/boringssl/ssl/ssl_transcript.cc +224 -0
- package/runtime/third_party/boringssl/ssl/ssl_versions.cc +436 -0
- package/runtime/third_party/boringssl/ssl/ssl_x509.cc +1229 -0
- package/runtime/third_party/boringssl/ssl/t1_enc.cc +266 -0
- package/runtime/third_party/boringssl/ssl/tls13_both.cc +764 -0
- package/runtime/third_party/boringssl/ssl/tls13_client.cc +1325 -0
- package/runtime/third_party/boringssl/ssl/tls13_enc.cc +746 -0
- package/runtime/third_party/boringssl/ssl/tls13_server.cc +1623 -0
- package/runtime/third_party/boringssl/ssl/tls_method.cc +266 -0
- package/runtime/third_party/boringssl/ssl/tls_record.cc +524 -0
- package/runtime/third_party/boringssl/third_party/fiat/asm/fiat_curve25519_adx_mul.S +178 -0
- package/runtime/third_party/boringssl/third_party/fiat/asm/fiat_curve25519_adx_square.S +146 -0
- package/runtime/third_party/boringssl/third_party/fiat/asm/fiat_p256_adx_mul.S +177 -0
- package/runtime/third_party/boringssl/third_party/fiat/asm/fiat_p256_adx_sqr.S +166 -0
- package/runtime/third_party/boringssl/third_party/fiat/bedrock_unverified_bareminimum.c.inc +47 -0
- package/runtime/third_party/boringssl/third_party/fiat/bedrock_unverified_platform.c.inc +137 -0
- package/runtime/third_party/boringssl/third_party/fiat/curve25519_32.h +1571 -0
- package/runtime/third_party/boringssl/third_party/fiat/curve25519_64.h +978 -0
- package/runtime/third_party/boringssl/third_party/fiat/curve25519_64_adx.h +700 -0
- package/runtime/third_party/boringssl/third_party/fiat/curve25519_64_msvc.h +1281 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_32.h +4760 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_64.h +1984 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_64_msvc.h +1939 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_field.c.inc +26 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_field_32.br.c.inc +71 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_field_64.br.c.inc +84 -0
- package/runtime/third_party/boringssl/third_party/fiat/p256_point.br.c.inc +112 -0
- package/runtime/third_party/v8-ieee754/README.md +2 -1
- package/runtime/third_party/v8-ieee754/convert.py +4 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +1 -1
- package/runtime/third_party/bearssl/LICENSE.txt +0 -21
- package/runtime/third_party/bearssl/README.txt +0 -136
- package/runtime/third_party/bearssl/VERSION +0 -1
- package/runtime/third_party/bearssl/inc/bearssl.h +0 -183
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +0 -1059
- package/runtime/third_party/bearssl/inc/bearssl_block.h +0 -2618
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +0 -967
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +0 -1346
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +0 -241
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +0 -284
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +0 -294
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +0 -150
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +0 -397
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +0 -1655
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +0 -4296
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +0 -1474
- package/runtime/third_party/bearssl/src/aead/ccm.c +0 -346
- package/runtime/third_party/bearssl/src/aead/eax.c +0 -525
- package/runtime/third_party/bearssl/src/aead/gcm.c +0 -318
- package/runtime/third_party/bearssl/src/codec/ccopy.c +0 -44
- package/runtime/third_party/bearssl/src/codec/dec16be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/dec16le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/dec32be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/dec32le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/dec64be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/dec64le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc16be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc16le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc32be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc32le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc64be.c +0 -38
- package/runtime/third_party/bearssl/src/codec/enc64le.c +0 -38
- package/runtime/third_party/bearssl/src/codec/pemdec.c +0 -526
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +0 -314
- package/runtime/third_party/bearssl/src/codec/pemenc.c +0 -173
- package/runtime/third_party/bearssl/src/config.h +0 -247
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +0 -121
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +0 -171
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +0 -398
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +0 -390
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +0 -1478
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +0 -800
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +0 -605
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +0 -831
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +0 -46
- package/runtime/third_party/bearssl/src/ec/ec_default.c +0 -36
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +0 -86
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +0 -2124
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +0 -1469
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +0 -1765
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +0 -1781
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +0 -824
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +0 -826
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +0 -85
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +0 -51
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +0 -57
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +0 -64
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +0 -134
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +0 -36
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +0 -36
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +0 -36
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +0 -36
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +0 -47
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +0 -45
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +0 -174
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +0 -48
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +0 -166
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +0 -47
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +0 -45
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +0 -173
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +0 -48
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +0 -165
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +0 -121
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +0 -84
- package/runtime/third_party/bearssl/src/hash/dig_size.c +0 -50
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +0 -345
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +0 -251
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +0 -154
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +0 -389
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +0 -411
- package/runtime/third_party/bearssl/src/hash/md5.c +0 -208
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +0 -141
- package/runtime/third_party/bearssl/src/hash/mgf1.c +0 -56
- package/runtime/third_party/bearssl/src/hash/multihash.c +0 -166
- package/runtime/third_party/bearssl/src/hash/sha1.c +0 -191
- package/runtime/third_party/bearssl/src/hash/sha2big.c +0 -285
- package/runtime/third_party/bearssl/src/hash/sha2small.c +0 -341
- package/runtime/third_party/bearssl/src/inner.h +0 -2577
- package/runtime/third_party/bearssl/src/int/i15_add.c +0 -46
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +0 -44
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +0 -124
- package/runtime/third_party/bearssl/src/int/i15_decode.c +0 -56
- package/runtime/third_party/bearssl/src/int/i15_decred.c +0 -100
- package/runtime/third_party/bearssl/src/int/i15_encode.c +0 -56
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +0 -59
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +0 -39
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +0 -465
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +0 -50
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +0 -160
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +0 -184
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +0 -61
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +0 -173
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +0 -38
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +0 -66
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +0 -47
- package/runtime/third_party/bearssl/src/int/i15_sub.c +0 -46
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +0 -36
- package/runtime/third_party/bearssl/src/int/i31_add.c +0 -46
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +0 -44
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +0 -124
- package/runtime/third_party/bearssl/src/int/i31_decode.c +0 -57
- package/runtime/third_party/bearssl/src/int/i31_decred.c +0 -103
- package/runtime/third_party/bearssl/src/int/i31_encode.c +0 -79
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +0 -60
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +0 -39
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +0 -488
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +0 -65
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +0 -160
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +0 -127
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +0 -74
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +0 -157
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +0 -39
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +0 -66
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +0 -47
- package/runtime/third_party/bearssl/src/int/i31_sub.c +0 -46
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +0 -36
- package/runtime/third_party/bearssl/src/int/i32_add.c +0 -51
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +0 -44
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +0 -77
- package/runtime/third_party/bearssl/src/int/i32_decode.c +0 -63
- package/runtime/third_party/bearssl/src/int/i32_decred.c +0 -107
- package/runtime/third_party/bearssl/src/int/i32_div32.c +0 -56
- package/runtime/third_party/bearssl/src/int/i32_encode.c +0 -72
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +0 -60
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +0 -39
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +0 -65
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +0 -69
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +0 -56
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +0 -138
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +0 -39
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +0 -66
- package/runtime/third_party/bearssl/src/int/i32_sub.c +0 -51
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +0 -36
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +0 -493
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +0 -107
- package/runtime/third_party/bearssl/src/kdf/shake.c +0 -590
- package/runtime/third_party/bearssl/src/mac/hmac.c +0 -122
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +0 -193
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +0 -206
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +0 -157
- package/runtime/third_party/bearssl/src/rand/sysrng.c +0 -252
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +0 -36
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +0 -36
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +0 -38
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +0 -36
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +0 -583
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +0 -99
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +0 -41
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +0 -37
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +0 -43
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +0 -209
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +0 -320
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +0 -40
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +0 -113
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +0 -152
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +0 -37
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +0 -608
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +0 -99
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +0 -41
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +0 -37
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +0 -43
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +0 -203
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +0 -318
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +0 -40
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +0 -106
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +0 -152
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +0 -41
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +0 -37
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +0 -43
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +0 -160
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +0 -40
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +0 -44
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +0 -77
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +0 -57
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +0 -61
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +0 -64
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +0 -57
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +0 -63
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +0 -223
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +0 -60
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +0 -64
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +0 -125
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +0 -112
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +0 -145
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +0 -100
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +0 -121
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +0 -106
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +0 -121
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +0 -52
- package/runtime/third_party/bearssl/src/settings.c +0 -306
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +0 -69
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +0 -67
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +0 -84
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +0 -142
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +0 -254
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +0 -157
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +0 -112
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +0 -328
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +0 -398
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +0 -104
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +0 -81
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +0 -114
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +0 -433
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +0 -159
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +0 -115
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +0 -111
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +0 -91
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +0 -116
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +0 -422
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +0 -170
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +0 -112
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +0 -445
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +0 -670
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +0 -417
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +0 -717
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +0 -946
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +0 -69
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +0 -67
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +0 -84
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +0 -142
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +0 -176
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +0 -129
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +0 -240
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +0 -223
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +0 -122
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +0 -211
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +0 -596
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +0 -106
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +0 -237
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +0 -411
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +0 -87
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +0 -69
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +0 -166
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +0 -310
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +0 -85
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +0 -67
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +0 -260
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +0 -297
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +0 -475
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +0 -221
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +0 -757
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +0 -93
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +0 -110
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +0 -161
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +0 -97
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +0 -96
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +0 -653
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +0 -376
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +0 -776
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +0 -324
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +0 -105
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +0 -1722
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +0 -1526
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +0 -59
|
@@ -0,0 +1,4132 @@
|
|
|
1
|
+
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
2
|
+
// Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
|
3
|
+
// Copyright 2005 Nokia. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
|
|
17
|
+
#include <openssl/ssl.h>
|
|
18
|
+
|
|
19
|
+
#include <algorithm>
|
|
20
|
+
#include <iterator>
|
|
21
|
+
#include <utility>
|
|
22
|
+
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <limits.h>
|
|
25
|
+
#include <stdlib.h>
|
|
26
|
+
#include <string.h>
|
|
27
|
+
|
|
28
|
+
#include <openssl/bytestring.h>
|
|
29
|
+
#include <openssl/crypto.h>
|
|
30
|
+
#include <openssl/err.h>
|
|
31
|
+
#include <openssl/evp.h>
|
|
32
|
+
#include <openssl/mem.h>
|
|
33
|
+
#include <openssl/nid.h>
|
|
34
|
+
#include <openssl/rand.h>
|
|
35
|
+
|
|
36
|
+
#include "../crypto/bytestring/internal.h"
|
|
37
|
+
#include "../crypto/internal.h"
|
|
38
|
+
#include "internal.h"
|
|
39
|
+
|
|
40
|
+
#if defined(OPENSSL_WINDOWS)
|
|
41
|
+
#include <sys/timeb.h>
|
|
42
|
+
#else
|
|
43
|
+
#include <sys/socket.h>
|
|
44
|
+
#include <sys/time.h>
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
BSSL_NAMESPACE_BEGIN
|
|
49
|
+
|
|
50
|
+
static_assert(SSL3_RT_MAX_ENCRYPTED_OVERHEAD >=
|
|
51
|
+
SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD,
|
|
52
|
+
"max overheads are inconsistent");
|
|
53
|
+
|
|
54
|
+
// `SSL_R_UNKNOWN_PROTOCOL` is no longer emitted, but continue to define it
|
|
55
|
+
// to avoid downstream churn.
|
|
56
|
+
OPENSSL_DECLARE_ERROR_REASON(SSL, UNKNOWN_PROTOCOL)
|
|
57
|
+
|
|
58
|
+
// The following errors are no longer emitted, but are used in nginx without
|
|
59
|
+
// #ifdefs.
|
|
60
|
+
OPENSSL_DECLARE_ERROR_REASON(SSL, BLOCK_CIPHER_PAD_IS_WRONG)
|
|
61
|
+
OPENSSL_DECLARE_ERROR_REASON(SSL, NO_CIPHERS_SPECIFIED)
|
|
62
|
+
|
|
63
|
+
// Some error codes are special. Ensure the make_errors.go script never
|
|
64
|
+
// regresses this.
|
|
65
|
+
static_assert(SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ==
|
|
66
|
+
SSL_AD_NO_RENEGOTIATION + SSL_AD_REASON_OFFSET,
|
|
67
|
+
"alert reason code mismatch");
|
|
68
|
+
|
|
69
|
+
// kMaxHandshakeSize is the maximum size, in bytes, of a handshake message.
|
|
70
|
+
static const size_t kMaxHandshakeSize = (1u << 24) - 1;
|
|
71
|
+
|
|
72
|
+
static ExDataClass g_ex_data_class_ssl(/*with_app_data=*/true);
|
|
73
|
+
static ExDataClass g_ex_data_class_ssl_ctx(/*with_app_data=*/true);
|
|
74
|
+
|
|
75
|
+
void ssl_reset_error_state(SSLImpl *ssl) {
|
|
76
|
+
// Functions which use `SSL_get_error` must reset I/O and error state on
|
|
77
|
+
// entry.
|
|
78
|
+
ssl->s3->rwstate = SSL_ERROR_NONE;
|
|
79
|
+
ERR_clear_error();
|
|
80
|
+
ERR_clear_system_error();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void ssl_set_read_error(SSLImpl *ssl) {
|
|
84
|
+
ssl->s3->read_shutdown = ssl_shutdown_error;
|
|
85
|
+
ssl->s3->read_error.reset(ERR_save_state());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static bool check_read_error(const SSLImpl *ssl) {
|
|
89
|
+
if (ssl->s3->read_shutdown == ssl_shutdown_error) {
|
|
90
|
+
ERR_restore_state(ssl->s3->read_error.get());
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
bool ssl_can_write(const SSLImpl *ssl) {
|
|
97
|
+
return !SSL_in_init(ssl) || ssl->s3->hs->can_early_write;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
bool ssl_can_read(const SSLImpl *ssl) {
|
|
101
|
+
return !SSL_in_init(ssl) || ssl->s3->hs->can_early_read;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
ssl_open_record_t ssl_open_handshake(SSLImpl *ssl, size_t *out_consumed,
|
|
105
|
+
uint8_t *out_alert, Span<uint8_t> in) {
|
|
106
|
+
*out_consumed = 0;
|
|
107
|
+
if (!check_read_error(ssl)) {
|
|
108
|
+
*out_alert = 0;
|
|
109
|
+
return ssl_open_record_error;
|
|
110
|
+
}
|
|
111
|
+
auto ret = ssl->method->open_handshake(ssl, out_consumed, out_alert, in);
|
|
112
|
+
if (ret == ssl_open_record_error) {
|
|
113
|
+
ssl_set_read_error(ssl);
|
|
114
|
+
}
|
|
115
|
+
return ret;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ssl_open_record_t ssl_open_change_cipher_spec(SSLImpl *ssl,
|
|
119
|
+
size_t *out_consumed,
|
|
120
|
+
uint8_t *out_alert,
|
|
121
|
+
Span<uint8_t> in) {
|
|
122
|
+
*out_consumed = 0;
|
|
123
|
+
if (!check_read_error(ssl)) {
|
|
124
|
+
*out_alert = 0;
|
|
125
|
+
return ssl_open_record_error;
|
|
126
|
+
}
|
|
127
|
+
auto ret =
|
|
128
|
+
ssl->method->open_change_cipher_spec(ssl, out_consumed, out_alert, in);
|
|
129
|
+
if (ret == ssl_open_record_error) {
|
|
130
|
+
ssl_set_read_error(ssl);
|
|
131
|
+
}
|
|
132
|
+
return ret;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
ssl_open_record_t ssl_open_app_data(SSLImpl *ssl, Span<uint8_t> *out,
|
|
136
|
+
size_t *out_consumed, uint8_t *out_alert,
|
|
137
|
+
Span<uint8_t> in) {
|
|
138
|
+
*out_consumed = 0;
|
|
139
|
+
if (!check_read_error(ssl)) {
|
|
140
|
+
*out_alert = 0;
|
|
141
|
+
return ssl_open_record_error;
|
|
142
|
+
}
|
|
143
|
+
auto ret = ssl->method->open_app_data(ssl, out, out_consumed, out_alert, in);
|
|
144
|
+
if (ret == ssl_open_record_error) {
|
|
145
|
+
ssl_set_read_error(ssl);
|
|
146
|
+
}
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static uint8_t hex_char_consttime(uint8_t b) {
|
|
151
|
+
declassify_assert(b < 16);
|
|
152
|
+
return constant_time_select_8(constant_time_lt_8(b, 10), b + '0',
|
|
153
|
+
b - 10 + 'a');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
static bool cbb_add_hex_consttime(CBB *cbb, Span<const uint8_t> in) {
|
|
157
|
+
uint8_t *out;
|
|
158
|
+
if (!CBB_add_space(cbb, &out, in.size() * 2)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
for (uint8_t b : in) {
|
|
163
|
+
*(out++) = hex_char_consttime(b >> 4);
|
|
164
|
+
*(out++) = hex_char_consttime(b & 0xf);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
bool ssl_log_secret(const SSLImpl *ssl, const char *label,
|
|
171
|
+
Span<const uint8_t> secret) {
|
|
172
|
+
if (ssl->ctx->keylog_callback == nullptr) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
ScopedCBB cbb;
|
|
177
|
+
Array<uint8_t> line;
|
|
178
|
+
auto label_bytes = bssl::StringAsBytes(label);
|
|
179
|
+
if (!CBB_init(cbb.get(), strlen(label) + 1 + SSL3_RANDOM_SIZE * 2 + 1 +
|
|
180
|
+
secret.size() * 2 + 1) ||
|
|
181
|
+
!CBB_add_bytes(cbb.get(), label_bytes.data(), label_bytes.size()) ||
|
|
182
|
+
!CBB_add_u8(cbb.get(), ' ') ||
|
|
183
|
+
!cbb_add_hex_consttime(cbb.get(), ssl->s3->client_random) ||
|
|
184
|
+
!CBB_add_u8(cbb.get(), ' ') ||
|
|
185
|
+
// Convert to hex in constant time to avoid leaking `secret`. If the
|
|
186
|
+
// callback discards the data, we should not introduce side channels.
|
|
187
|
+
!cbb_add_hex_consttime(cbb.get(), secret) ||
|
|
188
|
+
!CBB_add_u8(cbb.get(), 0 /* NUL */) ||
|
|
189
|
+
!CBBFinishArray(cbb.get(), &line)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
ssl->ctx->keylog_callback(ssl, reinterpret_cast<const char *>(line.data()));
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
void ssl_do_info_callback(const SSLImpl *ssl, int type, int value) {
|
|
198
|
+
void (*cb)(const SSL *ssl, int type, int value) = nullptr;
|
|
199
|
+
if (ssl->info_callback != nullptr) {
|
|
200
|
+
cb = ssl->info_callback;
|
|
201
|
+
} else if (ssl->ctx->info_callback != nullptr) {
|
|
202
|
+
cb = ssl->ctx->info_callback;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (cb != nullptr) {
|
|
206
|
+
cb(ssl, type, value);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
void ssl_do_msg_callback(const SSLImpl *ssl, int is_write, int content_type,
|
|
211
|
+
Span<const uint8_t> in) {
|
|
212
|
+
if (ssl->msg_callback == nullptr) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// `version` is zero when calling for `SSL3_RT_HEADER` and `SSL2_VERSION` for
|
|
217
|
+
// a V2ClientHello.
|
|
218
|
+
int version;
|
|
219
|
+
switch (content_type) {
|
|
220
|
+
case 0:
|
|
221
|
+
// V2ClientHello
|
|
222
|
+
version = SSL2_VERSION;
|
|
223
|
+
break;
|
|
224
|
+
case SSL3_RT_HEADER:
|
|
225
|
+
version = 0;
|
|
226
|
+
break;
|
|
227
|
+
default:
|
|
228
|
+
version = SSL_version(ssl);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
ssl->msg_callback(is_write, version, content_type, in.data(), in.size(),
|
|
232
|
+
const_cast<SSLImpl *>(ssl), ssl->msg_callback_arg);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
OPENSSL_timeval ssl_ctx_get_current_time(const SSLContext *ctx) {
|
|
236
|
+
if (ctx->current_time_cb != nullptr) {
|
|
237
|
+
// TODO(davidben): Update current_time_cb to use OPENSSL_timeval. See
|
|
238
|
+
// https://crbug.com/boringssl/155.
|
|
239
|
+
struct timeval clock;
|
|
240
|
+
ctx->current_time_cb(nullptr /* ssl */, &clock);
|
|
241
|
+
if (clock.tv_sec < 0) {
|
|
242
|
+
assert(0);
|
|
243
|
+
return {0, 0};
|
|
244
|
+
} else {
|
|
245
|
+
return {static_cast<uint64_t>(clock.tv_sec),
|
|
246
|
+
static_cast<uint32_t>(clock.tv_usec)};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#if defined(OPENSSL_WINDOWS)
|
|
251
|
+
struct _timeb time;
|
|
252
|
+
_ftime(&time);
|
|
253
|
+
if (time.time < 0) {
|
|
254
|
+
assert(0);
|
|
255
|
+
return {0, 0};
|
|
256
|
+
} else {
|
|
257
|
+
return {static_cast<uint64_t>(time.time),
|
|
258
|
+
static_cast<uint32_t>(time.millitm * 1000)};
|
|
259
|
+
}
|
|
260
|
+
#else
|
|
261
|
+
struct timeval clock;
|
|
262
|
+
gettimeofday(&clock, nullptr);
|
|
263
|
+
if (clock.tv_sec < 0) {
|
|
264
|
+
assert(0);
|
|
265
|
+
return {0, 0};
|
|
266
|
+
} else {
|
|
267
|
+
return {static_cast<uint64_t>(clock.tv_sec),
|
|
268
|
+
static_cast<uint32_t>(clock.tv_usec)};
|
|
269
|
+
}
|
|
270
|
+
#endif
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static bool ssl_can_renegotiate(const SSLImpl *ssl) {
|
|
274
|
+
if (ssl->server || SSL_is_dtls(ssl)) {
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (ssl->s3->version != 0 //
|
|
279
|
+
&& ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// The config has already been shed.
|
|
284
|
+
if (!ssl->config) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
switch (ssl->renegotiate_mode) {
|
|
289
|
+
case ssl_renegotiate_ignore:
|
|
290
|
+
case ssl_renegotiate_never:
|
|
291
|
+
return false;
|
|
292
|
+
|
|
293
|
+
case ssl_renegotiate_freely:
|
|
294
|
+
case ssl_renegotiate_explicit:
|
|
295
|
+
return true;
|
|
296
|
+
case ssl_renegotiate_once:
|
|
297
|
+
return ssl->s3->total_renegotiations == 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
assert(0);
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
static void ssl_maybe_shed_handshake_config(SSLImpl *ssl) {
|
|
305
|
+
if (ssl->s3->hs != nullptr || //
|
|
306
|
+
ssl->config == nullptr || //
|
|
307
|
+
!ssl->config->shed_handshake_config || //
|
|
308
|
+
ssl_can_renegotiate(ssl)) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
ssl->config.reset();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
bool SSL_get_traffic_secrets(const SSL *ssl,
|
|
316
|
+
Span<const uint8_t> *out_read_traffic_secret,
|
|
317
|
+
Span<const uint8_t> *out_write_traffic_secret) {
|
|
318
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
319
|
+
// This API is not well-defined for DTLS, where multiple epochs may be alive
|
|
320
|
+
// at once. Callers should use `SSL_get_dtls_*_traffic_secret` instead. In
|
|
321
|
+
// QUIC, the application is already handed the traffic secret.
|
|
322
|
+
if (SSL_is_dtls(ssl_impl) || SSL_is_quic(ssl_impl)) {
|
|
323
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (!ssl_impl->s3->initial_handshake_complete) {
|
|
328
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_HANDSHAKE_NOT_COMPLETE);
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (SSL_version(ssl_impl) < TLS1_3_VERSION) {
|
|
333
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SSL_VERSION);
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
*out_read_traffic_secret = ssl_impl->s3->read_traffic_secret;
|
|
338
|
+
*out_write_traffic_secret = ssl_impl->s3->write_traffic_secret;
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
BSSL_NAMESPACE_END
|
|
343
|
+
|
|
344
|
+
using namespace bssl;
|
|
345
|
+
|
|
346
|
+
int SSL_library_init() { return 1; }
|
|
347
|
+
|
|
348
|
+
int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) {
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// TODO(crbug.com/565766495): Take `SSLSession` when the lhash does.
|
|
353
|
+
static uint32_t ssl_session_hash(const SSL_SESSION *sess) {
|
|
354
|
+
return ssl_hash_session_id(FromOpaque(sess)->session_id);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// TODO(crbug.com/565766495): Take `SSLSession` when the lhash does.
|
|
358
|
+
static int ssl_session_cmp(const SSL_SESSION *a, const SSL_SESSION *b) {
|
|
359
|
+
return Span(FromOpaque(a)->session_id) == FromOpaque(b)->session_id ? 0 : 1;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
bssl::SSLContext::SSLContext(const SSL_METHOD *ssl_method)
|
|
363
|
+
: RefCounted(CheckSubClass()),
|
|
364
|
+
method(ssl_method->method),
|
|
365
|
+
x509_method(ssl_method->x509_method),
|
|
366
|
+
retain_only_sha256_of_client_certs(false),
|
|
367
|
+
quiet_shutdown(false),
|
|
368
|
+
ocsp_stapling_enabled(false),
|
|
369
|
+
signed_cert_timestamps_enabled(false),
|
|
370
|
+
channel_id_enabled(false),
|
|
371
|
+
grease_enabled(false),
|
|
372
|
+
grease_sigalgs_enabled(false),
|
|
373
|
+
permute_extensions(false),
|
|
374
|
+
allow_unknown_alpn_protos(false),
|
|
375
|
+
false_start_allowed_without_alpn(false),
|
|
376
|
+
enable_early_data(false),
|
|
377
|
+
resumption_across_names_enabled(false) {
|
|
378
|
+
CRYPTO_new_ex_data(&ex_data);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
bssl::SSLContext::~SSLContext() {
|
|
382
|
+
// Free the internal session cache. Note that this calls the caller-supplied
|
|
383
|
+
// remove callback, so we must do it before clearing ex_data. (See ticket
|
|
384
|
+
// [openssl.org #212].)
|
|
385
|
+
SSL_CTX_flush_sessions(this, 0);
|
|
386
|
+
|
|
387
|
+
CRYPTO_free_ex_data(&g_ex_data_class_ssl_ctx, &ex_data);
|
|
388
|
+
|
|
389
|
+
lh_SSL_SESSION_free(sessions);
|
|
390
|
+
x509_method->ssl_ctx_free(this);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
SSL_CTX *SSL_CTX_new(const SSL_METHOD *method) {
|
|
394
|
+
if (method == nullptr) {
|
|
395
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NULL_SSL_METHOD_PASSED);
|
|
396
|
+
return nullptr;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
UniquePtr<SSLContext> ret = MakeUnique<SSLContext>(method);
|
|
400
|
+
if (!ret) {
|
|
401
|
+
return nullptr;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
ret->cert = MakeUnique<CERT>(method->x509_method);
|
|
405
|
+
ret->sessions = lh_SSL_SESSION_new(ssl_session_hash, ssl_session_cmp);
|
|
406
|
+
ret->client_CA.reset(sk_CRYPTO_BUFFER_new_null());
|
|
407
|
+
ret->CA_names.reset(sk_CRYPTO_BUFFER_new_null());
|
|
408
|
+
if (ret->cert == nullptr || //
|
|
409
|
+
!ret->cert->is_valid() || //
|
|
410
|
+
ret->sessions == nullptr || //
|
|
411
|
+
ret->client_CA == nullptr || //
|
|
412
|
+
ret->CA_names == nullptr || //
|
|
413
|
+
!ret->x509_method->ssl_ctx_new(ret.get())) {
|
|
414
|
+
return nullptr;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (!SSL_CTX_set_strict_cipher_list(ret.get(), SSL_DEFAULT_CIPHER_LIST) ||
|
|
418
|
+
!ssl_create_default_tls13_cipher_list(&ret->tls13_cipher_list) ||
|
|
419
|
+
// Lock the SSL_CTX to the specified version, for compatibility with
|
|
420
|
+
// legacy uses of SSL_METHOD.
|
|
421
|
+
!SSL_CTX_set_max_proto_version(ret.get(), method->version) ||
|
|
422
|
+
!SSL_CTX_set_min_proto_version(ret.get(), method->version)) {
|
|
423
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
|
424
|
+
return nullptr;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
if (!ret->supported_group_list.CopyFrom(DefaultSupportedGroupIds())) {
|
|
428
|
+
return nullptr;
|
|
429
|
+
}
|
|
430
|
+
if (!ret->supported_group_list_flags.Init(ret->supported_group_list.size())) {
|
|
431
|
+
return nullptr;
|
|
432
|
+
}
|
|
433
|
+
ret->accepted_peer_cert_types.PushBack(kDefaultCertType);
|
|
434
|
+
|
|
435
|
+
return ret.release();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
int SSL_CTX_up_ref(SSL_CTX *ctx) {
|
|
439
|
+
FromOpaque(ctx)->UpRefInternal();
|
|
440
|
+
return 1;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
void SSL_CTX_free(SSL_CTX *ctx) {
|
|
444
|
+
if (ctx != nullptr) {
|
|
445
|
+
FromOpaque(ctx)->DecRefInternal();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
bssl::SSLImpl::SSLImpl(SSLContext *ctx_arg)
|
|
450
|
+
: method(ctx_arg->method),
|
|
451
|
+
max_send_fragment(ctx_arg->max_send_fragment),
|
|
452
|
+
msg_callback(ctx_arg->msg_callback),
|
|
453
|
+
msg_callback_arg(ctx_arg->msg_callback_arg),
|
|
454
|
+
ctx(UpRef(ctx_arg)),
|
|
455
|
+
session_ctx(UpRef(ctx_arg)),
|
|
456
|
+
options(ctx->options),
|
|
457
|
+
mode(ctx->mode),
|
|
458
|
+
max_cert_list(ctx->max_cert_list),
|
|
459
|
+
server(false),
|
|
460
|
+
quiet_shutdown(ctx->quiet_shutdown),
|
|
461
|
+
enable_early_data(ctx->enable_early_data),
|
|
462
|
+
resumption_across_names_enabled(ctx->resumption_across_names_enabled) {
|
|
463
|
+
CRYPTO_new_ex_data(&ex_data);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
bssl::SSLImpl::~SSLImpl() {
|
|
467
|
+
CRYPTO_free_ex_data(&g_ex_data_class_ssl, &ex_data);
|
|
468
|
+
// `config` refers to `this`, so we must release it earlier.
|
|
469
|
+
config.reset();
|
|
470
|
+
if (method != nullptr) {
|
|
471
|
+
method->ssl_free(this);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
SSL *SSL_new(SSL_CTX *ctx) {
|
|
476
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
477
|
+
if (ctx_impl == nullptr) {
|
|
478
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NULL_SSL_CTX);
|
|
479
|
+
return nullptr;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
UniquePtr<SSLImpl> ssl = MakeUnique<SSLImpl>(ctx_impl);
|
|
483
|
+
if (ssl == nullptr) {
|
|
484
|
+
return nullptr;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
ssl->config = MakeUnique<SSL_CONFIG>(ssl.get());
|
|
488
|
+
if (ssl->config == nullptr) {
|
|
489
|
+
return nullptr;
|
|
490
|
+
}
|
|
491
|
+
ssl->config->conf_min_version = ctx_impl->conf_min_version;
|
|
492
|
+
ssl->config->conf_max_version = ctx_impl->conf_max_version;
|
|
493
|
+
|
|
494
|
+
ssl->config->cert = ssl_cert_dup(ctx_impl->cert.get());
|
|
495
|
+
if (ssl->config->cert == nullptr) {
|
|
496
|
+
return nullptr;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
ssl->config->verify_mode = ctx_impl->verify_mode;
|
|
500
|
+
ssl->config->verify_callback = ctx_impl->default_verify_callback;
|
|
501
|
+
ssl->config->custom_verify_callback = ctx_impl->custom_verify_callback;
|
|
502
|
+
ssl->config->retain_only_sha256_of_client_certs =
|
|
503
|
+
ctx_impl->retain_only_sha256_of_client_certs;
|
|
504
|
+
ssl->config->permute_extensions = ctx_impl->permute_extensions;
|
|
505
|
+
ssl->config->compliance_policy = ctx_impl->compliance_policy;
|
|
506
|
+
|
|
507
|
+
if (!ssl->config->tls13_cipher_list.CopyFrom(ctx_impl->tls13_cipher_list)) {
|
|
508
|
+
return nullptr;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (!ssl->config->supported_group_list.CopyFrom(
|
|
512
|
+
ctx_impl->supported_group_list) ||
|
|
513
|
+
!ssl->config->supported_group_list_flags.CopyFrom(
|
|
514
|
+
ctx_impl->supported_group_list_flags) ||
|
|
515
|
+
!ssl->config->alpn_client_proto_list.CopyFrom(
|
|
516
|
+
ctx_impl->alpn_client_proto_list) ||
|
|
517
|
+
!ssl->config->verify_sigalgs.CopyFrom(ctx_impl->verify_sigalgs) ||
|
|
518
|
+
!ssl->config->accepted_peer_cert_types.TryCopyFrom(
|
|
519
|
+
ctx_impl->accepted_peer_cert_types) ||
|
|
520
|
+
!ssl->config->available_client_cert_types.TryCopyFrom(
|
|
521
|
+
ctx_impl->available_client_cert_types)) {
|
|
522
|
+
return nullptr;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (ctx_impl->requested_trust_anchors) {
|
|
526
|
+
ssl->config->requested_trust_anchors.emplace();
|
|
527
|
+
if (!ssl->config->requested_trust_anchors->CopyFrom(
|
|
528
|
+
*ctx_impl->requested_trust_anchors)) {
|
|
529
|
+
return nullptr;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
if (ctx_impl->psk_identity_hint) {
|
|
534
|
+
ssl->config->psk_identity_hint.reset(
|
|
535
|
+
OPENSSL_strdup(ctx_impl->psk_identity_hint.get()));
|
|
536
|
+
if (ssl->config->psk_identity_hint == nullptr) {
|
|
537
|
+
return nullptr;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
ssl->config->psk_client_callback = ctx_impl->psk_client_callback;
|
|
541
|
+
ssl->config->psk_server_callback = ctx_impl->psk_server_callback;
|
|
542
|
+
|
|
543
|
+
ssl->config->channel_id_enabled = ctx_impl->channel_id_enabled;
|
|
544
|
+
ssl->config->channel_id_private = UpRef(ctx_impl->channel_id_private);
|
|
545
|
+
|
|
546
|
+
ssl->config->signed_cert_timestamps_enabled =
|
|
547
|
+
ctx_impl->signed_cert_timestamps_enabled;
|
|
548
|
+
ssl->config->ocsp_stapling_enabled = ctx_impl->ocsp_stapling_enabled;
|
|
549
|
+
ssl->quic_method = ctx_impl->quic_method;
|
|
550
|
+
|
|
551
|
+
if (!ssl->method->ssl_new(ssl.get()) ||
|
|
552
|
+
!ssl->ctx->x509_method->ssl_new(ssl->s3->hs.get())) {
|
|
553
|
+
return nullptr;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return ssl.release();
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
SSL_CONFIG::SSL_CONFIG(SSLImpl *ssl_arg)
|
|
560
|
+
: ssl(ssl_arg),
|
|
561
|
+
ech_grease_enabled(false),
|
|
562
|
+
reject_unusable_ech_config(false),
|
|
563
|
+
signed_cert_timestamps_enabled(false),
|
|
564
|
+
ocsp_stapling_enabled(false),
|
|
565
|
+
channel_id_enabled(false),
|
|
566
|
+
retain_only_sha256_of_client_certs(false),
|
|
567
|
+
shed_handshake_config(false),
|
|
568
|
+
jdk11_workaround(false),
|
|
569
|
+
quic_use_legacy_codepoint(false),
|
|
570
|
+
permute_extensions(false),
|
|
571
|
+
alps_use_new_codepoint(true),
|
|
572
|
+
server_padding_enabled(false) {
|
|
573
|
+
assert(ssl);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
SSL_CONFIG::~SSL_CONFIG() {
|
|
577
|
+
if (ssl->ctx != nullptr) {
|
|
578
|
+
ssl->ctx->x509_method->ssl_config_free(this);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
void SSL_free(SSL *ssl) { Delete(FromOpaque(ssl)); }
|
|
583
|
+
|
|
584
|
+
void SSL_set_connect_state(SSL *ssl) {
|
|
585
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
586
|
+
ssl_impl->server = false;
|
|
587
|
+
ssl_impl->do_handshake = ssl_client_handshake;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
void SSL_set_accept_state(SSL *ssl) {
|
|
591
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
592
|
+
ssl_impl->server = true;
|
|
593
|
+
ssl_impl->do_handshake = ssl_server_handshake;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
void SSL_set0_rbio(SSL *ssl, BIO *rbio) { FromOpaque(ssl)->rbio.reset(rbio); }
|
|
597
|
+
|
|
598
|
+
void SSL_set0_wbio(SSL *ssl, BIO *wbio) { FromOpaque(ssl)->wbio.reset(wbio); }
|
|
599
|
+
|
|
600
|
+
void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio) {
|
|
601
|
+
// For historical reasons, this function has many different cases in ownership
|
|
602
|
+
// handling.
|
|
603
|
+
|
|
604
|
+
// If nothing has changed, do nothing
|
|
605
|
+
if (rbio == SSL_get_rbio(ssl) && wbio == SSL_get_wbio(ssl)) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// If the two arguments are equal, one fewer reference is granted than
|
|
610
|
+
// taken.
|
|
611
|
+
if (rbio != nullptr && rbio == wbio) {
|
|
612
|
+
BIO_up_ref(rbio);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// If only the wbio is changed, adopt only one reference.
|
|
616
|
+
if (rbio == SSL_get_rbio(ssl)) {
|
|
617
|
+
SSL_set0_wbio(ssl, wbio);
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// There is an asymmetry here for historical reasons. If only the rbio is
|
|
622
|
+
// changed AND the rbio and wbio were originally different, then we only adopt
|
|
623
|
+
// one reference.
|
|
624
|
+
if (wbio == SSL_get_wbio(ssl) && SSL_get_rbio(ssl) != SSL_get_wbio(ssl)) {
|
|
625
|
+
SSL_set0_rbio(ssl, rbio);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// Otherwise, adopt both references.
|
|
630
|
+
SSL_set0_rbio(ssl, rbio);
|
|
631
|
+
SSL_set0_wbio(ssl, wbio);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
BIO *SSL_get_rbio(const SSL *ssl) { return FromOpaque(ssl)->rbio.get(); }
|
|
635
|
+
|
|
636
|
+
BIO *SSL_get_wbio(const SSL *ssl) { return FromOpaque(ssl)->wbio.get(); }
|
|
637
|
+
|
|
638
|
+
size_t SSL_quic_max_handshake_flight_len(const SSL *ssl,
|
|
639
|
+
enum ssl_encryption_level_t level) {
|
|
640
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
641
|
+
// Limits flights to 16K by default when there are no large
|
|
642
|
+
// (certificate-carrying) messages.
|
|
643
|
+
static const size_t kDefaultLimit = 16384;
|
|
644
|
+
|
|
645
|
+
switch (level) {
|
|
646
|
+
case ssl_encryption_initial:
|
|
647
|
+
return kDefaultLimit;
|
|
648
|
+
case ssl_encryption_early_data:
|
|
649
|
+
// QUIC does not send EndOfEarlyData.
|
|
650
|
+
return 0;
|
|
651
|
+
case ssl_encryption_handshake:
|
|
652
|
+
if (ssl_impl->server) {
|
|
653
|
+
// Servers may receive Certificate message if configured to request
|
|
654
|
+
// client certificates.
|
|
655
|
+
if (!!(ssl_impl->config->verify_mode & SSL_VERIFY_PEER) &&
|
|
656
|
+
ssl_impl->max_cert_list > kDefaultLimit) {
|
|
657
|
+
return ssl_impl->max_cert_list;
|
|
658
|
+
}
|
|
659
|
+
} else {
|
|
660
|
+
// Clients may receive both Certificate message and a CertificateRequest
|
|
661
|
+
// message.
|
|
662
|
+
if (2 * ssl_impl->max_cert_list > kDefaultLimit) {
|
|
663
|
+
return 2 * ssl_impl->max_cert_list;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return kDefaultLimit;
|
|
667
|
+
case ssl_encryption_application:
|
|
668
|
+
// Note there is not actually a bound on the number of NewSessionTickets
|
|
669
|
+
// one may send in a row. This level may need more involved flow
|
|
670
|
+
// control. See https://github.com/quicwg/base-drafts/issues/1834.
|
|
671
|
+
return kDefaultLimit;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return 0;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
enum ssl_encryption_level_t SSL_quic_read_level(const SSL *ssl) {
|
|
678
|
+
assert(SSL_is_quic(ssl));
|
|
679
|
+
return FromOpaque(ssl)->s3->quic_read_level;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
enum ssl_encryption_level_t SSL_quic_write_level(const SSL *ssl) {
|
|
683
|
+
assert(SSL_is_quic(ssl));
|
|
684
|
+
return FromOpaque(ssl)->s3->quic_write_level;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
int SSL_provide_quic_data(SSL *ssl, enum ssl_encryption_level_t level,
|
|
688
|
+
const uint8_t *data, size_t len) {
|
|
689
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
690
|
+
if (!SSL_is_quic(ssl_impl)) {
|
|
691
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
692
|
+
return 0;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (level != ssl_impl->s3->quic_read_level) {
|
|
696
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED);
|
|
697
|
+
return 0;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
size_t new_len =
|
|
701
|
+
(ssl_impl->s3->hs_buf ? ssl_impl->s3->hs_buf->length : 0) + len;
|
|
702
|
+
if (new_len < len ||
|
|
703
|
+
new_len > SSL_quic_max_handshake_flight_len(ssl_impl, level)) {
|
|
704
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_EXCESSIVE_MESSAGE_SIZE);
|
|
705
|
+
return 0;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return tls_append_handshake_data(ssl_impl, Span(data, len));
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
int SSL_do_handshake(SSL *ssl) {
|
|
712
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
713
|
+
ssl_reset_error_state(ssl_impl);
|
|
714
|
+
|
|
715
|
+
if (ssl_impl->do_handshake == nullptr) {
|
|
716
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CONNECTION_TYPE_NOT_SET);
|
|
717
|
+
return -1;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (!SSL_in_init(ssl_impl)) {
|
|
721
|
+
return 1;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// Run the handshake.
|
|
725
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
726
|
+
|
|
727
|
+
bool early_return = false;
|
|
728
|
+
int ret = ssl_run_handshake(hs, &early_return);
|
|
729
|
+
ssl_do_info_callback(
|
|
730
|
+
ssl_impl, ssl_impl->server ? SSL_CB_ACCEPT_EXIT : SSL_CB_CONNECT_EXIT,
|
|
731
|
+
ret);
|
|
732
|
+
if (ret <= 0) {
|
|
733
|
+
return ret;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
// Destroy the handshake object if the handshake has completely finished.
|
|
737
|
+
if (!early_return) {
|
|
738
|
+
ssl_impl->s3->hs.reset();
|
|
739
|
+
ssl_maybe_shed_handshake_config(ssl_impl);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return 1;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
int SSL_connect(SSL *ssl) {
|
|
746
|
+
if (FromOpaque(ssl)->do_handshake == nullptr) {
|
|
747
|
+
// Not properly initialized yet
|
|
748
|
+
SSL_set_connect_state(ssl);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return SSL_do_handshake(ssl);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
int SSL_accept(SSL *ssl) {
|
|
755
|
+
if (FromOpaque(ssl)->do_handshake == nullptr) {
|
|
756
|
+
// Not properly initialized yet
|
|
757
|
+
SSL_set_accept_state(ssl);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return SSL_do_handshake(ssl);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
static int ssl_do_post_handshake(SSLImpl *ssl, const SSLMessage &msg) {
|
|
764
|
+
if (ssl_protocol_version(ssl) >= TLS1_3_VERSION) {
|
|
765
|
+
return tls13_post_handshake(ssl, msg);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// Check for renegotiation on the server before parsing to use the correct
|
|
769
|
+
// error. Renegotiation is triggered by a different message for servers.
|
|
770
|
+
if (ssl->server) {
|
|
771
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
|
|
772
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION);
|
|
773
|
+
return 0;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (msg.type != SSL3_MT_HELLO_REQUEST || CBS_len(&msg.body) != 0) {
|
|
777
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
|
778
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_HELLO_REQUEST);
|
|
779
|
+
return 0;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
if (ssl->renegotiate_mode == ssl_renegotiate_ignore) {
|
|
783
|
+
return 1; // Ignore the HelloRequest.
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
ssl->s3->renegotiate_pending = true;
|
|
787
|
+
if (ssl->renegotiate_mode == ssl_renegotiate_explicit) {
|
|
788
|
+
return 1; // Handle it later.
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (!SSL_renegotiate(ssl)) {
|
|
792
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION);
|
|
793
|
+
return 0;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
return 1;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
int SSL_process_quic_post_handshake(SSL *ssl) {
|
|
800
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
801
|
+
ssl_reset_error_state(ssl_impl);
|
|
802
|
+
|
|
803
|
+
if (!SSL_is_quic(ssl_impl) || SSL_in_init(ssl_impl)) {
|
|
804
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
805
|
+
return 0;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// Replay post-handshake message errors.
|
|
809
|
+
if (!check_read_error(ssl_impl)) {
|
|
810
|
+
return 0;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// Process any buffered post-handshake messages.
|
|
814
|
+
SSLMessage msg;
|
|
815
|
+
while (ssl_impl->method->get_message(ssl_impl, &msg)) {
|
|
816
|
+
// Handle the post-handshake message and try again.
|
|
817
|
+
if (!ssl_do_post_handshake(ssl_impl, msg)) {
|
|
818
|
+
ssl_set_read_error(ssl_impl);
|
|
819
|
+
return 0;
|
|
820
|
+
}
|
|
821
|
+
ssl_impl->method->next_message(ssl_impl);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return 1;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
static int ssl_read_impl(SSLImpl *ssl) {
|
|
828
|
+
ssl_reset_error_state(ssl);
|
|
829
|
+
|
|
830
|
+
if (ssl->do_handshake == nullptr) {
|
|
831
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
|
832
|
+
return -1;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// Replay post-handshake message errors.
|
|
836
|
+
if (!check_read_error(ssl)) {
|
|
837
|
+
return -1;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
while (ssl->s3->pending_app_data.empty()) {
|
|
841
|
+
if (ssl->s3->renegotiate_pending) {
|
|
842
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_RENEGOTIATE;
|
|
843
|
+
return -1;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// If a read triggered a DTLS ACK or retransmit, resolve that before reading
|
|
847
|
+
// more.
|
|
848
|
+
if (SSL_is_dtls(ssl)) {
|
|
849
|
+
int ret = ssl->method->flush(ssl);
|
|
850
|
+
if (ret <= 0) {
|
|
851
|
+
return ret;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Complete the current handshake, if any. False Start will cause
|
|
856
|
+
// `SSL_do_handshake` to return mid-handshake, so this may require multiple
|
|
857
|
+
// iterations.
|
|
858
|
+
while (!ssl_can_read(ssl)) {
|
|
859
|
+
int ret = SSL_do_handshake(ssl);
|
|
860
|
+
if (ret < 0) {
|
|
861
|
+
return ret;
|
|
862
|
+
}
|
|
863
|
+
if (ret == 0) {
|
|
864
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_SSL_HANDSHAKE_FAILURE);
|
|
865
|
+
return -1;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// Process any buffered post-handshake messages.
|
|
870
|
+
SSLMessage msg;
|
|
871
|
+
if (ssl->method->get_message(ssl, &msg)) {
|
|
872
|
+
// If we received an interrupt in early read (EndOfEarlyData), loop again
|
|
873
|
+
// for the handshake to process it.
|
|
874
|
+
if (SSL_in_init(ssl)) {
|
|
875
|
+
ssl->s3->hs->can_early_read = false;
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// Handle the post-handshake message and try again.
|
|
880
|
+
if (!ssl_do_post_handshake(ssl, msg)) {
|
|
881
|
+
ssl_set_read_error(ssl);
|
|
882
|
+
return -1;
|
|
883
|
+
}
|
|
884
|
+
ssl->method->next_message(ssl);
|
|
885
|
+
continue; // Loop again. We may have begun a new handshake.
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
uint8_t alert = SSL_AD_DECODE_ERROR;
|
|
889
|
+
size_t consumed = 0;
|
|
890
|
+
auto ret = ssl_open_app_data(ssl, &ssl->s3->pending_app_data, &consumed,
|
|
891
|
+
&alert, ssl->s3->read_buffer.span());
|
|
892
|
+
bool retry;
|
|
893
|
+
int bio_ret = ssl_handle_open_record(ssl, &retry, ret, consumed, alert);
|
|
894
|
+
if (bio_ret <= 0) {
|
|
895
|
+
return bio_ret;
|
|
896
|
+
}
|
|
897
|
+
if (!retry) {
|
|
898
|
+
assert(!ssl->s3->pending_app_data.empty());
|
|
899
|
+
ssl->s3->key_update_count = 0;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
return 1;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
int SSL_read(SSL *ssl, void *buf, int num) {
|
|
907
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
908
|
+
int ret = SSL_peek(ssl_impl, buf, num);
|
|
909
|
+
if (ret <= 0) {
|
|
910
|
+
return ret;
|
|
911
|
+
}
|
|
912
|
+
// TODO(davidben): In DTLS, should the rest of the record be discarded? DTLS
|
|
913
|
+
// is not a stream. See https://crbug.com/boringssl/65.
|
|
914
|
+
ssl_impl->s3->pending_app_data =
|
|
915
|
+
ssl_impl->s3->pending_app_data.subspan(static_cast<size_t>(ret));
|
|
916
|
+
if (ssl_impl->s3->pending_app_data.empty()) {
|
|
917
|
+
ssl_impl->s3->read_buffer.DiscardConsumed();
|
|
918
|
+
}
|
|
919
|
+
return ret;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
int SSL_peek(SSL *ssl, void *buf, int num) {
|
|
923
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
924
|
+
if (SSL_is_quic(ssl_impl)) {
|
|
925
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
926
|
+
return -1;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
int ret = ssl_read_impl(ssl_impl);
|
|
930
|
+
if (ret <= 0) {
|
|
931
|
+
return ret;
|
|
932
|
+
}
|
|
933
|
+
if (num <= 0) {
|
|
934
|
+
return num;
|
|
935
|
+
}
|
|
936
|
+
size_t todo =
|
|
937
|
+
std::min(ssl_impl->s3->pending_app_data.size(), static_cast<size_t>(num));
|
|
938
|
+
OPENSSL_memcpy(buf, ssl_impl->s3->pending_app_data.data(), todo);
|
|
939
|
+
return static_cast<int>(todo);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
int SSL_write(SSL *ssl, const void *buf, int num) {
|
|
943
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
944
|
+
ssl_reset_error_state(ssl_impl);
|
|
945
|
+
|
|
946
|
+
if (SSL_is_quic(ssl_impl)) {
|
|
947
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
948
|
+
return -1;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
if (ssl_impl->do_handshake == nullptr) {
|
|
952
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
|
953
|
+
return -1;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
int ret = 0;
|
|
957
|
+
size_t bytes_written = 0;
|
|
958
|
+
bool needs_handshake = false;
|
|
959
|
+
do {
|
|
960
|
+
// If necessary, complete the handshake implicitly.
|
|
961
|
+
if (!ssl_can_write(ssl_impl)) {
|
|
962
|
+
ret = SSL_do_handshake(ssl_impl);
|
|
963
|
+
if (ret < 0) {
|
|
964
|
+
return ret;
|
|
965
|
+
}
|
|
966
|
+
if (ret == 0) {
|
|
967
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_SSL_HANDSHAKE_FAILURE);
|
|
968
|
+
return -1;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
if (num < 0) {
|
|
973
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_LENGTH);
|
|
974
|
+
return -1;
|
|
975
|
+
}
|
|
976
|
+
ret = ssl_impl->method->write_app_data(
|
|
977
|
+
ssl_impl, &needs_handshake, &bytes_written,
|
|
978
|
+
Span(static_cast<const uint8_t *>(buf), static_cast<size_t>(num)));
|
|
979
|
+
} while (needs_handshake);
|
|
980
|
+
return ret <= 0 ? ret : static_cast<int>(bytes_written);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
int SSL_key_update(SSL *ssl, int request_type) {
|
|
984
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
985
|
+
ssl_reset_error_state(ssl_impl);
|
|
986
|
+
|
|
987
|
+
if (ssl_impl->do_handshake == nullptr) {
|
|
988
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
|
989
|
+
return 0;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if (SSL_is_quic(ssl_impl)) {
|
|
993
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
994
|
+
return 0;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if (!ssl_impl->s3->initial_handshake_complete) {
|
|
998
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_HANDSHAKE_NOT_COMPLETE);
|
|
999
|
+
return 0;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
if (ssl_protocol_version(ssl_impl) < TLS1_3_VERSION) {
|
|
1003
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_SSL_VERSION);
|
|
1004
|
+
return 0;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
return tls13_add_key_update(ssl_impl, request_type);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
int SSL_shutdown(SSL *ssl) {
|
|
1011
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1012
|
+
ssl_reset_error_state(ssl_impl);
|
|
1013
|
+
|
|
1014
|
+
if (ssl_impl->do_handshake == nullptr) {
|
|
1015
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNINITIALIZED);
|
|
1016
|
+
return -1;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// If we are in the middle of a handshake, silently succeed. Consumers often
|
|
1020
|
+
// call this function before `SSL_free`, whether the handshake succeeded or
|
|
1021
|
+
// not. We assume the caller has already handled failed handshakes.
|
|
1022
|
+
if (SSL_in_init(ssl_impl)) {
|
|
1023
|
+
return 1;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
if (ssl_impl->quiet_shutdown) {
|
|
1027
|
+
// Do nothing if configured not to send a close_notify.
|
|
1028
|
+
ssl_impl->s3->write_shutdown = ssl_shutdown_close_notify;
|
|
1029
|
+
ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
|
|
1030
|
+
return 1;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// This function completes in two stages. It sends a close_notify and then it
|
|
1034
|
+
// waits for a close_notify to come in. Perform exactly one action and return
|
|
1035
|
+
// whether or not it succeeds.
|
|
1036
|
+
|
|
1037
|
+
if (ssl_impl->s3->write_shutdown != ssl_shutdown_close_notify) {
|
|
1038
|
+
// Send a close_notify.
|
|
1039
|
+
if (ssl_send_alert_impl(ssl_impl, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY) <=
|
|
1040
|
+
0) {
|
|
1041
|
+
return -1;
|
|
1042
|
+
}
|
|
1043
|
+
} else if (ssl_impl->s3->alert_dispatch) {
|
|
1044
|
+
// Finish sending the close_notify.
|
|
1045
|
+
if (ssl_impl->method->dispatch_alert(ssl_impl) <= 0) {
|
|
1046
|
+
return -1;
|
|
1047
|
+
}
|
|
1048
|
+
} else if (ssl_impl->s3->read_shutdown != ssl_shutdown_close_notify) {
|
|
1049
|
+
if (SSL_is_dtls(ssl_impl)) {
|
|
1050
|
+
// Bidirectional shutdown doesn't make sense for an unordered
|
|
1051
|
+
// transport. DTLS alerts also aren't delivered reliably, so we may even
|
|
1052
|
+
// time out because the peer never received our close_notify. Report to
|
|
1053
|
+
// the caller that the channel has fully shut down.
|
|
1054
|
+
if (ssl_impl->s3->read_shutdown == ssl_shutdown_error) {
|
|
1055
|
+
ERR_restore_state(ssl_impl->s3->read_error.get());
|
|
1056
|
+
return -1;
|
|
1057
|
+
}
|
|
1058
|
+
ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
|
|
1059
|
+
} else {
|
|
1060
|
+
// Process records until an error, close_notify, or application data.
|
|
1061
|
+
if (ssl_read_impl(ssl_impl) > 0) {
|
|
1062
|
+
// We received some unexpected application data.
|
|
1063
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_APPLICATION_DATA_ON_SHUTDOWN);
|
|
1064
|
+
return -1;
|
|
1065
|
+
}
|
|
1066
|
+
if (ssl_impl->s3->read_shutdown != ssl_shutdown_close_notify) {
|
|
1067
|
+
return -1;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// Return 0 for unidirectional shutdown and 1 for bidirectional shutdown.
|
|
1073
|
+
return ssl_impl->s3->read_shutdown == ssl_shutdown_close_notify;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
int SSL_send_fatal_alert(SSL *ssl, uint8_t alert) {
|
|
1077
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1078
|
+
if (ssl_impl->s3->alert_dispatch) {
|
|
1079
|
+
if (ssl_impl->s3->send_alert[0] != SSL3_AL_FATAL ||
|
|
1080
|
+
ssl_impl->s3->send_alert[1] != alert) {
|
|
1081
|
+
// We are already attempting to write a different alert.
|
|
1082
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_PROTOCOL_IS_SHUTDOWN);
|
|
1083
|
+
return -1;
|
|
1084
|
+
}
|
|
1085
|
+
return ssl_impl->method->dispatch_alert(ssl_impl);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
return ssl_send_alert_impl(ssl_impl, SSL3_AL_FATAL, alert);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
int SSL_set_quic_transport_params(SSL *ssl, const uint8_t *params,
|
|
1092
|
+
size_t params_len) {
|
|
1093
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1094
|
+
return ssl_impl->config && ssl_impl->config->quic_transport_params.CopyFrom(
|
|
1095
|
+
Span(params, params_len));
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
void SSL_get_peer_quic_transport_params(const SSL *ssl,
|
|
1099
|
+
const uint8_t **out_params,
|
|
1100
|
+
size_t *out_params_len) {
|
|
1101
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1102
|
+
*out_params = ssl_impl->s3->peer_quic_transport_params.data();
|
|
1103
|
+
*out_params_len = ssl_impl->s3->peer_quic_transport_params.size();
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
int SSL_set_quic_early_data_context(SSL *ssl, const uint8_t *context,
|
|
1107
|
+
size_t context_len) {
|
|
1108
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1109
|
+
return ssl_impl->config && ssl_impl->config->quic_early_data_context.CopyFrom(
|
|
1110
|
+
Span(context, context_len));
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
void SSL_CTX_set_early_data_enabled(SSL_CTX *ctx, int enabled) {
|
|
1114
|
+
FromOpaque(ctx)->enable_early_data = !!enabled;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
void SSL_set_early_data_enabled(SSL *ssl, int enabled) {
|
|
1118
|
+
FromOpaque(ssl)->enable_early_data = !!enabled;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
int SSL_in_early_data(const SSL *ssl) {
|
|
1122
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1123
|
+
if (ssl_impl->s3->hs == nullptr) {
|
|
1124
|
+
return 0;
|
|
1125
|
+
}
|
|
1126
|
+
return ssl_impl->s3->hs->in_early_data;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
int SSL_early_data_accepted(const SSL *ssl) {
|
|
1130
|
+
return FromOpaque(ssl)->s3->early_data_accepted;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
void SSL_reset_early_data_reject(SSL *ssl) {
|
|
1134
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1135
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
1136
|
+
if (hs == nullptr || //
|
|
1137
|
+
hs->wait != ssl_hs_early_data_rejected) {
|
|
1138
|
+
abort();
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
hs->wait = ssl_hs_ok;
|
|
1142
|
+
hs->in_early_data = false;
|
|
1143
|
+
hs->early_session.reset();
|
|
1144
|
+
|
|
1145
|
+
// Discard any unfinished writes from the perspective of `SSL_write`'s
|
|
1146
|
+
// retry. The handshake will transparently flush out the pending record
|
|
1147
|
+
// (discarded by the server) to keep the framing correct.
|
|
1148
|
+
ssl_impl->s3->pending_write = {};
|
|
1149
|
+
ssl_impl->s3->unreported_bytes_written = 0;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
enum ssl_early_data_reason_t SSL_get_early_data_reason(const SSL *ssl) {
|
|
1153
|
+
return FromOpaque(ssl)->s3->early_data_reason;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
const char *SSL_early_data_reason_string(enum ssl_early_data_reason_t reason) {
|
|
1157
|
+
switch (reason) {
|
|
1158
|
+
case ssl_early_data_unknown:
|
|
1159
|
+
return "unknown";
|
|
1160
|
+
case ssl_early_data_disabled:
|
|
1161
|
+
return "disabled";
|
|
1162
|
+
case ssl_early_data_accepted:
|
|
1163
|
+
return "accepted";
|
|
1164
|
+
case ssl_early_data_protocol_version:
|
|
1165
|
+
return "protocol_version";
|
|
1166
|
+
case ssl_early_data_peer_declined:
|
|
1167
|
+
return "peer_declined";
|
|
1168
|
+
case ssl_early_data_no_session_offered:
|
|
1169
|
+
return "no_session_offered";
|
|
1170
|
+
case ssl_early_data_session_not_resumed:
|
|
1171
|
+
return "session_not_resumed";
|
|
1172
|
+
case ssl_early_data_unsupported_for_session:
|
|
1173
|
+
return "unsupported_for_session";
|
|
1174
|
+
case ssl_early_data_hello_retry_request:
|
|
1175
|
+
return "hello_retry_request";
|
|
1176
|
+
case ssl_early_data_alpn_mismatch:
|
|
1177
|
+
return "alpn_mismatch";
|
|
1178
|
+
case ssl_early_data_channel_id:
|
|
1179
|
+
return "channel_id";
|
|
1180
|
+
case ssl_early_data_ticket_age_skew:
|
|
1181
|
+
return "ticket_age_skew";
|
|
1182
|
+
case ssl_early_data_quic_parameter_mismatch:
|
|
1183
|
+
return "quic_parameter_mismatch";
|
|
1184
|
+
case ssl_early_data_alps_mismatch:
|
|
1185
|
+
return "alps_mismatch";
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
return nullptr;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
static int bio_retry_reason_to_error(int reason) {
|
|
1192
|
+
switch (reason) {
|
|
1193
|
+
case BIO_RR_CONNECT:
|
|
1194
|
+
return SSL_ERROR_WANT_CONNECT;
|
|
1195
|
+
case BIO_RR_ACCEPT:
|
|
1196
|
+
return SSL_ERROR_WANT_ACCEPT;
|
|
1197
|
+
default:
|
|
1198
|
+
return SSL_ERROR_SYSCALL;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
int SSL_get_error(const SSL *ssl, int ret_code) {
|
|
1203
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1204
|
+
if (ret_code > 0) {
|
|
1205
|
+
return SSL_ERROR_NONE;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// Make things return SSL_ERROR_SYSCALL when doing SSL_do_handshake etc,
|
|
1209
|
+
// where we do encode the error
|
|
1210
|
+
uint32_t err = ERR_peek_error();
|
|
1211
|
+
if (err != 0) {
|
|
1212
|
+
if (ERR_GET_LIB(err) == ERR_LIB_SYS) {
|
|
1213
|
+
return SSL_ERROR_SYSCALL;
|
|
1214
|
+
}
|
|
1215
|
+
return SSL_ERROR_SSL;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (ret_code == 0) {
|
|
1219
|
+
if (ssl_impl->s3->rwstate == SSL_ERROR_ZERO_RETURN) {
|
|
1220
|
+
return SSL_ERROR_ZERO_RETURN;
|
|
1221
|
+
}
|
|
1222
|
+
// An EOF was observed which violates the protocol, and the underlying
|
|
1223
|
+
// transport does not participate in the error queue. Bubble up to the
|
|
1224
|
+
// caller.
|
|
1225
|
+
return SSL_ERROR_SYSCALL;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
switch (ssl_impl->s3->rwstate) {
|
|
1229
|
+
case SSL_ERROR_PENDING_SESSION:
|
|
1230
|
+
case SSL_ERROR_PENDING_CERTIFICATE:
|
|
1231
|
+
case SSL_ERROR_WANT_X509_LOOKUP:
|
|
1232
|
+
case SSL_ERROR_WANT_PRIVATE_KEY_OPERATION:
|
|
1233
|
+
case SSL_ERROR_PENDING_TICKET:
|
|
1234
|
+
case SSL_ERROR_EARLY_DATA_REJECTED:
|
|
1235
|
+
case SSL_ERROR_WANT_CERTIFICATE_VERIFY:
|
|
1236
|
+
case SSL_ERROR_WANT_RENEGOTIATE:
|
|
1237
|
+
case SSL_ERROR_HANDSHAKE_HINTS_READY:
|
|
1238
|
+
return ssl_impl->s3->rwstate;
|
|
1239
|
+
|
|
1240
|
+
case SSL_ERROR_WANT_READ: {
|
|
1241
|
+
if (SSL_is_quic(ssl_impl)) {
|
|
1242
|
+
return SSL_ERROR_WANT_READ;
|
|
1243
|
+
}
|
|
1244
|
+
BIO *bio = SSL_get_rbio(ssl_impl);
|
|
1245
|
+
if (BIO_should_read(bio)) {
|
|
1246
|
+
return SSL_ERROR_WANT_READ;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
if (BIO_should_write(bio)) {
|
|
1250
|
+
// TODO(davidben): OpenSSL historically checked for writes on the read
|
|
1251
|
+
// BIO. Can this be removed?
|
|
1252
|
+
return SSL_ERROR_WANT_WRITE;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
if (BIO_should_io_special(bio)) {
|
|
1256
|
+
return bio_retry_reason_to_error(BIO_get_retry_reason(bio));
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
break;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
case SSL_ERROR_WANT_WRITE: {
|
|
1263
|
+
BIO *bio = SSL_get_wbio(ssl_impl);
|
|
1264
|
+
if (BIO_should_write(bio)) {
|
|
1265
|
+
return SSL_ERROR_WANT_WRITE;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
if (BIO_should_read(bio)) {
|
|
1269
|
+
// TODO(davidben): OpenSSL historically checked for reads on the write
|
|
1270
|
+
// BIO. Can this be removed?
|
|
1271
|
+
return SSL_ERROR_WANT_READ;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
if (BIO_should_io_special(bio)) {
|
|
1275
|
+
return bio_retry_reason_to_error(BIO_get_retry_reason(bio));
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
return SSL_ERROR_SYSCALL;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
const char *SSL_error_description(int err) {
|
|
1286
|
+
switch (err) {
|
|
1287
|
+
case SSL_ERROR_NONE:
|
|
1288
|
+
return "NONE";
|
|
1289
|
+
case SSL_ERROR_SSL:
|
|
1290
|
+
return "SSL";
|
|
1291
|
+
case SSL_ERROR_WANT_READ:
|
|
1292
|
+
return "WANT_READ";
|
|
1293
|
+
case SSL_ERROR_WANT_WRITE:
|
|
1294
|
+
return "WANT_WRITE";
|
|
1295
|
+
case SSL_ERROR_WANT_X509_LOOKUP:
|
|
1296
|
+
return "WANT_X509_LOOKUP";
|
|
1297
|
+
case SSL_ERROR_SYSCALL:
|
|
1298
|
+
return "SYSCALL";
|
|
1299
|
+
case SSL_ERROR_ZERO_RETURN:
|
|
1300
|
+
return "ZERO_RETURN";
|
|
1301
|
+
case SSL_ERROR_WANT_CONNECT:
|
|
1302
|
+
return "WANT_CONNECT";
|
|
1303
|
+
case SSL_ERROR_WANT_ACCEPT:
|
|
1304
|
+
return "WANT_ACCEPT";
|
|
1305
|
+
case SSL_ERROR_PENDING_SESSION:
|
|
1306
|
+
return "PENDING_SESSION";
|
|
1307
|
+
case SSL_ERROR_PENDING_CERTIFICATE:
|
|
1308
|
+
return "PENDING_CERTIFICATE";
|
|
1309
|
+
case SSL_ERROR_WANT_PRIVATE_KEY_OPERATION:
|
|
1310
|
+
return "WANT_PRIVATE_KEY_OPERATION";
|
|
1311
|
+
case SSL_ERROR_PENDING_TICKET:
|
|
1312
|
+
return "PENDING_TICKET";
|
|
1313
|
+
case SSL_ERROR_EARLY_DATA_REJECTED:
|
|
1314
|
+
return "EARLY_DATA_REJECTED";
|
|
1315
|
+
case SSL_ERROR_WANT_CERTIFICATE_VERIFY:
|
|
1316
|
+
return "WANT_CERTIFICATE_VERIFY";
|
|
1317
|
+
case SSL_ERROR_WANT_RENEGOTIATE:
|
|
1318
|
+
return "WANT_RENEGOTIATE";
|
|
1319
|
+
case SSL_ERROR_HANDSHAKE_HINTS_READY:
|
|
1320
|
+
return "HANDSHAKE_HINTS_READY";
|
|
1321
|
+
default:
|
|
1322
|
+
return nullptr;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
uint32_t SSL_CTX_set_options(SSL_CTX *ctx, uint32_t options) {
|
|
1327
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1328
|
+
ctx_impl->options |= options;
|
|
1329
|
+
return ctx_impl->options;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
uint32_t SSL_CTX_clear_options(SSL_CTX *ctx, uint32_t options) {
|
|
1333
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1334
|
+
ctx_impl->options &= ~options;
|
|
1335
|
+
return ctx_impl->options;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
uint32_t SSL_CTX_get_options(const SSL_CTX *ctx) {
|
|
1339
|
+
return FromOpaque(ctx)->options;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
uint32_t SSL_set_options(SSL *ssl, uint32_t options) {
|
|
1343
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1344
|
+
ssl_impl->options |= options;
|
|
1345
|
+
return ssl_impl->options;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
uint32_t SSL_clear_options(SSL *ssl, uint32_t options) {
|
|
1349
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1350
|
+
ssl_impl->options &= ~options;
|
|
1351
|
+
return ssl_impl->options;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
uint32_t SSL_get_options(const SSL *ssl) { return FromOpaque(ssl)->options; }
|
|
1355
|
+
|
|
1356
|
+
uint32_t SSL_CTX_set_mode(SSL_CTX *ctx, uint32_t mode) {
|
|
1357
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1358
|
+
ctx_impl->mode |= mode;
|
|
1359
|
+
return ctx_impl->mode;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
uint32_t SSL_CTX_clear_mode(SSL_CTX *ctx, uint32_t mode) {
|
|
1363
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1364
|
+
ctx_impl->mode &= ~mode;
|
|
1365
|
+
return ctx_impl->mode;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
uint32_t SSL_CTX_get_mode(const SSL_CTX *ctx) { return FromOpaque(ctx)->mode; }
|
|
1369
|
+
|
|
1370
|
+
uint32_t SSL_set_mode(SSL *ssl, uint32_t mode) {
|
|
1371
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1372
|
+
ssl_impl->mode |= mode;
|
|
1373
|
+
return ssl_impl->mode;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
uint32_t SSL_clear_mode(SSL *ssl, uint32_t mode) {
|
|
1377
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1378
|
+
ssl_impl->mode &= ~mode;
|
|
1379
|
+
return ssl_impl->mode;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
uint32_t SSL_get_mode(const SSL *ssl) { return FromOpaque(ssl)->mode; }
|
|
1383
|
+
|
|
1384
|
+
void SSL_CTX_set1_buffer_pool(SSL_CTX *ctx, CRYPTO_BUFFER_POOL *pool) {
|
|
1385
|
+
FromOpaque(ctx)->pool = UpRef(pool);
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
void SSL_CTX_set0_buffer_pool(SSL_CTX *ctx, CRYPTO_BUFFER_POOL *pool) {
|
|
1389
|
+
// Historically, `CRYPTO_BUFFER_POOL` was not reference-counted and this
|
|
1390
|
+
// function saved a non-owning pointer, expecting the caller to maintain a
|
|
1391
|
+
// lifetime relationship between the two objects. Now that pools are
|
|
1392
|
+
// reference-counted, the compatible behavior is to treat it as set0 rather
|
|
1393
|
+
// than ownership-transfering.
|
|
1394
|
+
return SSL_CTX_set1_buffer_pool(ctx, pool);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
int SSL_get_tls_unique(const SSL *ssl, uint8_t *out, size_t *out_len,
|
|
1398
|
+
size_t max_out) {
|
|
1399
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1400
|
+
*out_len = 0;
|
|
1401
|
+
OPENSSL_memset(out, 0, max_out);
|
|
1402
|
+
|
|
1403
|
+
// tls-unique is not defined for TLS 1.3.
|
|
1404
|
+
if (!ssl_impl->s3->initial_handshake_complete ||
|
|
1405
|
+
ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
|
|
1406
|
+
return 0;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
// The tls-unique value is the first Finished message in the handshake, which
|
|
1410
|
+
// is the client's in a full handshake and the server's for a resumption. See
|
|
1411
|
+
// https://tools.ietf.org/html/rfc5929#section-3.1.
|
|
1412
|
+
Span<const uint8_t> finished = ssl_impl->s3->previous_client_finished;
|
|
1413
|
+
if (ssl_impl->session != nullptr) {
|
|
1414
|
+
// tls-unique is broken for resumed sessions unless EMS is used.
|
|
1415
|
+
if (!ssl_impl->session->extended_master_secret) {
|
|
1416
|
+
return 0;
|
|
1417
|
+
}
|
|
1418
|
+
finished = ssl_impl->s3->previous_server_finished;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
*out_len = finished.size();
|
|
1422
|
+
if (finished.size() > max_out) {
|
|
1423
|
+
*out_len = max_out;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
OPENSSL_memcpy(out, finished.data(), *out_len);
|
|
1427
|
+
return 1;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
static int set_session_id_context(CERT *cert, const uint8_t *sid_ctx,
|
|
1431
|
+
size_t sid_ctx_len) {
|
|
1432
|
+
if (!cert->sid_ctx.TryCopyFrom(Span(sid_ctx, sid_ctx_len))) {
|
|
1433
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG);
|
|
1434
|
+
return 0;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return 1;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const uint8_t *sid_ctx,
|
|
1441
|
+
size_t sid_ctx_len) {
|
|
1442
|
+
return set_session_id_context(FromOpaque(ctx)->cert.get(), sid_ctx,
|
|
1443
|
+
sid_ctx_len);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
int SSL_set_session_id_context(SSL *ssl, const uint8_t *sid_ctx,
|
|
1447
|
+
size_t sid_ctx_len) {
|
|
1448
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1449
|
+
if (!ssl_impl->config) {
|
|
1450
|
+
return 0;
|
|
1451
|
+
}
|
|
1452
|
+
return set_session_id_context(ssl_impl->config->cert.get(), sid_ctx,
|
|
1453
|
+
sid_ctx_len);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
const uint8_t *SSL_get0_session_id_context(const SSL *ssl, size_t *out_len) {
|
|
1457
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1458
|
+
if (!ssl_impl->config) {
|
|
1459
|
+
assert(ssl_impl->config);
|
|
1460
|
+
*out_len = 0;
|
|
1461
|
+
return nullptr;
|
|
1462
|
+
}
|
|
1463
|
+
*out_len = ssl_impl->config->cert->sid_ctx.size();
|
|
1464
|
+
return ssl_impl->config->cert->sid_ctx.data();
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
int SSL_get_fd(const SSL *ssl) { return SSL_get_rfd(ssl); }
|
|
1468
|
+
|
|
1469
|
+
int SSL_get_rfd(const SSL *ssl) {
|
|
1470
|
+
int ret = -1;
|
|
1471
|
+
BIO *b = BIO_find_type(SSL_get_rbio(ssl), BIO_TYPE_DESCRIPTOR);
|
|
1472
|
+
if (b != nullptr) {
|
|
1473
|
+
BIO_get_fd(b, &ret);
|
|
1474
|
+
}
|
|
1475
|
+
return ret;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
int SSL_get_wfd(const SSL *ssl) {
|
|
1479
|
+
int ret = -1;
|
|
1480
|
+
BIO *b = BIO_find_type(SSL_get_wbio(ssl), BIO_TYPE_DESCRIPTOR);
|
|
1481
|
+
if (b != nullptr) {
|
|
1482
|
+
BIO_get_fd(b, &ret);
|
|
1483
|
+
}
|
|
1484
|
+
return ret;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
#if !defined(OPENSSL_NO_SOCK)
|
|
1488
|
+
int SSL_set_fd(SSL *ssl, int fd) {
|
|
1489
|
+
BIO *bio = BIO_new(BIO_s_socket());
|
|
1490
|
+
if (bio == nullptr) {
|
|
1491
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
|
|
1492
|
+
return 0;
|
|
1493
|
+
}
|
|
1494
|
+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
|
|
1495
|
+
SSL_set_bio(ssl, bio, bio);
|
|
1496
|
+
return 1;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
int SSL_set_wfd(SSL *ssl, int fd) {
|
|
1500
|
+
BIO *rbio = SSL_get_rbio(ssl);
|
|
1501
|
+
if (rbio == nullptr || BIO_method_type(rbio) != BIO_TYPE_SOCKET ||
|
|
1502
|
+
BIO_get_fd(rbio, nullptr) != fd) {
|
|
1503
|
+
BIO *bio = BIO_new(BIO_s_socket());
|
|
1504
|
+
if (bio == nullptr) {
|
|
1505
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
|
|
1506
|
+
return 0;
|
|
1507
|
+
}
|
|
1508
|
+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
|
|
1509
|
+
SSL_set0_wbio(ssl, bio);
|
|
1510
|
+
} else {
|
|
1511
|
+
// Copy the rbio over to the wbio.
|
|
1512
|
+
BIO_up_ref(rbio);
|
|
1513
|
+
SSL_set0_wbio(ssl, rbio);
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
return 1;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
int SSL_set_rfd(SSL *ssl, int fd) {
|
|
1520
|
+
BIO *wbio = SSL_get_wbio(ssl);
|
|
1521
|
+
if (wbio == nullptr || BIO_method_type(wbio) != BIO_TYPE_SOCKET ||
|
|
1522
|
+
BIO_get_fd(wbio, nullptr) != fd) {
|
|
1523
|
+
BIO *bio = BIO_new(BIO_s_socket());
|
|
1524
|
+
if (bio == nullptr) {
|
|
1525
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);
|
|
1526
|
+
return 0;
|
|
1527
|
+
}
|
|
1528
|
+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
|
|
1529
|
+
SSL_set0_rbio(ssl, bio);
|
|
1530
|
+
} else {
|
|
1531
|
+
// Copy the wbio over to the rbio.
|
|
1532
|
+
BIO_up_ref(wbio);
|
|
1533
|
+
SSL_set0_rbio(ssl, wbio);
|
|
1534
|
+
}
|
|
1535
|
+
return 1;
|
|
1536
|
+
}
|
|
1537
|
+
#endif // !OPENSSL_NO_SOCK
|
|
1538
|
+
|
|
1539
|
+
static size_t copy_finished(void *out, size_t out_len, Span<const uint8_t> in) {
|
|
1540
|
+
if (out_len > in.size()) {
|
|
1541
|
+
out_len = in.size();
|
|
1542
|
+
}
|
|
1543
|
+
OPENSSL_memcpy(out, in.data(), out_len);
|
|
1544
|
+
return in.size();
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
size_t SSL_get_finished(const SSL *ssl, void *buf, size_t count) {
|
|
1548
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1549
|
+
if (!ssl_impl->s3->initial_handshake_complete ||
|
|
1550
|
+
ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
|
|
1551
|
+
return 0;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
if (ssl_impl->server) {
|
|
1555
|
+
return copy_finished(buf, count, ssl_impl->s3->previous_server_finished);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
return copy_finished(buf, count, ssl_impl->s3->previous_client_finished);
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
size_t SSL_get_peer_finished(const SSL *ssl, void *buf, size_t count) {
|
|
1562
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1563
|
+
if (!ssl_impl->s3->initial_handshake_complete ||
|
|
1564
|
+
ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
|
|
1565
|
+
return 0;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
if (ssl_impl->server) {
|
|
1569
|
+
return copy_finished(buf, count, ssl_impl->s3->previous_client_finished);
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
return copy_finished(buf, count, ssl_impl->s3->previous_server_finished);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
int SSL_get_verify_mode(const SSL *ssl) {
|
|
1576
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1577
|
+
if (!ssl_impl->config) {
|
|
1578
|
+
assert(ssl_impl->config);
|
|
1579
|
+
return -1;
|
|
1580
|
+
}
|
|
1581
|
+
return ssl_impl->config->verify_mode;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
int SSL_get_extms_support(const SSL *ssl) {
|
|
1585
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1586
|
+
// TLS 1.3 does not require extended master secret and always reports as
|
|
1587
|
+
// supporting it.
|
|
1588
|
+
if (ssl_impl->s3->version == 0) {
|
|
1589
|
+
return 0;
|
|
1590
|
+
}
|
|
1591
|
+
if (ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION) {
|
|
1592
|
+
return 1;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
// If the initial handshake completed, query the established session.
|
|
1596
|
+
if (ssl_impl->s3->established_session != nullptr) {
|
|
1597
|
+
return ssl_impl->s3->established_session->extended_master_secret;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// Otherwise, query the in-progress handshake.
|
|
1601
|
+
if (ssl_impl->s3->hs != nullptr) {
|
|
1602
|
+
return ssl_impl->s3->hs->extended_master_secret;
|
|
1603
|
+
}
|
|
1604
|
+
assert(0);
|
|
1605
|
+
return 0;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
int SSL_CTX_get_read_ahead(const SSL_CTX *ctx) { return 0; }
|
|
1609
|
+
|
|
1610
|
+
int SSL_get_read_ahead(const SSL *ssl) { return 0; }
|
|
1611
|
+
|
|
1612
|
+
int SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes) { return 1; }
|
|
1613
|
+
|
|
1614
|
+
int SSL_set_read_ahead(SSL *ssl, int yes) { return 1; }
|
|
1615
|
+
|
|
1616
|
+
int SSL_pending(const SSL *ssl) {
|
|
1617
|
+
return static_cast<int>(FromOpaque(ssl)->s3->pending_app_data.size());
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
int SSL_has_pending(const SSL *ssl) {
|
|
1621
|
+
return SSL_pending(ssl) != 0 || !FromOpaque(ssl)->s3->read_buffer.empty();
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
static bool has_cert_and_key(const SSLCredential *cred) {
|
|
1625
|
+
// TODO(davidben): If `cred->key_method` is set, that should be fine too.
|
|
1626
|
+
if (cred->privkey == nullptr) {
|
|
1627
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_PRIVATE_KEY_ASSIGNED);
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
if (cred->chain == nullptr ||
|
|
1632
|
+
sk_CRYPTO_BUFFER_value(cred->chain.get(), 0) == nullptr) {
|
|
1633
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CERTIFICATE_ASSIGNED);
|
|
1634
|
+
return false;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
return true;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
int SSL_CTX_check_private_key(const SSL_CTX *ctx) {
|
|
1641
|
+
// There is no need to actually check consistency because inconsistent values
|
|
1642
|
+
// can never be configured.
|
|
1643
|
+
return has_cert_and_key(FromOpaque(ctx)->cert->legacy_credential.get());
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
int SSL_check_private_key(const SSL *ssl) {
|
|
1647
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1648
|
+
if (!ssl_impl->config) {
|
|
1649
|
+
return 0;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
// There is no need to actually check consistency because inconsistent values
|
|
1653
|
+
// can never be configured.
|
|
1654
|
+
return has_cert_and_key(ssl_impl->config->cert->legacy_credential.get());
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
long SSL_get_default_timeout(const SSL *ssl) {
|
|
1658
|
+
return SSL_DEFAULT_SESSION_TIMEOUT;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
int SSL_renegotiate(SSL *ssl) {
|
|
1662
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1663
|
+
// Caller-initiated renegotiation is not supported.
|
|
1664
|
+
if (!ssl_impl->s3->renegotiate_pending) {
|
|
1665
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
1666
|
+
return 0;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
if (!ssl_can_renegotiate(ssl_impl)) {
|
|
1670
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
|
|
1671
|
+
return 0;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
// We should not have told the caller to release the private key.
|
|
1675
|
+
assert(!SSL_can_release_private_key(ssl_impl));
|
|
1676
|
+
|
|
1677
|
+
// Renegotiation is only supported at quiescent points in the application
|
|
1678
|
+
// protocol, namely in HTTPS, just before reading the HTTP response.
|
|
1679
|
+
// Require the record-layer be idle and avoid complexities of sending a
|
|
1680
|
+
// handshake record while an application_data record is being written.
|
|
1681
|
+
if (!ssl_impl->s3->write_buffer.empty() ||
|
|
1682
|
+
ssl_impl->s3->write_shutdown != ssl_shutdown_none) {
|
|
1683
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION);
|
|
1684
|
+
return 0;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
// Begin a new handshake.
|
|
1688
|
+
if (ssl_impl->s3->hs != nullptr) {
|
|
1689
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
|
1690
|
+
return 0;
|
|
1691
|
+
}
|
|
1692
|
+
ssl_impl->s3->hs = ssl_handshake_new(ssl_impl);
|
|
1693
|
+
if (ssl_impl->s3->hs == nullptr) {
|
|
1694
|
+
return 0;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
ssl_impl->s3->renegotiate_pending = false;
|
|
1698
|
+
ssl_impl->s3->total_renegotiations++;
|
|
1699
|
+
return 1;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
int SSL_renegotiate_pending(SSL *ssl) {
|
|
1703
|
+
return SSL_in_init(ssl) && FromOpaque(ssl)->s3->initial_handshake_complete;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
int SSL_total_renegotiations(const SSL *ssl) {
|
|
1707
|
+
return FromOpaque(ssl)->s3->total_renegotiations;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
size_t SSL_CTX_get_max_cert_list(const SSL_CTX *ctx) {
|
|
1711
|
+
return FromOpaque(ctx)->max_cert_list;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
void SSL_CTX_set_max_cert_list(SSL_CTX *ctx, size_t max_cert_list) {
|
|
1715
|
+
if (max_cert_list > kMaxHandshakeSize) {
|
|
1716
|
+
max_cert_list = kMaxHandshakeSize;
|
|
1717
|
+
}
|
|
1718
|
+
FromOpaque(ctx)->max_cert_list = (uint32_t)max_cert_list;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
size_t SSL_get_max_cert_list(const SSL *ssl) {
|
|
1722
|
+
return FromOpaque(ssl)->max_cert_list;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
void SSL_set_max_cert_list(SSL *ssl, size_t max_cert_list) {
|
|
1726
|
+
if (max_cert_list > kMaxHandshakeSize) {
|
|
1727
|
+
max_cert_list = kMaxHandshakeSize;
|
|
1728
|
+
}
|
|
1729
|
+
FromOpaque(ssl)->max_cert_list = (uint32_t)max_cert_list;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
int SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, size_t max_send_fragment) {
|
|
1733
|
+
if (max_send_fragment < 512) {
|
|
1734
|
+
max_send_fragment = 512;
|
|
1735
|
+
}
|
|
1736
|
+
if (max_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
|
|
1737
|
+
max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;
|
|
1738
|
+
}
|
|
1739
|
+
FromOpaque(ctx)->max_send_fragment = (uint16_t)max_send_fragment;
|
|
1740
|
+
|
|
1741
|
+
return 1;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
int SSL_set_max_send_fragment(SSL *ssl, size_t max_send_fragment) {
|
|
1745
|
+
if (max_send_fragment < 512) {
|
|
1746
|
+
max_send_fragment = 512;
|
|
1747
|
+
}
|
|
1748
|
+
if (max_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
|
|
1749
|
+
max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH;
|
|
1750
|
+
}
|
|
1751
|
+
FromOpaque(ssl)->max_send_fragment = (uint16_t)max_send_fragment;
|
|
1752
|
+
|
|
1753
|
+
return 1;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
int SSL_set_mtu(SSL *ssl, unsigned mtu) {
|
|
1757
|
+
if (!SSL_is_dtls(ssl) || mtu < dtls1_min_mtu()) {
|
|
1758
|
+
return 0;
|
|
1759
|
+
}
|
|
1760
|
+
FromOpaque(ssl)->d1->mtu = mtu;
|
|
1761
|
+
return 1;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
int SSL_get_secure_renegotiation_support(const SSL *ssl) {
|
|
1765
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
1766
|
+
if (ssl_impl->s3->version == 0) {
|
|
1767
|
+
return 0;
|
|
1768
|
+
}
|
|
1769
|
+
return ssl_protocol_version(ssl_impl) >= TLS1_3_VERSION ||
|
|
1770
|
+
ssl_impl->s3->send_connection_binding;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
size_t SSL_CTX_sess_number(const SSL_CTX *ctx) {
|
|
1774
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1775
|
+
MutexReadLock lock(&ctx_impl->lock);
|
|
1776
|
+
return lh_SSL_SESSION_num_items(ctx_impl->sessions);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
unsigned long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, unsigned long size) {
|
|
1780
|
+
return std::exchange(FromOpaque(ctx)->session_cache_size, size);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
unsigned long SSL_CTX_sess_get_cache_size(const SSL_CTX *ctx) {
|
|
1784
|
+
return FromOpaque(ctx)->session_cache_size;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
int SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode) {
|
|
1788
|
+
return std::exchange(FromOpaque(ctx)->session_cache_mode, mode);
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
int SSL_CTX_get_session_cache_mode(const SSL_CTX *ctx) {
|
|
1792
|
+
return FromOpaque(ctx)->session_cache_mode;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
int SSL_CTX_get_tlsext_ticket_keys(SSL_CTX *ctx, void *out, size_t len) {
|
|
1797
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1798
|
+
if (out == nullptr) {
|
|
1799
|
+
return 48;
|
|
1800
|
+
}
|
|
1801
|
+
if (len != 48) {
|
|
1802
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
|
|
1803
|
+
return 0;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// The default ticket keys are initialized lazily. Trigger a key
|
|
1807
|
+
// rotation to initialize them.
|
|
1808
|
+
if (!ssl_ctx_rotate_ticket_encryption_key(ctx_impl)) {
|
|
1809
|
+
return 0;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
uint8_t *out_bytes = reinterpret_cast<uint8_t *>(out);
|
|
1813
|
+
MutexReadLock lock(&ctx_impl->lock);
|
|
1814
|
+
OPENSSL_memcpy(out_bytes, ctx_impl->ticket_key_current->name, 16);
|
|
1815
|
+
OPENSSL_memcpy(out_bytes + 16, ctx_impl->ticket_key_current->hmac_key, 16);
|
|
1816
|
+
OPENSSL_memcpy(out_bytes + 32, ctx_impl->ticket_key_current->aes_key, 16);
|
|
1817
|
+
return 1;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
int SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, const void *in, size_t len) {
|
|
1821
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1822
|
+
if (in == nullptr) {
|
|
1823
|
+
return 48;
|
|
1824
|
+
}
|
|
1825
|
+
if (len != 48) {
|
|
1826
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
|
|
1827
|
+
return 0;
|
|
1828
|
+
}
|
|
1829
|
+
auto key = MakeUnique<TicketKey>();
|
|
1830
|
+
if (!key) {
|
|
1831
|
+
return 0;
|
|
1832
|
+
}
|
|
1833
|
+
const uint8_t *in_bytes = reinterpret_cast<const uint8_t *>(in);
|
|
1834
|
+
OPENSSL_memcpy(key->name, in_bytes, 16);
|
|
1835
|
+
OPENSSL_memcpy(key->hmac_key, in_bytes + 16, 16);
|
|
1836
|
+
OPENSSL_memcpy(key->aes_key, in_bytes + 32, 16);
|
|
1837
|
+
// Disable automatic key rotation for manually-configured keys. This is now
|
|
1838
|
+
// the caller's responsibility.
|
|
1839
|
+
key->next_rotation_tv_sec = 0;
|
|
1840
|
+
ctx_impl->ticket_key_current = std::move(key);
|
|
1841
|
+
ctx_impl->ticket_key_prev.reset();
|
|
1842
|
+
return 1;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
int SSL_CTX_set_tlsext_ticket_key_cb(
|
|
1846
|
+
SSL_CTX *ctx,
|
|
1847
|
+
int (*callback)(SSL *ssl, uint8_t *key_name, uint8_t *iv,
|
|
1848
|
+
EVP_CIPHER_CTX *ctx, HMAC_CTX *hmac_ctx, int encrypt)) {
|
|
1849
|
+
FromOpaque(ctx)->ticket_key_cb = callback;
|
|
1850
|
+
return 1;
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
static bool check_no_duplicates(Span<const uint16_t> list, int reason) {
|
|
1854
|
+
if (list.size() < 2) {
|
|
1855
|
+
return true;
|
|
1856
|
+
}
|
|
1857
|
+
for (size_t i = 0; i < list.size() - 1; ++i) {
|
|
1858
|
+
for (size_t j = i + 1; j < list.size(); ++j) {
|
|
1859
|
+
if (list[i] == list[j]) {
|
|
1860
|
+
OPENSSL_PUT_ERROR(SSL, reason);
|
|
1861
|
+
return false;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
return true;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
static bool check_group_ids(Span<const uint16_t> group_ids) {
|
|
1869
|
+
for (uint16_t group_id : group_ids) {
|
|
1870
|
+
if (ssl_group_id_to_nid(group_id) == NID_undef) {
|
|
1871
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_ELLIPTIC_CURVE);
|
|
1872
|
+
return false;
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
return check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP);
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
// validate_key_shares returns whether the `requested_key_shares` are free of
|
|
1879
|
+
// duplicates and are a (correctly ordered) subsequence of the supported
|
|
1880
|
+
// `groups`.
|
|
1881
|
+
static bool validate_key_shares(Span<const uint16_t> requested_key_shares,
|
|
1882
|
+
Span<const uint16_t> groups) {
|
|
1883
|
+
if (!check_no_duplicates(requested_key_shares, SSL_R_DUPLICATE_GROUP)) {
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1886
|
+
if (requested_key_shares.size() > groups.size()) {
|
|
1887
|
+
return false;
|
|
1888
|
+
}
|
|
1889
|
+
size_t key_shares_idx = 0u, groups_idx = 0u;
|
|
1890
|
+
while (key_shares_idx < requested_key_shares.size() &&
|
|
1891
|
+
groups_idx < groups.size()) {
|
|
1892
|
+
if (requested_key_shares[key_shares_idx] == groups[groups_idx++]) {
|
|
1893
|
+
++key_shares_idx;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
return key_shares_idx == requested_key_shares.size();
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
static void clear_key_shares_if_invalid(SSL_CONFIG *config) {
|
|
1900
|
+
if (!config->client_key_share_selections) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
if (!validate_key_shares(*(config->client_key_share_selections),
|
|
1904
|
+
config->supported_group_list)) {
|
|
1905
|
+
config->client_key_share_selections.reset();
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
static bool check_group_flags(Span<const uint32_t> flags) {
|
|
1910
|
+
if (flags.empty()) {
|
|
1911
|
+
return true;
|
|
1912
|
+
}
|
|
1913
|
+
// The last element must not have the "equal preference with next" flag,
|
|
1914
|
+
// because there is no next element.
|
|
1915
|
+
return (flags.back() & SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT) == 0;
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
static bool set_group_ids_and_flags(const uint16_t *group_ids,
|
|
1919
|
+
const uint32_t *flags, size_t num_group_ids,
|
|
1920
|
+
Array<uint16_t> *groups_out,
|
|
1921
|
+
Array<uint32_t> *flags_out) {
|
|
1922
|
+
Span<const uint16_t> groups_span = num_group_ids == 0
|
|
1923
|
+
? DefaultSupportedGroupIds()
|
|
1924
|
+
: Span(group_ids, num_group_ids);
|
|
1925
|
+
if (!check_group_ids(groups_span)) {
|
|
1926
|
+
return false;
|
|
1927
|
+
}
|
|
1928
|
+
// If using default groups, always use default flags.
|
|
1929
|
+
if (flags == nullptr || num_group_ids == 0) {
|
|
1930
|
+
return groups_out->CopyFrom(groups_span) &&
|
|
1931
|
+
flags_out->Init(groups_span.size());
|
|
1932
|
+
}
|
|
1933
|
+
Span<const uint32_t> flags_span = Span(flags, num_group_ids);
|
|
1934
|
+
if (!check_group_flags(flags_span)) {
|
|
1935
|
+
return false;
|
|
1936
|
+
}
|
|
1937
|
+
return groups_out->CopyFrom(groups_span) && flags_out->CopyFrom(flags_span);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
int SSL_CTX_set1_group_ids(SSL_CTX *ctx, const uint16_t *group_ids,
|
|
1941
|
+
size_t num_group_ids) {
|
|
1942
|
+
return SSL_CTX_set1_group_ids_with_flags(ctx, group_ids, /*flags=*/nullptr,
|
|
1943
|
+
num_group_ids);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
int SSL_CTX_set1_group_ids_with_flags(SSL_CTX *ctx, const uint16_t *group_ids,
|
|
1947
|
+
const uint32_t *flags,
|
|
1948
|
+
size_t num_group_ids) {
|
|
1949
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
1950
|
+
return set_group_ids_and_flags(group_ids, flags, num_group_ids,
|
|
1951
|
+
&ctx_impl->supported_group_list,
|
|
1952
|
+
&ctx_impl->supported_group_list_flags);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
int SSL_set1_group_ids(SSL *ssl, const uint16_t *group_ids,
|
|
1956
|
+
size_t num_group_ids) {
|
|
1957
|
+
return SSL_set1_group_ids_with_flags(ssl, group_ids, /*flags=*/nullptr,
|
|
1958
|
+
num_group_ids);
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
int SSL_set1_group_ids_with_flags(SSL *ssl, const uint16_t *group_ids,
|
|
1962
|
+
const uint32_t *flags, size_t num_group_ids) {
|
|
1963
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
1964
|
+
if (!ssl_impl->config) {
|
|
1965
|
+
return 0;
|
|
1966
|
+
}
|
|
1967
|
+
if (set_group_ids_and_flags(group_ids, flags, num_group_ids,
|
|
1968
|
+
&ssl_impl->config->supported_group_list,
|
|
1969
|
+
&ssl_impl->config->supported_group_list_flags)) {
|
|
1970
|
+
clear_key_shares_if_invalid(ssl_impl->config.get());
|
|
1971
|
+
return 1;
|
|
1972
|
+
}
|
|
1973
|
+
return 0;
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
static bool check_tls13_cipher_flags(Span<const uint32_t> flags) {
|
|
1977
|
+
if (flags.empty()) {
|
|
1978
|
+
return true;
|
|
1979
|
+
}
|
|
1980
|
+
// The last element must not have the "equal preference with next" flag,
|
|
1981
|
+
// because there is no next element.
|
|
1982
|
+
if ((flags.back() & SSL_CIPHER_FLAG_EQUAL_PREFERENCE_WITH_NEXT) != 0) {
|
|
1983
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_CIPHER_FLAGS);
|
|
1984
|
+
return false;
|
|
1985
|
+
}
|
|
1986
|
+
return true;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
static bool check_tls13_cipher_ids(Span<const uint16_t> cipher_ids) {
|
|
1990
|
+
for (uint16_t cipher_id : cipher_ids) {
|
|
1991
|
+
const SSL_CIPHER *cipher = SSL_get_cipher_by_value(cipher_id);
|
|
1992
|
+
if (cipher == nullptr ||
|
|
1993
|
+
SSL_CIPHER_get_min_version(cipher) != TLS1_3_VERSION) {
|
|
1994
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_CIPHER_TYPE);
|
|
1995
|
+
return false;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
return check_no_duplicates(cipher_ids, SSL_R_DUPLICATE_CIPHER);
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
static bool set_tls13_ciphers(const uint16_t *cipher_ids, const uint32_t *flags,
|
|
2002
|
+
size_t num_cipher_ids,
|
|
2003
|
+
SSLCipherPreferenceList *out) {
|
|
2004
|
+
if (num_cipher_ids == 0) {
|
|
2005
|
+
return ssl_create_default_tls13_cipher_list(out);
|
|
2006
|
+
}
|
|
2007
|
+
Span<const uint16_t> ciphers_span(cipher_ids, num_cipher_ids);
|
|
2008
|
+
if (!check_tls13_cipher_ids(ciphers_span)) {
|
|
2009
|
+
return false;
|
|
2010
|
+
}
|
|
2011
|
+
Array<bool> in_group_flags;
|
|
2012
|
+
if (!in_group_flags.Init(num_cipher_ids)) {
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
if (flags == nullptr) {
|
|
2016
|
+
return out->Init(ciphers_span, in_group_flags);
|
|
2017
|
+
}
|
|
2018
|
+
Span<const uint32_t> flags_span = Span(flags, num_cipher_ids);
|
|
2019
|
+
if (!check_tls13_cipher_flags(flags_span)) {
|
|
2020
|
+
return false;
|
|
2021
|
+
}
|
|
2022
|
+
for (size_t i = 0; i < flags_span.size(); ++i) {
|
|
2023
|
+
in_group_flags[i] =
|
|
2024
|
+
(flags_span[i] & SSL_CIPHER_FLAG_EQUAL_PREFERENCE_WITH_NEXT) != 0;
|
|
2025
|
+
}
|
|
2026
|
+
return out->Init(ciphers_span, in_group_flags);
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
int SSL_CTX_set1_tls13_ciphers(SSL_CTX *ctx, const uint16_t *cipher_ids,
|
|
2030
|
+
const uint32_t *flags, size_t num_cipher_ids) {
|
|
2031
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2032
|
+
return set_tls13_ciphers(cipher_ids, flags, num_cipher_ids,
|
|
2033
|
+
&ctx_impl->tls13_cipher_list);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
int SSL_set1_tls13_ciphers(SSL *ssl, const uint16_t *cipher_ids,
|
|
2037
|
+
const uint32_t *flags, size_t num_cipher_ids) {
|
|
2038
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2039
|
+
if (!ssl_impl->config) {
|
|
2040
|
+
return 0;
|
|
2041
|
+
}
|
|
2042
|
+
return set_tls13_ciphers(cipher_ids, flags, num_cipher_ids,
|
|
2043
|
+
&ssl_impl->config->tls13_cipher_list);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
static bool ssl_nids_to_group_ids(Array<uint16_t> *out_group_ids,
|
|
2047
|
+
Span<const int> nids) {
|
|
2048
|
+
if (nids.empty()) {
|
|
2049
|
+
return out_group_ids->CopyFrom(DefaultSupportedGroupIds());
|
|
2050
|
+
}
|
|
2051
|
+
Array<uint16_t> group_ids;
|
|
2052
|
+
if (!group_ids.InitForOverwrite(nids.size())) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
for (size_t i = 0; i < nids.size(); i++) {
|
|
2057
|
+
if (!ssl_nid_to_group_id(&group_ids[i], nids[i])) {
|
|
2058
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_ELLIPTIC_CURVE);
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
if (!check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP)) {
|
|
2063
|
+
return false;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
*out_group_ids = std::move(group_ids);
|
|
2067
|
+
return true;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
int SSL_CTX_set1_groups(SSL_CTX *ctx, const int *groups, size_t num_groups) {
|
|
2071
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2072
|
+
return ssl_nids_to_group_ids(&ctx_impl->supported_group_list,
|
|
2073
|
+
Span(groups, num_groups)) &&
|
|
2074
|
+
ctx_impl->supported_group_list_flags.Init(
|
|
2075
|
+
ctx_impl->supported_group_list.size());
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
int SSL_set1_groups(SSL *ssl, const int *groups, size_t num_groups) {
|
|
2079
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2080
|
+
if (!ssl_impl->config) {
|
|
2081
|
+
return 0;
|
|
2082
|
+
}
|
|
2083
|
+
if (ssl_nids_to_group_ids(&ssl_impl->config->supported_group_list,
|
|
2084
|
+
Span(groups, num_groups)) &&
|
|
2085
|
+
ssl_impl->config->supported_group_list_flags.Init(
|
|
2086
|
+
ssl_impl->config->supported_group_list.size())) {
|
|
2087
|
+
clear_key_shares_if_invalid(ssl_impl->config.get());
|
|
2088
|
+
return 1;
|
|
2089
|
+
}
|
|
2090
|
+
return 0;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
static bool ssl_str_to_group_ids(Array<uint16_t> *out_group_ids,
|
|
2094
|
+
const char *str) {
|
|
2095
|
+
// Count the number of groups in the list.
|
|
2096
|
+
size_t count = 0;
|
|
2097
|
+
const char *ptr = str, *col;
|
|
2098
|
+
do {
|
|
2099
|
+
col = strchr(ptr, ':');
|
|
2100
|
+
count++;
|
|
2101
|
+
if (col) {
|
|
2102
|
+
ptr = col + 1;
|
|
2103
|
+
}
|
|
2104
|
+
} while (col);
|
|
2105
|
+
|
|
2106
|
+
Array<uint16_t> group_ids;
|
|
2107
|
+
if (!group_ids.InitForOverwrite(count)) {
|
|
2108
|
+
return false;
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
size_t i = 0;
|
|
2112
|
+
ptr = str;
|
|
2113
|
+
do {
|
|
2114
|
+
col = strchr(ptr, ':');
|
|
2115
|
+
if (!ssl_name_to_group_id(&group_ids[i++], ptr,
|
|
2116
|
+
col ? (size_t)(col - ptr) : strlen(ptr))) {
|
|
2117
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_UNSUPPORTED_ELLIPTIC_CURVE);
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2120
|
+
if (col) {
|
|
2121
|
+
ptr = col + 1;
|
|
2122
|
+
}
|
|
2123
|
+
} while (col);
|
|
2124
|
+
|
|
2125
|
+
assert(i == count);
|
|
2126
|
+
if (!check_no_duplicates(group_ids, SSL_R_DUPLICATE_GROUP)) {
|
|
2127
|
+
return false;
|
|
2128
|
+
}
|
|
2129
|
+
*out_group_ids = std::move(group_ids);
|
|
2130
|
+
return true;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
int SSL_CTX_set1_groups_list(SSL_CTX *ctx, const char *groups) {
|
|
2134
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2135
|
+
return ssl_str_to_group_ids(&ctx_impl->supported_group_list, groups) &&
|
|
2136
|
+
ctx_impl->supported_group_list_flags.Init(
|
|
2137
|
+
ctx_impl->supported_group_list.size());
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
int SSL_set1_groups_list(SSL *ssl, const char *groups) {
|
|
2141
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2142
|
+
if (!ssl_impl->config) {
|
|
2143
|
+
return 0;
|
|
2144
|
+
}
|
|
2145
|
+
if (ssl_str_to_group_ids(&ssl_impl->config->supported_group_list, groups) &&
|
|
2146
|
+
ssl_impl->config->supported_group_list_flags.Init(
|
|
2147
|
+
ssl_impl->config->supported_group_list.size())) {
|
|
2148
|
+
clear_key_shares_if_invalid(ssl_impl->config.get());
|
|
2149
|
+
return 1;
|
|
2150
|
+
}
|
|
2151
|
+
return 0;
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
uint16_t SSL_get_group_id(const SSL *ssl) {
|
|
2155
|
+
SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2156
|
+
if (session == nullptr) {
|
|
2157
|
+
return 0;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
return session->group_id;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
int SSL_get_negotiated_group(const SSL *ssl) {
|
|
2164
|
+
uint16_t group_id = SSL_get_group_id(ssl);
|
|
2165
|
+
if (group_id == 0) {
|
|
2166
|
+
return NID_undef;
|
|
2167
|
+
}
|
|
2168
|
+
return ssl_group_id_to_nid(group_id);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
int SSL_set1_client_key_shares(SSL *ssl, const uint16_t *group_ids,
|
|
2172
|
+
size_t num_group_ids) {
|
|
2173
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2174
|
+
if (!ssl_impl->config) {
|
|
2175
|
+
return 0;
|
|
2176
|
+
}
|
|
2177
|
+
auto requested_key_shares = Span(group_ids, num_group_ids);
|
|
2178
|
+
if (!validate_key_shares(requested_key_shares,
|
|
2179
|
+
ssl_impl->config->supported_group_list)) {
|
|
2180
|
+
return 0;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
assert(requested_key_shares.size() <= kNumNamedGroups);
|
|
2184
|
+
ssl_impl->config->client_key_share_selections.emplace();
|
|
2185
|
+
ssl_impl->config->client_key_share_selections->CopyFrom(requested_key_shares);
|
|
2186
|
+
return 1;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
int SSL_set1_server_supported_groups_hint(SSL *ssl,
|
|
2190
|
+
const uint16_t *server_groups,
|
|
2191
|
+
size_t num_server_groups) {
|
|
2192
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2193
|
+
if (!ssl_impl->config) {
|
|
2194
|
+
return 0;
|
|
2195
|
+
}
|
|
2196
|
+
auto span = Span(server_groups, num_server_groups);
|
|
2197
|
+
return ssl_impl->config->server_supported_groups_hint.CopyFrom(span);
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
int SSL_CTX_set_tmp_dh(SSL_CTX *ctx, const DH *dh) { return 1; }
|
|
2201
|
+
|
|
2202
|
+
int SSL_set_tmp_dh(SSL *ssl, const DH *dh) { return 1; }
|
|
2203
|
+
|
|
2204
|
+
STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx) {
|
|
2205
|
+
return FromOpaque(ctx)->cipher_list->ciphers();
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
int SSL_CTX_cipher_in_group(const SSL_CTX *ctx, size_t i) {
|
|
2209
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2210
|
+
if (i >= sk_SSL_CIPHER_num(ctx_impl->cipher_list->ciphers())) {
|
|
2211
|
+
return 0;
|
|
2212
|
+
}
|
|
2213
|
+
return ctx_impl->cipher_list->in_group_flags()[i];
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl) {
|
|
2217
|
+
if (ssl == nullptr) {
|
|
2218
|
+
return nullptr;
|
|
2219
|
+
}
|
|
2220
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2221
|
+
if (ssl_impl->config == nullptr) {
|
|
2222
|
+
assert(ssl_impl->config);
|
|
2223
|
+
return nullptr;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
return ssl_impl->config->cipher_list
|
|
2227
|
+
? ssl_impl->config->cipher_list->ciphers()
|
|
2228
|
+
: ssl_impl->ctx->cipher_list->ciphers();
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
const char *SSL_get_cipher_list(const SSL *ssl, int n) {
|
|
2232
|
+
if (ssl == nullptr) {
|
|
2233
|
+
return nullptr;
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
const STACK_OF(SSL_CIPHER) *sk = SSL_get_ciphers(ssl);
|
|
2237
|
+
if (sk == nullptr || n < 0 ||
|
|
2238
|
+
static_cast<size_t>(n) >= sk_SSL_CIPHER_num(sk)) {
|
|
2239
|
+
return nullptr;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
const SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, n);
|
|
2243
|
+
if (c == nullptr) {
|
|
2244
|
+
return nullptr;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
return c->name;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) {
|
|
2251
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2252
|
+
return ssl_create_cipher_list(&ctx_impl->cipher_list, str,
|
|
2253
|
+
false /* not strict */);
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
int SSL_CTX_set_strict_cipher_list(SSL_CTX *ctx, const char *str) {
|
|
2257
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2258
|
+
return ssl_create_cipher_list(&ctx_impl->cipher_list, str, true /* strict */);
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
int SSL_set_cipher_list(SSL *ssl, const char *str) {
|
|
2262
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2263
|
+
if (!ssl_impl->config) {
|
|
2264
|
+
return 0;
|
|
2265
|
+
}
|
|
2266
|
+
return ssl_create_cipher_list(&ssl_impl->config->cipher_list, str,
|
|
2267
|
+
false /* not strict */);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
int SSL_set_strict_cipher_list(SSL *ssl, const char *str) {
|
|
2271
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2272
|
+
if (!ssl_impl->config) {
|
|
2273
|
+
return 0;
|
|
2274
|
+
}
|
|
2275
|
+
return ssl_create_cipher_list(&ssl_impl->config->cipher_list, str,
|
|
2276
|
+
true /* strict */);
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
const char *SSL_get_servername(const SSL *ssl, const int type) {
|
|
2280
|
+
if (type != TLSEXT_NAMETYPE_host_name) {
|
|
2281
|
+
return nullptr;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2285
|
+
// Historically, `SSL_get_servername` was also the configuration getter
|
|
2286
|
+
// corresponding to `SSL_set_tlsext_host_name`.
|
|
2287
|
+
if (ssl_impl->hostname != nullptr) {
|
|
2288
|
+
return ssl_impl->hostname.get();
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
return ssl_impl->s3->hostname.get();
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
int SSL_get_servername_type(const SSL *ssl) {
|
|
2295
|
+
if (SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name) == nullptr) {
|
|
2296
|
+
return -1;
|
|
2297
|
+
}
|
|
2298
|
+
return TLSEXT_NAMETYPE_host_name;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
void SSL_CTX_set_custom_verify(
|
|
2302
|
+
SSL_CTX *ctx, int mode,
|
|
2303
|
+
enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)) {
|
|
2304
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2305
|
+
ctx_impl->verify_mode = mode;
|
|
2306
|
+
ctx_impl->custom_verify_callback = callback;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
void SSL_set_custom_verify(
|
|
2310
|
+
SSL *ssl, int mode,
|
|
2311
|
+
enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)) {
|
|
2312
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2313
|
+
if (!ssl_impl->config) {
|
|
2314
|
+
return;
|
|
2315
|
+
}
|
|
2316
|
+
ssl_impl->config->verify_mode = mode;
|
|
2317
|
+
ssl_impl->config->custom_verify_callback = callback;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
void SSL_CTX_enable_signed_cert_timestamps(SSL_CTX *ctx) {
|
|
2321
|
+
FromOpaque(ctx)->signed_cert_timestamps_enabled = true;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
void SSL_enable_signed_cert_timestamps(SSL *ssl) {
|
|
2325
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2326
|
+
if (!ssl_impl->config) {
|
|
2327
|
+
return;
|
|
2328
|
+
}
|
|
2329
|
+
ssl_impl->config->signed_cert_timestamps_enabled = true;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
void SSL_CTX_enable_ocsp_stapling(SSL_CTX *ctx) {
|
|
2333
|
+
FromOpaque(ctx)->ocsp_stapling_enabled = true;
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
void SSL_enable_ocsp_stapling(SSL *ssl) {
|
|
2337
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2338
|
+
if (!ssl_impl->config) {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
ssl_impl->config->ocsp_stapling_enabled = true;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
void SSL_get0_signed_cert_timestamp_list(const SSL *ssl, const uint8_t **out,
|
|
2345
|
+
size_t *out_len) {
|
|
2346
|
+
SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2347
|
+
if (FromOpaque(ssl)->server || !session ||
|
|
2348
|
+
!session->signed_cert_timestamp_list) {
|
|
2349
|
+
*out_len = 0;
|
|
2350
|
+
*out = nullptr;
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
*out = CRYPTO_BUFFER_data(session->signed_cert_timestamp_list.get());
|
|
2355
|
+
*out_len = CRYPTO_BUFFER_len(session->signed_cert_timestamp_list.get());
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
void SSL_get0_ocsp_response(const SSL *ssl, const uint8_t **out,
|
|
2359
|
+
size_t *out_len) {
|
|
2360
|
+
SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2361
|
+
if (FromOpaque(ssl)->server || !session || !session->ocsp_response) {
|
|
2362
|
+
*out_len = 0;
|
|
2363
|
+
*out = nullptr;
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
*out = CRYPTO_BUFFER_data(session->ocsp_response.get());
|
|
2368
|
+
*out_len = CRYPTO_BUFFER_len(session->ocsp_response.get());
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
int SSL_set_tlsext_host_name(SSL *ssl, const char *name) {
|
|
2372
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2373
|
+
ssl_impl->hostname.reset();
|
|
2374
|
+
if (name == nullptr) {
|
|
2375
|
+
return 1;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
size_t len = strlen(name);
|
|
2379
|
+
if (len == 0 || len > TLSEXT_MAXLEN_host_name) {
|
|
2380
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
|
|
2381
|
+
return 0;
|
|
2382
|
+
}
|
|
2383
|
+
ssl_impl->hostname.reset(OPENSSL_strdup(name));
|
|
2384
|
+
if (ssl_impl->hostname == nullptr) {
|
|
2385
|
+
return 0;
|
|
2386
|
+
}
|
|
2387
|
+
return 1;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
int SSL_CTX_set_tlsext_servername_callback(
|
|
2391
|
+
SSL_CTX *ctx, int (*callback)(SSL *ssl, int *out_alert, void *arg)) {
|
|
2392
|
+
FromOpaque(ctx)->servername_callback = callback;
|
|
2393
|
+
return 1;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
int SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg) {
|
|
2397
|
+
FromOpaque(ctx)->servername_arg = arg;
|
|
2398
|
+
return 1;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, const uint8_t *peer,
|
|
2402
|
+
unsigned peer_len, const uint8_t *supported,
|
|
2403
|
+
unsigned supported_len) {
|
|
2404
|
+
*out = nullptr;
|
|
2405
|
+
*out_len = 0;
|
|
2406
|
+
|
|
2407
|
+
// Both `peer` and `supported` must be valid protocol lists, but `peer` may be
|
|
2408
|
+
// empty in NPN.
|
|
2409
|
+
auto peer_span = Span(peer, peer_len);
|
|
2410
|
+
auto supported_span = Span(supported, supported_len);
|
|
2411
|
+
if ((!peer_span.empty() && !ssl_is_valid_alpn_list(peer_span)) ||
|
|
2412
|
+
!ssl_is_valid_alpn_list(supported_span)) {
|
|
2413
|
+
return OPENSSL_NPN_NO_OVERLAP;
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
// For each protocol in peer preference order, see if we support it.
|
|
2417
|
+
CBS cbs = peer_span, proto;
|
|
2418
|
+
while (CBS_len(&cbs) != 0) {
|
|
2419
|
+
if (!CBS_get_u8_length_prefixed(&cbs, &proto) || CBS_len(&proto) == 0) {
|
|
2420
|
+
return OPENSSL_NPN_NO_OVERLAP;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
if (ssl_alpn_list_contains_protocol(Span(supported, supported_len),
|
|
2424
|
+
proto)) {
|
|
2425
|
+
// This function is not const-correct for compatibility with existing
|
|
2426
|
+
// callers.
|
|
2427
|
+
*out = const_cast<uint8_t *>(CBS_data(&proto));
|
|
2428
|
+
// A u8 length prefix will fit in `uint8_t`.
|
|
2429
|
+
*out_len = static_cast<uint8_t>(CBS_len(&proto));
|
|
2430
|
+
return OPENSSL_NPN_NEGOTIATED;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
// There's no overlap between our protocols and the peer's list. In ALPN, the
|
|
2435
|
+
// caller is expected to fail the connection with no_application_protocol. In
|
|
2436
|
+
// NPN, the caller is expected to opportunistically select the first protocol.
|
|
2437
|
+
// See draft-agl-tls-nextprotoneg-04, section 6.
|
|
2438
|
+
cbs = supported_span;
|
|
2439
|
+
if (!CBS_get_u8_length_prefixed(&cbs, &proto) || CBS_len(&proto) == 0) {
|
|
2440
|
+
return OPENSSL_NPN_NO_OVERLAP;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
// See above.
|
|
2444
|
+
*out = const_cast<uint8_t *>(CBS_data(&proto));
|
|
2445
|
+
*out_len = static_cast<uint8_t>(CBS_len(&proto));
|
|
2446
|
+
return OPENSSL_NPN_NO_OVERLAP;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
void SSL_get0_next_proto_negotiated(const SSL *ssl, const uint8_t **out_data,
|
|
2450
|
+
unsigned *out_len) {
|
|
2451
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2452
|
+
// NPN protocols have one-byte lengths, so they must fit in `unsigned`.
|
|
2453
|
+
assert(ssl_impl->s3->next_proto_negotiated.size() <= UINT_MAX);
|
|
2454
|
+
*out_data = ssl_impl->s3->next_proto_negotiated.data();
|
|
2455
|
+
*out_len = static_cast<unsigned>(ssl_impl->s3->next_proto_negotiated.size());
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
void SSL_CTX_set_next_protos_advertised_cb(
|
|
2459
|
+
SSL_CTX *ctx,
|
|
2460
|
+
int (*cb)(SSL *ssl, const uint8_t **out, unsigned *out_len, void *arg),
|
|
2461
|
+
void *arg) {
|
|
2462
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2463
|
+
ctx_impl->next_protos_advertised_cb = cb;
|
|
2464
|
+
ctx_impl->next_protos_advertised_cb_arg = arg;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
void SSL_CTX_set_next_proto_select_cb(SSL_CTX *ctx,
|
|
2468
|
+
int (*cb)(SSL *ssl, uint8_t **out,
|
|
2469
|
+
uint8_t *out_len,
|
|
2470
|
+
const uint8_t *in,
|
|
2471
|
+
unsigned in_len, void *arg),
|
|
2472
|
+
void *arg) {
|
|
2473
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2474
|
+
ctx_impl->next_proto_select_cb = cb;
|
|
2475
|
+
ctx_impl->next_proto_select_cb_arg = arg;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const uint8_t *protos,
|
|
2479
|
+
size_t protos_len) {
|
|
2480
|
+
// Note this function's return value is backwards.
|
|
2481
|
+
auto span = Span(protos, protos_len);
|
|
2482
|
+
if (!span.empty() && !ssl_is_valid_alpn_list(span)) {
|
|
2483
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_ALPN_PROTOCOL_LIST);
|
|
2484
|
+
return 1;
|
|
2485
|
+
}
|
|
2486
|
+
return FromOpaque(ctx)->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
int SSL_set_alpn_protos(SSL *ssl, const uint8_t *protos, size_t protos_len) {
|
|
2490
|
+
// Note this function's return value is backwards.
|
|
2491
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2492
|
+
if (!ssl_impl->config) {
|
|
2493
|
+
return 1;
|
|
2494
|
+
}
|
|
2495
|
+
auto span = Span(protos, protos_len);
|
|
2496
|
+
if (!span.empty() && !ssl_is_valid_alpn_list(span)) {
|
|
2497
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_ALPN_PROTOCOL_LIST);
|
|
2498
|
+
return 1;
|
|
2499
|
+
}
|
|
2500
|
+
return ssl_impl->config->alpn_client_proto_list.CopyFrom(span) ? 0 : 1;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
|
|
2504
|
+
int (*cb)(SSL *ssl, const uint8_t **out,
|
|
2505
|
+
uint8_t *out_len, const uint8_t *in,
|
|
2506
|
+
unsigned in_len, void *arg),
|
|
2507
|
+
void *arg) {
|
|
2508
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2509
|
+
ctx_impl->alpn_select_cb = cb;
|
|
2510
|
+
ctx_impl->alpn_select_cb_arg = arg;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
void SSL_get0_alpn_selected(const SSL *ssl, const uint8_t **out_data,
|
|
2514
|
+
unsigned *out_len) {
|
|
2515
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2516
|
+
Span<const uint8_t> protocol;
|
|
2517
|
+
if (SSL_in_early_data(ssl_impl) && !ssl_impl->server) {
|
|
2518
|
+
protocol = ssl_impl->s3->hs->early_session->early_alpn;
|
|
2519
|
+
} else {
|
|
2520
|
+
protocol = ssl_impl->s3->alpn_selected;
|
|
2521
|
+
}
|
|
2522
|
+
// ALPN protocols have one-byte lengths, so they must fit in `unsigned`.
|
|
2523
|
+
assert(protocol.size() < UINT_MAX);
|
|
2524
|
+
*out_data = protocol.data();
|
|
2525
|
+
*out_len = static_cast<unsigned>(protocol.size());
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
void SSL_CTX_set_allow_unknown_alpn_protos(SSL_CTX *ctx, int enabled) {
|
|
2529
|
+
FromOpaque(ctx)->allow_unknown_alpn_protos = !!enabled;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
int SSL_add_application_settings(SSL *ssl, const uint8_t *proto,
|
|
2533
|
+
size_t proto_len, const uint8_t *settings,
|
|
2534
|
+
size_t settings_len) {
|
|
2535
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2536
|
+
if (!ssl_impl->config) {
|
|
2537
|
+
return 0;
|
|
2538
|
+
}
|
|
2539
|
+
ALPSConfig config;
|
|
2540
|
+
if (!config.protocol.CopyFrom(Span(proto, proto_len)) ||
|
|
2541
|
+
!config.settings.CopyFrom(Span(settings, settings_len)) ||
|
|
2542
|
+
!ssl_impl->config->alps_configs.Push(std::move(config))) {
|
|
2543
|
+
return 0;
|
|
2544
|
+
}
|
|
2545
|
+
return 1;
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
void SSL_get0_peer_application_settings(const SSL *ssl,
|
|
2549
|
+
const uint8_t **out_data,
|
|
2550
|
+
size_t *out_len) {
|
|
2551
|
+
const SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2552
|
+
Span<const uint8_t> settings =
|
|
2553
|
+
session ? session->peer_application_settings : Span<const uint8_t>();
|
|
2554
|
+
*out_data = settings.data();
|
|
2555
|
+
*out_len = settings.size();
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
int SSL_has_application_settings(const SSL *ssl) {
|
|
2559
|
+
const SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2560
|
+
return session && session->has_application_settings;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
void SSL_set_alps_use_new_codepoint(SSL *ssl, int use_new) {
|
|
2564
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2565
|
+
if (!ssl_impl->config) {
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
ssl_impl->config->alps_use_new_codepoint = !!use_new;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
int SSL_CTX_add_cert_compression_alg(SSL_CTX *ctx, uint16_t alg_id,
|
|
2572
|
+
ssl_cert_compression_func_t compress,
|
|
2573
|
+
ssl_cert_decompression_func_t decompress) {
|
|
2574
|
+
assert(compress != nullptr || decompress != nullptr);
|
|
2575
|
+
|
|
2576
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2577
|
+
for (const auto &alg : ctx_impl->cert_compression_algs) {
|
|
2578
|
+
if (alg.alg_id == alg_id) {
|
|
2579
|
+
return 0;
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
CertCompressionAlg alg;
|
|
2584
|
+
alg.alg_id = alg_id;
|
|
2585
|
+
alg.compress = compress;
|
|
2586
|
+
alg.decompress = decompress;
|
|
2587
|
+
return ctx_impl->cert_compression_algs.Push(alg);
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
void SSL_CTX_set_tls_channel_id_enabled(SSL_CTX *ctx, int enabled) {
|
|
2591
|
+
FromOpaque(ctx)->channel_id_enabled = !!enabled;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx) {
|
|
2595
|
+
SSL_CTX_set_tls_channel_id_enabled(ctx, 1);
|
|
2596
|
+
return 1;
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
void SSL_set_tls_channel_id_enabled(SSL *ssl, int enabled) {
|
|
2600
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2601
|
+
if (!ssl_impl->config) {
|
|
2602
|
+
return;
|
|
2603
|
+
}
|
|
2604
|
+
ssl_impl->config->channel_id_enabled = !!enabled;
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
int SSL_enable_tls_channel_id(SSL *ssl) {
|
|
2608
|
+
SSL_set_tls_channel_id_enabled(ssl, 1);
|
|
2609
|
+
return 1;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
int SSL_CTX_set1_tls_channel_id(SSL_CTX *ctx, EVP_PKEY *private_key) {
|
|
2613
|
+
if (EVP_PKEY_get_ec_curve_nid(private_key) != NID_X9_62_prime256v1) {
|
|
2614
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_NOT_P256);
|
|
2615
|
+
return 0;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
FromOpaque(ctx)->channel_id_private = UpRef(private_key);
|
|
2619
|
+
return 1;
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
int SSL_set1_tls_channel_id(SSL *ssl, EVP_PKEY *private_key) {
|
|
2623
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2624
|
+
if (!ssl_impl->config) {
|
|
2625
|
+
return 0;
|
|
2626
|
+
}
|
|
2627
|
+
if (EVP_PKEY_get_ec_curve_nid(private_key) != NID_X9_62_prime256v1) {
|
|
2628
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CHANNEL_ID_NOT_P256);
|
|
2629
|
+
return 0;
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
ssl_impl->config->channel_id_private = UpRef(private_key);
|
|
2633
|
+
return 1;
|
|
2634
|
+
}
|
|
2635
|
+
|
|
2636
|
+
size_t SSL_get_tls_channel_id(SSL *ssl, uint8_t *out, size_t max_out) {
|
|
2637
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2638
|
+
if (!ssl_impl->s3->channel_id_valid) {
|
|
2639
|
+
return 0;
|
|
2640
|
+
}
|
|
2641
|
+
OPENSSL_memcpy(out, ssl_impl->s3->channel_id, (max_out < 64) ? max_out : 64);
|
|
2642
|
+
return 64;
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
size_t SSL_get0_certificate_types(const SSL *ssl, const uint8_t **out_types) {
|
|
2646
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2647
|
+
Span<const uint8_t> types;
|
|
2648
|
+
if (!ssl_impl->server && ssl_impl->s3->hs != nullptr) {
|
|
2649
|
+
types = ssl_impl->s3->hs->certificate_types;
|
|
2650
|
+
}
|
|
2651
|
+
*out_types = types.data();
|
|
2652
|
+
return types.size();
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
size_t SSL_get0_peer_verify_algorithms(const SSL *ssl,
|
|
2656
|
+
const uint16_t **out_sigalgs) {
|
|
2657
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2658
|
+
Span<const uint16_t> sigalgs;
|
|
2659
|
+
if (ssl_impl->s3->hs != nullptr) {
|
|
2660
|
+
sigalgs = ssl_impl->s3->hs->peer_sigalgs;
|
|
2661
|
+
}
|
|
2662
|
+
*out_sigalgs = sigalgs.data();
|
|
2663
|
+
return sigalgs.size();
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
size_t SSL_get0_peer_delegation_algorithms(const SSL *ssl,
|
|
2667
|
+
const uint16_t **out_sigalgs) {
|
|
2668
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2669
|
+
Span<const uint16_t> sigalgs;
|
|
2670
|
+
if (ssl_impl->s3->hs != nullptr) {
|
|
2671
|
+
sigalgs = ssl_impl->s3->hs->peer_delegated_credential_sigalgs;
|
|
2672
|
+
}
|
|
2673
|
+
*out_sigalgs = sigalgs.data();
|
|
2674
|
+
return sigalgs.size();
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
EVP_PKEY *SSL_get_privatekey(const SSL *ssl) {
|
|
2678
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2679
|
+
if (!ssl_impl->config) {
|
|
2680
|
+
assert(ssl_impl->config);
|
|
2681
|
+
return nullptr;
|
|
2682
|
+
}
|
|
2683
|
+
return ssl_impl->config->cert->legacy_credential->privkey.get();
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx) {
|
|
2687
|
+
return FromOpaque(ctx)->cert->legacy_credential->privkey.get();
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl) {
|
|
2691
|
+
const SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2692
|
+
return session == nullptr ? nullptr : session->cipher;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
int SSL_session_reused(const SSL *ssl) {
|
|
2696
|
+
return FromOpaque(ssl)->s3->session_reused || SSL_in_early_data(ssl);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
const COMP_METHOD *SSL_get_current_compression(SSL *ssl) { return nullptr; }
|
|
2700
|
+
|
|
2701
|
+
const COMP_METHOD *SSL_get_current_expansion(SSL *ssl) { return nullptr; }
|
|
2702
|
+
|
|
2703
|
+
int SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; }
|
|
2704
|
+
|
|
2705
|
+
int SSL_get_peer_tmp_key(SSL *ssl, EVP_PKEY **out_key) { return 0; }
|
|
2706
|
+
|
|
2707
|
+
void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode) {
|
|
2708
|
+
FromOpaque(ctx)->quiet_shutdown = (mode != 0);
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx) {
|
|
2712
|
+
return FromOpaque(ctx)->quiet_shutdown;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
void SSL_set_quiet_shutdown(SSL *ssl, int mode) {
|
|
2716
|
+
FromOpaque(ssl)->quiet_shutdown = (mode != 0);
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
int SSL_get_quiet_shutdown(const SSL *ssl) {
|
|
2720
|
+
return FromOpaque(ssl)->quiet_shutdown;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
void SSL_set_shutdown(SSL *ssl, int mode) {
|
|
2724
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2725
|
+
// It is an error to clear any bits that have already been set. (We can't try
|
|
2726
|
+
// to get a second close_notify or send two.)
|
|
2727
|
+
assert((SSL_get_shutdown(ssl) & mode) == SSL_get_shutdown(ssl));
|
|
2728
|
+
|
|
2729
|
+
if (mode & SSL_RECEIVED_SHUTDOWN &&
|
|
2730
|
+
ssl_impl->s3->read_shutdown == ssl_shutdown_none) {
|
|
2731
|
+
ssl_impl->s3->read_shutdown = ssl_shutdown_close_notify;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
if (mode & SSL_SENT_SHUTDOWN &&
|
|
2735
|
+
ssl_impl->s3->write_shutdown == ssl_shutdown_none) {
|
|
2736
|
+
ssl_impl->s3->write_shutdown = ssl_shutdown_close_notify;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
int SSL_get_shutdown(const SSL *ssl) {
|
|
2741
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2742
|
+
int ret = 0;
|
|
2743
|
+
if (ssl_impl->s3->read_shutdown != ssl_shutdown_none) {
|
|
2744
|
+
// Historically, OpenSSL set `SSL_RECEIVED_SHUTDOWN` on both close_notify
|
|
2745
|
+
// and fatal alert.
|
|
2746
|
+
ret |= SSL_RECEIVED_SHUTDOWN;
|
|
2747
|
+
}
|
|
2748
|
+
if (ssl_impl->s3->write_shutdown == ssl_shutdown_close_notify) {
|
|
2749
|
+
// Historically, OpenSSL set `SSL_SENT_SHUTDOWN` on only close_notify.
|
|
2750
|
+
ret |= SSL_SENT_SHUTDOWN;
|
|
2751
|
+
}
|
|
2752
|
+
return ret;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) { return FromOpaque(ssl)->ctx.get(); }
|
|
2756
|
+
|
|
2757
|
+
SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) {
|
|
2758
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2759
|
+
if (!ssl_impl->config) {
|
|
2760
|
+
return nullptr;
|
|
2761
|
+
}
|
|
2762
|
+
if (ssl_impl->ctx.get() == ctx) {
|
|
2763
|
+
return ssl_impl->ctx.get();
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
// One cannot change the X.509 callbacks during a connection.
|
|
2767
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2768
|
+
if (ssl_impl->ctx->x509_method != ctx_impl->x509_method) {
|
|
2769
|
+
assert(0);
|
|
2770
|
+
return nullptr;
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
UniquePtr<CERT> new_cert = ssl_cert_dup(ctx_impl->cert.get());
|
|
2774
|
+
if (!new_cert) {
|
|
2775
|
+
return nullptr;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
ssl_impl->config->cert = std::move(new_cert);
|
|
2779
|
+
ssl_impl->ctx = UpRef(ctx_impl);
|
|
2780
|
+
ssl_impl->enable_early_data = ssl_impl->ctx->enable_early_data;
|
|
2781
|
+
|
|
2782
|
+
return ssl_impl->ctx.get();
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
void SSL_set_info_callback(SSL *ssl,
|
|
2786
|
+
void (*cb)(const SSL *ssl, int type, int value)) {
|
|
2787
|
+
FromOpaque(ssl)->info_callback = cb;
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type,
|
|
2791
|
+
int value) {
|
|
2792
|
+
return FromOpaque(ssl)->info_callback;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
int SSL_state(const SSL *ssl) {
|
|
2796
|
+
return SSL_in_init(ssl) ? SSL_ST_INIT : SSL_ST_OK;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
void SSL_set_state(SSL *ssl, int state) {}
|
|
2800
|
+
|
|
2801
|
+
char *SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len) {
|
|
2802
|
+
if (len <= 0) {
|
|
2803
|
+
return nullptr;
|
|
2804
|
+
}
|
|
2805
|
+
buf[0] = '\0';
|
|
2806
|
+
return buf;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
int SSL_get_shared_sigalgs(SSL *ssl, int idx, int *psign, int *phash,
|
|
2810
|
+
int *psignandhash, uint8_t *rsig, uint8_t *rhash) {
|
|
2811
|
+
return 0;
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
int SSL_CTX_set_quic_method(SSL_CTX *ctx, const SSL_QUIC_METHOD *quic_method) {
|
|
2815
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
2816
|
+
if (ctx_impl->method->is_dtls) {
|
|
2817
|
+
return 0;
|
|
2818
|
+
}
|
|
2819
|
+
ctx_impl->quic_method = quic_method;
|
|
2820
|
+
return 1;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
int SSL_set_quic_method(SSL *ssl, const SSL_QUIC_METHOD *quic_method) {
|
|
2824
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2825
|
+
if (ssl_impl->method->is_dtls) {
|
|
2826
|
+
return 0;
|
|
2827
|
+
}
|
|
2828
|
+
ssl_impl->quic_method = quic_method;
|
|
2829
|
+
return 1;
|
|
2830
|
+
}
|
|
2831
|
+
|
|
2832
|
+
int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
|
|
2833
|
+
CRYPTO_EX_dup *dup_unused, CRYPTO_EX_free *free_func) {
|
|
2834
|
+
return CRYPTO_get_ex_new_index_ex(&g_ex_data_class_ssl, argl, argp,
|
|
2835
|
+
free_func);
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
int SSL_set_ex_data(SSL *ssl, int idx, void *data) {
|
|
2839
|
+
return CRYPTO_set_ex_data(&FromOpaque(ssl)->ex_data, idx, data);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
void *SSL_get_ex_data(const SSL *ssl, int idx) {
|
|
2843
|
+
return CRYPTO_get_ex_data(&FromOpaque(ssl)->ex_data, idx);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
|
|
2847
|
+
CRYPTO_EX_dup *dup_unused,
|
|
2848
|
+
CRYPTO_EX_free *free_func) {
|
|
2849
|
+
return CRYPTO_get_ex_new_index_ex(&g_ex_data_class_ssl_ctx, argl, argp,
|
|
2850
|
+
free_func);
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *data) {
|
|
2854
|
+
return CRYPTO_set_ex_data(&FromOpaque(ctx)->ex_data, idx, data);
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx) {
|
|
2858
|
+
return CRYPTO_get_ex_data(&FromOpaque(ctx)->ex_data, idx);
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
int SSL_want(const SSL *ssl) {
|
|
2862
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2863
|
+
// Historically, OpenSSL did not track `SSL_ERROR_ZERO_RETURN` as an `rwstate`
|
|
2864
|
+
// value. We do, but map it back to `SSL_ERROR_NONE` to preserve the original
|
|
2865
|
+
// behavior.
|
|
2866
|
+
return ssl_impl->s3->rwstate == SSL_ERROR_ZERO_RETURN ? SSL_ERROR_NONE
|
|
2867
|
+
: ssl_impl->s3->rwstate;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
|
|
2871
|
+
RSA *(*cb)(SSL *ssl, int is_export,
|
|
2872
|
+
int keylength)) {}
|
|
2873
|
+
|
|
2874
|
+
void SSL_set_tmp_rsa_callback(SSL *ssl, RSA *(*cb)(SSL *ssl, int is_export,
|
|
2875
|
+
int keylength)) {}
|
|
2876
|
+
|
|
2877
|
+
void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
|
|
2878
|
+
DH *(*cb)(SSL *ssl, int is_export,
|
|
2879
|
+
int keylength)) {}
|
|
2880
|
+
|
|
2881
|
+
void SSL_set_tmp_dh_callback(SSL *ssl, DH *(*cb)(SSL *ssl, int is_export,
|
|
2882
|
+
int keylength)) {}
|
|
2883
|
+
|
|
2884
|
+
static int use_psk_identity_hint(UniquePtr<char> *out,
|
|
2885
|
+
const char *identity_hint) {
|
|
2886
|
+
if (identity_hint != nullptr &&
|
|
2887
|
+
strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) {
|
|
2888
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DATA_LENGTH_TOO_LONG);
|
|
2889
|
+
return 0;
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
// Clear currently configured hint, if any.
|
|
2893
|
+
out->reset();
|
|
2894
|
+
|
|
2895
|
+
// Treat the empty hint as not supplying one. Plain PSK makes it possible to
|
|
2896
|
+
// send either no hint (omit ServerKeyExchange) or an empty hint, while
|
|
2897
|
+
// ECDHE_PSK can only spell empty hint. Having different capabilities is odd,
|
|
2898
|
+
// so we interpret empty and missing as identical.
|
|
2899
|
+
if (identity_hint != nullptr && identity_hint[0] != '\0') {
|
|
2900
|
+
out->reset(OPENSSL_strdup(identity_hint));
|
|
2901
|
+
if (*out == nullptr) {
|
|
2902
|
+
return 0;
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
return 1;
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint) {
|
|
2910
|
+
return use_psk_identity_hint(&FromOpaque(ctx)->psk_identity_hint,
|
|
2911
|
+
identity_hint);
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
int SSL_use_psk_identity_hint(SSL *ssl, const char *identity_hint) {
|
|
2915
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2916
|
+
if (!ssl_impl->config) {
|
|
2917
|
+
return 0;
|
|
2918
|
+
}
|
|
2919
|
+
return use_psk_identity_hint(&ssl_impl->config->psk_identity_hint,
|
|
2920
|
+
identity_hint);
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
const char *SSL_get_psk_identity_hint(const SSL *ssl) {
|
|
2924
|
+
if (ssl == nullptr) {
|
|
2925
|
+
return nullptr;
|
|
2926
|
+
}
|
|
2927
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
2928
|
+
if (ssl_impl->config == nullptr) {
|
|
2929
|
+
assert(ssl_impl->config);
|
|
2930
|
+
return nullptr;
|
|
2931
|
+
}
|
|
2932
|
+
return ssl_impl->config->psk_identity_hint.get();
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
const char *SSL_get_psk_identity(const SSL *ssl) {
|
|
2936
|
+
if (ssl == nullptr) {
|
|
2937
|
+
return nullptr;
|
|
2938
|
+
}
|
|
2939
|
+
SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
2940
|
+
if (session == nullptr) {
|
|
2941
|
+
return nullptr;
|
|
2942
|
+
}
|
|
2943
|
+
return session->psk_identity.get();
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
void SSL_set_psk_client_callback(
|
|
2947
|
+
SSL *ssl, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
|
|
2948
|
+
unsigned max_identity_len, uint8_t *psk,
|
|
2949
|
+
unsigned max_psk_len)) {
|
|
2950
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2951
|
+
if (!ssl_impl->config) {
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
ssl_impl->config->psk_client_callback = cb;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
void SSL_CTX_set_psk_client_callback(
|
|
2958
|
+
SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *hint, char *identity,
|
|
2959
|
+
unsigned max_identity_len, uint8_t *psk,
|
|
2960
|
+
unsigned max_psk_len)) {
|
|
2961
|
+
FromOpaque(ctx)->psk_client_callback = cb;
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2964
|
+
void SSL_set_psk_server_callback(SSL *ssl,
|
|
2965
|
+
unsigned (*cb)(SSL *ssl, const char *identity,
|
|
2966
|
+
uint8_t *psk,
|
|
2967
|
+
unsigned max_psk_len)) {
|
|
2968
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
2969
|
+
if (!ssl_impl->config) {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
ssl_impl->config->psk_server_callback = cb;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
void SSL_CTX_set_psk_server_callback(
|
|
2976
|
+
SSL_CTX *ctx, unsigned (*cb)(SSL *ssl, const char *identity, uint8_t *psk,
|
|
2977
|
+
unsigned max_psk_len)) {
|
|
2978
|
+
FromOpaque(ctx)->psk_server_callback = cb;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
|
|
2982
|
+
void (*cb)(int write_p, int version,
|
|
2983
|
+
int content_type, const void *buf,
|
|
2984
|
+
size_t len, SSL *ssl, void *arg)) {
|
|
2985
|
+
FromOpaque(ctx)->msg_callback = cb;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg) {
|
|
2989
|
+
FromOpaque(ctx)->msg_callback_arg = arg;
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
void SSL_set_msg_callback(SSL *ssl,
|
|
2993
|
+
void (*cb)(int write_p, int version, int content_type,
|
|
2994
|
+
const void *buf, size_t len, SSL *ssl,
|
|
2995
|
+
void *arg)) {
|
|
2996
|
+
FromOpaque(ssl)->msg_callback = cb;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
void SSL_set_msg_callback_arg(SSL *ssl, void *arg) {
|
|
3000
|
+
FromOpaque(ssl)->msg_callback_arg = arg;
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
void SSL_CTX_set_keylog_callback(SSL_CTX *ctx,
|
|
3004
|
+
void (*cb)(const SSL *ssl, const char *line)) {
|
|
3005
|
+
FromOpaque(ctx)->keylog_callback = cb;
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
void (*SSL_CTX_get_keylog_callback(const SSL_CTX *ctx))(const SSL *ssl,
|
|
3009
|
+
const char *line) {
|
|
3010
|
+
return FromOpaque(ctx)->keylog_callback;
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
void SSL_CTX_set_current_time_cb(SSL_CTX *ctx,
|
|
3014
|
+
void (*cb)(const SSL *ssl,
|
|
3015
|
+
struct timeval *out_clock)) {
|
|
3016
|
+
FromOpaque(ctx)->current_time_cb = cb;
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
int SSL_can_release_private_key(const SSL *ssl) {
|
|
3020
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3021
|
+
if (ssl_can_renegotiate(ssl_impl)) {
|
|
3022
|
+
// If the connection can renegotiate (client only), the private key may be
|
|
3023
|
+
// used in a future handshake.
|
|
3024
|
+
return 0;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
// Otherwise, this is determined by the current handshake.
|
|
3028
|
+
return !ssl_impl->s3->hs || ssl_impl->s3->hs->can_release_private_key;
|
|
3029
|
+
}
|
|
3030
|
+
|
|
3031
|
+
int SSL_is_init_finished(const SSL *ssl) { return !SSL_in_init(ssl); }
|
|
3032
|
+
|
|
3033
|
+
int SSL_in_init(const SSL *ssl) {
|
|
3034
|
+
// This returns false once all the handshake state has been finalized, to
|
|
3035
|
+
// allow callbacks and getters based on SSL_in_init to return the correct
|
|
3036
|
+
// values.
|
|
3037
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3038
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
3039
|
+
return hs != nullptr && !hs->handshake_finalized;
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
int SSL_in_false_start(const SSL *ssl) {
|
|
3043
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3044
|
+
if (ssl_impl->s3->hs == nullptr) {
|
|
3045
|
+
return 0;
|
|
3046
|
+
}
|
|
3047
|
+
return ssl_impl->s3->hs->in_false_start;
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
int SSL_cutthrough_complete(const SSL *ssl) { return SSL_in_false_start(ssl); }
|
|
3051
|
+
|
|
3052
|
+
int SSL_is_server(const SSL *ssl) { return FromOpaque(ssl)->server; }
|
|
3053
|
+
|
|
3054
|
+
int SSL_is_dtls(const SSL *ssl) { return FromOpaque(ssl)->method->is_dtls; }
|
|
3055
|
+
|
|
3056
|
+
int SSL_is_quic(const SSL *ssl) {
|
|
3057
|
+
return FromOpaque(ssl)->quic_method != nullptr;
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
void SSL_CTX_set_select_certificate_cb(
|
|
3061
|
+
SSL_CTX *ctx,
|
|
3062
|
+
enum ssl_select_cert_result_t (*cb)(const SSL_CLIENT_HELLO *)) {
|
|
3063
|
+
FromOpaque(ctx)->select_certificate_cb = cb;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
void SSL_CTX_set_dos_protection_cb(SSL_CTX *ctx,
|
|
3067
|
+
int (*cb)(const SSL_CLIENT_HELLO *)) {
|
|
3068
|
+
FromOpaque(ctx)->dos_protection_cb = cb;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
void SSL_CTX_set_reverify_on_resume(SSL_CTX *ctx, int enabled) {
|
|
3072
|
+
FromOpaque(ctx)->reverify_on_resume = !!enabled;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
void SSL_set_renegotiate_mode(SSL *ssl, enum ssl_renegotiate_mode_t mode) {
|
|
3076
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3077
|
+
ssl_impl->renegotiate_mode = mode;
|
|
3078
|
+
|
|
3079
|
+
// Check if `ssl_can_renegotiate` has changed and the configuration may now be
|
|
3080
|
+
// shed. HTTP clients may initially allow renegotiation for HTTP/1.1, and then
|
|
3081
|
+
// disable after the handshake once the ALPN protocol is known to be HTTP/2.
|
|
3082
|
+
ssl_maybe_shed_handshake_config(ssl_impl);
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3085
|
+
int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv,
|
|
3086
|
+
const uint8_t **out_write_iv, size_t *out_iv_len) {
|
|
3087
|
+
// No cipher suites maintain stateful internal IVs in DTLS. It would not be
|
|
3088
|
+
// compatible with reordering.
|
|
3089
|
+
if (SSL_is_dtls(ssl)) {
|
|
3090
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
3091
|
+
return 0;
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3095
|
+
size_t write_iv_len;
|
|
3096
|
+
if (!ssl_impl->s3->aead_read_ctx->GetIV(out_read_iv, out_iv_len) ||
|
|
3097
|
+
!ssl_impl->s3->aead_write_ctx->GetIV(out_write_iv, &write_iv_len) ||
|
|
3098
|
+
*out_iv_len != write_iv_len) {
|
|
3099
|
+
return 0;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
return 1;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
uint64_t SSL_get_read_sequence(const SSL *ssl) {
|
|
3106
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3107
|
+
if (SSL_is_dtls(ssl)) {
|
|
3108
|
+
// TODO(crbug.com/42290608): This API should not be implemented for DTLS or
|
|
3109
|
+
// QUIC. In QUIC we do not maintain a sequence number.
|
|
3110
|
+
const DTLSReadEpoch *read_epoch = &ssl_impl->d1->read_epoch;
|
|
3111
|
+
return DTLSRecordNumber(read_epoch->epoch, read_epoch->bitmap.max_seq_num())
|
|
3112
|
+
.combined();
|
|
3113
|
+
}
|
|
3114
|
+
return ssl_impl->s3->read_sequence;
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
uint64_t SSL_get_write_sequence(const SSL *ssl) {
|
|
3118
|
+
// TODO(crbug.com/42290608): This API should not be implemented for DTLS or
|
|
3119
|
+
// QUIC. In QUIC we do not maintain a sequence number. In DTLS, this API isn't
|
|
3120
|
+
// harmful per se, but the caller already needs to use a DTLS-specific API on
|
|
3121
|
+
// the read side.
|
|
3122
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3123
|
+
if (SSL_is_dtls(ssl)) {
|
|
3124
|
+
return ssl_impl->d1->write_epoch.next_record.combined();
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
return ssl_impl->s3->write_sequence;
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
int SSL_is_dtls_handshake_idle(const SSL *ssl) {
|
|
3131
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3132
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3133
|
+
|
|
3134
|
+
return !SSL_in_init(ssl) &&
|
|
3135
|
+
// No unacknowledged messages in DTLS 1.3. In DTLS 1.2, there no ACKs
|
|
3136
|
+
// and we currently never clear `outgoing_messages` on the side that
|
|
3137
|
+
// speaks last.
|
|
3138
|
+
(ssl_protocol_version(ssl_impl) < TLS1_3_VERSION ||
|
|
3139
|
+
ssl_impl->d1->outgoing_messages.empty()) &&
|
|
3140
|
+
// No partial or out-of-order messages.
|
|
3141
|
+
std::all_of(std::begin(ssl_impl->d1->incoming_messages),
|
|
3142
|
+
std::end(ssl_impl->d1->incoming_messages),
|
|
3143
|
+
[](const auto &msg) { return msg == nullptr; }) &&
|
|
3144
|
+
// Not trying to send a KeyUpdate.
|
|
3145
|
+
!ssl_impl->s3->key_update_pending &&
|
|
3146
|
+
ssl_impl->d1->queued_key_update == bssl::QueuedKeyUpdate::kNone;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
uint32_t SSL_get_dtls_handshake_read_seq(const SSL *ssl) {
|
|
3150
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3151
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3152
|
+
return ssl_impl->d1->handshake_read_overflow
|
|
3153
|
+
? uint32_t{0x10000}
|
|
3154
|
+
: uint32_t{ssl_impl->d1->handshake_read_seq};
|
|
3155
|
+
}
|
|
3156
|
+
|
|
3157
|
+
uint32_t SSL_get_dtls_handshake_write_seq(const SSL *ssl) {
|
|
3158
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3159
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3160
|
+
return ssl_impl->d1->handshake_write_overflow
|
|
3161
|
+
? uint32_t{0x10000}
|
|
3162
|
+
: uint32_t{ssl_impl->d1->handshake_write_seq};
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
uint16_t SSL_get_dtls_read_epoch(const SSL *ssl) {
|
|
3166
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3167
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3168
|
+
// Return the highest available epoch.
|
|
3169
|
+
return ssl_impl->d1->next_read_epoch ? ssl_impl->d1->next_read_epoch->epoch
|
|
3170
|
+
: ssl_impl->d1->read_epoch.epoch;
|
|
3171
|
+
}
|
|
3172
|
+
|
|
3173
|
+
uint16_t SSL_get_dtls_write_epoch(const SSL *ssl) {
|
|
3174
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3175
|
+
return FromOpaque(ssl)->d1->write_epoch.epoch();
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
uint64_t SSL_get_dtls_read_sequence(const SSL *ssl, uint16_t epoch) {
|
|
3179
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3180
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3181
|
+
const DTLSReadEpoch *read_epoch = dtls_get_read_epoch(ssl_impl, epoch);
|
|
3182
|
+
if (read_epoch == nullptr) {
|
|
3183
|
+
return UINT64_MAX;
|
|
3184
|
+
}
|
|
3185
|
+
uint64_t max_seq_num = read_epoch->bitmap.max_seq_num();
|
|
3186
|
+
assert(max_seq_num <= DTLSRecordNumber::kMaxSequence);
|
|
3187
|
+
if (read_epoch->bitmap.ShouldDiscard(max_seq_num)) {
|
|
3188
|
+
// Increment to get to an available sequence number.
|
|
3189
|
+
max_seq_num++;
|
|
3190
|
+
} else {
|
|
3191
|
+
// If `max_seq_num` was available, the bitmap must have been empty.
|
|
3192
|
+
assert(max_seq_num == 0);
|
|
3193
|
+
}
|
|
3194
|
+
return max_seq_num;
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
uint64_t SSL_get_dtls_write_sequence(const SSL *ssl, uint16_t epoch) {
|
|
3198
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3199
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3200
|
+
const DTLSWriteEpoch *write_epoch = dtls_get_write_epoch(ssl_impl, epoch);
|
|
3201
|
+
if (write_epoch == nullptr) {
|
|
3202
|
+
return UINT64_MAX;
|
|
3203
|
+
}
|
|
3204
|
+
return write_epoch->next_record.sequence();
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
template <typename EpochState>
|
|
3208
|
+
static int get_dtls_traffic_secret(
|
|
3209
|
+
const SSLImpl *ssl, EpochState *(*get_epoch)(const SSLImpl *, uint16_t),
|
|
3210
|
+
const uint8_t **out_data, size_t *out_len, uint16_t epoch) {
|
|
3211
|
+
BSSL_CHECK(SSL_is_dtls(ssl));
|
|
3212
|
+
// This function only applies to encrypted DTLS 1.3 epochs.
|
|
3213
|
+
if (epoch == 0 || ssl->s3->version == 0 ||
|
|
3214
|
+
ssl_protocol_version(ssl) < TLS1_3_VERSION) {
|
|
3215
|
+
return 0;
|
|
3216
|
+
}
|
|
3217
|
+
const EpochState *epoch_state = get_epoch(ssl, epoch);
|
|
3218
|
+
if (epoch_state == nullptr) {
|
|
3219
|
+
return 0;
|
|
3220
|
+
}
|
|
3221
|
+
assert(!epoch_state->traffic_secret.empty());
|
|
3222
|
+
*out_data = epoch_state->traffic_secret.data();
|
|
3223
|
+
*out_len = epoch_state->traffic_secret.size();
|
|
3224
|
+
return 1;
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
int SSL_get_dtls_read_traffic_secret(const SSL *ssl, const uint8_t **out_data,
|
|
3228
|
+
size_t *out_len, uint16_t epoch) {
|
|
3229
|
+
return get_dtls_traffic_secret(FromOpaque(ssl), dtls_get_read_epoch, out_data,
|
|
3230
|
+
out_len, epoch);
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
int SSL_get_dtls_write_traffic_secret(const SSL *ssl, const uint8_t **out_data,
|
|
3234
|
+
size_t *out_len, uint16_t epoch) {
|
|
3235
|
+
return get_dtls_traffic_secret(FromOpaque(ssl), dtls_get_write_epoch,
|
|
3236
|
+
out_data, out_len, epoch);
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
uint16_t SSL_get_peer_signature_algorithm(const SSL *ssl) {
|
|
3240
|
+
SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
3241
|
+
if (session == nullptr) {
|
|
3242
|
+
return 0;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
return session->peer_signature_algorithm;
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
size_t SSL_get_client_random(const SSL *ssl, uint8_t *out, size_t max_out) {
|
|
3249
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3250
|
+
if (max_out == 0) {
|
|
3251
|
+
return sizeof(ssl_impl->s3->client_random);
|
|
3252
|
+
}
|
|
3253
|
+
if (max_out > sizeof(ssl_impl->s3->client_random)) {
|
|
3254
|
+
max_out = sizeof(ssl_impl->s3->client_random);
|
|
3255
|
+
}
|
|
3256
|
+
OPENSSL_memcpy(out, ssl_impl->s3->client_random, max_out);
|
|
3257
|
+
return max_out;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
size_t SSL_get_server_random(const SSL *ssl, uint8_t *out, size_t max_out) {
|
|
3261
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3262
|
+
if (max_out == 0) {
|
|
3263
|
+
return sizeof(ssl_impl->s3->server_random);
|
|
3264
|
+
}
|
|
3265
|
+
if (max_out > sizeof(ssl_impl->s3->server_random)) {
|
|
3266
|
+
max_out = sizeof(ssl_impl->s3->server_random);
|
|
3267
|
+
}
|
|
3268
|
+
OPENSSL_memcpy(out, ssl_impl->s3->server_random, max_out);
|
|
3269
|
+
return max_out;
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
uint16_t SSL_get_signature_algorithm_used(const SSL *ssl) {
|
|
3273
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3274
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
3275
|
+
if (hs == nullptr) {
|
|
3276
|
+
return 0;
|
|
3277
|
+
}
|
|
3278
|
+
return hs->signature_algorithm;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
const SSL_CIPHER *SSL_get_pending_cipher(const SSL *ssl) {
|
|
3282
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3283
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
3284
|
+
if (hs == nullptr) {
|
|
3285
|
+
return nullptr;
|
|
3286
|
+
}
|
|
3287
|
+
return hs->new_cipher;
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
void SSL_set_retain_only_sha256_of_client_certs(SSL *ssl, int enabled) {
|
|
3291
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3292
|
+
if (!ssl_impl->config) {
|
|
3293
|
+
return;
|
|
3294
|
+
}
|
|
3295
|
+
ssl_impl->config->retain_only_sha256_of_client_certs = !!enabled;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
void SSL_CTX_set_retain_only_sha256_of_client_certs(SSL_CTX *ctx, int enabled) {
|
|
3299
|
+
FromOpaque(ctx)->retain_only_sha256_of_client_certs = !!enabled;
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
void SSL_CTX_set_grease_enabled(SSL_CTX *ctx, int enabled) {
|
|
3303
|
+
FromOpaque(ctx)->grease_enabled = !!enabled;
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
void SSL_CTX_set_grease_sigalgs_enabled(SSL_CTX *ctx, int enabled) {
|
|
3307
|
+
FromOpaque(ctx)->grease_sigalgs_enabled = !!enabled;
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
void SSL_CTX_set_permute_extensions(SSL_CTX *ctx, int enabled) {
|
|
3311
|
+
FromOpaque(ctx)->permute_extensions = !!enabled;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
void SSL_set_permute_extensions(SSL *ssl, int enabled) {
|
|
3315
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3316
|
+
if (!ssl_impl->config) {
|
|
3317
|
+
return;
|
|
3318
|
+
}
|
|
3319
|
+
ssl_impl->config->permute_extensions = !!enabled;
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
int32_t SSL_get_ticket_age_skew(const SSL *ssl) {
|
|
3323
|
+
return FromOpaque(ssl)->s3->ticket_age_skew;
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
void SSL_CTX_set_false_start_allowed_without_alpn(SSL_CTX *ctx, int allowed) {
|
|
3327
|
+
FromOpaque(ctx)->false_start_allowed_without_alpn = !!allowed;
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
int SSL_used_hello_retry_request(const SSL *ssl) {
|
|
3331
|
+
return FromOpaque(ssl)->s3->used_hello_retry_request;
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
void SSL_set_shed_handshake_config(SSL *ssl, int enable) {
|
|
3335
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3336
|
+
if (!ssl_impl->config) {
|
|
3337
|
+
return;
|
|
3338
|
+
}
|
|
3339
|
+
ssl_impl->config->shed_handshake_config = !!enable;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
void SSL_set_jdk11_workaround(SSL *ssl, int enable) {
|
|
3343
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3344
|
+
if (!ssl_impl->config) {
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
3347
|
+
ssl_impl->config->jdk11_workaround = !!enable;
|
|
3348
|
+
}
|
|
3349
|
+
|
|
3350
|
+
void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy) {
|
|
3351
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3352
|
+
if (!ssl_impl->config) {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
ssl_impl->config->quic_use_legacy_codepoint = !!use_legacy;
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
int SSL_clear(SSL *ssl) {
|
|
3359
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3360
|
+
if (!ssl_impl->config) {
|
|
3361
|
+
return 0; // SSL_clear may not be used after shedding config.
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
// In OpenSSL, reusing a client `SSL` with `SSL_clear` causes the previously
|
|
3365
|
+
// established session to be offered the next time around. wpa_supplicant
|
|
3366
|
+
// depends on this behavior, so emulate it.
|
|
3367
|
+
UniquePtr<SSLSession> session;
|
|
3368
|
+
if (!ssl_impl->server && ssl_impl->s3->established_session != nullptr) {
|
|
3369
|
+
session = UpRef(ssl_impl->s3->established_session);
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
// The ssl->d1->mtu is simultaneously configuration (preserved across
|
|
3373
|
+
// clear) and connection-specific state (gets reset).
|
|
3374
|
+
//
|
|
3375
|
+
// TODO(davidben): Avoid this.
|
|
3376
|
+
unsigned mtu = 0;
|
|
3377
|
+
if (ssl_impl->d1 != nullptr) {
|
|
3378
|
+
mtu = ssl_impl->d1->mtu;
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
ssl_impl->method->ssl_free(ssl_impl);
|
|
3382
|
+
if (!ssl_impl->method->ssl_new(ssl_impl)) {
|
|
3383
|
+
return 0;
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
if (SSL_is_dtls(ssl) && (SSL_get_options(ssl) & SSL_OP_NO_QUERY_MTU)) {
|
|
3387
|
+
ssl_impl->d1->mtu = mtu;
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
if (session != nullptr) {
|
|
3391
|
+
SSL_set_session(ssl, session.get());
|
|
3392
|
+
}
|
|
3393
|
+
|
|
3394
|
+
return 1;
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3397
|
+
int SSL_CTX_sess_connect(const SSL_CTX *ctx) { return 0; }
|
|
3398
|
+
int SSL_CTX_sess_connect_good(const SSL_CTX *ctx) { return 0; }
|
|
3399
|
+
int SSL_CTX_sess_connect_renegotiate(const SSL_CTX *ctx) { return 0; }
|
|
3400
|
+
int SSL_CTX_sess_accept(const SSL_CTX *ctx) { return 0; }
|
|
3401
|
+
int SSL_CTX_sess_accept_renegotiate(const SSL_CTX *ctx) { return 0; }
|
|
3402
|
+
int SSL_CTX_sess_accept_good(const SSL_CTX *ctx) { return 0; }
|
|
3403
|
+
int SSL_CTX_sess_hits(const SSL_CTX *ctx) { return 0; }
|
|
3404
|
+
int SSL_CTX_sess_cb_hits(const SSL_CTX *ctx) { return 0; }
|
|
3405
|
+
int SSL_CTX_sess_misses(const SSL_CTX *ctx) { return 0; }
|
|
3406
|
+
int SSL_CTX_sess_timeouts(const SSL_CTX *ctx) { return 0; }
|
|
3407
|
+
int SSL_CTX_sess_cache_full(const SSL_CTX *ctx) { return 0; }
|
|
3408
|
+
|
|
3409
|
+
int SSL_num_renegotiations(const SSL *ssl) {
|
|
3410
|
+
return SSL_total_renegotiations(ssl);
|
|
3411
|
+
}
|
|
3412
|
+
|
|
3413
|
+
int SSL_CTX_need_tmp_RSA(const SSL_CTX *ctx) { return 0; }
|
|
3414
|
+
int SSL_need_tmp_RSA(const SSL *ssl) { return 0; }
|
|
3415
|
+
int SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, const RSA *rsa) { return 1; }
|
|
3416
|
+
int SSL_set_tmp_rsa(SSL *ssl, const RSA *rsa) { return 1; }
|
|
3417
|
+
void ERR_load_SSL_strings() {}
|
|
3418
|
+
void SSL_load_error_strings() {}
|
|
3419
|
+
int SSL_cache_hit(SSL *ssl) { return SSL_session_reused(ssl); }
|
|
3420
|
+
|
|
3421
|
+
int SSL_CTX_set_tmp_ecdh(SSL_CTX *ctx, const EC_KEY *ec_key) {
|
|
3422
|
+
if (ec_key == nullptr || EC_KEY_get0_group(ec_key) == nullptr) {
|
|
3423
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
|
|
3424
|
+
return 0;
|
|
3425
|
+
}
|
|
3426
|
+
int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec_key));
|
|
3427
|
+
return SSL_CTX_set1_groups(ctx, &nid, 1);
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3430
|
+
int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key) {
|
|
3431
|
+
if (ec_key == nullptr || EC_KEY_get0_group(ec_key) == nullptr) {
|
|
3432
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_PASSED_NULL_PARAMETER);
|
|
3433
|
+
return 0;
|
|
3434
|
+
}
|
|
3435
|
+
int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec_key));
|
|
3436
|
+
return SSL_set1_groups(ssl, &nid, 1);
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3439
|
+
void SSL_CTX_set_ticket_aead_method(SSL_CTX *ctx,
|
|
3440
|
+
const SSL_TICKET_AEAD_METHOD *aead_method) {
|
|
3441
|
+
FromOpaque(ctx)->ticket_aead_method = aead_method;
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3444
|
+
SSL_SESSION *SSL_process_tls13_new_session_ticket(SSL *ssl, const uint8_t *buf,
|
|
3445
|
+
size_t buf_len) {
|
|
3446
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3447
|
+
if (SSL_in_init(ssl_impl) || //
|
|
3448
|
+
ssl_protocol_version(ssl_impl) != TLS1_3_VERSION || //
|
|
3449
|
+
ssl_impl->server) {
|
|
3450
|
+
// Only TLS 1.3 clients are supported.
|
|
3451
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
|
3452
|
+
return nullptr;
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
CBS cbs, body;
|
|
3456
|
+
CBS_init(&cbs, buf, buf_len);
|
|
3457
|
+
uint8_t type;
|
|
3458
|
+
if (!CBS_get_u8(&cbs, &type) || //
|
|
3459
|
+
!CBS_get_u24_length_prefixed(&cbs, &body) || //
|
|
3460
|
+
CBS_len(&cbs) != 0) {
|
|
3461
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
|
3462
|
+
return nullptr;
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
UniquePtr<SSLSession> session =
|
|
3466
|
+
tls13_create_session_with_ticket(ssl_impl, &body);
|
|
3467
|
+
if (!session) {
|
|
3468
|
+
// `tls13_create_session_with_ticket` puts the correct error.
|
|
3469
|
+
return nullptr;
|
|
3470
|
+
}
|
|
3471
|
+
return session.release();
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets) {
|
|
3475
|
+
num_tickets = std::min(num_tickets, kMaxTickets);
|
|
3476
|
+
static_assert(kMaxTickets <= 0xff, "Too many tickets.");
|
|
3477
|
+
FromOpaque(ctx)->num_tickets = static_cast<uint8_t>(num_tickets);
|
|
3478
|
+
return 1;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx) {
|
|
3482
|
+
return FromOpaque(ctx)->num_tickets;
|
|
3483
|
+
}
|
|
3484
|
+
|
|
3485
|
+
int SSL_set_tlsext_status_type(SSL *ssl, int type) {
|
|
3486
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3487
|
+
if (!ssl_impl->config) {
|
|
3488
|
+
return 0;
|
|
3489
|
+
}
|
|
3490
|
+
ssl_impl->config->ocsp_stapling_enabled = type == TLSEXT_STATUSTYPE_ocsp;
|
|
3491
|
+
return 1;
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
int SSL_get_tlsext_status_type(const SSL *ssl) {
|
|
3495
|
+
const auto *ssl_impl = FromOpaque(ssl);
|
|
3496
|
+
if (ssl_impl->server) {
|
|
3497
|
+
SSL_HANDSHAKE *hs = ssl_impl->s3->hs.get();
|
|
3498
|
+
return hs != nullptr && hs->ocsp_stapling_requested
|
|
3499
|
+
? TLSEXT_STATUSTYPE_ocsp
|
|
3500
|
+
: TLSEXT_STATUSTYPE_nothing;
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
return ssl_impl->config != nullptr && ssl_impl->config->ocsp_stapling_enabled
|
|
3504
|
+
? TLSEXT_STATUSTYPE_ocsp
|
|
3505
|
+
: TLSEXT_STATUSTYPE_nothing;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
int SSL_set_tlsext_status_ocsp_resp(SSL *ssl, uint8_t *resp, size_t resp_len) {
|
|
3509
|
+
if (SSL_set_ocsp_response(ssl, resp, resp_len)) {
|
|
3510
|
+
OPENSSL_free(resp);
|
|
3511
|
+
return 1;
|
|
3512
|
+
}
|
|
3513
|
+
return 0;
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
size_t SSL_get_tlsext_status_ocsp_resp(const SSL *ssl, const uint8_t **out) {
|
|
3517
|
+
size_t ret;
|
|
3518
|
+
SSL_get0_ocsp_response(ssl, out, &ret);
|
|
3519
|
+
return ret;
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
int SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx,
|
|
3523
|
+
int (*callback)(SSL *ssl, void *arg)) {
|
|
3524
|
+
FromOpaque(ctx)->legacy_ocsp_callback = callback;
|
|
3525
|
+
return 1;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) {
|
|
3529
|
+
FromOpaque(ctx)->legacy_ocsp_callback_arg = arg;
|
|
3530
|
+
return 1;
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
uint16_t SSL_get_curve_id(const SSL *ssl) { return SSL_get_group_id(ssl); }
|
|
3534
|
+
|
|
3535
|
+
const char *SSL_get_curve_name(uint16_t curve_id) {
|
|
3536
|
+
return SSL_get_group_name(curve_id);
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
size_t SSL_get_all_curve_names(const char **out, size_t max_out) {
|
|
3540
|
+
return SSL_get_all_group_names(out, max_out);
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves, size_t num_curves) {
|
|
3544
|
+
return SSL_CTX_set1_groups(ctx, curves, num_curves);
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
int SSL_set1_curves(SSL *ssl, const int *curves, size_t num_curves) {
|
|
3548
|
+
return SSL_set1_groups(ssl, curves, num_curves);
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves) {
|
|
3552
|
+
return SSL_CTX_set1_groups_list(ctx, curves);
|
|
3553
|
+
}
|
|
3554
|
+
|
|
3555
|
+
int SSL_set1_curves_list(SSL *ssl, const char *curves) {
|
|
3556
|
+
return SSL_set1_groups_list(ssl, curves);
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
namespace fips202205 {
|
|
3560
|
+
|
|
3561
|
+
// (References are to SP 800-52r2):
|
|
3562
|
+
|
|
3563
|
+
// Section 3.4.2.2
|
|
3564
|
+
// "at least one of the NIST-approved curves, P-256 (secp256r1) and P384
|
|
3565
|
+
// (secp384r1), shall be supported as described in RFC 8422."
|
|
3566
|
+
//
|
|
3567
|
+
// Section 3.3.1
|
|
3568
|
+
// "The server shall be configured to only use cipher suites that are
|
|
3569
|
+
// composed entirely of NIST approved algorithms"
|
|
3570
|
+
static const uint16_t kGroups[] = {SSL_GROUP_SECP256R1, SSL_GROUP_SECP384R1};
|
|
3571
|
+
|
|
3572
|
+
static const uint16_t kSigAlgs[] = {
|
|
3573
|
+
SSL_SIGN_RSA_PKCS1_SHA256,
|
|
3574
|
+
SSL_SIGN_RSA_PKCS1_SHA384,
|
|
3575
|
+
SSL_SIGN_RSA_PKCS1_SHA512,
|
|
3576
|
+
// Table 4.1:
|
|
3577
|
+
// "The curve should be P-256 or P-384"
|
|
3578
|
+
SSL_SIGN_ECDSA_SECP256R1_SHA256,
|
|
3579
|
+
SSL_SIGN_ECDSA_SECP384R1_SHA384,
|
|
3580
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA256,
|
|
3581
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA384,
|
|
3582
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA512,
|
|
3583
|
+
};
|
|
3584
|
+
|
|
3585
|
+
static const char kTLS12Ciphers[] =
|
|
3586
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:"
|
|
3587
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:"
|
|
3588
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
|
|
3589
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
|
|
3590
|
+
|
|
3591
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3592
|
+
SSL_CIPHER_AES_128_GCM_SHA256,
|
|
3593
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3594
|
+
};
|
|
3595
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3596
|
+
true,
|
|
3597
|
+
false,
|
|
3598
|
+
};
|
|
3599
|
+
|
|
3600
|
+
static int Configure(SSLContext *ctx) {
|
|
3601
|
+
ctx->compliance_policy = ssl_compliance_policy_fips_202205;
|
|
3602
|
+
|
|
3603
|
+
return
|
|
3604
|
+
// Section 3.1:
|
|
3605
|
+
// "Servers that support government-only applications shall be
|
|
3606
|
+
// configured to use TLS 1.2 and should be configured to use TLS 1.3
|
|
3607
|
+
// as well. These servers should not be configured to use TLS 1.1 and
|
|
3608
|
+
// shall not use TLS 1.0, SSL 3.0, or SSL 2.0.
|
|
3609
|
+
SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
|
|
3610
|
+
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3611
|
+
// Sections 3.3.1.1.1 and 3.3.1.1.2 are ambiguous about whether
|
|
3612
|
+
// HMAC-SHA-1 cipher suites are permitted with TLS 1.2. However, later the
|
|
3613
|
+
// Encrypt-then-MAC extension is required for all CBC cipher suites and so
|
|
3614
|
+
// it's easier to drop them.
|
|
3615
|
+
SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
|
|
3616
|
+
ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3617
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3618
|
+
SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
|
|
3619
|
+
SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3620
|
+
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
|
|
3621
|
+
}
|
|
3622
|
+
|
|
3623
|
+
static int Configure(SSLImpl *ssl) {
|
|
3624
|
+
ssl->config->compliance_policy = ssl_compliance_policy_fips_202205;
|
|
3625
|
+
|
|
3626
|
+
// See `Configure(SSL_CTX)`, above, for reasoning.
|
|
3627
|
+
return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
|
|
3628
|
+
SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3629
|
+
SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
|
|
3630
|
+
ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3631
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3632
|
+
SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
|
|
3633
|
+
SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3634
|
+
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
} // namespace fips202205
|
|
3638
|
+
|
|
3639
|
+
namespace fips202609 {
|
|
3640
|
+
|
|
3641
|
+
// (References are to SP 800-52r2):
|
|
3642
|
+
|
|
3643
|
+
static const uint16_t kGroups[] = {
|
|
3644
|
+
SSL_GROUP_X25519_MLKEM768,
|
|
3645
|
+
SSL_GROUP_MLKEM1024,
|
|
3646
|
+
SSL_GROUP_SECP256R1,
|
|
3647
|
+
SSL_GROUP_SECP384R1,
|
|
3648
|
+
};
|
|
3649
|
+
static const uint32_t kGroupsFlags[] = {
|
|
3650
|
+
SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT,
|
|
3651
|
+
0,
|
|
3652
|
+
0,
|
|
3653
|
+
0,
|
|
3654
|
+
};
|
|
3655
|
+
|
|
3656
|
+
// Prefer post-quantum groups equally if the client supports them.
|
|
3657
|
+
static const uint32_t kOptions = SSL_OP_CIPHER_SERVER_PREFERENCE;
|
|
3658
|
+
|
|
3659
|
+
static const uint16_t kSigAlgs[] = {
|
|
3660
|
+
SSL_SIGN_RSA_PKCS1_SHA256,
|
|
3661
|
+
SSL_SIGN_RSA_PKCS1_SHA384,
|
|
3662
|
+
SSL_SIGN_RSA_PKCS1_SHA512,
|
|
3663
|
+
// Table 4.1:
|
|
3664
|
+
// "The curve should be P-256 or P-384"
|
|
3665
|
+
SSL_SIGN_ECDSA_SECP256R1_SHA256,
|
|
3666
|
+
SSL_SIGN_ECDSA_SECP384R1_SHA384,
|
|
3667
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA256,
|
|
3668
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA384,
|
|
3669
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA512,
|
|
3670
|
+
};
|
|
3671
|
+
|
|
3672
|
+
static const char kTLS12Ciphers[] =
|
|
3673
|
+
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:"
|
|
3674
|
+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:"
|
|
3675
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
|
|
3676
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
|
|
3677
|
+
|
|
3678
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3679
|
+
SSL_CIPHER_AES_128_GCM_SHA256,
|
|
3680
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3681
|
+
};
|
|
3682
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3683
|
+
true,
|
|
3684
|
+
false,
|
|
3685
|
+
};
|
|
3686
|
+
|
|
3687
|
+
static int Configure(SSLContext *ctx) {
|
|
3688
|
+
ctx->compliance_policy = ssl_compliance_policy_fips_202609;
|
|
3689
|
+
|
|
3690
|
+
return
|
|
3691
|
+
// Section 3.1:
|
|
3692
|
+
// "Servers that support government-only applications shall be
|
|
3693
|
+
// configured to use TLS 1.2 and should be configured to use TLS 1.3
|
|
3694
|
+
// as well. These servers should not be configured to use TLS 1.1 and
|
|
3695
|
+
// shall not use TLS 1.0, SSL 3.0, or SSL 2.0.
|
|
3696
|
+
SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
|
|
3697
|
+
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3698
|
+
// Sections 3.3.1.1.1 and 3.3.1.1.2 are ambiguous about whether
|
|
3699
|
+
// HMAC-SHA-1 cipher suites are permitted with TLS 1.2. However, later the
|
|
3700
|
+
// Encrypt-then-MAC extension is required for all CBC cipher suites and so
|
|
3701
|
+
// it's easier to drop them.
|
|
3702
|
+
SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
|
|
3703
|
+
ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3704
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3705
|
+
SSL_CTX_set1_group_ids_with_flags(ctx, kGroups, kGroupsFlags,
|
|
3706
|
+
std::size(kGroups)) &&
|
|
3707
|
+
SSL_CTX_set_options(ctx, kOptions) &&
|
|
3708
|
+
SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3709
|
+
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
static int Configure(SSLImpl *ssl) {
|
|
3713
|
+
ssl->config->compliance_policy = ssl_compliance_policy_fips_202609;
|
|
3714
|
+
|
|
3715
|
+
// See `Configure(SSL_CTX)`, above, for reasoning.
|
|
3716
|
+
return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
|
|
3717
|
+
SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3718
|
+
SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
|
|
3719
|
+
ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3720
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3721
|
+
SSL_set1_group_ids_with_flags(ssl, kGroups, kGroupsFlags,
|
|
3722
|
+
std::size(kGroups)) &&
|
|
3723
|
+
SSL_set_options(ssl, kOptions) &&
|
|
3724
|
+
SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3725
|
+
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
} // namespace fips202609
|
|
3729
|
+
|
|
3730
|
+
namespace wpa202304 {
|
|
3731
|
+
|
|
3732
|
+
// See WPA version 3.1, section 3.5.
|
|
3733
|
+
|
|
3734
|
+
static const uint16_t kGroups[] = {SSL_GROUP_SECP384R1};
|
|
3735
|
+
|
|
3736
|
+
static const uint16_t kSigAlgs[] = {
|
|
3737
|
+
SSL_SIGN_RSA_PKCS1_SHA384, //
|
|
3738
|
+
SSL_SIGN_RSA_PKCS1_SHA512, //
|
|
3739
|
+
SSL_SIGN_ECDSA_SECP384R1_SHA384, //
|
|
3740
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA384, //
|
|
3741
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA512, //
|
|
3742
|
+
};
|
|
3743
|
+
|
|
3744
|
+
static const char kTLS12Ciphers[] =
|
|
3745
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
|
|
3746
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
|
|
3747
|
+
|
|
3748
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3749
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3750
|
+
};
|
|
3751
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3752
|
+
false,
|
|
3753
|
+
};
|
|
3754
|
+
|
|
3755
|
+
static int Configure(SSLContext *ctx) {
|
|
3756
|
+
ctx->compliance_policy = ssl_compliance_policy_wpa3_192_202304;
|
|
3757
|
+
|
|
3758
|
+
return SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
|
|
3759
|
+
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3760
|
+
SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
|
|
3761
|
+
SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
|
|
3762
|
+
ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3763
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3764
|
+
SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
|
|
3765
|
+
std::size(kSigAlgs)) &&
|
|
3766
|
+
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
static int Configure(SSLImpl *ssl) {
|
|
3770
|
+
ssl->config->compliance_policy = ssl_compliance_policy_wpa3_192_202304;
|
|
3771
|
+
|
|
3772
|
+
return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
|
|
3773
|
+
SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3774
|
+
SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
|
|
3775
|
+
ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3776
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3777
|
+
SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
|
|
3778
|
+
SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3779
|
+
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
} // namespace wpa202304
|
|
3783
|
+
|
|
3784
|
+
namespace cnsa202407 {
|
|
3785
|
+
|
|
3786
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3787
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3788
|
+
SSL_CIPHER_AES_128_GCM_SHA256,
|
|
3789
|
+
SSL_CIPHER_CHACHA20_POLY1305_SHA256,
|
|
3790
|
+
};
|
|
3791
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3792
|
+
false,
|
|
3793
|
+
false,
|
|
3794
|
+
false,
|
|
3795
|
+
};
|
|
3796
|
+
|
|
3797
|
+
static int Configure(SSLContext *ctx) {
|
|
3798
|
+
ctx->compliance_policy = ssl_compliance_policy_cnsa_202407;
|
|
3799
|
+
return ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3800
|
+
Span(kTLS13CiphersInGroup));
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
static int Configure(SSLImpl *ssl) {
|
|
3804
|
+
ssl->config->compliance_policy = ssl_compliance_policy_cnsa_202407;
|
|
3805
|
+
return ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3806
|
+
Span(kTLS13CiphersInGroup));
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3809
|
+
} // namespace cnsa202407
|
|
3810
|
+
|
|
3811
|
+
namespace cnsa1_202603 {
|
|
3812
|
+
|
|
3813
|
+
// Approximates CNSA 1.0 (RFC 9151).
|
|
3814
|
+
|
|
3815
|
+
static const uint16_t kGroups[] = {SSL_GROUP_MLKEM1024, SSL_GROUP_SECP384R1};
|
|
3816
|
+
|
|
3817
|
+
// Prefer ML-KEM-1024 if the client supports it.
|
|
3818
|
+
static const uint32_t kOptions = SSL_OP_CIPHER_SERVER_PREFERENCE;
|
|
3819
|
+
|
|
3820
|
+
static const uint16_t kSigAlgs[] = {
|
|
3821
|
+
SSL_SIGN_ECDSA_SECP384R1_SHA384,
|
|
3822
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA384,
|
|
3823
|
+
SSL_SIGN_RSA_PKCS1_SHA384,
|
|
3824
|
+
};
|
|
3825
|
+
|
|
3826
|
+
static const char kTLS12Ciphers[] =
|
|
3827
|
+
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:"
|
|
3828
|
+
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:"
|
|
3829
|
+
"TLS_RSA_WITH_AES_256_GCM_SHA384";
|
|
3830
|
+
|
|
3831
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3832
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3833
|
+
};
|
|
3834
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3835
|
+
false,
|
|
3836
|
+
};
|
|
3837
|
+
|
|
3838
|
+
static int Configure(SSLContext *ctx) {
|
|
3839
|
+
ctx->compliance_policy = ssl_compliance_policy_cnsa1_202603;
|
|
3840
|
+
|
|
3841
|
+
return SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION) &&
|
|
3842
|
+
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3843
|
+
SSL_CTX_set_strict_cipher_list(ctx, kTLS12Ciphers) &&
|
|
3844
|
+
ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3845
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3846
|
+
SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
|
|
3847
|
+
SSL_CTX_set_options(ctx, kOptions) &&
|
|
3848
|
+
SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
|
|
3849
|
+
std::size(kSigAlgs)) &&
|
|
3850
|
+
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
|
|
3851
|
+
}
|
|
3852
|
+
|
|
3853
|
+
static int Configure(SSLImpl *ssl) {
|
|
3854
|
+
ssl->config->compliance_policy = ssl_compliance_policy_cnsa1_202603;
|
|
3855
|
+
|
|
3856
|
+
return SSL_set_min_proto_version(ssl, TLS1_2_VERSION) &&
|
|
3857
|
+
SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3858
|
+
SSL_set_strict_cipher_list(ssl, kTLS12Ciphers) &&
|
|
3859
|
+
ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3860
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3861
|
+
SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
|
|
3862
|
+
SSL_set_options(ssl, kOptions) &&
|
|
3863
|
+
SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3864
|
+
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
} // namespace cnsa1_202603
|
|
3868
|
+
|
|
3869
|
+
namespace cnsa2_202603 {
|
|
3870
|
+
|
|
3871
|
+
// Approximates CNSA 2.0 (draft-becker-cnsa2-tls-profile).
|
|
3872
|
+
|
|
3873
|
+
static const uint16_t kGroups[] = {SSL_GROUP_MLKEM1024};
|
|
3874
|
+
|
|
3875
|
+
static const uint16_t kSigAlgs[] = {
|
|
3876
|
+
SSL_SIGN_ECDSA_SECP384R1_SHA384,
|
|
3877
|
+
SSL_SIGN_RSA_PSS_RSAE_SHA384,
|
|
3878
|
+
SSL_SIGN_RSA_PKCS1_SHA384,
|
|
3879
|
+
};
|
|
3880
|
+
|
|
3881
|
+
static const uint16_t kTLS13Ciphers[] = {
|
|
3882
|
+
SSL_CIPHER_AES_256_GCM_SHA384,
|
|
3883
|
+
};
|
|
3884
|
+
static const bool kTLS13CiphersInGroup[] = {
|
|
3885
|
+
false,
|
|
3886
|
+
};
|
|
3887
|
+
|
|
3888
|
+
static int Configure(SSLContext *ctx) {
|
|
3889
|
+
ctx->compliance_policy = ssl_compliance_policy_cnsa2_202603;
|
|
3890
|
+
|
|
3891
|
+
return SSL_CTX_set_min_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3892
|
+
SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION) &&
|
|
3893
|
+
ctx->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3894
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3895
|
+
SSL_CTX_set1_group_ids(ctx, kGroups, std::size(kGroups)) &&
|
|
3896
|
+
SSL_CTX_set_signing_algorithm_prefs(ctx, kSigAlgs,
|
|
3897
|
+
std::size(kSigAlgs)) &&
|
|
3898
|
+
SSL_CTX_set_verify_algorithm_prefs(ctx, kSigAlgs, std::size(kSigAlgs));
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
static int Configure(SSLImpl *ssl) {
|
|
3902
|
+
ssl->config->compliance_policy = ssl_compliance_policy_cnsa2_202603;
|
|
3903
|
+
|
|
3904
|
+
return SSL_set_min_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3905
|
+
SSL_set_max_proto_version(ssl, TLS1_3_VERSION) &&
|
|
3906
|
+
ssl->config->tls13_cipher_list.Init(Span(kTLS13Ciphers),
|
|
3907
|
+
Span(kTLS13CiphersInGroup)) &&
|
|
3908
|
+
SSL_set1_group_ids(ssl, kGroups, std::size(kGroups)) &&
|
|
3909
|
+
SSL_set_signing_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs)) &&
|
|
3910
|
+
SSL_set_verify_algorithm_prefs(ssl, kSigAlgs, std::size(kSigAlgs));
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
} // namespace cnsa2_202603
|
|
3914
|
+
|
|
3915
|
+
int SSL_CTX_set_compliance_policy(SSL_CTX *ctx,
|
|
3916
|
+
enum ssl_compliance_policy_t policy) {
|
|
3917
|
+
auto *ctx_impl = FromOpaque(ctx);
|
|
3918
|
+
switch (policy) {
|
|
3919
|
+
case ssl_compliance_policy_fips_202205:
|
|
3920
|
+
return fips202205::Configure(ctx_impl);
|
|
3921
|
+
case ssl_compliance_policy_fips_202609:
|
|
3922
|
+
return fips202609::Configure(ctx_impl);
|
|
3923
|
+
case ssl_compliance_policy_wpa3_192_202304:
|
|
3924
|
+
return wpa202304::Configure(ctx_impl);
|
|
3925
|
+
case ssl_compliance_policy_cnsa_202407:
|
|
3926
|
+
return cnsa202407::Configure(ctx_impl);
|
|
3927
|
+
case ssl_compliance_policy_cnsa1_202603:
|
|
3928
|
+
return cnsa1_202603::Configure(ctx_impl);
|
|
3929
|
+
case ssl_compliance_policy_cnsa2_202603:
|
|
3930
|
+
return cnsa2_202603::Configure(ctx_impl);
|
|
3931
|
+
default:
|
|
3932
|
+
return 0;
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
enum ssl_compliance_policy_t SSL_CTX_get_compliance_policy(const SSL_CTX *ctx) {
|
|
3937
|
+
return FromOpaque(ctx)->compliance_policy;
|
|
3938
|
+
}
|
|
3939
|
+
|
|
3940
|
+
int SSL_set_compliance_policy(SSL *ssl, enum ssl_compliance_policy_t policy) {
|
|
3941
|
+
auto *ssl_impl = FromOpaque(ssl);
|
|
3942
|
+
switch (policy) {
|
|
3943
|
+
case ssl_compliance_policy_fips_202205:
|
|
3944
|
+
return fips202205::Configure(ssl_impl);
|
|
3945
|
+
case ssl_compliance_policy_fips_202609:
|
|
3946
|
+
return fips202609::Configure(ssl_impl);
|
|
3947
|
+
case ssl_compliance_policy_wpa3_192_202304:
|
|
3948
|
+
return wpa202304::Configure(ssl_impl);
|
|
3949
|
+
case ssl_compliance_policy_cnsa_202407:
|
|
3950
|
+
return cnsa202407::Configure(ssl_impl);
|
|
3951
|
+
case ssl_compliance_policy_cnsa1_202603:
|
|
3952
|
+
return cnsa1_202603::Configure(ssl_impl);
|
|
3953
|
+
case ssl_compliance_policy_cnsa2_202603:
|
|
3954
|
+
return cnsa2_202603::Configure(ssl_impl);
|
|
3955
|
+
default:
|
|
3956
|
+
return 0;
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3960
|
+
enum ssl_compliance_policy_t SSL_get_compliance_policy(const SSL *ssl) {
|
|
3961
|
+
return FromOpaque(ssl)->config->compliance_policy;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
int SSL_peer_matched_trust_anchor(const SSL *ssl) {
|
|
3965
|
+
return FromOpaque(ssl)->s3->hs != nullptr &&
|
|
3966
|
+
FromOpaque(ssl)->s3->hs->peer_matched_trust_anchor;
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
void SSL_get0_peer_available_trust_anchors(const SSL *ssl, const uint8_t **out,
|
|
3970
|
+
size_t *out_len) {
|
|
3971
|
+
Span<const uint8_t> ret;
|
|
3972
|
+
if (SSL_HANDSHAKE *hs = FromOpaque(ssl)->s3->hs.get(); hs != nullptr) {
|
|
3973
|
+
ret = hs->peer_available_trust_anchors;
|
|
3974
|
+
}
|
|
3975
|
+
*out = ret.data();
|
|
3976
|
+
*out_len = ret.size();
|
|
3977
|
+
}
|
|
3978
|
+
|
|
3979
|
+
int SSL_CTX_set1_available_trust_anchors(SSL_CTX *ctx, const uint8_t *ids,
|
|
3980
|
+
size_t ids_len) {
|
|
3981
|
+
auto span = Span(ids, ids_len);
|
|
3982
|
+
if (span.empty() || !ssl_is_valid_trust_anchor_list(span)) {
|
|
3983
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
|
|
3984
|
+
return 0;
|
|
3985
|
+
}
|
|
3986
|
+
return FromOpaque(ctx)->cert->available_trust_anchors.CopyFrom(span);
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
int SSL_set1_available_trust_anchors(SSL *ssl, const uint8_t *ids,
|
|
3990
|
+
size_t ids_len) {
|
|
3991
|
+
if (!FromOpaque(ssl)->config) {
|
|
3992
|
+
return 0;
|
|
3993
|
+
}
|
|
3994
|
+
auto span = Span(ids, ids_len);
|
|
3995
|
+
if (span.empty() || !ssl_is_valid_trust_anchor_list(span)) {
|
|
3996
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
|
|
3997
|
+
return 0;
|
|
3998
|
+
}
|
|
3999
|
+
return FromOpaque(ssl)->config->cert->available_trust_anchors.CopyFrom(span);
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
int SSL_CTX_set1_requested_trust_anchors(SSL_CTX *ctx, const uint8_t *ids,
|
|
4003
|
+
size_t ids_len) {
|
|
4004
|
+
auto span = Span(ids, ids_len);
|
|
4005
|
+
if (!ssl_is_valid_trust_anchor_list(span)) {
|
|
4006
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
|
|
4007
|
+
return 0;
|
|
4008
|
+
}
|
|
4009
|
+
Array<uint8_t> copy;
|
|
4010
|
+
if (!copy.CopyFrom(span)) {
|
|
4011
|
+
return 0;
|
|
4012
|
+
}
|
|
4013
|
+
FromOpaque(ctx)->requested_trust_anchors = std::move(copy);
|
|
4014
|
+
return 1;
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
int SSL_set1_requested_trust_anchors(SSL *ssl, const uint8_t *ids,
|
|
4018
|
+
size_t ids_len) {
|
|
4019
|
+
if (!FromOpaque(ssl)->config) {
|
|
4020
|
+
return 0;
|
|
4021
|
+
}
|
|
4022
|
+
auto span = Span(ids, ids_len);
|
|
4023
|
+
if (!ssl_is_valid_trust_anchor_list(span)) {
|
|
4024
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_TRUST_ANCHOR_LIST);
|
|
4025
|
+
return 0;
|
|
4026
|
+
}
|
|
4027
|
+
Array<uint8_t> copy;
|
|
4028
|
+
if (!copy.CopyFrom(span)) {
|
|
4029
|
+
return 0;
|
|
4030
|
+
}
|
|
4031
|
+
FromOpaque(ssl)->config->requested_trust_anchors = std::move(copy);
|
|
4032
|
+
return 1;
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
int SSL_CTX_get_security_level(const SSL_CTX *ctx) { return 0; }
|
|
4036
|
+
|
|
4037
|
+
static bool is_valid_cert_types_list(Span<const uint8_t> list) {
|
|
4038
|
+
if (list.empty() || list.size() > kNumCertTypes) {
|
|
4039
|
+
return false;
|
|
4040
|
+
}
|
|
4041
|
+
for (size_t i = 0u; i < list.size(); ++i) {
|
|
4042
|
+
// Check that each value is a recognized cert type.
|
|
4043
|
+
if (std::find(std::begin(kAllCertTypes), std::end(kAllCertTypes),
|
|
4044
|
+
list[i]) == std::end(kAllCertTypes)) {
|
|
4045
|
+
return false;
|
|
4046
|
+
}
|
|
4047
|
+
// Reject duplicates.
|
|
4048
|
+
for (size_t j = 0u; j < i; ++j) {
|
|
4049
|
+
if (list[i] == list[j]) {
|
|
4050
|
+
return false;
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
return true;
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
static bool set1_cert_types(InplaceVector<uint8_t, kNumCertTypes> *out,
|
|
4058
|
+
Span<const uint8_t> values) {
|
|
4059
|
+
if (!is_valid_cert_types_list(values)) {
|
|
4060
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_CERT_TYPES_LIST);
|
|
4061
|
+
return false;
|
|
4062
|
+
}
|
|
4063
|
+
out->CopyFrom(values);
|
|
4064
|
+
return true;
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
int SSL_CTX_set1_accepted_peer_cert_types(SSL_CTX *ctx, const uint8_t *values,
|
|
4068
|
+
size_t num_values) {
|
|
4069
|
+
return set1_cert_types(&FromOpaque(ctx)->accepted_peer_cert_types,
|
|
4070
|
+
Span(values, num_values));
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
int SSL_set1_accepted_peer_cert_types(SSL *ssl, const uint8_t *values,
|
|
4074
|
+
size_t num_values) {
|
|
4075
|
+
if (!FromOpaque(ssl)->config) {
|
|
4076
|
+
return 0;
|
|
4077
|
+
}
|
|
4078
|
+
return set1_cert_types(&FromOpaque(ssl)->config->accepted_peer_cert_types,
|
|
4079
|
+
Span(values, num_values));
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
int SSL_CTX_set1_available_client_cert_types(SSL_CTX *ctx,
|
|
4083
|
+
const uint8_t *values,
|
|
4084
|
+
size_t num_values) {
|
|
4085
|
+
return set1_cert_types(&FromOpaque(ctx)->available_client_cert_types,
|
|
4086
|
+
Span(values, num_values));
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4089
|
+
int SSL_set1_available_client_cert_types(SSL *ssl, const uint8_t *values,
|
|
4090
|
+
size_t num_values) {
|
|
4091
|
+
if (!FromOpaque(ssl)->config) {
|
|
4092
|
+
return 0;
|
|
4093
|
+
}
|
|
4094
|
+
return set1_cert_types(&FromOpaque(ssl)->config->available_client_cert_types,
|
|
4095
|
+
Span(values, num_values));
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
int SSL_get_peer_cert_type(const SSL *ssl) {
|
|
4099
|
+
if (const SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
4100
|
+
session != nullptr) {
|
|
4101
|
+
return session->peer_cert_type;
|
|
4102
|
+
}
|
|
4103
|
+
return kDefaultCertType;
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
EVP_PKEY *SSL_get0_peer_rpk(const SSL *ssl) {
|
|
4107
|
+
if (const SSLSession *session = ssl_get_session(FromOpaque(ssl));
|
|
4108
|
+
session != nullptr) {
|
|
4109
|
+
return session->peer_raw_public_key.get();
|
|
4110
|
+
}
|
|
4111
|
+
return nullptr;
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
void SSL_set_server_padding_request(SSL *ssl, uint16_t num_bytes) {
|
|
4115
|
+
if (!FromOpaque(ssl)->config) {
|
|
4116
|
+
return;
|
|
4117
|
+
}
|
|
4118
|
+
|
|
4119
|
+
FromOpaque(ssl)->config->server_padding_request = num_bytes;
|
|
4120
|
+
}
|
|
4121
|
+
|
|
4122
|
+
void SSL_set_server_padding_enabled(SSL *ssl, int enabled) {
|
|
4123
|
+
if (!FromOpaque(ssl)->config) {
|
|
4124
|
+
return;
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
FromOpaque(ssl)->config->server_padding_enabled = enabled;
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
int SSL_server_sent_requested_padding(const SSL *ssl) {
|
|
4131
|
+
return FromOpaque(ssl)->s3->server_sent_requested_padding;
|
|
4132
|
+
}
|