aws-crt 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/auth.h +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/aws_imds_client.h +5 -0
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +5 -0
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/aws_signing.h +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +2 -0
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/signing_config.h +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +3 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +146 -63
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +41 -19
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_imds.c +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/source/signable_http_request.c +2 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/signing_config.c +25 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +197 -31
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_imds_tests.c +16 -18
- data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +3 -1
- data/aws-crt-ffi/crt/aws-c-cal/include/aws/cal/private/opensslcrypto_common.h +22 -0
- data/aws-crt-ffi/crt/aws-c-cal/source/darwin/commoncrypto_aes.c +46 -17
- data/aws-crt-ffi/crt/aws-c-cal/source/unix/openssl_aes.c +1 -0
- data/aws-crt-ffi/crt/aws-c-cal/source/unix/openssl_platform_init.c +7 -0
- data/aws-crt-ffi/crt/aws-c-cal/source/unix/openssl_rsa.c +59 -2
- data/aws-crt-ffi/crt/aws-c-cal/source/unix/opensslcrypto_ecc.c +1 -0
- data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +13 -1
- data/aws-crt-ffi/crt/aws-c-common/THIRD-PARTY-LICENSES.txt +28 -7
- data/aws-crt-ffi/crt/aws-c-common/bin/system_info/CMakeLists.txt +18 -0
- data/aws-crt-ffi/crt/aws-c-common/bin/system_info/print_system_info.c +48 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/allocator.h +23 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +12 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/cross_process_lock.h +35 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/hash_table.h +1 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/priority_queue.h +24 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/system_info_priv.h +37 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/system_info.h +47 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/system_resource_util.h +30 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +3 -2
- data/aws-crt-ffi/crt/aws-c-common/source/allocator.c +64 -13
- data/aws-crt-ffi/crt/aws-c-common/source/android/logging.c +14 -0
- data/aws-crt-ffi/crt/aws-c-common/source/common.c +3 -3
- data/aws-crt-ffi/crt/aws-c-common/source/file.c +96 -35
- data/aws-crt-ffi/crt/aws-c-common/source/linux/system_info.c +24 -0
- data/aws-crt-ffi/crt/aws-c-common/source/memtrace.c +10 -3
- data/aws-crt-ffi/crt/aws-c-common/source/platform_fallback_stubs/system_info.c +21 -0
- data/aws-crt-ffi/crt/aws-c-common/source/posix/cross_process_lock.c +141 -0
- data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +1 -1
- data/aws-crt-ffi/crt/aws-c-common/source/posix/system_resource_utils.c +32 -0
- data/aws-crt-ffi/crt/aws-c-common/source/priority_queue.c +24 -0
- data/aws-crt-ffi/crt/aws-c-common/source/system_info.c +80 -0
- data/aws-crt-ffi/crt/aws-c-common/source/task_scheduler.c +2 -2
- data/aws-crt-ffi/crt/aws-c-common/source/windows/cross_process_lock.c +93 -0
- data/aws-crt-ffi/crt/aws-c-common/source/windows/system_resource_utils.c +31 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +16 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/alloc_test.c +83 -22
- data/aws-crt-ffi/crt/aws-c-common/tests/cross_process_lock_tests.c +116 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/file_test.c +103 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/priority_queue_test.c +36 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/system_info_tests.c +19 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/system_resource_util_test.c +37 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +9 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http.h +1 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +5 -4
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_manager_system_vtable.h +10 -18
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/proxy_impl.h +5 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +5 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +10 -0
- data/aws-crt-ffi/crt/aws-c-http/source/connection.c +5 -2
- data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -21
- data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +102 -17
- data/aws-crt-ffi/crt/aws-c-http/source/h1_stream.c +1 -0
- data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
- data/aws-crt-ffi/crt/aws-c-http/source/proxy_connection.c +2 -2
- data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +2 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +18 -18
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +111 -1
- data/aws-crt-ffi/crt/aws-c-http/tests/test_proxy.c +2 -2
- data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +2 -2
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/retry_strategy.h +1 -1
- data/aws-crt-ffi/crt/aws-c-io/source/exponential_backoff_retry_strategy.c +1 -1
- data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +2 -4
- data/aws-crt-ffi/crt/aws-lc/CMakeLists.txt +16 -8
- data/aws-crt-ffi/crt/aws-lc/cmake/go.cmake +6 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/CMakeLists.txt +6 -9
- data/aws-crt-ffi/crt/aws-lc/crypto/asn1/a_time.c +34 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/asn1/a_utctm.c +4 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/asn1/asn1_test.cc +41 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/bio_mem.c +6 -7
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/bio_test.cc +152 -16
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/connect.c +6 -12
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/fd.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/file.c +20 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/socket.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/bio/socket_helper.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/blake2/blake2.c +11 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/bytestring/cbb.c +13 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/bytestring/cbs.c +9 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/chacha/asm/chacha-armv8.pl +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/chacha/chacha.c +49 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/chacha/chacha_test.cc +110 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/chacha/internal.h +8 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/compiler_test.cc +4 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/conf/conf_test.cc +1 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/crypto_test.cc +9 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/curve25519.c +189 -108
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/curve25519_nohw.c +78 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/ed25519_test.cc +9 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/internal.h +24 -10
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/spake25519.c +4 -4
- data/aws-crt-ffi/crt/aws-lc/crypto/curve25519/x25519_test.cc +80 -11
- data/aws-crt-ffi/crt/aws-lc/crypto/decrepit/evp/evp_do_all.c +2 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/digest_extra/digest_extra.c +8 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/digest_extra/digest_test.cc +110 -45
- data/aws-crt-ffi/crt/aws-lc/crypto/dsa/dsa_test.cc +8 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/dsa/internal.h +18 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/dynamic_loading_test.c +8 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/ec_extra/ec_derive.c +4 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/ec_extra/hash_to_curve.c +6 -18
- data/aws-crt-ffi/crt/aws-lc/crypto/endian_test.cc +308 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/err/ssl.errordata +2 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/evp_extra_test.cc +2 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/evp_test.cc +11 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/evp_tests.txt +25 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/p_ec_asn1.c +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/p_kem.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/p_rsa_asn1.c +1 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/print.c +7 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/evp_extra/scrypt.c +13 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/CMakeLists.txt +13 -4
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/aes/aes_nohw.c +18 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bcm.c +12 -4
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/bn_assert_test.cc +77 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/bn_test.cc +30 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/bytes.c +112 -22
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/div.c +12 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/exponentiation.c +54 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/gcd.c +5 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/internal.h +37 -15
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/montgomery.c +4 -11
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/bn/montgomery_inv.c +51 -15
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/cipher/aead.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/digest/digest.c +29 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/digest/digests.c +89 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/digest/internal.h +4 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/ec.c +19 -36
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/ec_key.c +3 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/ec_montgomery.c +9 -7
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/ec_test.cc +33 -9
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/internal.h +17 -12
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/p224-64.c +5 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/p256-nistz.c +8 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/p256.c +9 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/p384.c +33 -16
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/p521.c +14 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/scalar.c +26 -24
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/simple_mul.c +8 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ec/wnaf.c +3 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/ecdsa/ecdsa.c +9 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/evp/evp.c +43 -12
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/evp/p_ec.c +4 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/hmac/hmac.c +3 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/modes/xts.c +26 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rand/cpu_jitter_test.cc +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rand/internal.h +20 -11
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rand/rand.c +10 -10
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rand/urandom.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rsa/internal.h +59 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rsa/padding.c +9 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rsa/rsa.c +7 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/rsa/rsa_impl.c +51 -60
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/service_indicator/service_indicator.c +5 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/service_indicator/service_indicator_test.cc +205 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/asm/sha1-armv8.pl +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/asm/sha512-armv8.pl +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/internal.h +8 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/sha3.c +37 -15
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/sha3_test.cc +115 -110
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sha/sha512.c +55 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/fipsmodule/sshkdf/sshkdf.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/hmac_extra/hmac_test.cc +12 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/hmac_extra/hmac_tests.txt +10 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/hrss/asm/poly_rq_mul.S +2 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/impl_dispatch_test.cc +9 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/internal.h +90 -8
- data/aws-crt-ffi/crt/aws-lc/crypto/kem/kem.c +28 -27
- data/aws-crt-ffi/crt/aws-lc/crypto/kyber/kem_kyber.h +14 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/obj/obj_dat.h +52 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/obj/obj_mac.num +5 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/obj/objects.txt +7 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/perlasm/arm-xlate.pl +3 -14
- data/aws-crt-ffi/crt/aws-lc/crypto/perlasm/ppc-xlate.pl +1 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/perlasm/x86_64-xlate.pl +4 -15
- data/aws-crt-ffi/crt/aws-lc/crypto/perlasm/x86asm.pl +4 -13
- data/aws-crt-ffi/crt/aws-lc/crypto/poly1305/poly1305_arm_asm.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/crypto/rand_extra/deterministic.c +4 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/rand_extra/fuchsia.c +4 -4
- data/aws-crt-ffi/crt/aws-lc/crypto/rand_extra/rand_test.cc +0 -63
- data/aws-crt-ffi/crt/aws-lc/crypto/rand_extra/windows.c +41 -19
- data/aws-crt-ffi/crt/aws-lc/crypto/rsa_extra/rsa_test.cc +3 -3
- data/aws-crt-ffi/crt/aws-lc/crypto/siphash/siphash.c +12 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/siphash/siphash_test.cc +5 -5
- data/aws-crt-ffi/crt/aws-lc/crypto/stack/stack.c +68 -46
- data/aws-crt-ffi/crt/aws-lc/crypto/trust_token/pmbtoken.c +4 -4
- data/aws-crt-ffi/crt/aws-lc/crypto/trust_token/voprf.c +2 -2
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/by_dir.c +0 -6
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/internal.h +4 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/x509_lu.c +33 -9
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/x509_test.cc +87 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/x509_trs.c +1 -1
- data/aws-crt-ffi/crt/aws-lc/crypto/x509/x509_vfy.c +35 -13
- data/aws-crt-ffi/crt/aws-lc/crypto/x509v3/v3_lib.c +2 -0
- data/aws-crt-ffi/crt/aws-lc/crypto/x509v3/v3_purp.c +4 -6
- data/aws-crt-ffi/crt/aws-lc/generated-src/crypto_test_data.cc +179 -151
- data/aws-crt-ffi/crt/aws-lc/generated-src/err_data.c +353 -349
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/chacha/chacha-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/aesv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/aesv8-gcm-armv8-unroll8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/aesv8-gcm-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/armv8-mont.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/bn-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/ghash-neon-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/ghashv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/keccak1600-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/md5-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/p256-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/sha1-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/sha256-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/sha512-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/fipsmodule/vpaes-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-aarch64/crypto/test/trampoline-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/chacha/chacha-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/aesv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/armv4-mont.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/bsaes-armv7.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/ghash-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/ghashv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/sha1-armv4-large.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/sha256-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/sha512-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/fipsmodule/vpaes-armv7.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/ios-arm/crypto/test/trampoline-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/chacha/chacha-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/aesv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/aesv8-gcm-armv8-unroll8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/aesv8-gcm-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/armv8-mont.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/bn-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/ghash-neon-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/ghashv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/keccak1600-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/md5-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/p256-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/sha1-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/sha256-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/sha512-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/fipsmodule/vpaes-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-aarch64/crypto/test/trampoline-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/chacha/chacha-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/aesv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/armv4-mont.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/bsaes-armv7.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/ghash-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/ghashv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/sha1-armv4-large.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/sha256-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/sha512-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/fipsmodule/vpaes-armv7.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-arm/crypto/test/trampoline-armv4.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-ppc64le/crypto/fipsmodule/aesp8-ppc.S +1 -5
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-ppc64le/crypto/fipsmodule/ghashp8-ppc.S +1 -5
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-ppc64le/crypto/test/trampoline-ppc.S +1 -5
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/chacha/chacha-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/aesni-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/bn-586.S +4 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/co-586.S +4 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/ghash-ssse3-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/ghash-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/md5-586.S +4 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/sha1-586.S +4 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/sha256-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/sha512-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/vpaes-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/fipsmodule/x86-mont.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86/crypto/test/trampoline-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/cipher_extra/aesni-sha1-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/cipher_extra/aesni-sha256-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/aesni-gcm-avx512.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/aesni-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/aesni-xts-avx512.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/ghash-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/md5-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/p256-x86_64-asm.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/rdrand-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/rsaz-avx2.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/sha256-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/sha512-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/vpaes-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/x86_64-mont.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/fipsmodule/x86_64-mont5.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/linux-x86_64/crypto/test/trampoline-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/chacha/chacha-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/aesni-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/bn-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/co-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/ghash-ssse3-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/ghash-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/md5-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/sha1-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/sha256-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/sha512-586.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/vpaes-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/fipsmodule/x86-mont.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86/crypto/test/trampoline-x86.S +3 -12
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/cipher_extra/aes128gcmsiv-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/cipher_extra/aesni-sha1-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/cipher_extra/aesni-sha256-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/cipher_extra/chacha20_poly1305_x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/aesni-gcm-avx512.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/aesni-gcm-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/aesni-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/aesni-xts-avx512.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/ghash-ssse3-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/ghash-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/md5-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/p256-x86_64-asm.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/p256_beeu-x86_64-asm.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/rdrand-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/rsaz-avx2.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/sha256-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/sha512-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/vpaes-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/x86_64-mont.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/fipsmodule/x86_64-mont5.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/mac-x86_64/crypto/test/trampoline-x86_64.S +2 -11
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/chacha/chacha-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/cipher_extra/chacha20_poly1305_armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/aesv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/aesv8-gcm-armv8-unroll8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/aesv8-gcm-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/armv8-mont.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/bn-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/ghash-neon-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/ghashv8-armx.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/keccak1600-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/md5-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/p256-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/p256_beeu-armv8-asm.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/sha1-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/sha256-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/sha512-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/fipsmodule/vpaes-armv8.S +3 -13
- data/aws-crt-ffi/crt/aws-lc/generated-src/win-aarch64/crypto/test/trampoline-armv8.S +4 -14
- data/aws-crt-ffi/crt/aws-lc/go.mod +4 -4
- data/aws-crt-ffi/crt/aws-lc/go.sum +8 -10
- data/aws-crt-ffi/crt/aws-lc/include/openssl/aead.h +2 -2
- data/aws-crt-ffi/crt/aws-lc/include/openssl/arm_arch.h +4 -119
- data/aws-crt-ffi/crt/aws-lc/include/openssl/asm_base.h +185 -0
- data/aws-crt-ffi/crt/aws-lc/include/openssl/asn1.h +5 -0
- data/aws-crt-ffi/crt/aws-lc/include/openssl/base.h +31 -134
- data/aws-crt-ffi/crt/aws-lc/include/openssl/bio.h +30 -18
- data/aws-crt-ffi/crt/aws-lc/include/openssl/bn.h +0 -2
- data/aws-crt-ffi/crt/aws-lc/include/openssl/chacha.h +6 -0
- data/aws-crt-ffi/crt/aws-lc/include/openssl/cipher.h +2 -2
- data/aws-crt-ffi/crt/aws-lc/include/openssl/digest.h +9 -6
- data/aws-crt-ffi/crt/aws-lc/include/openssl/dsa.h +0 -21
- data/aws-crt-ffi/crt/aws-lc/include/openssl/ec.h +1 -1
- data/aws-crt-ffi/crt/aws-lc/include/openssl/err.h +1 -1
- data/aws-crt-ffi/crt/aws-lc/include/openssl/evp.h +8 -5
- data/aws-crt-ffi/crt/aws-lc/include/openssl/nid.h +21 -0
- data/aws-crt-ffi/crt/aws-lc/include/openssl/rsa.h +1 -65
- data/aws-crt-ffi/crt/aws-lc/include/openssl/sha.h +22 -1
- data/aws-crt-ffi/crt/aws-lc/include/openssl/ssl.h +121 -13
- data/aws-crt-ffi/crt/aws-lc/include/openssl/stack.h +229 -208
- data/aws-crt-ffi/crt/aws-lc/include/openssl/target.h +166 -0
- data/aws-crt-ffi/crt/aws-lc/include/openssl/x509.h +30 -10
- data/aws-crt-ffi/crt/aws-lc/include/openssl/x509v3.h +6 -4
- data/aws-crt-ffi/crt/aws-lc/sources.cmake +2 -0
- data/aws-crt-ffi/crt/aws-lc/ssl/extensions.cc +12 -7
- data/aws-crt-ffi/crt/aws-lc/ssl/handshake_server.cc +28 -18
- data/aws-crt-ffi/crt/aws-lc/ssl/internal.h +41 -6
- data/aws-crt-ffi/crt/aws-lc/ssl/s3_both.cc +9 -17
- data/aws-crt-ffi/crt/aws-lc/ssl/ssl_cipher.cc +13 -5
- data/aws-crt-ffi/crt/aws-lc/ssl/ssl_key_share.cc +542 -2
- data/aws-crt-ffi/crt/aws-lc/ssl/ssl_lib.cc +35 -0
- data/aws-crt-ffi/crt/aws-lc/ssl/ssl_test.cc +1847 -14
- data/aws-crt-ffi/crt/aws-lc/ssl/ssl_x509.cc +128 -0
- data/aws-crt-ffi/crt/aws-lc/ssl/test/PORTING.md +10 -7
- data/aws-crt-ffi/crt/aws-lc/ssl/test/bssl_shim.cc +133 -77
- data/aws-crt-ffi/crt/aws-lc/ssl/test/handshake_util.cc +3 -3
- data/aws-crt-ffi/crt/aws-lc/ssl/test/handshaker.cc +4 -0
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/handshake_client.go +6 -2
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/handshake_messages.go +894 -1042
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/handshake_server.go +24 -23
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/prf.go +6 -5
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/runner.go +56 -55
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/shim_dispatcher.go +188 -0
- data/aws-crt-ffi/crt/aws-lc/ssl/test/runner/ticket.go +37 -39
- data/aws-crt-ffi/crt/aws-lc/ssl/test/test_config.cc +59 -24
- data/aws-crt-ffi/crt/aws-lc/ssl/test/test_config.h +3 -2
- data/aws-crt-ffi/crt/aws-lc/ssl/tls13_server.cc +10 -11
- data/aws-crt-ffi/crt/aws-lc/tests/ci/cdk/app.py +4 -4
- data/aws-crt-ffi/crt/aws-lc/tests/ci/cdk/cdk/{aws_lc_mac_arm_ci_stack.py → aws_lc_ec2_test_framework_ci_stack.py} +13 -29
- data/aws-crt-ffi/crt/aws-lc/tests/ci/cdk/cdk/ssm/general_test_run_ssm_document.yaml +43 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/common_posix_setup.sh +10 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-aarch/amazonlinux-2023_base/Dockerfile +5 -1
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-aarch/ubuntu-22.04_base/Dockerfile +19 -3
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/amazonlinux-2_gcc-7x-intel-sde/Dockerfile +5 -4
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/build_images.sh +1 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/push_images.sh +2 -1
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/ubuntu-20.04_clang-10x_formal-verification/create_image.sh +1 -1
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/ubuntu-22.04_base/Dockerfile +1 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/linux-x86/ubuntu-22.04_clang-14x-sde/Dockerfile +42 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/windows/vs2017/Dockerfile +14 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/docker_images/windows/windows_base/Dockerfile +3 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/integration/README.md +12 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/integration/nginx_patch/aws-lc-nginx.patch +68 -23
- data/aws-crt-ffi/crt/aws-lc/tests/ci/integration/run_crt_integration.sh +27 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/integration/run_monit_integration.sh +56 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/integration/sslproxy_patch/aws-lc-sslproxy.patch +2 -2
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_ec2_test_framework.sh +135 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_fips_tests.sh +14 -2
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_tests_with_sde.sh +4 -1
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_tests_with_sde_asan.sh +14 -0
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_windows_tests.bat +39 -3
- data/aws-crt-ffi/crt/aws-lc/third_party/fiat/README.md +21 -6
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_madd_n25519.S +284 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_madd_n25519_alt.S +210 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_mod_n25519.S +186 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/bignum_neg_p25519.S +65 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519.S +1043 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519_alt.S +1043 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519_byte.S +1043 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519_byte_alt.S +1043 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519base.S +1042 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519base_alt.S +1042 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519base_byte.S +1042 -352
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/curve25519_x25519base_byte_alt.S +1043 -354
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_decode.S +700 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_decode_alt.S +563 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_encode.S +131 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_scalarmulbase.S +9626 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_scalarmulbase_alt.S +9468 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_scalarmuldouble.S +3157 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/curve25519/edwards25519_scalarmuldouble_alt.S +2941 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/p384/Makefile +1 -1
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/arm/p521/Makefile +1 -1
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/include/s2n-bignum_aws-lc.h +34 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519.S +219 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/bignum_madd_n25519_alt.S +245 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/bignum_mod_n25519.S +228 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/bignum_neg_p25519.S +86 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/curve25519_x25519.S +1350 -407
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/curve25519_x25519_alt.S +1350 -407
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/curve25519_x25519base.S +1344 -400
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/curve25519_x25519base_alt.S +1348 -402
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_decode.S +670 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_decode_alt.S +751 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_encode.S +81 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_scalarmulbase.S +9910 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_scalarmulbase_alt.S +9986 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_scalarmuldouble.S +3619 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/s2n-bignum/x86_att/curve25519/edwards25519_scalarmuldouble_alt.S +3736 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/wycheproof_testvectors/hmac_sha512_224_test.json +1978 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/wycheproof_testvectors/hmac_sha512_224_test.txt +1403 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/wycheproof_testvectors/hmac_sha512_256_test.json +1993 -0
- data/aws-crt-ffi/crt/aws-lc/third_party/wycheproof_testvectors/hmac_sha512_256_test.txt +1416 -0
- data/aws-crt-ffi/crt/aws-lc/tool/digest.cc +4 -0
- data/aws-crt-ffi/crt/aws-lc/tool/internal.h +1 -0
- data/aws-crt-ffi/crt/aws-lc/tool/speed.cc +53 -6
- data/aws-crt-ffi/crt/aws-lc/util/all_tests.go +43 -12
- data/aws-crt-ffi/crt/aws-lc/util/all_tests.json +13 -5
- data/aws-crt-ffi/crt/aws-lc/util/bot/DEPS +4 -4
- data/aws-crt-ffi/crt/aws-lc/util/bot/update_clang.py +8 -2
- data/aws-crt-ffi/crt/aws-lc/util/codecov-ci.sh +82 -0
- data/aws-crt-ffi/crt/aws-lc/util/convert_wycheproof/convert_wycheproof.go +7 -5
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/ACVP.md +7 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/subprocess/hash.go +24 -9
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/subprocess/rsa.go +3 -4
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/subprocess/subprocess.go +15 -10
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/expected/HMAC-SHA2-512-224.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/expected/SHA2-512-224.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/expected/SHAKE-128.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/expected/SHAKE-256.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/sha-tests/sha512-224-tests.json +1 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/sha-tests/shake-128-tests.json +1 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/sha-tests/shake-256-tests.json +1 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/tests.json +1 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/vectors/HMAC-SHA2-512-224.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/vectors/SHA2-512-224.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/vectors/SHAKE-128.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/acvptool/test/vectors/SHAKE-256.bz2 +0 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/modulewrapper/main.cc +4 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/acvp/modulewrapper/modulewrapper.cc +144 -1
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/delocate/delocate.go +9 -3
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/delocate/testdata/aarch64-Basic/in.s +4 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/delocate/testdata/aarch64-Basic/out.s +11 -0
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/inject_hash/inject_hash.go +13 -4
- data/aws-crt-ffi/crt/aws-lc/util/fipstools/test-break-kat.sh +2 -0
- data/aws-crt-ffi/crt/aws-lc/util/testconfig/testconfig.go +2 -1
- data/aws-crt-ffi/crt/s2n/api/s2n.h +9 -5
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/benches/handshake.rs +9 -6
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/benches/resumption.rs +14 -14
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/benches/throughput.rs +9 -6
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/src/harness.rs +106 -102
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/src/openssl.rs +24 -20
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/src/rustls.rs +28 -24
- data/aws-crt-ffi/crt/s2n/bindings/rust/bench/src/s2n_tls.rs +52 -50
- data/aws-crt-ffi/crt/s2n/bindings/rust/generate/Cargo.toml +1 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/integration/Cargo.toml +3 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/connection.rs +9 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/templates/Cargo.template +2 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +2 -2
- data/aws-crt-ffi/crt/s2n/tests/cbmc/sources/make_common_datastructures.c +9 -2
- data/aws-crt-ffi/crt/s2n/tests/fuzz/s2n_client_cert_verify_recv_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/fuzz/s2n_hybrid_ecdhe_kyber_r3_fuzz_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/fuzz/s2n_tls13_cert_verify_recv_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +4 -4
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_auth_selection_test.c +19 -9
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_auth_handshake_test.c +3 -3
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_cert_verify_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_recv_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_test.c +4 -4
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_signature_algorithms_extension_test.c +4 -5
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_protocol_versions_test.c +390 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +8 -4
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_handshake_test.c +2 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_quic_support_io_test.c +106 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_security_policies_test.c +6 -2
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_offload_signing_test.c +3 -3
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_session_resumption_test.c +135 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_server_new_session_ticket_test.c +32 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_server_signature_algorithms_extension_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_signature_algorithms_test.c +307 -283
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_cert_request_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_cert_verify_test.c +18 -17
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_x509_validator_test.c +125 -0
- data/aws-crt-ffi/crt/s2n/tls/extensions/s2n_client_signature_algorithms.c +8 -1
- data/aws-crt-ffi/crt/s2n/tls/extensions/s2n_client_supported_versions.c +43 -11
- data/aws-crt-ffi/crt/s2n/tls/extensions/s2n_client_supported_versions.h +3 -0
- data/aws-crt-ffi/crt/s2n/tls/extensions/s2n_server_signature_algorithms.c +8 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_auth_selection.c +4 -2
- data/aws-crt-ffi/crt/s2n/tls/s2n_client_cert_verify.c +7 -10
- data/aws-crt-ffi/crt/s2n/tls/s2n_client_hello.c +2 -2
- data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +75 -14
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake.h +2 -2
- data/aws-crt-ffi/crt/s2n/tls/s2n_post_handshake.c +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_post_handshake.h +1 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.c +29 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +5 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_security_policies.c +40 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_security_policies.h +4 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_server_cert_request.c +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_server_hello.c +0 -3
- data/aws-crt-ffi/crt/s2n/tls/s2n_server_key_exchange.c +8 -9
- data/aws-crt-ffi/crt/s2n/tls/s2n_server_new_session_ticket.c +8 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_signature_algorithms.c +111 -72
- data/aws-crt-ffi/crt/s2n/tls/s2n_signature_algorithms.h +11 -9
- data/aws-crt-ffi/crt/s2n/tls/s2n_signature_scheme.c +9 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_signature_scheme.h +2 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_certificate_verify.c +12 -18
- data/aws-crt-ffi/crt/s2n/tls/s2n_x509_validator.c +7 -7
- data/aws-crt-ffi/src/api.h +1 -0
- data/lib/aws-crt/native.rb +1 -1
- metadata +68 -5
- data/aws-crt-ffi/crt/aws-lc/tests/ci/cdk/cdk/ssm/m1_tests_ssm_document.yaml +0 -34
- data/aws-crt-ffi/crt/aws-lc/tests/ci/run_m1_ec2_instance.sh +0 -96
@@ -36,6 +36,7 @@
|
|
36
36
|
#include <openssl/err.h>
|
37
37
|
#include <openssl/hmac.h>
|
38
38
|
#include <openssl/hpke.h>
|
39
|
+
#include <openssl/hrss.h>
|
39
40
|
#include <openssl/pem.h>
|
40
41
|
#include <openssl/rand.h>
|
41
42
|
#include <openssl/sha.h>
|
@@ -46,6 +47,9 @@
|
|
46
47
|
#include "../crypto/internal.h"
|
47
48
|
#include "../crypto/test/test_util.h"
|
48
49
|
#include "internal.h"
|
50
|
+
#include "../crypto/kyber/kem_kyber.h"
|
51
|
+
#include "../crypto/kem/internal.h"
|
52
|
+
#include "../crypto/fipsmodule/ec/internal.h"
|
49
53
|
|
50
54
|
#if defined(OPENSSL_WINDOWS)
|
51
55
|
// Windows defines struct timeval in winsock2.h.
|
@@ -60,7 +64,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
|
|
60
64
|
#include <thread>
|
61
65
|
#endif
|
62
66
|
|
63
|
-
|
64
67
|
BSSL_NAMESPACE_BEGIN
|
65
68
|
|
66
69
|
namespace {
|
@@ -154,6 +157,39 @@ struct CurveTest {
|
|
154
157
|
std::vector<uint16_t> expected;
|
155
158
|
};
|
156
159
|
|
160
|
+
struct GroupTest {
|
161
|
+
int nid;
|
162
|
+
uint16_t group_id;
|
163
|
+
size_t offer_key_share_size;
|
164
|
+
size_t accept_key_share_size;
|
165
|
+
size_t shared_secret_size;
|
166
|
+
};
|
167
|
+
|
168
|
+
struct HybridGroupTest {
|
169
|
+
int nid;
|
170
|
+
uint16_t group_id;
|
171
|
+
size_t offer_key_share_size;
|
172
|
+
size_t accept_key_share_size;
|
173
|
+
size_t shared_secret_size;
|
174
|
+
size_t offer_share_sizes[NUM_HYBRID_COMPONENTS];
|
175
|
+
size_t accept_share_sizes[NUM_HYBRID_COMPONENTS];
|
176
|
+
};
|
177
|
+
|
178
|
+
struct HybridHandshakeTest {
|
179
|
+
// The curves rule string to apply to the client
|
180
|
+
const char *client_rule;
|
181
|
+
// TLS version that the client is configured with
|
182
|
+
uint16_t client_version;
|
183
|
+
// The curves rule string to apply to the server
|
184
|
+
const char *server_rule;
|
185
|
+
// TLS version that the server is configured with
|
186
|
+
uint16_t server_version;
|
187
|
+
// The group that is expected to be negotiated
|
188
|
+
uint16_t expected_group;
|
189
|
+
// Is a HelloRetryRequest expected?
|
190
|
+
bool is_hrr_expected;
|
191
|
+
};
|
192
|
+
|
157
193
|
template <typename T>
|
158
194
|
class UnownedSSLExData {
|
159
195
|
public:
|
@@ -569,6 +605,90 @@ static const CurveTest kCurveTests[] = {
|
|
569
605
|
SSL_GROUP_X25519,
|
570
606
|
},
|
571
607
|
},
|
608
|
+
{
|
609
|
+
"SecP256r1Kyber768Draft00:prime256v1:secp384r1:secp521r1:x25519",
|
610
|
+
{
|
611
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
612
|
+
SSL_GROUP_SECP256R1,
|
613
|
+
SSL_GROUP_SECP384R1,
|
614
|
+
SSL_GROUP_SECP521R1,
|
615
|
+
SSL_GROUP_X25519,
|
616
|
+
},
|
617
|
+
},
|
618
|
+
{
|
619
|
+
"X25519Kyber768Draft00:prime256v1:secp384r1",
|
620
|
+
{
|
621
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
622
|
+
SSL_GROUP_SECP256R1,
|
623
|
+
SSL_GROUP_SECP384R1,
|
624
|
+
},
|
625
|
+
},
|
626
|
+
{
|
627
|
+
"X25519:X25519Kyber768Draft00",
|
628
|
+
{
|
629
|
+
SSL_GROUP_X25519,
|
630
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
631
|
+
},
|
632
|
+
},
|
633
|
+
{
|
634
|
+
"X25519:SecP256r1Kyber768Draft00:prime256v1",
|
635
|
+
{
|
636
|
+
SSL_GROUP_X25519,
|
637
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
638
|
+
SSL_GROUP_SECP256R1,
|
639
|
+
},
|
640
|
+
},
|
641
|
+
};
|
642
|
+
|
643
|
+
|
644
|
+
// SECP256R1: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.8.2
|
645
|
+
// X25519: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.8.2
|
646
|
+
static const size_t P256_KEYSHARE_SIZE = ((EC_P256R1_FIELD_ELEM_BYTES * 2) + 1);
|
647
|
+
static const size_t P256_SECRET_SIZE = EC_P256R1_FIELD_ELEM_BYTES;
|
648
|
+
static const size_t X25519_KEYSHARE_SIZE = 32;
|
649
|
+
static const size_t X25519_SECRET_SIZE = 32;
|
650
|
+
|
651
|
+
static const GroupTest kKemGroupTests[] = {
|
652
|
+
{
|
653
|
+
NID_KYBER768_R3,
|
654
|
+
SSL_GROUP_KYBER768_R3,
|
655
|
+
KYBER768_R3_PUBLIC_KEY_BYTES,
|
656
|
+
KYBER768_R3_CIPHERTEXT_BYTES,
|
657
|
+
KYBER_R3_SHARED_SECRET_LEN,
|
658
|
+
},
|
659
|
+
};
|
660
|
+
|
661
|
+
static const HybridGroupTest kHybridGroupTests[] = {
|
662
|
+
{
|
663
|
+
NID_SecP256r1Kyber768Draft00,
|
664
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
665
|
+
P256_KEYSHARE_SIZE + KYBER768_R3_PUBLIC_KEY_BYTES,
|
666
|
+
P256_KEYSHARE_SIZE + KYBER768_R3_CIPHERTEXT_BYTES,
|
667
|
+
P256_SECRET_SIZE + KYBER_R3_SHARED_SECRET_LEN,
|
668
|
+
{
|
669
|
+
P256_KEYSHARE_SIZE, // offer_share_sizes[0]
|
670
|
+
KYBER768_R3_PUBLIC_KEY_BYTES, // offer_share_sizes[1]
|
671
|
+
},
|
672
|
+
{
|
673
|
+
P256_KEYSHARE_SIZE, // accept_share_sizes[0]
|
674
|
+
KYBER768_R3_CIPHERTEXT_BYTES, // accept_share_sizes[1]
|
675
|
+
},
|
676
|
+
},
|
677
|
+
{
|
678
|
+
NID_X25519Kyber768Draft00,
|
679
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
680
|
+
X25519_KEYSHARE_SIZE + KYBER768_R3_PUBLIC_KEY_BYTES,
|
681
|
+
X25519_KEYSHARE_SIZE + KYBER768_R3_CIPHERTEXT_BYTES,
|
682
|
+
X25519_SECRET_SIZE + KYBER_R3_SHARED_SECRET_LEN,
|
683
|
+
{
|
684
|
+
X25519_KEYSHARE_SIZE, // offer_share_sizes[0]
|
685
|
+
KYBER768_R3_PUBLIC_KEY_BYTES, // offer_share_sizes[1]
|
686
|
+
},
|
687
|
+
{
|
688
|
+
X25519_KEYSHARE_SIZE, // accept_share_sizes[0]
|
689
|
+
KYBER768_R3_CIPHERTEXT_BYTES, // accept_share_sizes[1]
|
690
|
+
},
|
691
|
+
},
|
572
692
|
};
|
573
693
|
|
574
694
|
static const char *kBadCurvesLists[] = {
|
@@ -580,8 +700,335 @@ static const char *kBadCurvesLists[] = {
|
|
580
700
|
"P-256:RSA",
|
581
701
|
"X25519:P-256:",
|
582
702
|
":X25519:P-256",
|
703
|
+
"kyber768_r3",
|
704
|
+
"x25519_kyber768:prime256v1",
|
705
|
+
};
|
706
|
+
|
707
|
+
static const HybridHandshakeTest kHybridHandshakeTests[] = {
|
708
|
+
// The corresponding hybrid group should be negotiated when client
|
709
|
+
// and server support only that group
|
710
|
+
{
|
711
|
+
"X25519Kyber768Draft00",
|
712
|
+
TLS1_3_VERSION,
|
713
|
+
"X25519Kyber768Draft00",
|
714
|
+
TLS1_3_VERSION,
|
715
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
716
|
+
false,
|
717
|
+
},
|
718
|
+
|
719
|
+
{
|
720
|
+
"SecP256r1Kyber768Draft00",
|
721
|
+
TLS1_3_VERSION,
|
722
|
+
"SecP256r1Kyber768Draft00",
|
723
|
+
TLS1_3_VERSION,
|
724
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
725
|
+
false,
|
726
|
+
},
|
727
|
+
|
728
|
+
// The client's preferred hybrid group should be negotiated when also
|
729
|
+
// supported by the server, even if the server "prefers"/supports other groups.
|
730
|
+
{
|
731
|
+
"X25519Kyber768Draft00:x25519",
|
732
|
+
TLS1_3_VERSION,
|
733
|
+
"x25519:prime256v1:X25519Kyber768Draft00",
|
734
|
+
TLS1_3_VERSION,
|
735
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
736
|
+
false,
|
737
|
+
},
|
738
|
+
|
739
|
+
{
|
740
|
+
"X25519Kyber768Draft00:x25519",
|
741
|
+
TLS1_3_VERSION,
|
742
|
+
"X25519Kyber768Draft00:x25519",
|
743
|
+
TLS1_3_VERSION,
|
744
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
745
|
+
false,
|
746
|
+
},
|
747
|
+
|
748
|
+
{
|
749
|
+
"SecP256r1Kyber768Draft00",
|
750
|
+
TLS1_3_VERSION,
|
751
|
+
"X25519Kyber768Draft00:secp384r1:x25519:SecP256r1Kyber768Draft00",
|
752
|
+
TLS1_3_VERSION,
|
753
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
754
|
+
false,
|
755
|
+
},
|
756
|
+
|
757
|
+
// The client lists PQ/hybrid groups as both first and second preferences.
|
758
|
+
// The key share logic is implemented such that the client will always
|
759
|
+
// attempt to send one hybrid key share and one classical key share.
|
760
|
+
// Therefore, the client will send key shares [SecP256r1Kyber768Draft00, x25519],
|
761
|
+
// skipping X25519Kyber768Draft00, and the server will choose to negotiate
|
762
|
+
// x25519 since it is the only mutually supported group.
|
763
|
+
{
|
764
|
+
"SecP256r1Kyber768Draft00:X25519Kyber768Draft00:x25519",
|
765
|
+
TLS1_3_VERSION,
|
766
|
+
"secp384r1:x25519",
|
767
|
+
TLS1_3_VERSION,
|
768
|
+
SSL_GROUP_X25519,
|
769
|
+
false,
|
770
|
+
},
|
771
|
+
|
772
|
+
// The client will send key shares [x25519, SecP256r1Kyber768Draft00].
|
773
|
+
// The server will negotiate SecP256r1Kyber768Draft00 since it is the only
|
774
|
+
// mutually supported group.
|
775
|
+
{
|
776
|
+
"x25519:secp384r1:SecP256r1Kyber768Draft00",
|
777
|
+
TLS1_3_VERSION,
|
778
|
+
"SecP256r1Kyber768Draft00:prime256v1",
|
779
|
+
TLS1_3_VERSION,
|
780
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
781
|
+
false,
|
782
|
+
},
|
783
|
+
|
784
|
+
// The client will send key shares [x25519, SecP256r1Kyber768Draft00]. The
|
785
|
+
// server will negotiate x25519 since the client listed it as its first
|
786
|
+
// preference, even though it supports SecP256r1Kyber768Draft00.
|
787
|
+
{
|
788
|
+
"x25519:prime256v1:SecP256r1Kyber768Draft00",
|
789
|
+
TLS1_3_VERSION,
|
790
|
+
"prime256v1:x25519:SecP256r1Kyber768Draft00",
|
791
|
+
TLS1_3_VERSION,
|
792
|
+
SSL_GROUP_X25519,
|
793
|
+
false,
|
794
|
+
},
|
795
|
+
|
796
|
+
// The client will send key shares [SecP256r1Kyber768Draft00, x25519].
|
797
|
+
// The server will negotiate SecP256r1Kyber768Draft00 since the client listed
|
798
|
+
// it as its first preference.
|
799
|
+
{
|
800
|
+
"SecP256r1Kyber768Draft00:x25519:prime256v1",
|
801
|
+
TLS1_3_VERSION,
|
802
|
+
"prime256v1:x25519:SecP256r1Kyber768Draft00",
|
803
|
+
TLS1_3_VERSION,
|
804
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
805
|
+
false,
|
806
|
+
},
|
807
|
+
|
808
|
+
// In the supported_groups extension, the client will indicate its
|
809
|
+
// preferences, in order, as [SecP256r1Kyber768Draft00, X25519Kyber768Draft00,
|
810
|
+
// x25519, prime256v1]. From those groups, it will send key shares
|
811
|
+
// [SecP256r1Kyber768Draft00, x25519]. The server supports, and receives a
|
812
|
+
// key share for, x25519. However, when selecting a mutually supported group
|
813
|
+
// to negotiate, the server recognizes that the client prefers
|
814
|
+
// X25519Kyber768Draft00 over x25519. Since the server also supports
|
815
|
+
// X25519Kyber768Draft00, but did not receive a key share for it, it will
|
816
|
+
// select it and send an HRR. This ensures that the client's highest
|
817
|
+
// preference group will be negotiated, even at the expense of an additional
|
818
|
+
// round-trip.
|
819
|
+
//
|
820
|
+
// In our SSL implementation, this situation is unique to the case where the
|
821
|
+
// client supports both ECC and hybrid/PQ. When sending key shares, the
|
822
|
+
// client will send at most two key shares in one of the following ways:
|
823
|
+
|
824
|
+
// (a) one ECC key share - if the client supports only ECC;
|
825
|
+
// (b) one PQ key share - if the client supports only PQ;
|
826
|
+
// (c) one ECC and one PQ key share - if the client supports ECC and PQ.
|
827
|
+
//
|
828
|
+
// One of the above cases will be true irrespective of how many groups
|
829
|
+
// the client supports. If, say, the client supports four ECC groups
|
830
|
+
// and zero PQ groups, it will still only send a single ECC share. In cases
|
831
|
+
// (a) and (b), either the server supports that group and chooses to
|
832
|
+
// negotiate it, or it doesn't support it and sends an HRR. Case (c) is the
|
833
|
+
// only case where the server might receive a key share for a mutually
|
834
|
+
// supported group, but chooses to respect the client's preference order
|
835
|
+
// defined in the supported_groups extension at the expense of an additional
|
836
|
+
// round-trip.
|
837
|
+
{
|
838
|
+
"SecP256r1Kyber768Draft00:X25519Kyber768Draft00:x25519:prime256v1",
|
839
|
+
TLS1_3_VERSION,
|
840
|
+
"X25519Kyber768Draft00:prime256v1:x25519",
|
841
|
+
TLS1_3_VERSION,
|
842
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
843
|
+
true,
|
844
|
+
},
|
845
|
+
|
846
|
+
// Like the previous case, but the client's prioritization of ECC and PQ
|
847
|
+
// is inverted.
|
848
|
+
{
|
849
|
+
"x25519:prime256v1:SecP256r1Kyber768Draft00:X25519Kyber768Draft00",
|
850
|
+
TLS1_3_VERSION,
|
851
|
+
"X25519Kyber768Draft00:prime256v1",
|
852
|
+
TLS1_3_VERSION,
|
853
|
+
SSL_GROUP_SECP256R1,
|
854
|
+
true,
|
855
|
+
},
|
856
|
+
|
857
|
+
// The client will send key shares [SecP256r1Kyber768Draft00, x25519]. The
|
858
|
+
// server will negotiate X25519Kyber768Draft00 after an HRR.
|
859
|
+
{
|
860
|
+
"SecP256r1Kyber768Draft00:X25519Kyber768Draft00:x25519:prime256v1",
|
861
|
+
TLS1_3_VERSION,
|
862
|
+
"X25519Kyber768Draft00:prime256v1",
|
863
|
+
TLS1_3_VERSION,
|
864
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
865
|
+
true,
|
866
|
+
},
|
867
|
+
|
868
|
+
// EC should be negotiated when client prefers EC, or server does not
|
869
|
+
// support hybrid
|
870
|
+
{
|
871
|
+
"X25519Kyber768Draft00:x25519",
|
872
|
+
TLS1_3_VERSION,
|
873
|
+
"x25519",
|
874
|
+
TLS1_3_VERSION,
|
875
|
+
SSL_GROUP_X25519,
|
876
|
+
false,
|
877
|
+
},
|
878
|
+
{
|
879
|
+
"x25519:SecP256r1Kyber768Draft00",
|
880
|
+
TLS1_3_VERSION,
|
881
|
+
"x25519",
|
882
|
+
TLS1_3_VERSION,
|
883
|
+
SSL_GROUP_X25519,
|
884
|
+
false,
|
885
|
+
},
|
886
|
+
{
|
887
|
+
"prime256v1:X25519Kyber768Draft00",
|
888
|
+
TLS1_3_VERSION,
|
889
|
+
"X25519Kyber768Draft00:prime256v1",
|
890
|
+
TLS1_3_VERSION,
|
891
|
+
SSL_GROUP_SECP256R1,
|
892
|
+
false,
|
893
|
+
},
|
894
|
+
{
|
895
|
+
"prime256v1:x25519:SecP256r1Kyber768Draft00",
|
896
|
+
TLS1_3_VERSION,
|
897
|
+
"x25519:prime256v1:SecP256r1Kyber768Draft00",
|
898
|
+
TLS1_3_VERSION,
|
899
|
+
SSL_GROUP_SECP256R1,
|
900
|
+
false,
|
901
|
+
},
|
902
|
+
|
903
|
+
// EC should be negotiated, after a HelloRetryRequest, if the server
|
904
|
+
// supports only curves for which it did not initially receive a key share
|
905
|
+
{
|
906
|
+
"X25519Kyber768Draft00:x25519:SecP256r1Kyber768Draft00:prime256v1",
|
907
|
+
TLS1_3_VERSION,
|
908
|
+
"prime256v1",
|
909
|
+
TLS1_3_VERSION,
|
910
|
+
SSL_GROUP_SECP256R1,
|
911
|
+
true,
|
912
|
+
},
|
913
|
+
{
|
914
|
+
"X25519Kyber768Draft00:SecP256r1Kyber768Draft00:prime256v1:x25519",
|
915
|
+
TLS1_3_VERSION,
|
916
|
+
"secp224r1:secp384r1:secp521r1:x25519",
|
917
|
+
TLS1_3_VERSION,
|
918
|
+
SSL_GROUP_X25519,
|
919
|
+
true,
|
920
|
+
},
|
921
|
+
|
922
|
+
// Hybrid should be negotiated, after a HelloRetryRequest, if the server
|
923
|
+
// supports only curves for which it did not initially receive a key share
|
924
|
+
{
|
925
|
+
"x25519:prime256v1:SecP256r1Kyber768Draft00:X25519Kyber768Draft00",
|
926
|
+
TLS1_3_VERSION,
|
927
|
+
"secp224r1:X25519Kyber768Draft00:secp521r1",
|
928
|
+
TLS1_3_VERSION,
|
929
|
+
SSL_GROUP_X25519_KYBER768_DRAFT00,
|
930
|
+
true,
|
931
|
+
},
|
932
|
+
{
|
933
|
+
"X25519Kyber768Draft00:x25519:prime256v1:SecP256r1Kyber768Draft00",
|
934
|
+
TLS1_3_VERSION,
|
935
|
+
"SecP256r1Kyber768Draft00",
|
936
|
+
TLS1_3_VERSION,
|
937
|
+
SSL_GROUP_SECP256R1_KYBER768_DRAFT00,
|
938
|
+
true,
|
939
|
+
},
|
940
|
+
|
941
|
+
// If there is no overlap between client and server groups,
|
942
|
+
// the handshake should fail
|
943
|
+
{
|
944
|
+
"SecP256r1Kyber768Draft00:X25519Kyber768Draft00:secp384r1",
|
945
|
+
TLS1_3_VERSION,
|
946
|
+
"prime256v1:x25519",
|
947
|
+
TLS1_3_VERSION,
|
948
|
+
0,
|
949
|
+
false,
|
950
|
+
},
|
951
|
+
{
|
952
|
+
"secp384r1:SecP256r1Kyber768Draft00:X25519Kyber768Draft00",
|
953
|
+
TLS1_3_VERSION,
|
954
|
+
"prime256v1:x25519",
|
955
|
+
TLS1_3_VERSION,
|
956
|
+
0,
|
957
|
+
false,
|
958
|
+
},
|
959
|
+
{
|
960
|
+
"secp384r1:SecP256r1Kyber768Draft00",
|
961
|
+
TLS1_3_VERSION,
|
962
|
+
"prime256v1:x25519:X25519Kyber768Draft00",
|
963
|
+
TLS1_3_VERSION,
|
964
|
+
0,
|
965
|
+
false,
|
966
|
+
},
|
967
|
+
{
|
968
|
+
"SecP256r1Kyber768Draft00",
|
969
|
+
TLS1_3_VERSION,
|
970
|
+
"X25519Kyber768Draft00",
|
971
|
+
TLS1_3_VERSION,
|
972
|
+
0,
|
973
|
+
false,
|
974
|
+
},
|
975
|
+
|
976
|
+
// If the client supports hybrid TLS 1.3, but the server
|
977
|
+
// only supports TLS 1.2, then TLS 1.2 EC should be negotiated.
|
978
|
+
{
|
979
|
+
"SecP256r1Kyber768Draft00:prime256v1",
|
980
|
+
TLS1_3_VERSION,
|
981
|
+
"prime256v1:x25519",
|
982
|
+
TLS1_2_VERSION,
|
983
|
+
SSL_GROUP_SECP256R1,
|
984
|
+
false,
|
985
|
+
},
|
986
|
+
|
987
|
+
// Same as above, but server also has SecP256r1Kyber768Draft00 in it's
|
988
|
+
// supported list, but can't use it since TLS 1.3 is the minimum version that
|
989
|
+
// supports PQ.
|
990
|
+
{
|
991
|
+
"SecP256r1Kyber768Draft00:prime256v1",
|
992
|
+
TLS1_3_VERSION,
|
993
|
+
"SecP256r1Kyber768Draft00:prime256v1:x25519",
|
994
|
+
TLS1_2_VERSION,
|
995
|
+
SSL_GROUP_SECP256R1,
|
996
|
+
false,
|
997
|
+
},
|
998
|
+
|
999
|
+
// If the client configures the curve list to include a hybrid
|
1000
|
+
// curve, then initiates a 1.2 handshake, it will not advertise
|
1001
|
+
// hybrid groups because hybrid is not supported for 1.2. So
|
1002
|
+
// a 1.2 EC handshake will be negotiated (even if the server
|
1003
|
+
// supports 1.3 with corresponding hybrid group).
|
1004
|
+
{
|
1005
|
+
"SecP256r1Kyber768Draft00:x25519",
|
1006
|
+
TLS1_2_VERSION,
|
1007
|
+
"SecP256r1Kyber768Draft00:x25519",
|
1008
|
+
TLS1_3_VERSION,
|
1009
|
+
SSL_GROUP_X25519,
|
1010
|
+
false,
|
1011
|
+
},
|
1012
|
+
{
|
1013
|
+
"SecP256r1Kyber768Draft00:prime256v1",
|
1014
|
+
TLS1_2_VERSION,
|
1015
|
+
"prime256v1:x25519",
|
1016
|
+
TLS1_2_VERSION,
|
1017
|
+
SSL_GROUP_SECP256R1,
|
1018
|
+
false,
|
1019
|
+
},
|
583
1020
|
};
|
584
1021
|
|
1022
|
+
const HybridGroup* GetHybridGroup(uint16_t group_id){
|
1023
|
+
for (const HybridGroup &g : HybridGroups()) {
|
1024
|
+
if (group_id == g.group_id) {
|
1025
|
+
return &g;
|
1026
|
+
}
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
return NULL;
|
1030
|
+
}
|
1031
|
+
|
585
1032
|
static STACK_OF(SSL_CIPHER) *tls13_ciphers(const SSL_CTX *ctx) {
|
586
1033
|
return ctx->tls13_cipher_list->ciphers.get();
|
587
1034
|
}
|
@@ -1392,6 +1839,9 @@ TEST(SSLTest, CipherProperties) {
|
|
1392
1839
|
EXPECT_EQ(t.digest_nid, SSL_CIPHER_get_digest_nid(cipher));
|
1393
1840
|
EXPECT_EQ(t.kx_nid, SSL_CIPHER_get_kx_nid(cipher));
|
1394
1841
|
EXPECT_EQ(t.auth_nid, SSL_CIPHER_get_auth_nid(cipher));
|
1842
|
+
const EVP_MD *md = SSL_CIPHER_get_handshake_digest(cipher);
|
1843
|
+
ASSERT_TRUE(md);
|
1844
|
+
EXPECT_EQ(t.prf_nid, EVP_MD_nid(md));
|
1395
1845
|
EXPECT_EQ(t.prf_nid, SSL_CIPHER_get_prf_nid(cipher));
|
1396
1846
|
}
|
1397
1847
|
}
|
@@ -2536,10 +2986,7 @@ TEST(SSLTest, ECHPublicName) {
|
|
2536
2986
|
EXPECT_FALSE(ssl_is_valid_ech_public_name(str_to_span("0X01.")));
|
2537
2987
|
}
|
2538
2988
|
|
2539
|
-
//
|
2540
|
-
// applied automatically.
|
2541
|
-
TEST(SSLTest, ECHBuiltinVerifier) {
|
2542
|
-
// These test certificates generated with the following Go program.
|
2989
|
+
// These test certificates generated with the following Go program.
|
2543
2990
|
/* clang-format off
|
2544
2991
|
func main() {
|
2545
2992
|
notBefore := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)
|
@@ -2573,6 +3020,7 @@ func main() {
|
|
2573
3020
|
}
|
2574
3021
|
}
|
2575
3022
|
clang-format on */
|
3023
|
+
static bssl::UniquePtr<X509> GetLeafRoot() {
|
2576
3024
|
bssl::UniquePtr<X509> root = CertFromPEM(R"(
|
2577
3025
|
-----BEGIN CERTIFICATE-----
|
2578
3026
|
MIIBRzCB7aADAgECAgEBMAoGCCqGSM49BAMCMBIxEDAOBgNVBAMTB1Rlc3QgQ0Ew
|
@@ -2584,7 +3032,11 @@ GU5F4zAKBggqhkjOPQQDAgNJADBGAiEAiiNowddQeHZaZFIygwe6RW5/WG4sUXWC
|
|
2584
3032
|
dkyl9CQzRaYCIQCFS1EvwZbZtMny27fYm1eeYciY0TkJTEi34H1KwyzzIA==
|
2585
3033
|
-----END CERTIFICATE-----
|
2586
3034
|
)");
|
2587
|
-
|
3035
|
+
EXPECT_TRUE(root);
|
3036
|
+
return root;
|
3037
|
+
}
|
3038
|
+
|
3039
|
+
static bssl::UniquePtr<EVP_PKEY> GetLeafKey() {
|
2588
3040
|
bssl::UniquePtr<EVP_PKEY> leaf_key = KeyFromPEM(R"(
|
2589
3041
|
-----BEGIN PRIVATE KEY-----
|
2590
3042
|
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgj5WKHwHnziiyPauf
|
@@ -2592,7 +3044,11 @@ MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgj5WKHwHnziiyPauf
|
|
2592
3044
|
hr6PDITHi1lDlJzvVT4aXBH87sH2n2UV5zpx13NHkq1bIC8eRT8eOIe0
|
2593
3045
|
-----END PRIVATE KEY-----
|
2594
3046
|
)");
|
2595
|
-
|
3047
|
+
EXPECT_TRUE(leaf_key);
|
3048
|
+
return leaf_key;
|
3049
|
+
}
|
3050
|
+
|
3051
|
+
static bssl::UniquePtr<X509> GetLeafPublic() {
|
2596
3052
|
bssl::UniquePtr<X509> leaf_public = CertFromPEM(R"(
|
2597
3053
|
-----BEGIN CERTIFICATE-----
|
2598
3054
|
MIIBaDCCAQ6gAwIBAgIBAjAKBggqhkjOPQQDAjASMRAwDgYDVQQDEwdUZXN0IENB
|
@@ -2605,7 +3061,11 @@ AwIDSAAwRQIhANqZRhDR/+QL05hsWXMYEwaiHifd9iakKoFEhKFchcF3AiBRAeXw
|
|
2605
3061
|
wRGGT6+iPmTYM6N5/IDyAb5B9Ke38O6lLEsUwA==
|
2606
3062
|
-----END CERTIFICATE-----
|
2607
3063
|
)");
|
2608
|
-
|
3064
|
+
EXPECT_TRUE(leaf_public);
|
3065
|
+
return leaf_public;
|
3066
|
+
}
|
3067
|
+
|
3068
|
+
static bssl::UniquePtr<X509> GetLeafSecret() {
|
2609
3069
|
bssl::UniquePtr<X509> leaf_secret = CertFromPEM(R"(
|
2610
3070
|
-----BEGIN CERTIFICATE-----
|
2611
3071
|
MIIBaTCCAQ6gAwIBAgIBAzAKBggqhkjOPQQDAjASMRAwDgYDVQQDEwdUZXN0IENB
|
@@ -2618,8 +3078,13 @@ AwIDSQAwRgIhAPQdIz1xCFkc9WuSkxOxJDpywZiEp9SnKcxJ9nwrlRp3AiEA+O3+
|
|
2618
3078
|
XRqE7XFhHL+7TNC2a9OOAjQsEF137YPWo+rhgko=
|
2619
3079
|
-----END CERTIFICATE-----
|
2620
3080
|
)");
|
2621
|
-
|
3081
|
+
EXPECT_TRUE(leaf_secret);
|
3082
|
+
return leaf_secret;
|
3083
|
+
}
|
2622
3084
|
|
3085
|
+
// When using the built-in verifier, test that |SSL_get0_ech_name_override| is
|
3086
|
+
// applied automatically.
|
3087
|
+
TEST(SSLTest, ECHBuiltinVerifier) {
|
2623
3088
|
// Use different config IDs so that fuzzer mode, which breaks trial
|
2624
3089
|
// decryption, will observe the key mismatch.
|
2625
3090
|
bssl::UniquePtr<SSL_ECH_KEYS> keys = MakeTestECHKeys(/*config_id=*/1);
|
@@ -2637,7 +3102,7 @@ XRqE7XFhHL+7TNC2a9OOAjQsEF137YPWo+rhgko=
|
|
2637
3102
|
// BoringSSL will internally override this setting with the public name.
|
2638
3103
|
bssl::UniquePtr<X509_STORE> store(X509_STORE_new());
|
2639
3104
|
ASSERT_TRUE(store);
|
2640
|
-
ASSERT_TRUE(X509_STORE_add_cert(store.get(),
|
3105
|
+
ASSERT_TRUE(X509_STORE_add_cert(store.get(), GetLeafRoot().get()));
|
2641
3106
|
SSL_CTX_set_cert_store(client_ctx.get(), store.release());
|
2642
3107
|
SSL_CTX_set_verify(client_ctx.get(), SSL_VERIFY_PEER, nullptr);
|
2643
3108
|
X509_VERIFY_PARAM_set_flags(SSL_CTX_get0_param(client_ctx.get()),
|
@@ -2664,10 +3129,10 @@ XRqE7XFhHL+7TNC2a9OOAjQsEF137YPWo+rhgko=
|
|
2664
3129
|
ASSERT_TRUE(InstallECHConfigList(client.get(), keys.get()));
|
2665
3130
|
|
2666
3131
|
// Configure the server with the selected certificate.
|
2667
|
-
ASSERT_TRUE(SSL_use_certificate(
|
2668
|
-
|
2669
|
-
|
2670
|
-
ASSERT_TRUE(SSL_use_PrivateKey(server.get(),
|
3132
|
+
ASSERT_TRUE(SSL_use_certificate(
|
3133
|
+
server.get(),
|
3134
|
+
use_leaf_secret ? GetLeafSecret().get() : GetLeafPublic().get()));
|
3135
|
+
ASSERT_TRUE(SSL_use_PrivateKey(server.get(), GetLeafKey().get()));
|
2671
3136
|
|
2672
3137
|
// The handshake may fail due to name mismatch or ECH reject. We check
|
2673
3138
|
// |SSL_get_verify_result| to confirm the handshake got far enough.
|
@@ -4328,6 +4793,37 @@ TEST_P(SSLVersionTest, SSLClearFailsWithShedding) {
|
|
4328
4793
|
ASSERT_FALSE(SSL_clear(server_.get()));
|
4329
4794
|
}
|
4330
4795
|
|
4796
|
+
TEST_P(SSLVersionTest, SSLClientCiphers) {
|
4797
|
+
// Client ciphers ARE NOT SERIALIZED, so skip tests that rely on transfer or
|
4798
|
+
// serialization of |ssl| and accompanying objects under test.
|
4799
|
+
if (GetParam().transfer_ssl) {
|
4800
|
+
return;
|
4801
|
+
}
|
4802
|
+
|
4803
|
+
EXPECT_FALSE(SSL_get_client_ciphers(client_.get()));
|
4804
|
+
EXPECT_FALSE(SSL_get_client_ciphers(server_.get()));
|
4805
|
+
|
4806
|
+
shed_handshake_config_ = false;
|
4807
|
+
ASSERT_TRUE(Connect());
|
4808
|
+
|
4809
|
+
// The client should still have no view of the server's preferences, but the
|
4810
|
+
// server should have seen at least one cipher from the client.
|
4811
|
+
EXPECT_FALSE(SSL_get_client_ciphers(client_.get()));
|
4812
|
+
EXPECT_GT(sk_SSL_CIPHER_num(SSL_get_client_ciphers(server_.get())), (size_t) 0);
|
4813
|
+
|
4814
|
+
// With config shedding disabled, clearing |server| shouldn't error and
|
4815
|
+
// should reset server's client ciphers
|
4816
|
+
ASSERT_TRUE(SSL_clear(server_.get()));
|
4817
|
+
EXPECT_FALSE(SSL_get_client_ciphers(server_.get()));
|
4818
|
+
|
4819
|
+
shed_handshake_config_ = true;
|
4820
|
+
ASSERT_TRUE(Connect());
|
4821
|
+
|
4822
|
+
// These should be unaffected by config shedding
|
4823
|
+
EXPECT_FALSE(SSL_get_client_ciphers(client_.get()));
|
4824
|
+
EXPECT_GT(sk_SSL_CIPHER_num(SSL_get_client_ciphers(server_.get())), (size_t) 0);
|
4825
|
+
}
|
4826
|
+
|
4331
4827
|
static bool ChainsEqual(STACK_OF(X509) *chain,
|
4332
4828
|
const std::vector<X509 *> &expected) {
|
4333
4829
|
if (sk_X509_num(chain) != expected.size()) {
|
@@ -4422,6 +4918,94 @@ static bool ExpectSingleError(int lib, int reason) {
|
|
4422
4918
|
return true;
|
4423
4919
|
}
|
4424
4920
|
|
4921
|
+
TEST(SSLTest, BuildCertChain) {
|
4922
|
+
bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method()));
|
4923
|
+
|
4924
|
+
// No certificate set, so this should fail.
|
4925
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(ctx.get(), 0));
|
4926
|
+
EXPECT_TRUE(ExpectSingleError(ERR_LIB_SSL, SSL_R_NO_CERTIFICATE_SET));
|
4927
|
+
|
4928
|
+
ASSERT_TRUE(SSL_CTX_use_certificate(ctx.get(), GetLeafPublic().get()));
|
4929
|
+
ASSERT_TRUE(SSL_CTX_use_PrivateKey(ctx.get(), GetLeafKey().get()));
|
4930
|
+
|
4931
|
+
// Verification will fail because there is no valid root cert available.
|
4932
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(ctx.get(), 0));
|
4933
|
+
|
4934
|
+
// Should return 2 when |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR| is set.
|
4935
|
+
EXPECT_EQ(
|
4936
|
+
SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR),
|
4937
|
+
2);
|
4938
|
+
EXPECT_TRUE(ExpectSingleError(ERR_LIB_SSL, SSL_R_CERTIFICATE_VERIFY_FAILED));
|
4939
|
+
|
4940
|
+
// Should return 2, but with no error on the stack when
|
4941
|
+
// |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR| and |SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR|
|
4942
|
+
// are set.
|
4943
|
+
EXPECT_EQ(
|
4944
|
+
SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR |
|
4945
|
+
SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR),
|
4946
|
+
2);
|
4947
|
+
EXPECT_FALSE(ERR_get_error());
|
4948
|
+
|
4949
|
+
// Pass in the trust store. |SSL_CTX_build_cert_chain| should succeed now.
|
4950
|
+
ASSERT_TRUE(X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx.get()),
|
4951
|
+
GetLeafRoot().get()));
|
4952
|
+
X509_VERIFY_PARAM_set_flags(SSL_CTX_get0_param(ctx.get()),
|
4953
|
+
X509_V_FLAG_NO_CHECK_TIME);
|
4954
|
+
EXPECT_EQ(SSL_CTX_build_cert_chain(ctx.get(), 0), 1);
|
4955
|
+
STACK_OF(X509) *chain;
|
4956
|
+
ASSERT_TRUE(SSL_CTX_get0_chain_certs(ctx.get(), &chain));
|
4957
|
+
EXPECT_TRUE(ChainsEqual(chain, {GetLeafRoot().get()}));
|
4958
|
+
|
4959
|
+
// Root cert is self-signed, so |SSL_BUILD_CHAIN_FLAG_UNTRUSTED| will
|
4960
|
+
// still pass.
|
4961
|
+
ASSERT_TRUE(SSL_CTX_clear_chain_certs(ctx.get()));
|
4962
|
+
EXPECT_TRUE(
|
4963
|
+
SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_UNTRUSTED));
|
4964
|
+
ASSERT_TRUE(SSL_CTX_get0_chain_certs(ctx.get(), &chain));
|
4965
|
+
EXPECT_TRUE(ChainsEqual(chain, {GetLeafRoot().get()}));
|
4966
|
+
|
4967
|
+
// |SSL_BUILD_CHAIN_FLAG_CHECK| uses the already built cert chain as the trust
|
4968
|
+
// store and verifies against it. If we clear the cert chain, there should be
|
4969
|
+
// no trust store to compare against if |SSL_BUILD_CHAIN_FLAG_CHECK| is still
|
4970
|
+
// set.
|
4971
|
+
EXPECT_EQ(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK), 1);
|
4972
|
+
ASSERT_TRUE(SSL_CTX_clear_chain_certs(ctx.get()));
|
4973
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK));
|
4974
|
+
EXPECT_TRUE(ExpectSingleError(ERR_LIB_SSL, SSL_R_CERTIFICATE_VERIFY_FAILED));
|
4975
|
+
|
4976
|
+
// |SSL_BUILD_CHAIN_FLAG_CHECK| and |SSL_BUILD_CHAIN_FLAG_UNTRUSTED| are
|
4977
|
+
// mutually exclusive, with |SSL_BUILD_CHAIN_FLAG_CHECK| taking priority.
|
4978
|
+
// The result with both set should be the same as only
|
4979
|
+
// |SSL_BUILD_CHAIN_FLAG_CHECK| being set.
|
4980
|
+
ASSERT_TRUE(SSL_CTX_clear_chain_certs(ctx.get()));
|
4981
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(
|
4982
|
+
ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK | SSL_BUILD_CHAIN_FLAG_UNTRUSTED));
|
4983
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK));
|
4984
|
+
// First call with |SSL_BUILD_CHAIN_FLAG_CHECK| existing will fail, second
|
4985
|
+
// call with |SSL_BUILD_CHAIN_FLAG_UNTRUSTED| will succeed.
|
4986
|
+
EXPECT_FALSE(SSL_CTX_build_cert_chain(
|
4987
|
+
ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK | SSL_BUILD_CHAIN_FLAG_UNTRUSTED));
|
4988
|
+
EXPECT_EQ(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_UNTRUSTED),
|
4989
|
+
1);
|
4990
|
+
// |SSL_BUILD_CHAIN_FLAG_CHECK| will succeed since we have a built chain now.
|
4991
|
+
EXPECT_EQ(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_CHECK), 1);
|
4992
|
+
|
4993
|
+
// Test that successful verification with |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR|
|
4994
|
+
// does not return 2.
|
4995
|
+
ASSERT_TRUE(SSL_CTX_clear_chain_certs(ctx.get()));
|
4996
|
+
EXPECT_EQ(
|
4997
|
+
SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR),
|
4998
|
+
1);
|
4999
|
+
|
5000
|
+
// Test that successful verification with |SSL_BUILD_CHAIN_FLAG_NO_ROOT|
|
5001
|
+
// does include the root cert.
|
5002
|
+
ASSERT_TRUE(SSL_CTX_clear_chain_certs(ctx.get()));
|
5003
|
+
EXPECT_EQ(SSL_CTX_build_cert_chain(ctx.get(), SSL_BUILD_CHAIN_FLAG_NO_ROOT),
|
5004
|
+
1);
|
5005
|
+
ASSERT_TRUE(SSL_CTX_get0_chain_certs(ctx.get(), &chain));
|
5006
|
+
EXPECT_TRUE(ChainsEqual(chain, {}));
|
5007
|
+
}
|
5008
|
+
|
4425
5009
|
TEST_P(SSLVersionTest, SSLWriteRetry) {
|
4426
5010
|
if (is_dtls()) {
|
4427
5011
|
return;
|
@@ -7730,6 +8314,9 @@ TEST_F(QUICMethodTest, ZeroRTTAccept) {
|
|
7730
8314
|
ASSERT_TRUE(CreateClientAndServer());
|
7731
8315
|
SSL_set_session(client_.get(), session.get());
|
7732
8316
|
|
8317
|
+
EXPECT_FALSE(SSL_get_client_ciphers(client_.get()));
|
8318
|
+
EXPECT_FALSE(SSL_get_client_ciphers(server_.get()));
|
8319
|
+
|
7733
8320
|
// The client handshake should return immediately into the early data state.
|
7734
8321
|
ASSERT_EQ(SSL_do_handshake(client_.get()), 1);
|
7735
8322
|
EXPECT_TRUE(SSL_in_early_data(client_.get()));
|
@@ -7746,6 +8333,10 @@ TEST_F(QUICMethodTest, ZeroRTTAccept) {
|
|
7746
8333
|
// 1-RTT read keys until client Finished.
|
7747
8334
|
EXPECT_TRUE(transport_->server()->HasWriteSecret(ssl_encryption_application));
|
7748
8335
|
EXPECT_FALSE(transport_->server()->HasReadSecret(ssl_encryption_application));
|
8336
|
+
// The client should still have no view of the server's preferences, but the
|
8337
|
+
// server should have seen at least one cipher from the client.
|
8338
|
+
EXPECT_FALSE(SSL_get_client_ciphers(client_.get()));
|
8339
|
+
EXPECT_GT(sk_SSL_CIPHER_num(SSL_get_client_ciphers(server_.get())), (size_t) 0);
|
7749
8340
|
|
7750
8341
|
// Finish up the client and server handshakes.
|
7751
8342
|
ASSERT_TRUE(CompleteHandshakesForQUIC());
|
@@ -9930,6 +10521,154 @@ TEST(SSLTest, NameLists) {
|
|
9930
10521
|
}
|
9931
10522
|
}
|
9932
10523
|
|
10524
|
+
class KemKeyShareTest : public testing::TestWithParam<GroupTest> {};
|
10525
|
+
|
10526
|
+
INSTANTIATE_TEST_SUITE_P(KemKeyShareTests, KemKeyShareTest, testing::ValuesIn(kKemGroupTests));
|
10527
|
+
|
10528
|
+
// Test a successful round-trip for KemKeyShare
|
10529
|
+
TEST_P(KemKeyShareTest, KemKeyShares) {
|
10530
|
+
GroupTest t = GetParam();
|
10531
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10532
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10533
|
+
ASSERT_TRUE(client_key_share);
|
10534
|
+
ASSERT_TRUE(server_key_share);
|
10535
|
+
EXPECT_EQ(t.group_id, client_key_share->GroupID());
|
10536
|
+
EXPECT_EQ(t.group_id, server_key_share->GroupID());
|
10537
|
+
|
10538
|
+
// The client generates its key pair and outputs the public key.
|
10539
|
+
// We initialize the CBB with a capacity of 2 as a sanity check to
|
10540
|
+
// ensure that the CBB will grow accordingly if necessary.
|
10541
|
+
CBB client_out_public_key;
|
10542
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 2));
|
10543
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10544
|
+
EXPECT_EQ(CBB_len(&client_out_public_key), t.offer_key_share_size);
|
10545
|
+
|
10546
|
+
// The server accepts the public key, generates the shared secret,
|
10547
|
+
// and outputs the ciphertext. Again, we initialize the CBB with
|
10548
|
+
// a capacity of 2 to ensure it will grow accordingly.
|
10549
|
+
CBB server_out_public_key;
|
10550
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 2));
|
10551
|
+
uint8_t server_alert = 0;
|
10552
|
+
Array<uint8_t> server_secret;
|
10553
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
10554
|
+
ASSERT_TRUE(client_out_public_key_data);
|
10555
|
+
Span<const uint8_t> client_public_key =
|
10556
|
+
MakeConstSpan(client_out_public_key_data, CBB_len(&client_out_public_key));
|
10557
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key, &server_secret,
|
10558
|
+
&server_alert, client_public_key));
|
10559
|
+
EXPECT_EQ(CBB_len(&server_out_public_key), t.accept_key_share_size);
|
10560
|
+
EXPECT_EQ(server_secret.size(), t.shared_secret_size);
|
10561
|
+
EXPECT_EQ(server_alert, 0);
|
10562
|
+
|
10563
|
+
// The client accepts the ciphertext and decrypts it to obtain
|
10564
|
+
// the shared secret.
|
10565
|
+
uint8_t client_alert = 0;
|
10566
|
+
Array<uint8_t> client_secret;
|
10567
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
10568
|
+
ASSERT_TRUE(server_out_public_key_data);
|
10569
|
+
Span<const uint8_t> server_public_key =
|
10570
|
+
MakeConstSpan(server_out_public_key_data, CBB_len(&server_out_public_key));
|
10571
|
+
EXPECT_TRUE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
10572
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
10573
|
+
EXPECT_EQ(client_alert, 0);
|
10574
|
+
|
10575
|
+
// Verify that client and server arrived at the same shared secret.
|
10576
|
+
EXPECT_EQ(Bytes(client_secret), Bytes(server_secret));
|
10577
|
+
|
10578
|
+
CBB_cleanup(&client_out_public_key);
|
10579
|
+
CBB_cleanup(&server_out_public_key);
|
10580
|
+
}
|
10581
|
+
|
10582
|
+
class BadKemKeyShareOfferTest : public testing::TestWithParam<GroupTest> {};
|
10583
|
+
INSTANTIATE_TEST_SUITE_P(BadKemKeyShareOfferTests, BadKemKeyShareOfferTest, testing::ValuesIn(kKemGroupTests));
|
10584
|
+
|
10585
|
+
// Test failure cases for KEMKeyShare::Offer()
|
10586
|
+
TEST_P(BadKemKeyShareOfferTest, BadKemKeyShareOffers) {
|
10587
|
+
GroupTest t = GetParam();
|
10588
|
+
// Basic nullptr checks
|
10589
|
+
{
|
10590
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10591
|
+
ASSERT_TRUE(client_key_share);
|
10592
|
+
|
10593
|
+
ASSERT_FALSE(client_key_share->Offer(nullptr));
|
10594
|
+
}
|
10595
|
+
|
10596
|
+
// Offer() should fail if |client_out_public_key| has children
|
10597
|
+
{
|
10598
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10599
|
+
ASSERT_TRUE(client_key_share);
|
10600
|
+
CBB client_out_public_key;
|
10601
|
+
CBB child;
|
10602
|
+
|
10603
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 2));
|
10604
|
+
client_out_public_key.child = &child;
|
10605
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
10606
|
+
CBB_cleanup(&client_out_public_key);
|
10607
|
+
}
|
10608
|
+
|
10609
|
+
// Offer() should succeed on the first call, but fail on all repeated calls
|
10610
|
+
{
|
10611
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10612
|
+
ASSERT_TRUE(client_key_share);
|
10613
|
+
CBB client_out_public_key;
|
10614
|
+
|
10615
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 2));
|
10616
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10617
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
10618
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
10619
|
+
CBB_cleanup(&client_out_public_key);
|
10620
|
+
}
|
10621
|
+
|
10622
|
+
// Offer() should fail if Accept() was previously called
|
10623
|
+
{
|
10624
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10625
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10626
|
+
ASSERT_TRUE(client_key_share);
|
10627
|
+
ASSERT_TRUE(server_key_share);
|
10628
|
+
uint8_t server_alert = 0;
|
10629
|
+
Array<uint8_t> server_secret;
|
10630
|
+
CBB client_out_public_key;
|
10631
|
+
CBB server_out_public_key;
|
10632
|
+
CBB server_offer_out;
|
10633
|
+
|
10634
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, t.offer_key_share_size));
|
10635
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10636
|
+
EXPECT_TRUE(CBB_init(&server_offer_out, t.offer_key_share_size));
|
10637
|
+
|
10638
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10639
|
+
const uint8_t *client_public_key_data = CBB_data(&client_out_public_key);
|
10640
|
+
Span<const uint8_t> client_public_key =
|
10641
|
+
MakeConstSpan(client_public_key_data, CBB_len(&client_out_public_key));
|
10642
|
+
|
10643
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key, &server_secret, &server_alert, client_public_key));
|
10644
|
+
EXPECT_EQ(server_alert, 0);
|
10645
|
+
|
10646
|
+
EXPECT_FALSE(server_key_share->Offer(&server_offer_out));
|
10647
|
+
|
10648
|
+
CBB_cleanup(&client_out_public_key);
|
10649
|
+
CBB_cleanup(&server_out_public_key);
|
10650
|
+
CBB_cleanup(&server_offer_out);
|
10651
|
+
}
|
10652
|
+
|
10653
|
+
// |client_out_public_key| is properly initialized, some zeros are written
|
10654
|
+
// to it so that it records a non-zero length, then its buffer is
|
10655
|
+
// invalidated.
|
10656
|
+
{
|
10657
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10658
|
+
ASSERT_TRUE(client_key_share);
|
10659
|
+
CBB client_out_public_key;
|
10660
|
+
CBB_init(&client_out_public_key, t.offer_key_share_size);
|
10661
|
+
EXPECT_TRUE(CBB_add_zeros(&client_out_public_key, 2));
|
10662
|
+
// Keep a pointer to the buffer so we can cleanup correctly
|
10663
|
+
uint8_t *buf = client_out_public_key.u.base.buf;
|
10664
|
+
client_out_public_key.u.base.buf = nullptr;
|
10665
|
+
EXPECT_EQ(CBB_len(&client_out_public_key), (size_t) 2);
|
10666
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
10667
|
+
client_out_public_key.u.base.buf = buf;
|
10668
|
+
CBB_cleanup(&client_out_public_key);
|
10669
|
+
}
|
10670
|
+
}
|
10671
|
+
|
9933
10672
|
TEST(SSLTest, SessionPrint) {
|
9934
10673
|
static const std::array<std::string, 15> kExpectedTLS13{
|
9935
10674
|
{"SSL-Session:", " Protocol :", " Cipher : ",
|
@@ -9977,5 +10716,1099 @@ TEST(SSLTest, SessionPrint) {
|
|
9977
10716
|
}
|
9978
10717
|
}
|
9979
10718
|
|
10719
|
+
class BadKemKeyShareAcceptTest : public testing::TestWithParam<GroupTest> {};
|
10720
|
+
INSTANTIATE_TEST_SUITE_P(BadKemKeyShareAcceptTests, BadKemKeyShareAcceptTest, testing::ValuesIn(kKemGroupTests));
|
10721
|
+
|
10722
|
+
// Test failure cases for KEMKeyShare::Accept()
|
10723
|
+
TEST_P(BadKemKeyShareAcceptTest, BadKemKeyShareAccept) {
|
10724
|
+
GroupTest t = GetParam();
|
10725
|
+
// Basic nullptr checks
|
10726
|
+
{
|
10727
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10728
|
+
ASSERT_TRUE(server_key_share);
|
10729
|
+
uint8_t server_alert = 0;
|
10730
|
+
Array<uint8_t> server_secret;
|
10731
|
+
Span<const uint8_t> client_public_key;
|
10732
|
+
CBB server_out_public_key;
|
10733
|
+
|
10734
|
+
EXPECT_FALSE(server_key_share->Accept(nullptr, &server_secret,
|
10735
|
+
&server_alert, client_public_key));
|
10736
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
10737
|
+
server_alert = 0;
|
10738
|
+
|
10739
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key, nullptr,
|
10740
|
+
&server_alert, client_public_key));
|
10741
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
10742
|
+
server_alert = 0;
|
10743
|
+
|
10744
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10745
|
+
&server_secret, nullptr,
|
10746
|
+
client_public_key));
|
10747
|
+
}
|
10748
|
+
|
10749
|
+
// |server_out_public_key| is properly initialized, then is assigned a child
|
10750
|
+
{
|
10751
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10752
|
+
ASSERT_TRUE(server_key_share);
|
10753
|
+
uint8_t server_alert = 0;
|
10754
|
+
Array<uint8_t> server_secret;
|
10755
|
+
Span<const uint8_t> client_public_key;
|
10756
|
+
CBB server_out_public_key;
|
10757
|
+
CBB child;
|
10758
|
+
|
10759
|
+
CBB_init(&server_out_public_key, t.accept_key_share_size);
|
10760
|
+
server_out_public_key.child = &child;
|
10761
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10762
|
+
&server_secret, &server_alert,
|
10763
|
+
client_public_key));
|
10764
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
10765
|
+
CBB_cleanup(&server_out_public_key);
|
10766
|
+
}
|
10767
|
+
|
10768
|
+
// |server_out_public_key| is properly initialized with CBB_init,
|
10769
|
+
// some zeros are written to it so that it records a non-zero length,
|
10770
|
+
// then its buffer is invalidated.
|
10771
|
+
{
|
10772
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10773
|
+
ASSERT_TRUE(server_key_share);
|
10774
|
+
uint8_t server_alert = 0;
|
10775
|
+
Array<uint8_t> server_secret;
|
10776
|
+
Span<const uint8_t> client_public_key;
|
10777
|
+
CBB server_out_public_key;
|
10778
|
+
|
10779
|
+
CBB_init(&server_out_public_key, t.accept_key_share_size);
|
10780
|
+
EXPECT_TRUE(CBB_add_zeros(&server_out_public_key, 2));
|
10781
|
+
// Keep a pointer to the buffer so we can cleanup correctly
|
10782
|
+
uint8_t *buf = server_out_public_key.u.base.buf;
|
10783
|
+
server_out_public_key.u.base.buf = nullptr;
|
10784
|
+
EXPECT_EQ(CBB_len(&server_out_public_key), (size_t) 2);
|
10785
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10786
|
+
&server_secret, &server_alert,
|
10787
|
+
client_public_key));
|
10788
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
10789
|
+
server_out_public_key.u.base.buf = buf;
|
10790
|
+
CBB_cleanup(&server_out_public_key);
|
10791
|
+
}
|
10792
|
+
|
10793
|
+
// KemKeyShare::Accept() should fail if KemKeyShare::Offer() has been
|
10794
|
+
// previously called by that peer. The server should have no reason to
|
10795
|
+
// call Offer(); enforcing this case will guard against that type of bug.
|
10796
|
+
{
|
10797
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10798
|
+
ASSERT_TRUE(server_key_share);
|
10799
|
+
uint8_t server_alert = 0;
|
10800
|
+
Array<uint8_t> server_secret;
|
10801
|
+
CBB server_out_public_key;
|
10802
|
+
CBB server_offer_out;
|
10803
|
+
|
10804
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10805
|
+
EXPECT_TRUE(CBB_init(&server_offer_out, t.offer_key_share_size));
|
10806
|
+
EXPECT_TRUE(server_key_share->Offer(&server_offer_out));
|
10807
|
+
const uint8_t *server_offer_out_data = CBB_data(&server_offer_out);
|
10808
|
+
ASSERT_TRUE(server_offer_out_data);
|
10809
|
+
Span<const uint8_t> server_offered_pk =
|
10810
|
+
MakeConstSpan(server_offer_out_data, CBB_len(&server_offer_out));
|
10811
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10812
|
+
&server_secret, &server_alert,
|
10813
|
+
server_offered_pk));
|
10814
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
10815
|
+
CBB_cleanup(&server_out_public_key);
|
10816
|
+
CBB_cleanup(&server_offer_out);
|
10817
|
+
}
|
10818
|
+
|
10819
|
+
// |client_public_key| is initialized with too little data
|
10820
|
+
{
|
10821
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10822
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10823
|
+
ASSERT_TRUE(server_key_share);
|
10824
|
+
ASSERT_TRUE(client_key_share);
|
10825
|
+
Span<const uint8_t> client_public_key;
|
10826
|
+
Array<uint8_t> server_secret;
|
10827
|
+
CBB server_out_public_key;
|
10828
|
+
CBB client_out_public_key;
|
10829
|
+
uint8_t server_alert = 0;
|
10830
|
+
|
10831
|
+
// Generate a valid |client_public_key|, then truncate the last byte
|
10832
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
10833
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10834
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
10835
|
+
ASSERT_TRUE(client_out_public_key_data);
|
10836
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
10837
|
+
CBB_len(&client_out_public_key) - 1);
|
10838
|
+
|
10839
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10840
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10841
|
+
&server_secret, &server_alert,
|
10842
|
+
client_public_key));
|
10843
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
10844
|
+
CBB_cleanup(&server_out_public_key);
|
10845
|
+
CBB_cleanup(&client_out_public_key);
|
10846
|
+
}
|
10847
|
+
|
10848
|
+
// |client_public_key| is initialized with too much data
|
10849
|
+
{
|
10850
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10851
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10852
|
+
ASSERT_TRUE(server_key_share);
|
10853
|
+
ASSERT_TRUE(client_key_share);
|
10854
|
+
Span<const uint8_t> client_public_key;
|
10855
|
+
Array<uint8_t> server_secret;
|
10856
|
+
CBB server_out_public_key;
|
10857
|
+
CBB client_out_public_key;
|
10858
|
+
uint8_t server_alert = 0;
|
10859
|
+
|
10860
|
+
// Generate a valid |client_public_key|, then append a byte
|
10861
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
10862
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10863
|
+
EXPECT_TRUE(CBB_add_zeros(&client_out_public_key, 1));
|
10864
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
10865
|
+
ASSERT_TRUE(client_out_public_key_data);
|
10866
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
10867
|
+
CBB_len(&client_out_public_key));
|
10868
|
+
|
10869
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10870
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10871
|
+
&server_secret, &server_alert,
|
10872
|
+
client_public_key));
|
10873
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
10874
|
+
CBB_cleanup(&server_out_public_key);
|
10875
|
+
CBB_cleanup(&client_out_public_key);
|
10876
|
+
}
|
10877
|
+
|
10878
|
+
// |client_public_key| has been initialized but is empty
|
10879
|
+
{
|
10880
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10881
|
+
ASSERT_TRUE(server_key_share);
|
10882
|
+
uint8_t server_alert = 0;
|
10883
|
+
Array<uint8_t> server_secret;
|
10884
|
+
CBB server_out_public_key;
|
10885
|
+
|
10886
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10887
|
+
const uint8_t empty_client_public_key_buf[] = {0};
|
10888
|
+
Span<const uint8_t> client_public_key =
|
10889
|
+
MakeConstSpan(empty_client_public_key_buf, 0);
|
10890
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
10891
|
+
&server_secret, &server_alert,
|
10892
|
+
client_public_key));
|
10893
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
10894
|
+
CBB_cleanup(&server_out_public_key);
|
10895
|
+
}
|
10896
|
+
|
10897
|
+
// |client_public_key| is initialized with key material that is the correct
|
10898
|
+
// length, but is not a valid key. In this case, the basic sanity checks
|
10899
|
+
// will not reject the key because it has been initialized properly with
|
10900
|
+
// the correct amount of data. The KEM encapsulate function is written
|
10901
|
+
// so that it will return success if given an invalid key of the correct
|
10902
|
+
// length. Therefore, the call to server_key_share->Accept() will succeed,
|
10903
|
+
// but ultimately, the ciphertext (server's public key) will be garbage,
|
10904
|
+
// the server and client will end up with different secrets, and the
|
10905
|
+
// overall handshake will eventually fail.
|
10906
|
+
{
|
10907
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10908
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10909
|
+
ASSERT_TRUE(server_key_share);
|
10910
|
+
ASSERT_TRUE(client_key_share);
|
10911
|
+
uint8_t server_alert = 0;
|
10912
|
+
uint8_t client_alert = 0;
|
10913
|
+
Array<uint8_t> server_secret;
|
10914
|
+
Array<uint8_t> client_secret;
|
10915
|
+
CBB server_out_public_key;
|
10916
|
+
CBB client_out_public_key;
|
10917
|
+
|
10918
|
+
// Start by having the client Offer() its public key
|
10919
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, t.offer_key_share_size));
|
10920
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
10921
|
+
|
10922
|
+
// Then invalidate it by negating the bits in the first byte
|
10923
|
+
uint8_t *invalid_client_public_key_buf =
|
10924
|
+
(uint8_t *)OPENSSL_malloc(t.offer_key_share_size);
|
10925
|
+
ASSERT_TRUE(invalid_client_public_key_buf);
|
10926
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
10927
|
+
ASSERT_TRUE(client_out_public_key_data);
|
10928
|
+
OPENSSL_memcpy(invalid_client_public_key_buf, client_out_public_key_data,
|
10929
|
+
t.offer_key_share_size);
|
10930
|
+
invalid_client_public_key_buf[0] = ~invalid_client_public_key_buf[0];
|
10931
|
+
Span<const uint8_t> client_public_key =
|
10932
|
+
MakeConstSpan(invalid_client_public_key_buf, t.offer_key_share_size);
|
10933
|
+
|
10934
|
+
// When the server calls Accept() with the invalid public key, it will
|
10935
|
+
// return success
|
10936
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
10937
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key,
|
10938
|
+
&server_secret, &server_alert,
|
10939
|
+
client_public_key));
|
10940
|
+
|
10941
|
+
// And when the client calls Finish(), it will also return success
|
10942
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
10943
|
+
ASSERT_TRUE(server_out_public_key_data);
|
10944
|
+
Span<const uint8_t> server_public_key =
|
10945
|
+
MakeConstSpan(server_out_public_key_data, CBB_len(&server_out_public_key));
|
10946
|
+
EXPECT_TRUE(client_key_share->Finish(&client_secret, &client_alert,
|
10947
|
+
server_public_key));
|
10948
|
+
|
10949
|
+
// The shared secrets are of the correct length...
|
10950
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
10951
|
+
EXPECT_EQ(server_secret.size(), t.shared_secret_size);
|
10952
|
+
|
10953
|
+
// ... but they are not equal
|
10954
|
+
EXPECT_NE(Bytes(client_secret), Bytes(server_secret));
|
10955
|
+
|
10956
|
+
EXPECT_EQ(server_alert, 0);
|
10957
|
+
EXPECT_EQ(client_alert, 0);
|
10958
|
+
OPENSSL_free(invalid_client_public_key_buf);
|
10959
|
+
CBB_cleanup(&server_out_public_key);
|
10960
|
+
CBB_cleanup(&client_out_public_key);
|
10961
|
+
}
|
10962
|
+
}
|
10963
|
+
|
10964
|
+
class BadKemKeyShareFinishTest : public testing::TestWithParam<GroupTest> {};
|
10965
|
+
INSTANTIATE_TEST_SUITE_P(BadKemKeyShareFinishTests, BadKemKeyShareFinishTest, testing::ValuesIn(kKemGroupTests));
|
10966
|
+
|
10967
|
+
TEST_P(BadKemKeyShareFinishTest, BadKemKeyShareFinish) {
|
10968
|
+
GroupTest t = GetParam();
|
10969
|
+
|
10970
|
+
// Basic nullptr checks
|
10971
|
+
{
|
10972
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10973
|
+
ASSERT_TRUE(client_key_share);
|
10974
|
+
Span<const uint8_t> server_public_key;
|
10975
|
+
Array<uint8_t> client_secret;
|
10976
|
+
uint8_t client_alert = 0;
|
10977
|
+
|
10978
|
+
EXPECT_FALSE(client_key_share->Finish(nullptr, &client_alert,
|
10979
|
+
server_public_key));
|
10980
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
10981
|
+
client_alert = 0;
|
10982
|
+
|
10983
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, nullptr,
|
10984
|
+
server_public_key));
|
10985
|
+
}
|
10986
|
+
|
10987
|
+
// A call to Finish() should fail if Offer() was not called previously
|
10988
|
+
{
|
10989
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
10990
|
+
ASSERT_TRUE(client_key_share);
|
10991
|
+
Span<const uint8_t> server_public_key;
|
10992
|
+
Array<uint8_t> client_secret;
|
10993
|
+
uint8_t client_alert = 0;
|
10994
|
+
|
10995
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert,
|
10996
|
+
server_public_key));
|
10997
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
10998
|
+
}
|
10999
|
+
|
11000
|
+
// Set up the client and server states for the remaining tests
|
11001
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
11002
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
11003
|
+
ASSERT_TRUE(server_key_share);
|
11004
|
+
ASSERT_TRUE(client_key_share);
|
11005
|
+
CBB client_out_public_key;
|
11006
|
+
CBB server_out_public_key;
|
11007
|
+
Array<uint8_t> server_secret;
|
11008
|
+
Array<uint8_t> client_secret;
|
11009
|
+
uint8_t client_alert = 0;
|
11010
|
+
uint8_t server_alert = 0;
|
11011
|
+
Span<const uint8_t> client_public_key;
|
11012
|
+
Span<const uint8_t> server_public_key;
|
11013
|
+
|
11014
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, t.offer_key_share_size));
|
11015
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, t.accept_key_share_size));
|
11016
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11017
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11018
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11019
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
11020
|
+
CBB_len(&client_out_public_key));
|
11021
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key, &server_secret,
|
11022
|
+
&server_alert, client_public_key));
|
11023
|
+
EXPECT_EQ(server_alert, 0);
|
11024
|
+
|
11025
|
+
// |server_public_key| has been initialized with too little data. Here, we
|
11026
|
+
// initialize |server_public_key| with a fragment of an otherwise valid
|
11027
|
+
// key. However, it doesn't matter if it is a fragment of a valid key, or
|
11028
|
+
// complete garbage, the client will reject it all the same.
|
11029
|
+
{
|
11030
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11031
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11032
|
+
server_public_key = MakeConstSpan(server_out_public_key_data, t.accept_key_share_size - 1);
|
11033
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11034
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
11035
|
+
client_alert = 0;
|
11036
|
+
}
|
11037
|
+
|
11038
|
+
// |server_public_key| has been initialized with too much data. Here, we
|
11039
|
+
// initialize |server_public_key| with a valid public key, and over-read
|
11040
|
+
// the buffer to append a random byte. However, it doesn't matter if it is a
|
11041
|
+
// valid key with nonsense appended, or complete garbage, the client will
|
11042
|
+
// reject it all the same.
|
11043
|
+
{
|
11044
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11045
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11046
|
+
server_public_key = MakeConstSpan(server_out_public_key_data, t.accept_key_share_size + 1);
|
11047
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11048
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
11049
|
+
client_alert = 0;
|
11050
|
+
}
|
11051
|
+
|
11052
|
+
// |server_public_key| is initialized with an invalid key of the correct
|
11053
|
+
// length. The decapsulation operations will succeed; however, the resulting
|
11054
|
+
// shared secret will be garbage, and eventually the overall handshake
|
11055
|
+
// would fail because the client secret does not match the server secret.
|
11056
|
+
{
|
11057
|
+
// The server's public key was already correctly generated previously in
|
11058
|
+
// a call to Accept(). Here we invalidate it by negating the first byte.
|
11059
|
+
uint8_t *invalid_server_public_key_buf = (uint8_t *) OPENSSL_malloc(t.accept_key_share_size);
|
11060
|
+
ASSERT_TRUE(invalid_server_public_key_buf);
|
11061
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11062
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11063
|
+
OPENSSL_memcpy(invalid_server_public_key_buf, server_out_public_key_data, t.accept_key_share_size);
|
11064
|
+
invalid_server_public_key_buf[0] = ~invalid_server_public_key_buf[0];
|
11065
|
+
|
11066
|
+
// The call to Finish() will return success
|
11067
|
+
server_public_key =
|
11068
|
+
MakeConstSpan(invalid_server_public_key_buf, t.accept_key_share_size);
|
11069
|
+
EXPECT_TRUE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11070
|
+
EXPECT_EQ(client_alert, 0);
|
11071
|
+
|
11072
|
+
// The shared secrets are of the correct length...
|
11073
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
11074
|
+
EXPECT_EQ(server_secret.size(), t.shared_secret_size);
|
11075
|
+
|
11076
|
+
// ... but they are not equal
|
11077
|
+
EXPECT_NE(Bytes(client_secret), Bytes(server_secret));
|
11078
|
+
|
11079
|
+
|
11080
|
+
OPENSSL_free(invalid_server_public_key_buf);
|
11081
|
+
}
|
11082
|
+
|
11083
|
+
CBB_cleanup(&server_out_public_key);
|
11084
|
+
CBB_cleanup(&client_out_public_key);
|
11085
|
+
}
|
11086
|
+
|
11087
|
+
class HybridKeyShareTest : public testing::TestWithParam<HybridGroupTest> {};
|
11088
|
+
INSTANTIATE_TEST_SUITE_P(HybridKeyShareTests, HybridKeyShareTest, testing::ValuesIn(kHybridGroupTests));
|
11089
|
+
|
11090
|
+
// Test a successful round-trip for HybridKeyShare
|
11091
|
+
TEST_P(HybridKeyShareTest, HybridKeyShares) {
|
11092
|
+
HybridGroupTest t = GetParam();
|
11093
|
+
|
11094
|
+
// Set up client and server with test case parameters
|
11095
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11096
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11097
|
+
ASSERT_TRUE(client_key_share);
|
11098
|
+
ASSERT_TRUE(server_key_share);
|
11099
|
+
EXPECT_EQ(t.group_id, client_key_share->GroupID());
|
11100
|
+
EXPECT_EQ(t.group_id, server_key_share->GroupID());
|
11101
|
+
|
11102
|
+
// The client generates its key pair and outputs the public key.
|
11103
|
+
// We initialize the CBB with a capacity of 2 as a simple sanity check
|
11104
|
+
// to ensure that the CBB will grow accordingly when necessary.
|
11105
|
+
CBB client_out_public_key;
|
11106
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 2));
|
11107
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11108
|
+
EXPECT_EQ(CBB_len(&client_out_public_key), t.offer_key_share_size);
|
11109
|
+
|
11110
|
+
// The server accepts the public key, generates the shared secret,
|
11111
|
+
// and outputs the ciphertext. Again, we initialize the CBB with
|
11112
|
+
// a capacity of 2 to ensure it will grow accordingly.
|
11113
|
+
CBB server_out_public_key;
|
11114
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 2));
|
11115
|
+
uint8_t server_alert = 0;
|
11116
|
+
Array<uint8_t> server_secret;
|
11117
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11118
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11119
|
+
Span<const uint8_t> client_public_key =
|
11120
|
+
MakeConstSpan(client_out_public_key_data, CBB_len(&client_out_public_key));
|
11121
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key, &server_secret,
|
11122
|
+
&server_alert, client_public_key));
|
11123
|
+
EXPECT_EQ(CBB_len(&server_out_public_key), t.accept_key_share_size);
|
11124
|
+
EXPECT_EQ(server_alert, 0);
|
11125
|
+
|
11126
|
+
// The client accepts the server's public key and decrypts it to obtain
|
11127
|
+
// the shared secret.
|
11128
|
+
uint8_t client_alert = 0;
|
11129
|
+
Array<uint8_t> client_secret;
|
11130
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11131
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11132
|
+
Span<const uint8_t> server_public_key = MakeConstSpan(
|
11133
|
+
server_out_public_key_data, CBB_len(&server_out_public_key));
|
11134
|
+
EXPECT_TRUE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11135
|
+
EXPECT_EQ(client_alert, 0);
|
11136
|
+
|
11137
|
+
// Verify that client and server arrived at the same shared secret.
|
11138
|
+
EXPECT_EQ(server_secret.size(), t.shared_secret_size);
|
11139
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
11140
|
+
EXPECT_EQ(Bytes(client_secret), Bytes(server_secret));
|
11141
|
+
|
11142
|
+
CBB_cleanup(&client_out_public_key);
|
11143
|
+
CBB_cleanup(&server_out_public_key);
|
11144
|
+
|
11145
|
+
}
|
11146
|
+
|
11147
|
+
class BadHybridKeyShareOfferTest : public testing::TestWithParam<HybridGroupTest> {};
|
11148
|
+
INSTANTIATE_TEST_SUITE_P(BadHybridKeyShareOfferTests, BadHybridKeyShareOfferTest, testing::ValuesIn(kHybridGroupTests));
|
11149
|
+
|
11150
|
+
// Test failure cases for HybridKeyShare::Offer()
|
11151
|
+
TEST_P(BadHybridKeyShareOfferTest, BadHybridKeyShareOffers) {
|
11152
|
+
HybridGroupTest t = GetParam();
|
11153
|
+
// Basic nullptr check
|
11154
|
+
{
|
11155
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11156
|
+
ASSERT_TRUE(client_key_share);
|
11157
|
+
|
11158
|
+
ASSERT_FALSE(client_key_share->Offer(nullptr));
|
11159
|
+
}
|
11160
|
+
|
11161
|
+
// Offer() should fail if |client_out| has not been initialized at all.
|
11162
|
+
{
|
11163
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11164
|
+
ASSERT_TRUE(client_key_share);
|
11165
|
+
CBB client_out_public_key;
|
11166
|
+
CBB_zero(&client_out_public_key);
|
11167
|
+
|
11168
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
11169
|
+
}
|
11170
|
+
|
11171
|
+
// Offer() should fail if the CBB has children
|
11172
|
+
{
|
11173
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11174
|
+
ASSERT_TRUE(client_key_share);
|
11175
|
+
CBB client_out_public_key;
|
11176
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11177
|
+
CBB child;
|
11178
|
+
|
11179
|
+
client_out_public_key.child = &child;
|
11180
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
11181
|
+
CBB_cleanup(&client_out_public_key);
|
11182
|
+
}
|
11183
|
+
|
11184
|
+
// Offer() should succeed on the first call, but fail on all repeated calls
|
11185
|
+
{
|
11186
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = bssl::SSLKeyShare::Create(t.group_id);
|
11187
|
+
ASSERT_TRUE(client_key_share);
|
11188
|
+
CBB client_out_public_key;
|
11189
|
+
|
11190
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 2));
|
11191
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11192
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
11193
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
11194
|
+
CBB_cleanup(&client_out_public_key);
|
11195
|
+
}
|
11196
|
+
|
11197
|
+
// |client_out| is properly initialized, some zeros are written
|
11198
|
+
// to it so that it records a non-zero length, then its buffer is
|
11199
|
+
// invalidated.
|
11200
|
+
{
|
11201
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11202
|
+
ASSERT_TRUE(client_key_share);
|
11203
|
+
CBB client_out_public_key;
|
11204
|
+
|
11205
|
+
CBB_init(&client_out_public_key, t.offer_key_share_size);
|
11206
|
+
EXPECT_TRUE(CBB_add_zeros(&client_out_public_key, 2));
|
11207
|
+
// Keep a pointer to the buffer so we can cleanup correctly
|
11208
|
+
uint8_t *buf = client_out_public_key.u.base.buf;
|
11209
|
+
client_out_public_key.u.base.buf = nullptr;
|
11210
|
+
EXPECT_EQ(CBB_len(&client_out_public_key), (size_t) 2);
|
11211
|
+
EXPECT_FALSE(client_key_share->Offer(&client_out_public_key));
|
11212
|
+
client_out_public_key.u.base.buf = buf;
|
11213
|
+
CBB_cleanup(&client_out_public_key);
|
11214
|
+
}
|
11215
|
+
}
|
11216
|
+
|
11217
|
+
class BadHybridKeyShareAcceptTest : public testing::TestWithParam<HybridGroupTest> {};
|
11218
|
+
INSTANTIATE_TEST_SUITE_P(BadHybridKeyShareAcceptTests, BadHybridKeyShareAcceptTest, testing::ValuesIn(kHybridGroupTests));
|
11219
|
+
|
11220
|
+
// Test failure cases for HybridKeyShare::Accept()
|
11221
|
+
TEST_P(BadHybridKeyShareAcceptTest, BadHybridKeyShareAccept) {
|
11222
|
+
HybridGroupTest t = GetParam();
|
11223
|
+
// Basic nullptr checks
|
11224
|
+
{
|
11225
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11226
|
+
ASSERT_TRUE(server_key_share);
|
11227
|
+
Span<const uint8_t> client_public_key;
|
11228
|
+
Array<uint8_t> server_secret;
|
11229
|
+
CBB server_out_public_key;
|
11230
|
+
uint8_t server_alert = 0;
|
11231
|
+
|
11232
|
+
EXPECT_FALSE(server_key_share->Accept(nullptr, &server_secret,
|
11233
|
+
&server_alert, client_public_key));
|
11234
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11235
|
+
server_alert = 0;
|
11236
|
+
|
11237
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key, nullptr,
|
11238
|
+
&server_alert, client_public_key));
|
11239
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11240
|
+
server_alert = 0;
|
11241
|
+
|
11242
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11243
|
+
&server_secret, nullptr,
|
11244
|
+
client_public_key));
|
11245
|
+
}
|
11246
|
+
|
11247
|
+
// |server_out_public_key| has not been initialized
|
11248
|
+
{
|
11249
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11250
|
+
ASSERT_TRUE(server_key_share);
|
11251
|
+
Span<const uint8_t> client_public_key;
|
11252
|
+
Array<uint8_t> server_secret;
|
11253
|
+
CBB server_out_public_key;
|
11254
|
+
uint8_t server_alert = 0;
|
11255
|
+
|
11256
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11257
|
+
&server_secret, &server_alert,
|
11258
|
+
client_public_key));
|
11259
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11260
|
+
}
|
11261
|
+
|
11262
|
+
// |server_out_public_key| is properly initialized, then is assigned a child
|
11263
|
+
{
|
11264
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11265
|
+
ASSERT_TRUE(server_key_share);
|
11266
|
+
Span<const uint8_t> client_public_key;
|
11267
|
+
Array<uint8_t> server_secret;
|
11268
|
+
CBB server_out_public_key;
|
11269
|
+
uint8_t server_alert = 0;
|
11270
|
+
CBB child;
|
11271
|
+
|
11272
|
+
CBB_init(&server_out_public_key, 64);
|
11273
|
+
server_out_public_key.child = &child;
|
11274
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11275
|
+
&server_secret, &server_alert,
|
11276
|
+
client_public_key));
|
11277
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11278
|
+
CBB_cleanup(&server_out_public_key);
|
11279
|
+
}
|
11280
|
+
|
11281
|
+
// |server_out_public_key| is properly initialized with CBB_init,
|
11282
|
+
// some zeros are written to it so that it records a non-zero length,
|
11283
|
+
// then its buffer is invalidated.
|
11284
|
+
{
|
11285
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11286
|
+
ASSERT_TRUE(server_key_share);
|
11287
|
+
Span<const uint8_t> client_public_key;
|
11288
|
+
Array<uint8_t> server_secret;
|
11289
|
+
CBB server_out_public_key;
|
11290
|
+
uint8_t server_alert = 0;
|
11291
|
+
|
11292
|
+
CBB_init(&server_out_public_key, t.accept_key_share_size);
|
11293
|
+
EXPECT_TRUE(CBB_add_zeros(&server_out_public_key, 2));
|
11294
|
+
// Keep a pointer to the buffer so we can cleanup correctly
|
11295
|
+
uint8_t *buf = server_out_public_key.u.base.buf;
|
11296
|
+
server_out_public_key.u.base.buf = nullptr;
|
11297
|
+
EXPECT_EQ(CBB_len(&server_out_public_key), (size_t) 2);
|
11298
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11299
|
+
&server_secret, &server_alert,
|
11300
|
+
client_public_key));
|
11301
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11302
|
+
server_out_public_key.u.base.buf = buf;
|
11303
|
+
CBB_cleanup(&server_out_public_key);
|
11304
|
+
}
|
11305
|
+
|
11306
|
+
// |client_public_key| has not been initialized with anything
|
11307
|
+
{
|
11308
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11309
|
+
ASSERT_TRUE(server_key_share);
|
11310
|
+
Span<const uint8_t> client_public_key;
|
11311
|
+
Array<uint8_t> server_secret;
|
11312
|
+
CBB server_out_public_key;
|
11313
|
+
uint8_t server_alert = 0;
|
11314
|
+
|
11315
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11316
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11317
|
+
&server_secret, &server_alert,
|
11318
|
+
client_public_key));
|
11319
|
+
EXPECT_EQ(server_alert, SSL_AD_INTERNAL_ERROR);
|
11320
|
+
CBB_cleanup(&server_out_public_key);
|
11321
|
+
}
|
11322
|
+
|
11323
|
+
// |client_public_key| has been initialized but is empty
|
11324
|
+
{
|
11325
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11326
|
+
ASSERT_TRUE(server_key_share);
|
11327
|
+
Array<uint8_t> server_secret;
|
11328
|
+
CBB server_out_public_key;
|
11329
|
+
uint8_t server_alert = 0;
|
11330
|
+
|
11331
|
+
const uint8_t empty_buffer[1] = {0}; // Arrays must have at least 1 element to compile on Windows
|
11332
|
+
Span<const uint8_t> client_public_key = MakeConstSpan(empty_buffer, 0);
|
11333
|
+
|
11334
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11335
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11336
|
+
&server_secret, &server_alert,
|
11337
|
+
client_public_key));
|
11338
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
11339
|
+
CBB_cleanup(&server_out_public_key);
|
11340
|
+
}
|
11341
|
+
|
11342
|
+
// |client_public_key| is initialized with too little data
|
11343
|
+
{
|
11344
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11345
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11346
|
+
ASSERT_TRUE(server_key_share);
|
11347
|
+
ASSERT_TRUE(client_key_share);
|
11348
|
+
Span<const uint8_t> client_public_key;
|
11349
|
+
Array<uint8_t> server_secret;
|
11350
|
+
CBB server_out_public_key;
|
11351
|
+
CBB client_out_public_key;
|
11352
|
+
uint8_t server_alert = 0;
|
11353
|
+
|
11354
|
+
// Generate a valid |client_public_key|, then truncate the last byte
|
11355
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11356
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11357
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11358
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11359
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
11360
|
+
CBB_len(&client_out_public_key) - 1);
|
11361
|
+
|
11362
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11363
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11364
|
+
&server_secret, &server_alert,
|
11365
|
+
client_public_key));
|
11366
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
11367
|
+
CBB_cleanup(&server_out_public_key);
|
11368
|
+
CBB_cleanup(&client_out_public_key);
|
11369
|
+
}
|
11370
|
+
|
11371
|
+
// |client_public_key| is initialized with too much data
|
11372
|
+
{
|
11373
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11374
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11375
|
+
ASSERT_TRUE(server_key_share);
|
11376
|
+
ASSERT_TRUE(client_key_share);
|
11377
|
+
Span<const uint8_t> client_public_key;
|
11378
|
+
Array<uint8_t> server_secret;
|
11379
|
+
CBB server_out_public_key;
|
11380
|
+
CBB client_out_public_key;
|
11381
|
+
uint8_t server_alert = 0;
|
11382
|
+
|
11383
|
+
// Generate a valid |client_public_key|, then append a byte
|
11384
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11385
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11386
|
+
EXPECT_TRUE(CBB_add_zeros(&client_out_public_key, 1));
|
11387
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11388
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11389
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
11390
|
+
CBB_len(&client_out_public_key));
|
11391
|
+
|
11392
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11393
|
+
EXPECT_FALSE(server_key_share->Accept(&server_out_public_key,
|
11394
|
+
&server_secret, &server_alert,
|
11395
|
+
client_public_key));
|
11396
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
11397
|
+
CBB_cleanup(&server_out_public_key);
|
11398
|
+
CBB_cleanup(&client_out_public_key);
|
11399
|
+
}
|
11400
|
+
|
11401
|
+
// |client_public_key| is initialized with key material that is the correct
|
11402
|
+
// length, but is not a valid key. We do this iteratively over each
|
11403
|
+
// component group that makes up the hybrid group so that we can test
|
11404
|
+
// all Accept() code paths in the hybrid key share.
|
11405
|
+
{
|
11406
|
+
size_t client_public_key_index = 0;
|
11407
|
+
for (size_t i = 0; i < NUM_HYBRID_COMPONENTS; i++) {
|
11408
|
+
// We'll need the hybrid group to retrieve the component share sizes
|
11409
|
+
const HybridGroup *hybrid_group = GetHybridGroup(t.group_id);
|
11410
|
+
ASSERT_TRUE(hybrid_group != NULL);
|
11411
|
+
|
11412
|
+
// Create the hybrid key shares and generate a valid |client_public_key|
|
11413
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11414
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11415
|
+
ASSERT_TRUE(client_key_share);
|
11416
|
+
ASSERT_TRUE(server_key_share);
|
11417
|
+
|
11418
|
+
CBB client_out_public_key;
|
11419
|
+
CBB server_out_public_key;
|
11420
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11421
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11422
|
+
|
11423
|
+
Array<uint8_t> server_secret;
|
11424
|
+
Array<uint8_t> client_secret;
|
11425
|
+
uint8_t client_alert = 0;
|
11426
|
+
uint8_t server_alert = 0;
|
11427
|
+
|
11428
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11429
|
+
|
11430
|
+
// For the current component group, overwrite the bytes of that
|
11431
|
+
// component's key share (and *only* that component's key share) with
|
11432
|
+
// arbitrary nonsense; leave all other sections of the key share alone.
|
11433
|
+
// This ensures:
|
11434
|
+
// 1. The overall size of the hybrid key share is still correct
|
11435
|
+
// 2. The sizes of the component key shares are still correct; in other
|
11436
|
+
// words, the component key shares are still partitioned correctly
|
11437
|
+
// and will be parsed individually, as intended
|
11438
|
+
// 2. The key share associated with the current component group is invalid
|
11439
|
+
// 3. All other component key shares are still valid
|
11440
|
+
//
|
11441
|
+
// (We have to do this in a roundabout way with malloc'ing another
|
11442
|
+
// buffer because CBBs cannot be arbitrarily edited.)
|
11443
|
+
size_t client_out_public_key_len = CBB_len(&client_out_public_key);
|
11444
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11445
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11446
|
+
uint8_t *buffer = (uint8_t *)OPENSSL_malloc(client_out_public_key_len);
|
11447
|
+
ASSERT_TRUE(buffer);
|
11448
|
+
OPENSSL_memcpy(buffer, client_out_public_key_data, client_out_public_key_len);
|
11449
|
+
|
11450
|
+
for (size_t j = client_public_key_index; j < t.offer_share_sizes[i]; j++) {
|
11451
|
+
buffer[j] = 7; // 7 is arbitrary
|
11452
|
+
}
|
11453
|
+
Span<const uint8_t> client_public_key =
|
11454
|
+
MakeConstSpan(buffer, client_out_public_key_len);
|
11455
|
+
|
11456
|
+
// The server will Accept() the invalid public key
|
11457
|
+
bool accepted = server_key_share->
|
11458
|
+
Accept(&server_out_public_key, &server_secret, &server_alert, client_public_key);
|
11459
|
+
|
11460
|
+
if (accepted) {
|
11461
|
+
// The Accept() functionality for X25519 and all KEM key shares is
|
11462
|
+
// written so that, even if the given public key is invalid, it will
|
11463
|
+
// return success, output its own public key, and continue with the
|
11464
|
+
// handshake. (This is the intended functionality.) So, in this
|
11465
|
+
// case, we assert that the component group was one of those groups,
|
11466
|
+
// continue with the handshake, then verify that the client and
|
11467
|
+
// server ultimately arrived at different shared secrets.
|
11468
|
+
EXPECT_TRUE(
|
11469
|
+
hybrid_group->component_group_ids[i] == SSL_GROUP_KYBER768_R3 ||
|
11470
|
+
hybrid_group->component_group_ids[i] == SSL_GROUP_X25519
|
11471
|
+
);
|
11472
|
+
|
11473
|
+
// The handshake will complete without error...
|
11474
|
+
EXPECT_EQ(server_alert, 0);
|
11475
|
+
EXPECT_EQ(server_secret.size(), t.shared_secret_size);
|
11476
|
+
|
11477
|
+
Span<const uint8_t> server_public_key = MakeConstSpan(
|
11478
|
+
CBB_data(&server_out_public_key), CBB_len(&server_out_public_key));
|
11479
|
+
EXPECT_TRUE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11480
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
11481
|
+
EXPECT_EQ(client_alert, 0);
|
11482
|
+
|
11483
|
+
// ...but client and server will arrive at different shared secrets
|
11484
|
+
EXPECT_NE(Bytes(client_secret), Bytes(server_secret));
|
11485
|
+
|
11486
|
+
} else {
|
11487
|
+
// The Accept() functionality for the NIST curves (e.g. P256) is
|
11488
|
+
// written so that it will return failure if the key share is invalid.
|
11489
|
+
EXPECT_EQ(hybrid_group->component_group_ids[i], SSL_GROUP_SECP256R1);
|
11490
|
+
EXPECT_EQ(server_alert, SSL_AD_DECODE_ERROR);
|
11491
|
+
}
|
11492
|
+
|
11493
|
+
client_public_key_index += t.offer_share_sizes[i];
|
11494
|
+
CBB_cleanup(&client_out_public_key);
|
11495
|
+
CBB_cleanup(&server_out_public_key);
|
11496
|
+
OPENSSL_free(buffer);
|
11497
|
+
}
|
11498
|
+
}
|
11499
|
+
}
|
11500
|
+
|
11501
|
+
|
11502
|
+
class BadHybridKeyShareFinishTest : public testing::TestWithParam<HybridGroupTest> {};
|
11503
|
+
INSTANTIATE_TEST_SUITE_P(BadHybridKeyShareFinishTests, BadHybridKeyShareFinishTest, testing::ValuesIn(kHybridGroupTests));
|
11504
|
+
|
11505
|
+
// Test failure cases for HybridKeyShare::Finish()
|
11506
|
+
TEST_P(BadHybridKeyShareFinishTest, BadHybridKeyShareFinish) {
|
11507
|
+
HybridGroupTest t = GetParam();
|
11508
|
+
// Basic nullptr checks
|
11509
|
+
{
|
11510
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11511
|
+
Span<const uint8_t> server_public_key;
|
11512
|
+
Array<uint8_t> client_secret;
|
11513
|
+
uint8_t client_alert = 0;
|
11514
|
+
CBB client_public_key_out;
|
11515
|
+
CBB_init(&client_public_key_out, 2);
|
11516
|
+
EXPECT_TRUE(client_key_share->Offer(&client_public_key_out));
|
11517
|
+
|
11518
|
+
EXPECT_FALSE(client_key_share->Finish(nullptr, &client_alert, server_public_key));
|
11519
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
11520
|
+
client_alert = 0;
|
11521
|
+
|
11522
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, nullptr, server_public_key));
|
11523
|
+
|
11524
|
+
CBB_cleanup(&client_public_key_out);
|
11525
|
+
}
|
11526
|
+
|
11527
|
+
// It is an error if Finish() is called without there
|
11528
|
+
// having been a previous call to Offer()
|
11529
|
+
{
|
11530
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11531
|
+
ASSERT_TRUE(client_key_share);
|
11532
|
+
Array<uint8_t> client_secret;
|
11533
|
+
uint8_t client_alert = 0;
|
11534
|
+
uint8_t *buffer = (uint8_t *)OPENSSL_malloc(t.accept_key_share_size);
|
11535
|
+
|
11536
|
+
Span<const uint8_t> server_public_key = MakeConstSpan(buffer, t.accept_key_share_size);
|
11537
|
+
|
11538
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11539
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
11540
|
+
|
11541
|
+
OPENSSL_free(buffer);
|
11542
|
+
}
|
11543
|
+
|
11544
|
+
// |server_public_key| has not been initialized with anything
|
11545
|
+
{
|
11546
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11547
|
+
Span<const uint8_t> server_public_key;
|
11548
|
+
Array<uint8_t> client_secret;
|
11549
|
+
uint8_t client_alert = 0;
|
11550
|
+
CBB client_public_key_out;
|
11551
|
+
CBB_init(&client_public_key_out, 2);
|
11552
|
+
|
11553
|
+
EXPECT_TRUE(client_key_share->Offer(&client_public_key_out));
|
11554
|
+
|
11555
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11556
|
+
EXPECT_EQ(client_alert, SSL_AD_INTERNAL_ERROR);
|
11557
|
+
|
11558
|
+
CBB_cleanup(&client_public_key_out);
|
11559
|
+
}
|
11560
|
+
|
11561
|
+
// |server_public_key| is initialized but is empty
|
11562
|
+
{
|
11563
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11564
|
+
ASSERT_TRUE(client_key_share);
|
11565
|
+
Array<uint8_t> client_secret;
|
11566
|
+
uint8_t client_alert = 0;
|
11567
|
+
const uint8_t empty_buffer[1] = {0}; // Arrays must have at least 1 element to compile on Windows
|
11568
|
+
Span<const uint8_t> server_public_key = MakeConstSpan(empty_buffer, 0);
|
11569
|
+
CBB client_public_key_out;
|
11570
|
+
CBB_init(&client_public_key_out, 2);
|
11571
|
+
|
11572
|
+
EXPECT_TRUE(client_key_share->Offer(&client_public_key_out));
|
11573
|
+
|
11574
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11575
|
+
CBB_cleanup(&client_public_key_out);
|
11576
|
+
EXPECT_EQ(client_alert, SSL_AD_DECODE_ERROR);
|
11577
|
+
}
|
11578
|
+
|
11579
|
+
// |server_public_key| is initialized with too little data
|
11580
|
+
{
|
11581
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11582
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11583
|
+
ASSERT_TRUE(server_key_share);
|
11584
|
+
ASSERT_TRUE(client_key_share);
|
11585
|
+
Span<const uint8_t> client_public_key;
|
11586
|
+
Span<const uint8_t> server_public_key;
|
11587
|
+
Array<uint8_t> server_secret;
|
11588
|
+
Array<uint8_t> client_secret;
|
11589
|
+
CBB server_out_public_key;
|
11590
|
+
CBB client_out_public_key;
|
11591
|
+
uint8_t server_alert = 0;
|
11592
|
+
uint8_t client_alert = 0;
|
11593
|
+
|
11594
|
+
// Generate a valid |client_public_key|
|
11595
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11596
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11597
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11598
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11599
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
11600
|
+
CBB_len(&client_out_public_key));
|
11601
|
+
|
11602
|
+
// Generate a valid |server_public_key|, then truncate the last byte
|
11603
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11604
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key,
|
11605
|
+
&server_secret, &server_alert,
|
11606
|
+
client_public_key));
|
11607
|
+
EXPECT_EQ(server_alert, 0);
|
11608
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11609
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11610
|
+
server_public_key = MakeConstSpan(server_out_public_key_data,
|
11611
|
+
CBB_len(&server_out_public_key) - 1);
|
11612
|
+
|
11613
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11614
|
+
EXPECT_EQ(client_alert, SSL_AD_DECODE_ERROR);
|
11615
|
+
|
11616
|
+
CBB_cleanup(&server_out_public_key);
|
11617
|
+
CBB_cleanup(&client_out_public_key);
|
11618
|
+
}
|
11619
|
+
|
11620
|
+
// |server_public_key| is initialized with too much data
|
11621
|
+
{
|
11622
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11623
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11624
|
+
ASSERT_TRUE(server_key_share);
|
11625
|
+
ASSERT_TRUE(client_key_share);
|
11626
|
+
Span<const uint8_t> client_public_key;
|
11627
|
+
Span<const uint8_t> server_public_key;
|
11628
|
+
Array<uint8_t> server_secret;
|
11629
|
+
Array<uint8_t> client_secret;
|
11630
|
+
CBB server_out_public_key;
|
11631
|
+
CBB client_out_public_key;
|
11632
|
+
uint8_t server_alert = 0;
|
11633
|
+
uint8_t client_alert = 0;
|
11634
|
+
|
11635
|
+
// Generate a valid |client_public_key|
|
11636
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11637
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11638
|
+
const uint8_t *client_out_public_key_data = CBB_data(&client_out_public_key);
|
11639
|
+
ASSERT_TRUE(client_out_public_key_data);
|
11640
|
+
client_public_key = MakeConstSpan(client_out_public_key_data,
|
11641
|
+
CBB_len(&client_out_public_key));
|
11642
|
+
|
11643
|
+
// Generate a valid |server_public_key|, then append a byte
|
11644
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11645
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key,
|
11646
|
+
&server_secret, &server_alert,
|
11647
|
+
client_public_key));
|
11648
|
+
EXPECT_EQ(server_alert, 0);
|
11649
|
+
EXPECT_TRUE(CBB_add_zeros(&server_out_public_key, 1));
|
11650
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11651
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11652
|
+
server_public_key = MakeConstSpan(server_out_public_key_data,
|
11653
|
+
CBB_len(&server_out_public_key));
|
11654
|
+
|
11655
|
+
EXPECT_FALSE(client_key_share->Finish(&client_secret, &client_alert, server_public_key));
|
11656
|
+
EXPECT_EQ(client_alert, SSL_AD_DECODE_ERROR);
|
11657
|
+
|
11658
|
+
CBB_cleanup(&server_out_public_key);
|
11659
|
+
CBB_cleanup(&client_out_public_key);
|
11660
|
+
}
|
11661
|
+
|
11662
|
+
// |server_public_key| is initialized with key material that is the correct
|
11663
|
+
// length, but is not a valid key. We do this iteratively over each
|
11664
|
+
// component group that makes up the hybrid group so that we can test
|
11665
|
+
// all Finish() code paths in the hybrid key share.
|
11666
|
+
{
|
11667
|
+
size_t server_public_key_index = 0;
|
11668
|
+
for (size_t i = 0; i < NUM_HYBRID_COMPONENTS; i++) {
|
11669
|
+
// We'll need the hybrid group to retrieve the component share sizes
|
11670
|
+
const HybridGroup *hybrid_group = GetHybridGroup(t.group_id);
|
11671
|
+
ASSERT_TRUE(hybrid_group != NULL);
|
11672
|
+
|
11673
|
+
// Create the hybrid key shares and generate a valid |server_public_key|
|
11674
|
+
bssl::UniquePtr<SSLKeyShare> client_key_share = SSLKeyShare::Create(t.group_id);
|
11675
|
+
bssl::UniquePtr<SSLKeyShare> server_key_share = SSLKeyShare::Create(t.group_id);
|
11676
|
+
ASSERT_TRUE(client_key_share);
|
11677
|
+
ASSERT_TRUE(server_key_share);
|
11678
|
+
|
11679
|
+
CBB client_out_public_key;
|
11680
|
+
CBB server_out_public_key;
|
11681
|
+
EXPECT_TRUE(CBB_init(&client_out_public_key, 64));
|
11682
|
+
EXPECT_TRUE(CBB_init(&server_out_public_key, 64));
|
11683
|
+
|
11684
|
+
Array<uint8_t> server_secret;
|
11685
|
+
Array<uint8_t> client_secret;
|
11686
|
+
uint8_t client_alert = 0;
|
11687
|
+
uint8_t server_alert = 0;
|
11688
|
+
|
11689
|
+
EXPECT_TRUE(client_key_share->Offer(&client_out_public_key));
|
11690
|
+
|
11691
|
+
Span<const uint8_t> client_public_key = MakeConstSpan(
|
11692
|
+
CBB_data(&client_out_public_key), CBB_len(&client_out_public_key));
|
11693
|
+
EXPECT_TRUE(server_key_share->Accept(&server_out_public_key,
|
11694
|
+
&server_secret, &server_alert,
|
11695
|
+
client_public_key));
|
11696
|
+
EXPECT_EQ(server_alert, 0);
|
11697
|
+
|
11698
|
+
// For the current component group, overwrite the bytes of that
|
11699
|
+
// component's key share (and *only* that component's key share) with
|
11700
|
+
// arbitrary nonsense; leave all other sections of the key share alone.
|
11701
|
+
// This ensures:
|
11702
|
+
// 1. The overall size of the hybrid key share is still correct
|
11703
|
+
// 2. The sizes of the component key shares are still correct; in other
|
11704
|
+
// words, the component key shares are still partitioned correctly
|
11705
|
+
// and will be parsed individually, as intended
|
11706
|
+
// 2. The key share associated with the current component group is invalid
|
11707
|
+
// 3. All other component key shares are still valid
|
11708
|
+
//
|
11709
|
+
// (We have to do this in a roundabout way with malloc'ing another
|
11710
|
+
// buffer because CBBs cannot be arbitrarily edited.)
|
11711
|
+
size_t server_out_public_key_len = CBB_len(&server_out_public_key);
|
11712
|
+
const uint8_t *server_out_public_key_data = CBB_data(&server_out_public_key);
|
11713
|
+
ASSERT_TRUE(server_out_public_key_data);
|
11714
|
+
uint8_t *buffer = (uint8_t *)OPENSSL_malloc(server_out_public_key_len);
|
11715
|
+
ASSERT_TRUE(buffer);
|
11716
|
+
OPENSSL_memcpy(buffer, server_out_public_key_data, server_out_public_key_len);
|
11717
|
+
for (size_t j = server_public_key_index; j < t.accept_share_sizes[i]; j++) {
|
11718
|
+
buffer[j] = 7; // 7 is arbitrary
|
11719
|
+
}
|
11720
|
+
Span<const uint8_t> server_public_key =
|
11721
|
+
MakeConstSpan(buffer, server_out_public_key_len);
|
11722
|
+
|
11723
|
+
// The client will Finish() with the invalid public key
|
11724
|
+
bool accepted = client_key_share->Finish(&client_secret, &client_alert,
|
11725
|
+
server_public_key);
|
11726
|
+
|
11727
|
+
if (accepted) {
|
11728
|
+
// The Finish() functionality for X25519 and all KEM key shares is
|
11729
|
+
// written so that, even if the given public key is invalid, it will
|
11730
|
+
// return success, output its own public key, and continue with the
|
11731
|
+
// handshake. (This is the intended functionality.) So, in this
|
11732
|
+
// case, we assert that the component group was one of those groups,
|
11733
|
+
// continue with the handshake, then verify that the client and
|
11734
|
+
// server ultimately arrived at different shared secrets.
|
11735
|
+
EXPECT_TRUE(
|
11736
|
+
hybrid_group->component_group_ids[i] == SSL_GROUP_KYBER768_R3 ||
|
11737
|
+
hybrid_group->component_group_ids[i] == SSL_GROUP_X25519
|
11738
|
+
);
|
11739
|
+
|
11740
|
+
// The handshake will complete without error...
|
11741
|
+
EXPECT_EQ(client_alert, 0);
|
11742
|
+
EXPECT_EQ(client_secret.size(), t.shared_secret_size);
|
11743
|
+
|
11744
|
+
// ...but client and server will arrive at different shared secrets
|
11745
|
+
EXPECT_NE(Bytes(client_secret), Bytes(server_secret));
|
11746
|
+
|
11747
|
+
} else {
|
11748
|
+
// The Finish() functionality for the NIST curves (e.g. P256) is
|
11749
|
+
// written so that it will return failure if the key share is invalid.
|
11750
|
+
EXPECT_EQ(hybrid_group->component_group_ids[i], SSL_GROUP_SECP256R1);
|
11751
|
+
EXPECT_EQ(client_alert, SSL_AD_DECODE_ERROR);
|
11752
|
+
}
|
11753
|
+
|
11754
|
+
server_public_key_index += t.accept_share_sizes[i];
|
11755
|
+
CBB_cleanup(&client_out_public_key);
|
11756
|
+
CBB_cleanup(&server_out_public_key);
|
11757
|
+
OPENSSL_free(buffer);
|
11758
|
+
}
|
11759
|
+
}
|
11760
|
+
}
|
11761
|
+
|
11762
|
+
class PerformHybridHandshakeTest : public testing::TestWithParam<HybridHandshakeTest> {};
|
11763
|
+
INSTANTIATE_TEST_SUITE_P(PerformHybridHandshakeTests, PerformHybridHandshakeTest, testing::ValuesIn(kHybridHandshakeTests));
|
11764
|
+
|
11765
|
+
// This test runs through an overall handshake flow for all of the cases
|
11766
|
+
// defined in kHybridHandshakeTests. This test runs through both positive and
|
11767
|
+
// negative cases; refer to the comments inline in kHybridHandshakeTests for
|
11768
|
+
// specifics about each test case.
|
11769
|
+
TEST_P(PerformHybridHandshakeTest, PerformHybridHandshake) {
|
11770
|
+
HybridHandshakeTest t = GetParam();
|
11771
|
+
// Set up client and server with test case parameters
|
11772
|
+
bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method()));
|
11773
|
+
ASSERT_TRUE(client_ctx);
|
11774
|
+
ASSERT_TRUE(SSL_CTX_set1_curves_list(client_ctx.get(), t.client_rule));
|
11775
|
+
ASSERT_TRUE(SSL_CTX_set_max_proto_version(client_ctx.get(), t.client_version));
|
11776
|
+
|
11777
|
+
bssl::UniquePtr<SSL_CTX> server_ctx = CreateContextWithTestCertificate(TLS_method());
|
11778
|
+
ASSERT_TRUE(server_ctx);
|
11779
|
+
ASSERT_TRUE(SSL_CTX_set1_curves_list(server_ctx.get(), t.server_rule));
|
11780
|
+
ASSERT_TRUE(SSL_CTX_set_max_proto_version(server_ctx.get(), t.server_version));
|
11781
|
+
|
11782
|
+
bssl::UniquePtr<SSL> client, server;
|
11783
|
+
ASSERT_TRUE(CreateClientAndServer(&client, &server, client_ctx.get(), server_ctx.get()));
|
11784
|
+
|
11785
|
+
if (t.expected_group != 0) {
|
11786
|
+
// In this case, assert that the handshake completes as expected.
|
11787
|
+
ASSERT_TRUE(CompleteHandshakes(client.get(), server.get()));
|
11788
|
+
|
11789
|
+
SSL_SESSION *client_session = SSL_get_session(client.get());
|
11790
|
+
ASSERT_TRUE(client_session);
|
11791
|
+
EXPECT_EQ(t.expected_group, client_session->group_id);
|
11792
|
+
EXPECT_EQ(t.is_hrr_expected, SSL_used_hello_retry_request(client.get()));
|
11793
|
+
EXPECT_EQ(std::min(t.client_version, t.server_version), client_session->ssl_version);
|
11794
|
+
|
11795
|
+
SSL_SESSION *server_session = SSL_get_session(server.get());
|
11796
|
+
ASSERT_TRUE(server_session);
|
11797
|
+
EXPECT_EQ(t.expected_group, server_session->group_id);
|
11798
|
+
EXPECT_EQ(t.is_hrr_expected, SSL_used_hello_retry_request(server.get()));
|
11799
|
+
EXPECT_EQ(std::min(t.client_version, t.server_version), server_session->ssl_version);
|
11800
|
+
} else {
|
11801
|
+
// In this case, we expect the handshake to fail because client and
|
11802
|
+
// server configurations are not compatible.
|
11803
|
+
ASSERT_FALSE(CompleteHandshakes(client.get(), server.get()));
|
11804
|
+
|
11805
|
+
ASSERT_FALSE(client.get()->s3->initial_handshake_complete);
|
11806
|
+
EXPECT_EQ(t.is_hrr_expected, SSL_used_hello_retry_request(client.get()));
|
11807
|
+
|
11808
|
+
ASSERT_FALSE(server.get()->s3->initial_handshake_complete);
|
11809
|
+
EXPECT_EQ(t.is_hrr_expected, SSL_used_hello_retry_request(server.get()));
|
11810
|
+
}
|
11811
|
+
}
|
11812
|
+
|
9980
11813
|
} // namespace
|
9981
11814
|
BSSL_NAMESPACE_END
|