grpc 1.24.0 → 1.25.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +306 -243
- data/etc/roots.pem +0 -100
- data/include/grpc/grpc_security.h +44 -18
- data/include/grpc/impl/codegen/grpc_types.h +15 -0
- data/include/grpc/impl/codegen/port_platform.h +27 -11
- data/include/grpc/impl/codegen/sync_generic.h +1 -1
- data/src/boringssl/err_data.c +695 -650
- data/src/core/ext/filters/client_channel/client_channel.cc +257 -179
- data/src/core/ext/filters/client_channel/client_channel.h +24 -0
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +2 -3
- data/src/core/ext/filters/client_channel/client_channel_factory.h +1 -5
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +18 -45
- data/src/core/ext/filters/client_channel/health/health_check_client.h +5 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +65 -55
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -14
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +113 -36
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +14 -19
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +36 -13
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +3 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +814 -1589
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +2 -5
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +3 -6
- data/src/core/ext/filters/client_channel/resolver.cc +1 -2
- data/src/core/ext/filters/client_channel/resolver.h +8 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +25 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +46 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +10 -17
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +7 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +111 -44
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +22 -14
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +29 -10
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +27 -36
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +7 -10
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +60 -16
- data/src/core/ext/filters/client_channel/resolver_factory.h +4 -8
- data/src/core/ext/filters/client_channel/resolver_registry.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_registry.h +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +7 -10
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +7 -8
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +1 -1
- data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -5
- data/src/core/ext/filters/client_channel/retry_throttle.h +1 -4
- data/src/core/ext/filters/client_channel/service_config.h +8 -8
- data/src/core/ext/filters/client_channel/subchannel.cc +53 -86
- data/src/core/ext/filters/client_channel/subchannel.h +7 -9
- data/src/core/ext/filters/client_channel/subchannel_interface.h +9 -13
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +3 -6
- data/src/core/ext/filters/client_channel/{lb_policy/xds/xds_load_balancer_api.cc → xds/xds_api.cc} +169 -52
- data/src/core/ext/filters/client_channel/xds/xds_api.h +171 -0
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +450 -0
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +99 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel.h +8 -6
- data/src/core/ext/filters/client_channel/xds/xds_channel_args.h +26 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_channel_secure.cc +28 -11
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +1413 -0
- data/src/core/ext/filters/client_channel/xds/xds_client.h +221 -0
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.cc +1 -5
- data/src/core/ext/filters/client_channel/{lb_policy/xds → xds}/xds_client_stats.h +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.cc +20 -20
- data/src/core/ext/filters/http/client/http_client_filter.cc +15 -15
- data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +12 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +59 -50
- data/src/core/ext/filters/message_size/message_size_filter.cc +18 -18
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -14
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +233 -175
- data/src/core/ext/transport/chttp2/transport/flow_control.h +21 -24
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +253 -163
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +24 -12
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +13 -15
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +20 -13
- data/src/core/lib/channel/channel_args.cc +16 -0
- data/src/core/lib/channel/channel_args.h +22 -0
- data/src/core/lib/channel/channelz.cc +5 -6
- data/src/core/lib/channel/channelz.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +20 -20
- data/src/core/lib/channel/handshaker.h +3 -4
- data/src/core/lib/channel/handshaker_factory.h +1 -3
- data/src/core/lib/debug/trace.h +3 -2
- data/src/core/lib/gprpp/arena.cc +3 -3
- data/src/core/lib/gprpp/arena.h +2 -3
- data/src/core/lib/gprpp/inlined_vector.h +9 -0
- data/src/core/lib/gprpp/map.h +3 -501
- data/src/core/lib/gprpp/memory.h +45 -41
- data/src/core/lib/gprpp/mpscq.cc +108 -0
- data/src/core/lib/gprpp/mpscq.h +98 -0
- data/src/core/lib/gprpp/orphanable.h +6 -11
- data/src/core/lib/gprpp/ref_counted.h +25 -19
- data/src/core/lib/gprpp/set.h +33 -0
- data/src/core/lib/gprpp/thd.h +2 -4
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +15 -11
- data/src/core/lib/http/parser.cc +1 -1
- data/src/core/lib/iomgr/buffer_list.cc +4 -5
- data/src/core/lib/iomgr/buffer_list.h +5 -6
- data/src/core/lib/iomgr/call_combiner.cc +4 -5
- data/src/core/lib/iomgr/call_combiner.h +2 -2
- data/src/core/lib/iomgr/cfstream_handle.h +3 -5
- data/src/core/lib/iomgr/closure.h +8 -3
- data/src/core/lib/iomgr/combiner.cc +45 -82
- data/src/core/lib/iomgr/combiner.h +32 -8
- data/src/core/lib/iomgr/endpoint_cfstream.cc +5 -3
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +19 -15
- data/src/core/lib/iomgr/exec_ctx.h +4 -3
- data/src/core/lib/iomgr/executor.cc +4 -2
- data/src/core/lib/iomgr/executor.h +3 -0
- data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -6
- data/src/core/lib/iomgr/executor/threadpool.cc +1 -2
- data/src/core/lib/iomgr/executor/threadpool.h +7 -11
- data/src/core/lib/iomgr/resource_quota.cc +55 -51
- data/src/core/lib/iomgr/resource_quota.h +13 -9
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +13 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.cc +4 -11
- data/src/core/lib/iomgr/tcp_custom.cc +9 -7
- data/src/core/lib/iomgr/tcp_posix.cc +20 -16
- data/src/core/lib/iomgr/tcp_server.h +1 -4
- data/src/core/lib/iomgr/tcp_server_custom.cc +5 -5
- data/src/core/lib/iomgr/tcp_server_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -11
- data/src/core/lib/iomgr/timer_custom.cc +2 -2
- data/src/core/lib/iomgr/udp_server.cc +3 -2
- data/src/core/lib/iomgr/udp_server.h +6 -12
- data/src/core/lib/json/json.h +1 -1
- data/src/core/lib/json/json_string.cc +2 -2
- data/src/core/lib/profiling/basic_timers.cc +2 -2
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -2
- data/src/core/lib/security/credentials/alts/grpc_alts_credentials_server_options.cc +1 -1
- data/src/core/lib/security/credentials/credentials.h +4 -20
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +4 -4
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +64 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +4 -4
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +9 -7
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -0
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -4
- data/src/core/lib/security/security_connector/security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/security_connector.h +19 -17
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +8 -5
- data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
- data/src/core/lib/security/security_connector/ssl_utils.h +1 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -6
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +4 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +17 -17
- data/src/core/lib/security/transport/security_handshaker.cc +29 -13
- data/src/core/lib/security/transport/security_handshaker.h +4 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +14 -14
- data/src/core/lib/slice/slice.cc +2 -10
- data/src/core/lib/slice/slice_hash_table.h +4 -6
- data/src/core/lib/slice/slice_intern.cc +42 -39
- data/src/core/lib/slice/slice_internal.h +3 -3
- data/src/core/lib/slice/slice_utils.h +21 -4
- data/src/core/lib/slice/slice_weak_hash_table.h +4 -6
- data/src/core/lib/surface/call.cc +3 -3
- data/src/core/lib/surface/channel.cc +7 -0
- data/src/core/lib/surface/completion_queue.cc +12 -11
- data/src/core/lib/surface/completion_queue.h +4 -2
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/lame_client.cc +33 -18
- data/src/core/lib/surface/server.cc +77 -76
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/byte_stream.h +3 -7
- data/src/core/lib/transport/connectivity_state.cc +112 -98
- data/src/core/lib/transport/connectivity_state.h +100 -50
- data/src/core/lib/transport/static_metadata.cc +276 -288
- data/src/core/lib/transport/static_metadata.h +73 -76
- data/src/core/lib/transport/status_conversion.cc +1 -1
- data/src/core/lib/transport/status_metadata.cc +1 -1
- data/src/core/lib/transport/transport.cc +2 -2
- data/src/core/lib/transport/transport.h +12 -4
- data/src/core/lib/transport/transport_op_string.cc +14 -11
- data/src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +5 -5
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +12 -2
- data/src/core/tsi/fake_transport_security.cc +7 -5
- data/src/core/tsi/grpc_shadow_boringssl.h +2918 -2627
- data/src/core/tsi/local_transport_security.cc +8 -6
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -3
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -2
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +7 -5
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -6
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -2
- data/src/core/tsi/ssl_transport_security.cc +12 -12
- data/src/core/tsi/ssl_transport_security.h +2 -2
- data/src/core/tsi/transport_security_grpc.cc +7 -0
- data/src/core/tsi/transport_security_grpc.h +6 -0
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call.c +1 -1
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/google_rpc_status_utils_spec.rb +2 -2
- data/third_party/boringssl/crypto/asn1/a_bool.c +18 -5
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +17 -221
- data/third_party/boringssl/crypto/asn1/a_dup.c +0 -24
- data/third_party/boringssl/crypto/asn1/a_enum.c +2 -2
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +10 -72
- data/third_party/boringssl/crypto/asn1/a_int.c +12 -71
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +110 -216
- data/third_party/boringssl/crypto/asn1/a_object.c +16 -5
- data/third_party/boringssl/crypto/asn1/a_strnid.c +1 -0
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -1
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +3 -1
- data/third_party/boringssl/crypto/base64/base64.c +2 -2
- data/third_party/boringssl/crypto/bio/bio.c +73 -9
- data/third_party/boringssl/crypto/bio/connect.c +4 -0
- data/third_party/boringssl/crypto/bio/fd.c +4 -0
- data/third_party/boringssl/crypto/bio/file.c +5 -2
- data/third_party/boringssl/crypto/bio/socket.c +4 -0
- data/third_party/boringssl/crypto/bio/socket_helper.c +4 -0
- data/third_party/boringssl/crypto/bn_extra/convert.c +11 -7
- data/third_party/boringssl/crypto/bytestring/ber.c +8 -4
- data/third_party/boringssl/crypto/bytestring/cbb.c +19 -7
- data/third_party/boringssl/crypto/bytestring/cbs.c +28 -15
- data/third_party/boringssl/crypto/bytestring/internal.h +28 -7
- data/third_party/boringssl/crypto/bytestring/unicode.c +155 -0
- data/third_party/boringssl/crypto/chacha/chacha.c +36 -19
- data/third_party/boringssl/crypto/chacha/internal.h +45 -0
- data/third_party/boringssl/crypto/cipher_extra/cipher_extra.c +29 -0
- data/third_party/boringssl/crypto/cipher_extra/e_aesccm.c +269 -25
- data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +16 -14
- data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +54 -38
- data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +133 -41
- data/third_party/boringssl/crypto/cipher_extra/e_tls.c +23 -15
- data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +24 -15
- data/third_party/boringssl/crypto/cmac/cmac.c +62 -25
- data/third_party/boringssl/crypto/conf/conf.c +7 -0
- data/third_party/boringssl/crypto/cpu-arm-linux.c +4 -148
- data/third_party/boringssl/crypto/cpu-arm-linux.h +201 -0
- data/third_party/boringssl/crypto/cpu-intel.c +45 -51
- data/third_party/boringssl/crypto/crypto.c +39 -22
- data/third_party/boringssl/crypto/curve25519/spake25519.c +1 -1
- data/third_party/boringssl/crypto/dsa/dsa.c +77 -53
- data/third_party/boringssl/crypto/ec_extra/ec_asn1.c +20 -8
- data/third_party/boringssl/crypto/ec_extra/ec_derive.c +96 -0
- data/third_party/boringssl/crypto/{ecdh/ecdh.c → ecdh_extra/ecdh_extra.c} +20 -58
- data/third_party/boringssl/crypto/ecdsa_extra/ecdsa_asn1.c +1 -9
- data/third_party/boringssl/crypto/engine/engine.c +2 -1
- data/third_party/boringssl/crypto/err/err.c +2 -0
- data/third_party/boringssl/crypto/err/internal.h +2 -2
- data/third_party/boringssl/crypto/evp/evp.c +89 -8
- data/third_party/boringssl/crypto/evp/evp_asn1.c +56 -5
- data/third_party/boringssl/crypto/evp/evp_ctx.c +52 -14
- data/third_party/boringssl/crypto/evp/internal.h +18 -1
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +5 -0
- data/third_party/boringssl/crypto/evp/p_ec.c +51 -3
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +6 -7
- data/third_party/boringssl/crypto/evp/p_ed25519.c +36 -3
- data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +76 -45
- data/third_party/boringssl/crypto/evp/p_rsa.c +3 -1
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +5 -0
- data/third_party/boringssl/crypto/evp/p_x25519.c +110 -0
- data/third_party/boringssl/crypto/evp/p_x25519_asn1.c +249 -0
- data/third_party/boringssl/crypto/evp/scrypt.c +6 -2
- data/third_party/boringssl/crypto/fipsmodule/aes/aes.c +34 -274
- data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +161 -21
- data/third_party/boringssl/crypto/fipsmodule/aes/key_wrap.c +111 -13
- data/third_party/boringssl/crypto/fipsmodule/aes/mode_wrappers.c +17 -21
- data/third_party/boringssl/crypto/fipsmodule/bcm.c +119 -7
- data/third_party/boringssl/crypto/fipsmodule/bn/bn.c +19 -2
- data/third_party/boringssl/crypto/fipsmodule/bn/cmp.c +2 -2
- data/third_party/boringssl/crypto/fipsmodule/bn/ctx.c +93 -160
- data/third_party/boringssl/crypto/fipsmodule/bn/div.c +48 -57
- data/third_party/boringssl/crypto/fipsmodule/bn/div_extra.c +87 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/exponentiation.c +143 -211
- data/third_party/boringssl/crypto/fipsmodule/bn/gcd.c +0 -305
- data/third_party/boringssl/crypto/fipsmodule/bn/gcd_extra.c +325 -0
- data/third_party/boringssl/crypto/fipsmodule/bn/internal.h +168 -50
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery.c +68 -92
- data/third_party/boringssl/crypto/fipsmodule/bn/montgomery_inv.c +7 -6
- data/third_party/boringssl/crypto/fipsmodule/bn/mul.c +11 -14
- data/third_party/boringssl/crypto/fipsmodule/bn/prime.c +358 -443
- data/third_party/boringssl/crypto/fipsmodule/bn/random.c +25 -35
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.c +20 -25
- data/third_party/boringssl/crypto/fipsmodule/bn/rsaz_exp.h +76 -5
- data/third_party/boringssl/crypto/fipsmodule/bn/shift.c +14 -14
- data/third_party/boringssl/crypto/fipsmodule/cipher/cipher.c +7 -2
- data/third_party/boringssl/crypto/fipsmodule/cipher/e_aes.c +383 -516
- data/third_party/boringssl/crypto/fipsmodule/cipher/e_des.c +4 -0
- data/third_party/boringssl/crypto/fipsmodule/cipher/internal.h +3 -4
- data/third_party/boringssl/crypto/fipsmodule/delocate.h +3 -2
- data/third_party/boringssl/crypto/fipsmodule/digest/digest.c +32 -17
- data/third_party/boringssl/crypto/fipsmodule/digest/md32_common.h +3 -3
- data/third_party/boringssl/crypto/fipsmodule/ec/ec.c +228 -122
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_key.c +34 -8
- data/third_party/boringssl/crypto/fipsmodule/ec/ec_montgomery.c +311 -98
- data/third_party/boringssl/crypto/fipsmodule/ec/felem.c +82 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/internal.h +263 -97
- data/third_party/boringssl/crypto/fipsmodule/ec/oct.c +22 -59
- data/third_party/boringssl/crypto/fipsmodule/ec/p224-64.c +317 -234
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64-table.h +9473 -9475
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.c +313 -109
- data/third_party/boringssl/crypto/fipsmodule/ec/p256-x86_64.h +36 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/scalar.c +96 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/simple.c +126 -792
- data/third_party/boringssl/crypto/fipsmodule/ec/simple_mul.c +84 -0
- data/third_party/boringssl/crypto/fipsmodule/ec/util.c +163 -12
- data/third_party/boringssl/crypto/fipsmodule/ec/wnaf.c +84 -211
- data/third_party/boringssl/crypto/fipsmodule/ecdh/ecdh.c +122 -0
- data/third_party/boringssl/crypto/fipsmodule/ecdsa/ecdsa.c +60 -205
- data/third_party/boringssl/crypto/fipsmodule/fips_shared_support.c +32 -0
- data/third_party/boringssl/crypto/fipsmodule/is_fips.c +2 -0
- data/third_party/boringssl/crypto/fipsmodule/md4/md4.c +3 -1
- data/third_party/boringssl/crypto/fipsmodule/md5/internal.h +37 -0
- data/third_party/boringssl/crypto/fipsmodule/md5/md5.c +11 -8
- data/third_party/boringssl/crypto/fipsmodule/modes/cbc.c +35 -79
- data/third_party/boringssl/crypto/fipsmodule/modes/cfb.c +7 -39
- data/third_party/boringssl/crypto/fipsmodule/modes/ctr.c +7 -27
- data/third_party/boringssl/crypto/fipsmodule/modes/gcm.c +123 -309
- data/third_party/boringssl/crypto/fipsmodule/modes/internal.h +189 -126
- data/third_party/boringssl/crypto/fipsmodule/modes/ofb.c +3 -2
- data/third_party/boringssl/crypto/fipsmodule/rand/ctrdrbg.c +2 -2
- data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +35 -0
- data/third_party/boringssl/crypto/fipsmodule/rand/rand.c +24 -19
- data/third_party/boringssl/crypto/fipsmodule/rand/urandom.c +256 -77
- data/third_party/boringssl/crypto/fipsmodule/rsa/padding.c +10 -7
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa.c +5 -1
- data/third_party/boringssl/crypto/fipsmodule/rsa/rsa_impl.c +131 -14
- data/third_party/boringssl/crypto/fipsmodule/self_check/self_check.c +83 -10
- data/third_party/boringssl/crypto/fipsmodule/sha/internal.h +53 -0
- data/third_party/boringssl/crypto/fipsmodule/sha/sha1.c +9 -13
- data/third_party/boringssl/crypto/fipsmodule/sha/sha256.c +18 -12
- data/third_party/boringssl/crypto/fipsmodule/sha/sha512.c +95 -168
- data/third_party/boringssl/crypto/hrss/hrss.c +2201 -0
- data/third_party/boringssl/crypto/hrss/internal.h +62 -0
- data/third_party/boringssl/crypto/internal.h +95 -20
- data/third_party/boringssl/crypto/lhash/lhash.c +45 -33
- data/third_party/boringssl/crypto/mem.c +39 -2
- data/third_party/boringssl/crypto/obj/obj.c +4 -4
- data/third_party/boringssl/crypto/obj/obj_dat.h +6181 -875
- data/third_party/boringssl/crypto/pem/pem_all.c +2 -3
- data/third_party/boringssl/crypto/pem/pem_info.c +144 -162
- data/third_party/boringssl/crypto/pem/pem_lib.c +53 -52
- data/third_party/boringssl/crypto/pem/pem_pkey.c +13 -21
- data/third_party/boringssl/crypto/pkcs7/pkcs7.c +15 -22
- data/third_party/boringssl/crypto/pkcs7/pkcs7_x509.c +168 -16
- data/third_party/boringssl/crypto/pkcs8/internal.h +11 -0
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +24 -15
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +42 -25
- data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +559 -43
- data/third_party/boringssl/crypto/pool/internal.h +1 -1
- data/third_party/boringssl/crypto/pool/pool.c +21 -0
- data/third_party/boringssl/crypto/rand_extra/deterministic.c +8 -0
- data/third_party/boringssl/crypto/rand_extra/fuchsia.c +1 -14
- data/third_party/boringssl/crypto/refcount_lock.c +2 -2
- data/third_party/boringssl/crypto/rsa_extra/rsa_print.c +22 -0
- data/third_party/boringssl/crypto/siphash/siphash.c +80 -0
- data/third_party/boringssl/crypto/stack/stack.c +83 -32
- data/third_party/boringssl/crypto/thread_none.c +2 -2
- data/third_party/boringssl/crypto/thread_pthread.c +2 -2
- data/third_party/boringssl/crypto/thread_win.c +38 -19
- data/third_party/boringssl/crypto/x509/a_strex.c +22 -2
- data/third_party/boringssl/crypto/x509/asn1_gen.c +2 -1
- data/third_party/boringssl/crypto/x509/by_dir.c +7 -0
- data/third_party/boringssl/crypto/x509/by_file.c +12 -10
- data/third_party/boringssl/crypto/x509/t_crl.c +5 -8
- data/third_party/boringssl/crypto/x509/t_req.c +1 -3
- data/third_party/boringssl/crypto/x509/t_x509.c +5 -8
- data/third_party/boringssl/crypto/x509/x509_cmp.c +1 -1
- data/third_party/boringssl/crypto/x509/x509_def.c +1 -1
- data/third_party/boringssl/crypto/x509/x509_lu.c +114 -5
- data/third_party/boringssl/crypto/x509/x509_req.c +20 -0
- data/third_party/boringssl/crypto/x509/x509_set.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_trs.c +1 -0
- data/third_party/boringssl/crypto/x509/x509_txt.c +4 -5
- data/third_party/boringssl/crypto/x509/x509_vfy.c +145 -138
- data/third_party/boringssl/crypto/x509/x509_vpm.c +2 -0
- data/third_party/boringssl/crypto/x509/x509cset.c +40 -0
- data/third_party/boringssl/crypto/x509/x509name.c +2 -3
- data/third_party/boringssl/crypto/x509/x_all.c +109 -210
- data/third_party/boringssl/crypto/x509/x_x509.c +6 -0
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +1 -3
- data/third_party/boringssl/crypto/x509v3/internal.h +56 -0
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +2 -0
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -0
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +4 -2
- data/third_party/boringssl/crypto/x509v3/v3_akey.c +5 -2
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +19 -13
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +3 -2
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +1 -6
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +1 -0
- data/third_party/boringssl/crypto/x509v3/v3_ocsp.c +68 -0
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +47 -69
- data/third_party/boringssl/crypto/x509v3/v3_skey.c +5 -2
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +69 -25
- data/third_party/boringssl/include/openssl/aead.h +45 -19
- data/third_party/boringssl/include/openssl/aes.h +32 -7
- data/third_party/boringssl/include/openssl/asn1.h +7 -77
- data/third_party/boringssl/include/openssl/base.h +120 -6
- data/third_party/boringssl/include/openssl/base64.h +4 -1
- data/third_party/boringssl/include/openssl/bio.h +112 -81
- data/third_party/boringssl/include/openssl/blowfish.h +3 -3
- data/third_party/boringssl/include/openssl/bn.h +55 -29
- data/third_party/boringssl/include/openssl/buf.h +2 -2
- data/third_party/boringssl/include/openssl/bytestring.h +54 -32
- data/third_party/boringssl/include/openssl/cast.h +2 -2
- data/third_party/boringssl/include/openssl/cipher.h +46 -16
- data/third_party/boringssl/include/openssl/cmac.h +6 -2
- data/third_party/boringssl/include/openssl/conf.h +3 -6
- data/third_party/boringssl/include/openssl/cpu.h +25 -9
- data/third_party/boringssl/include/openssl/crypto.h +32 -10
- data/third_party/boringssl/include/openssl/curve25519.h +4 -4
- data/third_party/boringssl/include/openssl/dh.h +3 -2
- data/third_party/boringssl/include/openssl/digest.h +21 -7
- data/third_party/boringssl/include/openssl/dsa.h +8 -2
- data/third_party/boringssl/include/openssl/e_os2.h +18 -0
- data/third_party/boringssl/include/openssl/ec.h +25 -21
- data/third_party/boringssl/include/openssl/ec_key.h +36 -8
- data/third_party/boringssl/include/openssl/ecdh.h +17 -0
- data/third_party/boringssl/include/openssl/ecdsa.h +3 -3
- data/third_party/boringssl/include/openssl/engine.h +4 -4
- data/third_party/boringssl/include/openssl/err.h +3 -0
- data/third_party/boringssl/include/openssl/evp.h +199 -42
- data/third_party/boringssl/include/openssl/hmac.h +4 -4
- data/third_party/boringssl/include/openssl/hrss.h +100 -0
- data/third_party/boringssl/include/openssl/lhash.h +131 -23
- data/third_party/boringssl/include/openssl/md4.h +6 -4
- data/third_party/boringssl/include/openssl/md5.h +6 -4
- data/third_party/boringssl/include/openssl/mem.h +6 -2
- data/third_party/boringssl/include/openssl/nid.h +3 -0
- data/third_party/boringssl/include/openssl/obj.h +3 -0
- data/third_party/boringssl/include/openssl/pem.h +102 -64
- data/third_party/boringssl/include/openssl/pkcs7.h +136 -3
- data/third_party/boringssl/include/openssl/pkcs8.h +42 -3
- data/third_party/boringssl/include/openssl/pool.h +13 -2
- data/third_party/boringssl/include/openssl/ripemd.h +5 -4
- data/third_party/boringssl/include/openssl/rsa.h +46 -15
- data/third_party/boringssl/include/openssl/sha.h +40 -28
- data/third_party/boringssl/include/openssl/siphash.h +37 -0
- data/third_party/boringssl/include/openssl/span.h +17 -9
- data/third_party/boringssl/include/openssl/ssl.h +766 -393
- data/third_party/boringssl/include/openssl/ssl3.h +4 -3
- data/third_party/boringssl/include/openssl/stack.h +134 -77
- data/third_party/boringssl/include/openssl/thread.h +1 -1
- data/third_party/boringssl/include/openssl/tls1.h +25 -9
- data/third_party/boringssl/include/openssl/type_check.h +14 -15
- data/third_party/boringssl/include/openssl/x509.h +28 -3
- data/third_party/boringssl/include/openssl/x509_vfy.h +98 -32
- data/third_party/boringssl/include/openssl/x509v3.h +17 -13
- data/third_party/boringssl/ssl/d1_both.cc +9 -18
- data/third_party/boringssl/ssl/d1_lib.cc +4 -3
- data/third_party/boringssl/ssl/d1_pkt.cc +4 -4
- data/third_party/boringssl/ssl/d1_srtp.cc +15 -15
- data/third_party/boringssl/ssl/dtls_method.cc +0 -1
- data/third_party/boringssl/ssl/dtls_record.cc +28 -28
- data/third_party/boringssl/ssl/handoff.cc +295 -91
- data/third_party/boringssl/ssl/handshake.cc +133 -72
- data/third_party/boringssl/ssl/handshake_client.cc +218 -189
- data/third_party/boringssl/ssl/handshake_server.cc +399 -272
- data/third_party/boringssl/ssl/internal.h +1413 -928
- data/third_party/boringssl/ssl/s3_both.cc +175 -36
- data/third_party/boringssl/ssl/s3_lib.cc +9 -13
- data/third_party/boringssl/ssl/s3_pkt.cc +63 -29
- data/third_party/boringssl/ssl/ssl_aead_ctx.cc +55 -35
- data/third_party/boringssl/ssl/ssl_asn1.cc +57 -73
- data/third_party/boringssl/ssl/ssl_buffer.cc +13 -12
- data/third_party/boringssl/ssl/ssl_cert.cc +313 -210
- data/third_party/boringssl/ssl/ssl_cipher.cc +159 -221
- data/third_party/boringssl/ssl/ssl_file.cc +2 -0
- data/third_party/boringssl/ssl/ssl_key_share.cc +164 -19
- data/third_party/boringssl/ssl/ssl_lib.cc +847 -555
- data/third_party/boringssl/ssl/ssl_privkey.cc +441 -111
- data/third_party/boringssl/ssl/ssl_session.cc +230 -178
- data/third_party/boringssl/ssl/ssl_transcript.cc +21 -142
- data/third_party/boringssl/ssl/ssl_versions.cc +88 -93
- data/third_party/boringssl/ssl/ssl_x509.cc +279 -218
- data/third_party/boringssl/ssl/t1_enc.cc +5 -96
- data/third_party/boringssl/ssl/t1_lib.cc +931 -678
- data/third_party/boringssl/ssl/tls13_both.cc +251 -121
- data/third_party/boringssl/ssl/tls13_client.cc +129 -73
- data/third_party/boringssl/ssl/tls13_enc.cc +350 -282
- data/third_party/boringssl/ssl/tls13_server.cc +259 -192
- data/third_party/boringssl/ssl/tls_method.cc +26 -21
- data/third_party/boringssl/ssl/tls_record.cc +42 -47
- data/third_party/boringssl/third_party/fiat/curve25519.c +261 -1324
- data/third_party/boringssl/third_party/fiat/curve25519_32.h +911 -0
- data/third_party/boringssl/third_party/fiat/curve25519_64.h +559 -0
- data/third_party/boringssl/third_party/fiat/p256.c +238 -999
- data/third_party/boringssl/third_party/fiat/p256_32.h +3226 -0
- data/third_party/boringssl/third_party/fiat/p256_64.h +1217 -0
- data/third_party/upb/upb/port_def.inc +1 -1
- data/third_party/upb/upb/table.c +2 -1
- metadata +71 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +0 -127
- data/src/core/lib/gpr/mpscq.cc +0 -117
- data/src/core/lib/gpr/mpscq.h +0 -88
- data/src/core/lib/gprpp/abstract.h +0 -47
- data/src/core/lib/gprpp/pair.h +0 -38
- data/third_party/boringssl/crypto/cipher_extra/e_ssl3.c +0 -460
- data/third_party/boringssl/crypto/fipsmodule/modes/ccm.c +0 -256
- data/third_party/boringssl/include/openssl/lhash_macros.h +0 -174
- data/third_party/boringssl/ssl/custom_extensions.cc +0 -265
@@ -122,7 +122,7 @@
|
|
122
122
|
#include "internal.h"
|
123
123
|
|
124
124
|
|
125
|
-
|
125
|
+
BSSL_NAMESPACE_BEGIN
|
126
126
|
|
127
127
|
SSL_HANDSHAKE::SSL_HANDSHAKE(SSL *ssl_arg)
|
128
128
|
: ssl(ssl_arg),
|
@@ -130,12 +130,12 @@ SSL_HANDSHAKE::SSL_HANDSHAKE(SSL *ssl_arg)
|
|
130
130
|
needs_psk_binder(false),
|
131
131
|
received_hello_retry_request(false),
|
132
132
|
sent_hello_retry_request(false),
|
133
|
-
received_custom_extension(false),
|
134
133
|
handshake_finalized(false),
|
135
134
|
accept_psk_mode(false),
|
136
135
|
cert_request(false),
|
137
136
|
certificate_status_expected(false),
|
138
137
|
ocsp_stapling_requested(false),
|
138
|
+
delegated_credential_requested(false),
|
139
139
|
should_ack_sni(false),
|
140
140
|
in_false_start(false),
|
141
141
|
in_early_data(false),
|
@@ -146,17 +146,32 @@ SSL_HANDSHAKE::SSL_HANDSHAKE(SSL *ssl_arg)
|
|
146
146
|
ticket_expected(false),
|
147
147
|
extended_master_secret(false),
|
148
148
|
pending_private_key_op(false),
|
149
|
-
grease_seeded(false)
|
149
|
+
grease_seeded(false),
|
150
|
+
handback(false),
|
151
|
+
cert_compression_negotiated(false),
|
152
|
+
apply_jdk11_workaround(false) {
|
153
|
+
assert(ssl);
|
150
154
|
}
|
151
155
|
|
152
156
|
SSL_HANDSHAKE::~SSL_HANDSHAKE() {
|
153
157
|
ssl->ctx->x509_method->hs_flush_cached_ca_names(this);
|
154
158
|
}
|
155
159
|
|
160
|
+
void SSL_HANDSHAKE::ResizeSecrets(size_t hash_len) {
|
161
|
+
if (hash_len > SSL_MAX_MD_SIZE) {
|
162
|
+
abort();
|
163
|
+
}
|
164
|
+
hash_len_ = hash_len;
|
165
|
+
}
|
166
|
+
|
156
167
|
UniquePtr<SSL_HANDSHAKE> ssl_handshake_new(SSL *ssl) {
|
157
168
|
UniquePtr<SSL_HANDSHAKE> hs = MakeUnique<SSL_HANDSHAKE>(ssl);
|
158
|
-
if (!hs ||
|
159
|
-
|
169
|
+
if (!hs || !hs->transcript.Init()) {
|
170
|
+
return nullptr;
|
171
|
+
}
|
172
|
+
hs->config = ssl->config.get();
|
173
|
+
if (!hs->config) {
|
174
|
+
assert(hs->config);
|
160
175
|
return nullptr;
|
161
176
|
}
|
162
177
|
return hs;
|
@@ -189,7 +204,8 @@ size_t ssl_max_handshake_message_len(const SSL *ssl) {
|
|
189
204
|
static const size_t kMaxMessageLen = 16384;
|
190
205
|
|
191
206
|
if (SSL_in_init(ssl)) {
|
192
|
-
|
207
|
+
SSL_CONFIG *config = ssl->config.get(); // SSL_in_init() implies not NULL.
|
208
|
+
if ((!ssl->server || (config->verify_mode & SSL_VERIFY_PEER)) &&
|
193
209
|
kMaxMessageLen < ssl->max_cert_list) {
|
194
210
|
return ssl->max_cert_list;
|
195
211
|
}
|
@@ -272,16 +288,6 @@ int ssl_parse_extensions(const CBS *cbs, uint8_t *out_alert,
|
|
272
288
|
return 1;
|
273
289
|
}
|
274
290
|
|
275
|
-
static void set_crypto_buffer(CRYPTO_BUFFER **dest, CRYPTO_BUFFER *src) {
|
276
|
-
// TODO(davidben): Remove this helper once |SSL_SESSION| can use |UniquePtr|
|
277
|
-
// and |UniquePtr| has up_ref helpers.
|
278
|
-
CRYPTO_BUFFER_free(*dest);
|
279
|
-
*dest = src;
|
280
|
-
if (src != nullptr) {
|
281
|
-
CRYPTO_BUFFER_up_ref(src);
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
291
|
enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs) {
|
286
292
|
SSL *const ssl = hs->ssl;
|
287
293
|
const SSL_SESSION *prev_session = ssl->s3->established_session.get();
|
@@ -291,18 +297,19 @@ enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs) {
|
|
291
297
|
// so this check is sufficient to ensure the reported peer certificate never
|
292
298
|
// changes on renegotiation.
|
293
299
|
assert(!ssl->server);
|
294
|
-
if (sk_CRYPTO_BUFFER_num(prev_session->certs) !=
|
295
|
-
sk_CRYPTO_BUFFER_num(hs->new_session->certs)) {
|
300
|
+
if (sk_CRYPTO_BUFFER_num(prev_session->certs.get()) !=
|
301
|
+
sk_CRYPTO_BUFFER_num(hs->new_session->certs.get())) {
|
296
302
|
OPENSSL_PUT_ERROR(SSL, SSL_R_SERVER_CERT_CHANGED);
|
297
303
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
298
304
|
return ssl_verify_invalid;
|
299
305
|
}
|
300
306
|
|
301
|
-
for (size_t i = 0; i < sk_CRYPTO_BUFFER_num(hs->new_session->certs);
|
307
|
+
for (size_t i = 0; i < sk_CRYPTO_BUFFER_num(hs->new_session->certs.get());
|
308
|
+
i++) {
|
302
309
|
const CRYPTO_BUFFER *old_cert =
|
303
|
-
sk_CRYPTO_BUFFER_value(prev_session->certs, i);
|
310
|
+
sk_CRYPTO_BUFFER_value(prev_session->certs.get(), i);
|
304
311
|
const CRYPTO_BUFFER *new_cert =
|
305
|
-
sk_CRYPTO_BUFFER_value(hs->new_session->certs, i);
|
312
|
+
sk_CRYPTO_BUFFER_value(hs->new_session->certs.get(), i);
|
306
313
|
if (CRYPTO_BUFFER_len(old_cert) != CRYPTO_BUFFER_len(new_cert) ||
|
307
314
|
OPENSSL_memcmp(CRYPTO_BUFFER_data(old_cert),
|
308
315
|
CRYPTO_BUFFER_data(new_cert),
|
@@ -317,25 +324,24 @@ enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs) {
|
|
317
324
|
// certificate. Since we only authenticated the previous one, copy other
|
318
325
|
// authentication from the established session and ignore what was newly
|
319
326
|
// received.
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
prev_session->signed_cert_timestamp_list);
|
327
|
+
hs->new_session->ocsp_response = UpRef(prev_session->ocsp_response);
|
328
|
+
hs->new_session->signed_cert_timestamp_list =
|
329
|
+
UpRef(prev_session->signed_cert_timestamp_list);
|
324
330
|
hs->new_session->verify_result = prev_session->verify_result;
|
325
331
|
return ssl_verify_ok;
|
326
332
|
}
|
327
333
|
|
328
334
|
uint8_t alert = SSL_AD_CERTIFICATE_UNKNOWN;
|
329
335
|
enum ssl_verify_result_t ret;
|
330
|
-
if (
|
331
|
-
ret =
|
336
|
+
if (hs->config->custom_verify_callback != nullptr) {
|
337
|
+
ret = hs->config->custom_verify_callback(ssl, &alert);
|
332
338
|
switch (ret) {
|
333
339
|
case ssl_verify_ok:
|
334
340
|
hs->new_session->verify_result = X509_V_OK;
|
335
341
|
break;
|
336
342
|
case ssl_verify_invalid:
|
337
343
|
// If |SSL_VERIFY_NONE|, the error is non-fatal, but we keep the result.
|
338
|
-
if (
|
344
|
+
if (hs->config->verify_mode == SSL_VERIFY_NONE) {
|
339
345
|
ERR_clear_error();
|
340
346
|
ret = ssl_verify_ok;
|
341
347
|
}
|
@@ -346,7 +352,7 @@ enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs) {
|
|
346
352
|
}
|
347
353
|
} else {
|
348
354
|
ret = ssl->ctx->x509_method->session_verify_cert_chain(
|
349
|
-
hs->new_session.get(),
|
355
|
+
hs->new_session.get(), hs, &alert)
|
350
356
|
? ssl_verify_ok
|
351
357
|
: ssl_verify_invalid;
|
352
358
|
}
|
@@ -356,6 +362,48 @@ enum ssl_verify_result_t ssl_verify_peer_cert(SSL_HANDSHAKE *hs) {
|
|
356
362
|
ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
|
357
363
|
}
|
358
364
|
|
365
|
+
// Emulate OpenSSL's client OCSP callback. OpenSSL verifies certificates
|
366
|
+
// before it receives the OCSP, so it needs a second callback for OCSP.
|
367
|
+
if (ret == ssl_verify_ok && !ssl->server &&
|
368
|
+
hs->config->ocsp_stapling_enabled &&
|
369
|
+
ssl->ctx->legacy_ocsp_callback != nullptr) {
|
370
|
+
int cb_ret =
|
371
|
+
ssl->ctx->legacy_ocsp_callback(ssl, ssl->ctx->legacy_ocsp_callback_arg);
|
372
|
+
if (cb_ret <= 0) {
|
373
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_OCSP_CB_ERROR);
|
374
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL,
|
375
|
+
cb_ret == 0 ? SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE
|
376
|
+
: SSL_AD_INTERNAL_ERROR);
|
377
|
+
ret = ssl_verify_invalid;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
return ret;
|
382
|
+
}
|
383
|
+
|
384
|
+
// Verifies a stored certificate when resuming a session. A few things are
|
385
|
+
// different from verify_peer_cert:
|
386
|
+
// 1. We can't be renegotiating if we're resuming a session.
|
387
|
+
// 2. The session is immutable, so we don't support verify_mode ==
|
388
|
+
// SSL_VERIFY_NONE
|
389
|
+
// 3. We don't call the OCSP callback.
|
390
|
+
// 4. We only support custom verify callbacks.
|
391
|
+
enum ssl_verify_result_t ssl_reverify_peer_cert(SSL_HANDSHAKE *hs) {
|
392
|
+
SSL *const ssl = hs->ssl;
|
393
|
+
assert(ssl->s3->established_session == nullptr);
|
394
|
+
assert(hs->config->verify_mode != SSL_VERIFY_NONE);
|
395
|
+
|
396
|
+
uint8_t alert = SSL_AD_CERTIFICATE_UNKNOWN;
|
397
|
+
enum ssl_verify_result_t ret = ssl_verify_invalid;
|
398
|
+
if (hs->config->custom_verify_callback != nullptr) {
|
399
|
+
ret = hs->config->custom_verify_callback(ssl, &alert);
|
400
|
+
}
|
401
|
+
|
402
|
+
if (ret == ssl_verify_invalid) {
|
403
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_CERTIFICATE_VERIFY_FAILED);
|
404
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
|
405
|
+
}
|
406
|
+
|
359
407
|
return ret;
|
360
408
|
}
|
361
409
|
|
@@ -408,20 +456,18 @@ enum ssl_hs_wait_t ssl_get_finished(SSL_HANDSHAKE *hs) {
|
|
408
456
|
}
|
409
457
|
|
410
458
|
// Copy the Finished so we can use it for renegotiation checks.
|
411
|
-
if (ssl->
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
}
|
459
|
+
if (finished_len > sizeof(ssl->s3->previous_client_finished) ||
|
460
|
+
finished_len > sizeof(ssl->s3->previous_server_finished)) {
|
461
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
462
|
+
return ssl_hs_error;
|
463
|
+
}
|
417
464
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
}
|
465
|
+
if (ssl->server) {
|
466
|
+
OPENSSL_memcpy(ssl->s3->previous_client_finished, finished, finished_len);
|
467
|
+
ssl->s3->previous_client_finished_len = finished_len;
|
468
|
+
} else {
|
469
|
+
OPENSSL_memcpy(ssl->s3->previous_server_finished, finished, finished_len);
|
470
|
+
ssl->s3->previous_server_finished_len = finished_len;
|
425
471
|
}
|
426
472
|
|
427
473
|
ssl->method->next_message(ssl);
|
@@ -440,27 +486,25 @@ bool ssl_send_finished(SSL_HANDSHAKE *hs) {
|
|
440
486
|
}
|
441
487
|
|
442
488
|
// Log the master secret, if logging is enabled.
|
443
|
-
if (!ssl_log_secret(
|
444
|
-
|
445
|
-
|
489
|
+
if (!ssl_log_secret(
|
490
|
+
ssl, "CLIENT_RANDOM",
|
491
|
+
MakeConstSpan(session->master_key, session->master_key_length))) {
|
446
492
|
return 0;
|
447
493
|
}
|
448
494
|
|
449
495
|
// Copy the Finished so we can use it for renegotiation checks.
|
450
|
-
if (ssl->
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
}
|
496
|
+
if (finished_len > sizeof(ssl->s3->previous_client_finished) ||
|
497
|
+
finished_len > sizeof(ssl->s3->previous_server_finished)) {
|
498
|
+
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
499
|
+
return 0;
|
500
|
+
}
|
456
501
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
}
|
502
|
+
if (ssl->server) {
|
503
|
+
OPENSSL_memcpy(ssl->s3->previous_server_finished, finished, finished_len);
|
504
|
+
ssl->s3->previous_server_finished_len = finished_len;
|
505
|
+
} else {
|
506
|
+
OPENSSL_memcpy(ssl->s3->previous_client_finished, finished, finished_len);
|
507
|
+
ssl->s3->previous_client_finished_len = finished_len;
|
464
508
|
}
|
465
509
|
|
466
510
|
ScopedCBB cbb;
|
@@ -475,12 +519,13 @@ bool ssl_send_finished(SSL_HANDSHAKE *hs) {
|
|
475
519
|
return 1;
|
476
520
|
}
|
477
521
|
|
478
|
-
bool ssl_output_cert_chain(
|
522
|
+
bool ssl_output_cert_chain(SSL_HANDSHAKE *hs) {
|
479
523
|
ScopedCBB cbb;
|
480
524
|
CBB body;
|
481
|
-
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
482
|
-
|
483
|
-
!
|
525
|
+
if (!hs->ssl->method->init_message(hs->ssl, cbb.get(), &body,
|
526
|
+
SSL3_MT_CERTIFICATE) ||
|
527
|
+
!ssl_add_cert_chain(hs, &body) ||
|
528
|
+
!ssl_add_message_cbb(hs->ssl, cbb.get())) {
|
484
529
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
485
530
|
return false;
|
486
531
|
}
|
@@ -508,6 +553,16 @@ int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return) {
|
|
508
553
|
case ssl_hs_read_server_hello:
|
509
554
|
case ssl_hs_read_message:
|
510
555
|
case ssl_hs_read_change_cipher_spec: {
|
556
|
+
if (ssl->quic_method) {
|
557
|
+
hs->wait = ssl_hs_ok;
|
558
|
+
// The change cipher spec is omitted in QUIC.
|
559
|
+
if (hs->wait != ssl_hs_read_change_cipher_spec) {
|
560
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_READ;
|
561
|
+
return -1;
|
562
|
+
}
|
563
|
+
break;
|
564
|
+
}
|
565
|
+
|
511
566
|
uint8_t alert = SSL_AD_DECODE_ERROR;
|
512
567
|
size_t consumed = 0;
|
513
568
|
ssl_open_record_t ret;
|
@@ -556,47 +611,53 @@ int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return) {
|
|
556
611
|
}
|
557
612
|
|
558
613
|
case ssl_hs_certificate_selection_pending:
|
559
|
-
ssl->s3->rwstate =
|
614
|
+
ssl->s3->rwstate = SSL_ERROR_PENDING_CERTIFICATE;
|
560
615
|
hs->wait = ssl_hs_ok;
|
561
616
|
return -1;
|
562
617
|
|
563
618
|
case ssl_hs_handoff:
|
564
|
-
ssl->s3->rwstate =
|
619
|
+
ssl->s3->rwstate = SSL_ERROR_HANDOFF;
|
565
620
|
hs->wait = ssl_hs_ok;
|
566
621
|
return -1;
|
567
622
|
|
623
|
+
case ssl_hs_handback:
|
624
|
+
ssl->s3->rwstate = SSL_ERROR_HANDBACK;
|
625
|
+
hs->wait = ssl_hs_handback;
|
626
|
+
return -1;
|
627
|
+
|
568
628
|
case ssl_hs_x509_lookup:
|
569
|
-
ssl->s3->rwstate =
|
629
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_X509_LOOKUP;
|
570
630
|
hs->wait = ssl_hs_ok;
|
571
631
|
return -1;
|
572
632
|
|
573
633
|
case ssl_hs_channel_id_lookup:
|
574
|
-
ssl->s3->rwstate =
|
634
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_CHANNEL_ID_LOOKUP;
|
575
635
|
hs->wait = ssl_hs_ok;
|
576
636
|
return -1;
|
577
637
|
|
578
638
|
case ssl_hs_private_key_operation:
|
579
|
-
ssl->s3->rwstate =
|
639
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_PRIVATE_KEY_OPERATION;
|
580
640
|
hs->wait = ssl_hs_ok;
|
581
641
|
return -1;
|
582
642
|
|
583
643
|
case ssl_hs_pending_session:
|
584
|
-
ssl->s3->rwstate =
|
644
|
+
ssl->s3->rwstate = SSL_ERROR_PENDING_SESSION;
|
585
645
|
hs->wait = ssl_hs_ok;
|
586
646
|
return -1;
|
587
647
|
|
588
648
|
case ssl_hs_pending_ticket:
|
589
|
-
ssl->s3->rwstate =
|
649
|
+
ssl->s3->rwstate = SSL_ERROR_PENDING_TICKET;
|
590
650
|
hs->wait = ssl_hs_ok;
|
591
651
|
return -1;
|
592
652
|
|
593
653
|
case ssl_hs_certificate_verify:
|
594
|
-
ssl->s3->rwstate =
|
654
|
+
ssl->s3->rwstate = SSL_ERROR_WANT_CERTIFICATE_VERIFY;
|
595
655
|
hs->wait = ssl_hs_ok;
|
596
656
|
return -1;
|
597
657
|
|
598
658
|
case ssl_hs_early_data_rejected:
|
599
|
-
ssl->s3->
|
659
|
+
assert(ssl->s3->early_data_reason != ssl_early_data_unknown);
|
660
|
+
ssl->s3->rwstate = SSL_ERROR_EARLY_DATA_REJECTED;
|
600
661
|
// Cause |SSL_write| to start failing immediately.
|
601
662
|
hs->can_early_write = false;
|
602
663
|
return -1;
|
@@ -627,4 +688,4 @@ int ssl_run_handshake(SSL_HANDSHAKE *hs, bool *out_early_return) {
|
|
627
688
|
}
|
628
689
|
}
|
629
690
|
|
630
|
-
|
691
|
+
BSSL_NAMESPACE_END
|
@@ -166,22 +166,25 @@
|
|
166
166
|
#include <openssl/md5.h>
|
167
167
|
#include <openssl/mem.h>
|
168
168
|
#include <openssl/rand.h>
|
169
|
+
#include <openssl/sha.h>
|
169
170
|
|
170
171
|
#include "../crypto/internal.h"
|
171
172
|
#include "internal.h"
|
172
173
|
|
173
174
|
|
174
|
-
|
175
|
+
BSSL_NAMESPACE_BEGIN
|
175
176
|
|
176
177
|
enum ssl_client_hs_state_t {
|
177
178
|
state_start_connect = 0,
|
178
179
|
state_enter_early_data,
|
180
|
+
state_early_reverify_server_certificate,
|
179
181
|
state_read_hello_verify_request,
|
180
182
|
state_read_server_hello,
|
181
183
|
state_tls13,
|
182
184
|
state_read_server_certificate,
|
183
185
|
state_read_certificate_status,
|
184
186
|
state_verify_server_certificate,
|
187
|
+
state_reverify_server_certificate,
|
185
188
|
state_read_server_key_exchange,
|
186
189
|
state_read_certificate_request,
|
187
190
|
state_read_server_hello_done,
|
@@ -199,32 +202,32 @@ enum ssl_client_hs_state_t {
|
|
199
202
|
|
200
203
|
// ssl_get_client_disabled sets |*out_mask_a| and |*out_mask_k| to masks of
|
201
204
|
// disabled algorithms.
|
202
|
-
static void ssl_get_client_disabled(
|
205
|
+
static void ssl_get_client_disabled(SSL_HANDSHAKE *hs, uint32_t *out_mask_a,
|
203
206
|
uint32_t *out_mask_k) {
|
204
207
|
*out_mask_a = 0;
|
205
208
|
*out_mask_k = 0;
|
206
209
|
|
207
210
|
// PSK requires a client callback.
|
208
|
-
if (
|
211
|
+
if (hs->config->psk_client_callback == NULL) {
|
209
212
|
*out_mask_a |= SSL_aPSK;
|
210
213
|
*out_mask_k |= SSL_kPSK;
|
211
214
|
}
|
212
215
|
}
|
213
216
|
|
214
|
-
static
|
217
|
+
static bool ssl_write_client_cipher_list(SSL_HANDSHAKE *hs, CBB *out) {
|
215
218
|
SSL *const ssl = hs->ssl;
|
216
219
|
uint32_t mask_a, mask_k;
|
217
|
-
ssl_get_client_disabled(
|
220
|
+
ssl_get_client_disabled(hs, &mask_a, &mask_k);
|
218
221
|
|
219
222
|
CBB child;
|
220
223
|
if (!CBB_add_u16_length_prefixed(out, &child)) {
|
221
|
-
return
|
224
|
+
return false;
|
222
225
|
}
|
223
226
|
|
224
227
|
// Add a fake cipher suite. See draft-davidben-tls-grease-01.
|
225
228
|
if (ssl->ctx->grease_enabled &&
|
226
229
|
!CBB_add_u16(&child, ssl_get_grease_value(hs, ssl_grease_cipher))) {
|
227
|
-
return
|
230
|
+
return false;
|
228
231
|
}
|
229
232
|
|
230
233
|
// Add TLS 1.3 ciphers. Order ChaCha20-Poly1305 relative to AES-GCM based on
|
@@ -232,20 +235,20 @@ static int ssl_write_client_cipher_list(SSL_HANDSHAKE *hs, CBB *out) {
|
|
232
235
|
if (hs->max_version >= TLS1_3_VERSION) {
|
233
236
|
if (!EVP_has_aes_hardware() &&
|
234
237
|
!CBB_add_u16(&child, TLS1_CK_CHACHA20_POLY1305_SHA256 & 0xffff)) {
|
235
|
-
return
|
238
|
+
return false;
|
236
239
|
}
|
237
240
|
if (!CBB_add_u16(&child, TLS1_CK_AES_128_GCM_SHA256 & 0xffff) ||
|
238
241
|
!CBB_add_u16(&child, TLS1_CK_AES_256_GCM_SHA384 & 0xffff)) {
|
239
|
-
return
|
242
|
+
return false;
|
240
243
|
}
|
241
244
|
if (EVP_has_aes_hardware() &&
|
242
245
|
!CBB_add_u16(&child, TLS1_CK_CHACHA20_POLY1305_SHA256 & 0xffff)) {
|
243
|
-
return
|
246
|
+
return false;
|
244
247
|
}
|
245
248
|
}
|
246
249
|
|
247
250
|
if (hs->min_version < TLS1_3_VERSION) {
|
248
|
-
|
251
|
+
bool any_enabled = false;
|
249
252
|
for (const SSL_CIPHER *cipher : SSL_get_ciphers(ssl)) {
|
250
253
|
// Skip disabled ciphers
|
251
254
|
if ((cipher->algorithm_mkey & mask_k) ||
|
@@ -256,62 +259,53 @@ static int ssl_write_client_cipher_list(SSL_HANDSHAKE *hs, CBB *out) {
|
|
256
259
|
SSL_CIPHER_get_max_version(cipher) < hs->min_version) {
|
257
260
|
continue;
|
258
261
|
}
|
259
|
-
any_enabled =
|
262
|
+
any_enabled = true;
|
260
263
|
if (!CBB_add_u16(&child, ssl_cipher_get_value(cipher))) {
|
261
|
-
return
|
264
|
+
return false;
|
262
265
|
}
|
263
266
|
}
|
264
267
|
|
265
268
|
// If all ciphers were disabled, return the error to the caller.
|
266
269
|
if (!any_enabled && hs->max_version < TLS1_3_VERSION) {
|
267
270
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CIPHERS_AVAILABLE);
|
268
|
-
return
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
// For SSLv3, the SCSV is added. Otherwise the renegotiation extension is
|
273
|
-
// added.
|
274
|
-
if (hs->max_version == SSL3_VERSION &&
|
275
|
-
!ssl->s3->initial_handshake_complete) {
|
276
|
-
if (!CBB_add_u16(&child, SSL3_CK_SCSV & 0xffff)) {
|
277
|
-
return 0;
|
271
|
+
return false;
|
278
272
|
}
|
279
273
|
}
|
280
274
|
|
281
275
|
if (ssl->mode & SSL_MODE_SEND_FALLBACK_SCSV) {
|
282
276
|
if (!CBB_add_u16(&child, SSL3_CK_FALLBACK_SCSV & 0xffff)) {
|
283
|
-
return
|
277
|
+
return false;
|
284
278
|
}
|
285
279
|
}
|
286
280
|
|
287
281
|
return CBB_flush(out);
|
288
282
|
}
|
289
283
|
|
290
|
-
|
284
|
+
bool ssl_write_client_hello(SSL_HANDSHAKE *hs) {
|
291
285
|
SSL *const ssl = hs->ssl;
|
292
286
|
ScopedCBB cbb;
|
293
287
|
CBB body;
|
294
288
|
if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_CLIENT_HELLO)) {
|
295
|
-
return
|
289
|
+
return false;
|
296
290
|
}
|
297
291
|
|
298
292
|
CBB child;
|
299
293
|
if (!CBB_add_u16(&body, hs->client_version) ||
|
300
294
|
!CBB_add_bytes(&body, ssl->s3->client_random, SSL3_RANDOM_SIZE) ||
|
301
295
|
!CBB_add_u8_length_prefixed(&body, &child)) {
|
302
|
-
return
|
296
|
+
return false;
|
303
297
|
}
|
304
298
|
|
305
299
|
// Do not send a session ID on renegotiation.
|
306
300
|
if (!ssl->s3->initial_handshake_complete &&
|
307
301
|
!CBB_add_bytes(&child, hs->session_id, hs->session_id_len)) {
|
308
|
-
return
|
302
|
+
return false;
|
309
303
|
}
|
310
304
|
|
311
305
|
if (SSL_is_dtls(ssl)) {
|
312
306
|
if (!CBB_add_u8_length_prefixed(&body, &child) ||
|
313
307
|
!CBB_add_bytes(&child, ssl->d1->cookie, ssl->d1->cookie_len)) {
|
314
|
-
return
|
308
|
+
return false;
|
315
309
|
}
|
316
310
|
}
|
317
311
|
|
@@ -321,19 +315,19 @@ int ssl_write_client_hello(SSL_HANDSHAKE *hs) {
|
|
321
315
|
!CBB_add_u8(&body, 1 /* one compression method */) ||
|
322
316
|
!CBB_add_u8(&body, 0 /* null compression */) ||
|
323
317
|
!ssl_add_clienthello_tlsext(hs, &body, header_len + CBB_len(&body))) {
|
324
|
-
return
|
318
|
+
return false;
|
325
319
|
}
|
326
320
|
|
327
321
|
Array<uint8_t> msg;
|
328
322
|
if (!ssl->method->finish_message(ssl, cbb.get(), &msg)) {
|
329
|
-
return
|
323
|
+
return false;
|
330
324
|
}
|
331
325
|
|
332
326
|
// Now that the length prefixes have been computed, fill in the placeholder
|
333
327
|
// PSK binder.
|
334
328
|
if (hs->needs_psk_binder &&
|
335
|
-
!tls13_write_psk_binder(hs,
|
336
|
-
return
|
329
|
+
!tls13_write_psk_binder(hs, MakeSpan(msg))) {
|
330
|
+
return false;
|
337
331
|
}
|
338
332
|
|
339
333
|
return ssl->method->add_message(ssl, std::move(msg));
|
@@ -390,16 +384,10 @@ static enum ssl_hs_wait_t do_start_connect(SSL_HANDSHAKE *hs) {
|
|
390
384
|
ssl->s3->session_reused = false;
|
391
385
|
|
392
386
|
// Freeze the version range.
|
393
|
-
if (!ssl_get_version_range(
|
387
|
+
if (!ssl_get_version_range(hs, &hs->min_version, &hs->max_version)) {
|
394
388
|
return ssl_hs_error;
|
395
389
|
}
|
396
390
|
|
397
|
-
// SSL 3.0 ClientHellos should use SSL 3.0 not TLS 1.0, for the record-layer
|
398
|
-
// version.
|
399
|
-
if (hs->max_version == SSL3_VERSION) {
|
400
|
-
ssl->s3->aead_write_ctx->SetVersionIfNullCipher(SSL3_VERSION);
|
401
|
-
}
|
402
|
-
|
403
391
|
// Always advertise the ClientHello version from the original maximum version,
|
404
392
|
// even on renegotiation. The static RSA key exchange uses this field, and
|
405
393
|
// some servers fail when it changes across handshakes.
|
@@ -417,9 +405,9 @@ static enum ssl_hs_wait_t do_start_connect(SSL_HANDSHAKE *hs) {
|
|
417
405
|
if (ssl->session->is_server ||
|
418
406
|
!ssl_supports_version(hs, ssl->session->ssl_version) ||
|
419
407
|
(ssl->session->session_id_length == 0 &&
|
420
|
-
ssl->session->
|
408
|
+
ssl->session->ticket.empty()) ||
|
421
409
|
ssl->session->not_resumable ||
|
422
|
-
!ssl_session_is_time_valid(ssl, ssl->session)) {
|
410
|
+
!ssl_session_is_time_valid(ssl, ssl->session.get())) {
|
423
411
|
ssl_set_session(ssl, NULL);
|
424
412
|
}
|
425
413
|
}
|
@@ -428,8 +416,6 @@ static enum ssl_hs_wait_t do_start_connect(SSL_HANDSHAKE *hs) {
|
|
428
416
|
return ssl_hs_error;
|
429
417
|
}
|
430
418
|
|
431
|
-
// Initialize a random session ID for the experimental TLS 1.3 variant
|
432
|
-
// requiring a session id.
|
433
419
|
if (ssl->session != nullptr &&
|
434
420
|
!ssl->s3->initial_handshake_complete &&
|
435
421
|
ssl->session->session_id_length > 0) {
|
@@ -437,6 +423,7 @@ static enum ssl_hs_wait_t do_start_connect(SSL_HANDSHAKE *hs) {
|
|
437
423
|
OPENSSL_memcpy(hs->session_id, ssl->session->session_id,
|
438
424
|
hs->session_id_len);
|
439
425
|
} else if (hs->max_version >= TLS1_3_VERSION) {
|
426
|
+
// Initialize a random session ID.
|
440
427
|
hs->session_id_len = sizeof(hs->session_id);
|
441
428
|
if (!RAND_bytes(hs->session_id, hs->session_id_len)) {
|
442
429
|
return ssl_hs_error;
|
@@ -469,21 +456,41 @@ static enum ssl_hs_wait_t do_enter_early_data(SSL_HANDSHAKE *hs) {
|
|
469
456
|
return ssl_hs_error;
|
470
457
|
}
|
471
458
|
|
472
|
-
if (!tls13_init_early_key_schedule(
|
473
|
-
|
474
|
-
|
475
|
-
!
|
476
|
-
|
459
|
+
if (!tls13_init_early_key_schedule(
|
460
|
+
hs, MakeConstSpan(ssl->session->master_key,
|
461
|
+
ssl->session->master_key_length)) ||
|
462
|
+
!tls13_derive_early_secret(hs) ||
|
463
|
+
!tls13_set_early_secret_for_quic(hs)) {
|
464
|
+
return ssl_hs_error;
|
465
|
+
}
|
466
|
+
if (ssl->quic_method == nullptr &&
|
467
|
+
!tls13_set_traffic_key(ssl, ssl_encryption_early_data, evp_aead_seal,
|
468
|
+
hs->early_traffic_secret())) {
|
477
469
|
return ssl_hs_error;
|
478
470
|
}
|
479
471
|
|
480
472
|
// Stash the early data session, so connection properties may be queried out
|
481
473
|
// of it.
|
474
|
+
hs->early_session = UpRef(ssl->session);
|
475
|
+
hs->state = state_early_reverify_server_certificate;
|
476
|
+
return ssl_hs_ok;
|
477
|
+
}
|
478
|
+
|
479
|
+
static enum ssl_hs_wait_t do_early_reverify_server_certificate(SSL_HANDSHAKE *hs) {
|
480
|
+
if (hs->ssl->ctx->reverify_on_resume) {
|
481
|
+
switch (ssl_reverify_peer_cert(hs)) {
|
482
|
+
case ssl_verify_ok:
|
483
|
+
break;
|
484
|
+
case ssl_verify_invalid:
|
485
|
+
return ssl_hs_error;
|
486
|
+
case ssl_verify_retry:
|
487
|
+
hs->state = state_early_reverify_server_certificate;
|
488
|
+
return ssl_hs_certificate_verify;
|
489
|
+
}
|
490
|
+
}
|
491
|
+
|
482
492
|
hs->in_early_data = true;
|
483
|
-
SSL_SESSION_up_ref(ssl->session);
|
484
|
-
hs->early_session.reset(ssl->session);
|
485
493
|
hs->can_early_write = true;
|
486
|
-
|
487
494
|
hs->state = state_read_server_hello;
|
488
495
|
return ssl_hs_early_return;
|
489
496
|
}
|
@@ -587,12 +594,13 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
587
594
|
}
|
588
595
|
|
589
596
|
// Clear some TLS 1.3 state that no longer needs to be retained.
|
590
|
-
hs->
|
597
|
+
hs->key_shares[0].reset();
|
598
|
+
hs->key_shares[1].reset();
|
591
599
|
hs->key_share_bytes.Reset();
|
592
600
|
|
593
601
|
// A TLS 1.2 server would not know to skip the early data we offered. Report
|
594
602
|
// an error code sooner. The caller may use this error code to implement the
|
595
|
-
// fallback described in
|
603
|
+
// fallback described in RFC 8446 appendix D.3.
|
596
604
|
if (hs->early_data_offered) {
|
597
605
|
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_VERSION_ON_EARLY_DATA);
|
598
606
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_PROTOCOL_VERSION);
|
@@ -603,22 +611,30 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
603
611
|
OPENSSL_memcpy(ssl->s3->server_random, CBS_data(&server_random),
|
604
612
|
SSL3_RANDOM_SIZE);
|
605
613
|
|
606
|
-
//
|
607
|
-
// different value.
|
608
|
-
//
|
609
|
-
// For draft TLS 1.3 versions, it is not safe to deploy this feature. However,
|
610
|
-
// some TLS terminators are non-compliant and copy the origin server's value,
|
611
|
-
// so we wish to measure eventual compatibility impact.
|
614
|
+
// Enforce the TLS 1.3 anti-downgrade feature.
|
612
615
|
if (!ssl->s3->initial_handshake_complete &&
|
613
|
-
hs
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
616
|
+
ssl_supports_version(hs, TLS1_3_VERSION)) {
|
617
|
+
static_assert(
|
618
|
+
sizeof(kTLS12DowngradeRandom) == sizeof(kTLS13DowngradeRandom),
|
619
|
+
"downgrade signals have different size");
|
620
|
+
static_assert(
|
621
|
+
sizeof(kJDK11DowngradeRandom) == sizeof(kTLS13DowngradeRandom),
|
622
|
+
"downgrade signals have different size");
|
623
|
+
auto suffix =
|
624
|
+
MakeConstSpan(ssl->s3->server_random, sizeof(ssl->s3->server_random))
|
625
|
+
.subspan(SSL3_RANDOM_SIZE - sizeof(kTLS13DowngradeRandom));
|
626
|
+
if (suffix == kTLS12DowngradeRandom || suffix == kTLS13DowngradeRandom ||
|
627
|
+
suffix == kJDK11DowngradeRandom) {
|
628
|
+
ssl->s3->tls13_downgrade = true;
|
629
|
+
if (!hs->config->ignore_tls13_downgrade) {
|
630
|
+
OPENSSL_PUT_ERROR(SSL, SSL_R_TLS13_DOWNGRADE);
|
631
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
632
|
+
return ssl_hs_error;
|
633
|
+
}
|
634
|
+
}
|
619
635
|
}
|
620
636
|
|
621
|
-
if (!ssl->s3->initial_handshake_complete && ssl->session !=
|
637
|
+
if (!ssl->s3->initial_handshake_complete && ssl->session != nullptr &&
|
622
638
|
ssl->session->session_id_length != 0 &&
|
623
639
|
CBS_mem_equal(&session_id, ssl->session->session_id,
|
624
640
|
ssl->session->session_id_length)) {
|
@@ -659,7 +675,7 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
659
675
|
|
660
676
|
// The cipher must be allowed in the selected version and enabled.
|
661
677
|
uint32_t mask_a, mask_k;
|
662
|
-
ssl_get_client_disabled(
|
678
|
+
ssl_get_client_disabled(hs, &mask_a, &mask_k);
|
663
679
|
if ((cipher->algorithm_mkey & mask_k) || (cipher->algorithm_auth & mask_a) ||
|
664
680
|
SSL_CIPHER_get_min_version(cipher) > ssl_protocol_version(ssl) ||
|
665
681
|
SSL_CIPHER_get_max_version(cipher) < ssl_protocol_version(ssl) ||
|
@@ -680,7 +696,7 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
680
696
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
681
697
|
return ssl_hs_error;
|
682
698
|
}
|
683
|
-
if (!ssl_session_is_context_valid(
|
699
|
+
if (!ssl_session_is_context_valid(hs, ssl->session.get())) {
|
684
700
|
// This is actually a client application bug.
|
685
701
|
OPENSSL_PUT_ERROR(SSL,
|
686
702
|
SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT);
|
@@ -740,7 +756,7 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
740
756
|
return ssl_hs_error;
|
741
757
|
}
|
742
758
|
|
743
|
-
if (ssl->token_binding_negotiated &&
|
759
|
+
if (ssl->s3->token_binding_negotiated &&
|
744
760
|
(!hs->extended_master_secret || !ssl->s3->send_connection_binding)) {
|
745
761
|
OPENSSL_PUT_ERROR(SSL, SSL_R_NEGOTIATED_TB_WITHOUT_EMS_OR_RI);
|
746
762
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_UNSUPPORTED_EXTENSION);
|
@@ -750,7 +766,12 @@ static enum ssl_hs_wait_t do_read_server_hello(SSL_HANDSHAKE *hs) {
|
|
750
766
|
ssl->method->next_message(ssl);
|
751
767
|
|
752
768
|
if (ssl->session != NULL) {
|
753
|
-
|
769
|
+
if (ssl->ctx->reverify_on_resume &&
|
770
|
+
ssl_cipher_uses_certificate_auth(hs->new_cipher)) {
|
771
|
+
hs->state = state_reverify_server_certificate;
|
772
|
+
} else {
|
773
|
+
hs->state = state_read_session_ticket;
|
774
|
+
}
|
754
775
|
return ssl_hs_ok;
|
755
776
|
}
|
756
777
|
|
@@ -788,16 +809,13 @@ static enum ssl_hs_wait_t do_read_server_certificate(SSL_HANDSHAKE *hs) {
|
|
788
809
|
|
789
810
|
CBS body = msg.body;
|
790
811
|
uint8_t alert = SSL_AD_DECODE_ERROR;
|
791
|
-
|
792
|
-
|
793
|
-
ssl->ctx->pool)) {
|
812
|
+
if (!ssl_parse_cert_chain(&alert, &hs->new_session->certs, &hs->peer_pubkey,
|
813
|
+
NULL, &body, ssl->ctx->pool)) {
|
794
814
|
ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
|
795
815
|
return ssl_hs_error;
|
796
816
|
}
|
797
|
-
sk_CRYPTO_BUFFER_pop_free(hs->new_session->certs, CRYPTO_BUFFER_free);
|
798
|
-
hs->new_session->certs = chain.release();
|
799
817
|
|
800
|
-
if (sk_CRYPTO_BUFFER_num(hs->new_session->certs) == 0 ||
|
818
|
+
if (sk_CRYPTO_BUFFER_num(hs->new_session->certs.get()) == 0 ||
|
801
819
|
CBS_len(&body) != 0 ||
|
802
820
|
!ssl->ctx->x509_method->session_cache_objects(hs->new_session.get())) {
|
803
821
|
OPENSSL_PUT_ERROR(SSL, SSL_R_DECODE_ERROR);
|
@@ -807,7 +825,7 @@ static enum ssl_hs_wait_t do_read_server_certificate(SSL_HANDSHAKE *hs) {
|
|
807
825
|
|
808
826
|
if (!ssl_check_leaf_certificate(
|
809
827
|
hs, hs->peer_pubkey.get(),
|
810
|
-
sk_CRYPTO_BUFFER_value(hs->new_session->certs, 0))) {
|
828
|
+
sk_CRYPTO_BUFFER_value(hs->new_session->certs.get(), 0))) {
|
811
829
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
812
830
|
return ssl_hs_error;
|
813
831
|
}
|
@@ -854,9 +872,8 @@ static enum ssl_hs_wait_t do_read_certificate_status(SSL_HANDSHAKE *hs) {
|
|
854
872
|
return ssl_hs_error;
|
855
873
|
}
|
856
874
|
|
857
|
-
|
858
|
-
|
859
|
-
CRYPTO_BUFFER_new_from_CBS(&ocsp_response, ssl->ctx->pool);
|
875
|
+
hs->new_session->ocsp_response.reset(
|
876
|
+
CRYPTO_BUFFER_new_from_CBS(&ocsp_response, ssl->ctx->pool));
|
860
877
|
if (hs->new_session->ocsp_response == nullptr) {
|
861
878
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
862
879
|
return ssl_hs_error;
|
@@ -888,6 +905,23 @@ static enum ssl_hs_wait_t do_verify_server_certificate(SSL_HANDSHAKE *hs) {
|
|
888
905
|
return ssl_hs_ok;
|
889
906
|
}
|
890
907
|
|
908
|
+
static enum ssl_hs_wait_t do_reverify_server_certificate(SSL_HANDSHAKE *hs) {
|
909
|
+
assert(hs->ssl->ctx->reverify_on_resume);
|
910
|
+
|
911
|
+
switch (ssl_reverify_peer_cert(hs)) {
|
912
|
+
case ssl_verify_ok:
|
913
|
+
break;
|
914
|
+
case ssl_verify_invalid:
|
915
|
+
return ssl_hs_error;
|
916
|
+
case ssl_verify_retry:
|
917
|
+
hs->state = state_reverify_server_certificate;
|
918
|
+
return ssl_hs_certificate_verify;
|
919
|
+
}
|
920
|
+
|
921
|
+
hs->state = state_read_session_ticket;
|
922
|
+
return ssl_hs_ok;
|
923
|
+
}
|
924
|
+
|
891
925
|
static enum ssl_hs_wait_t do_read_server_key_exchange(SSL_HANDSHAKE *hs) {
|
892
926
|
SSL *const ssl = hs->ssl;
|
893
927
|
SSLMessage msg;
|
@@ -970,15 +1004,15 @@ static enum ssl_hs_wait_t do_read_server_key_exchange(SSL_HANDSHAKE *hs) {
|
|
970
1004
|
hs->new_session->group_id = group_id;
|
971
1005
|
|
972
1006
|
// Ensure the group is consistent with preferences.
|
973
|
-
if (!tls1_check_group_id(
|
1007
|
+
if (!tls1_check_group_id(hs, group_id)) {
|
974
1008
|
OPENSSL_PUT_ERROR(SSL, SSL_R_WRONG_CURVE);
|
975
1009
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);
|
976
1010
|
return ssl_hs_error;
|
977
1011
|
}
|
978
1012
|
|
979
1013
|
// Initialize ECDH and save the peer public key for later.
|
980
|
-
hs->
|
981
|
-
if (!hs->
|
1014
|
+
hs->key_shares[0] = SSLKeyShare::Create(group_id);
|
1015
|
+
if (!hs->key_shares[0] ||
|
982
1016
|
!hs->peer_key.CopyFrom(point)) {
|
983
1017
|
return ssl_hs_error;
|
984
1018
|
}
|
@@ -1042,13 +1076,8 @@ static enum ssl_hs_wait_t do_read_server_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1042
1076
|
return ssl_hs_error;
|
1043
1077
|
}
|
1044
1078
|
|
1045
|
-
|
1046
|
-
|
1047
|
-
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
|
1048
|
-
sig_ok = true;
|
1049
|
-
ERR_clear_error();
|
1050
|
-
#endif
|
1051
|
-
if (!sig_ok) {
|
1079
|
+
if (!ssl_public_key_verify(ssl, signature, signature_algorithm,
|
1080
|
+
hs->peer_pubkey.get(), transcript_data)) {
|
1052
1081
|
// bad signature
|
1053
1082
|
OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SIGNATURE);
|
1054
1083
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECRYPT_ERROR);
|
@@ -1176,8 +1205,8 @@ static enum ssl_hs_wait_t do_send_client_certificate(SSL_HANDSHAKE *hs) {
|
|
1176
1205
|
}
|
1177
1206
|
|
1178
1207
|
// Call cert_cb to update the certificate.
|
1179
|
-
if (
|
1180
|
-
int rv =
|
1208
|
+
if (hs->config->cert->cert_cb != NULL) {
|
1209
|
+
int rv = hs->config->cert->cert_cb(ssl, hs->config->cert->cert_cb_arg);
|
1181
1210
|
if (rv == 0) {
|
1182
1211
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
|
1183
1212
|
OPENSSL_PUT_ERROR(SSL, SSL_R_CERT_CB_ERROR);
|
@@ -1189,23 +1218,13 @@ static enum ssl_hs_wait_t do_send_client_certificate(SSL_HANDSHAKE *hs) {
|
|
1189
1218
|
}
|
1190
1219
|
}
|
1191
1220
|
|
1192
|
-
if (!ssl_has_certificate(
|
1221
|
+
if (!ssl_has_certificate(hs)) {
|
1193
1222
|
// Without a client certificate, the handshake buffer may be released.
|
1194
1223
|
hs->transcript.FreeBuffer();
|
1195
|
-
|
1196
|
-
// In SSL 3.0, the Certificate message is replaced with a warning alert.
|
1197
|
-
if (ssl->version == SSL3_VERSION) {
|
1198
|
-
if (!ssl->method->add_alert(ssl, SSL3_AL_WARNING,
|
1199
|
-
SSL_AD_NO_CERTIFICATE)) {
|
1200
|
-
return ssl_hs_error;
|
1201
|
-
}
|
1202
|
-
hs->state = state_send_client_key_exchange;
|
1203
|
-
return ssl_hs_ok;
|
1204
|
-
}
|
1205
1224
|
}
|
1206
1225
|
|
1207
1226
|
if (!ssl_on_certificate_selected(hs) ||
|
1208
|
-
!ssl_output_cert_chain(
|
1227
|
+
!ssl_output_cert_chain(hs)) {
|
1209
1228
|
return ssl_hs_error;
|
1210
1229
|
}
|
1211
1230
|
|
@@ -1229,21 +1248,42 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1229
1248
|
Array<uint8_t> pms;
|
1230
1249
|
uint32_t alg_k = hs->new_cipher->algorithm_mkey;
|
1231
1250
|
uint32_t alg_a = hs->new_cipher->algorithm_auth;
|
1251
|
+
if (ssl_cipher_uses_certificate_auth(hs->new_cipher)) {
|
1252
|
+
CRYPTO_BUFFER *leaf =
|
1253
|
+
sk_CRYPTO_BUFFER_value(hs->new_session->certs.get(), 0);
|
1254
|
+
CBS leaf_cbs;
|
1255
|
+
CBS_init(&leaf_cbs, CRYPTO_BUFFER_data(leaf), CRYPTO_BUFFER_len(leaf));
|
1256
|
+
|
1257
|
+
// Check the key usage matches the cipher suite. We do this unconditionally
|
1258
|
+
// for non-RSA certificates. In particular, it's needed to distinguish ECDH
|
1259
|
+
// certificates, which we do not support, from ECDSA certificates.
|
1260
|
+
// Historically, we have not checked RSA key usages, so it is controlled by
|
1261
|
+
// a flag for now. See https://crbug.com/795089.
|
1262
|
+
ssl_key_usage_t intended_use = (alg_k & SSL_kRSA)
|
1263
|
+
? key_usage_encipherment
|
1264
|
+
: key_usage_digital_signature;
|
1265
|
+
if (ssl->config->enforce_rsa_key_usage ||
|
1266
|
+
EVP_PKEY_id(hs->peer_pubkey.get()) != EVP_PKEY_RSA) {
|
1267
|
+
if (!ssl_cert_check_key_usage(&leaf_cbs, intended_use)) {
|
1268
|
+
return ssl_hs_error;
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
}
|
1232
1272
|
|
1233
1273
|
// If using a PSK key exchange, prepare the pre-shared key.
|
1234
1274
|
unsigned psk_len = 0;
|
1235
1275
|
uint8_t psk[PSK_MAX_PSK_LEN];
|
1236
1276
|
if (alg_a & SSL_aPSK) {
|
1237
|
-
if (
|
1277
|
+
if (hs->config->psk_client_callback == NULL) {
|
1238
1278
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_NO_CLIENT_CB);
|
1239
1279
|
return ssl_hs_error;
|
1240
1280
|
}
|
1241
1281
|
|
1242
1282
|
char identity[PSK_MAX_IDENTITY_LEN + 1];
|
1243
1283
|
OPENSSL_memset(identity, 0, sizeof(identity));
|
1244
|
-
psk_len =
|
1245
|
-
ssl
|
1246
|
-
|
1284
|
+
psk_len = hs->config->psk_client_callback(
|
1285
|
+
ssl, hs->peer_psk_identity_hint.get(), identity, sizeof(identity), psk,
|
1286
|
+
sizeof(psk));
|
1247
1287
|
if (psk_len == 0) {
|
1248
1288
|
OPENSSL_PUT_ERROR(SSL, SSL_R_PSK_IDENTITY_NOT_FOUND);
|
1249
1289
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
@@ -1251,9 +1291,8 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1251
1291
|
}
|
1252
1292
|
assert(psk_len <= PSK_MAX_PSK_LEN);
|
1253
1293
|
|
1254
|
-
|
1255
|
-
hs->new_session->psk_identity
|
1256
|
-
if (hs->new_session->psk_identity == NULL) {
|
1294
|
+
hs->new_session->psk_identity.reset(BUF_strdup(identity));
|
1295
|
+
if (hs->new_session->psk_identity == nullptr) {
|
1257
1296
|
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
1258
1297
|
return ssl_hs_error;
|
1259
1298
|
}
|
@@ -1286,21 +1325,14 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1286
1325
|
return ssl_hs_error;
|
1287
1326
|
}
|
1288
1327
|
|
1289
|
-
CBB
|
1290
|
-
size_t enc_pms_len;
|
1291
|
-
// In TLS, there is a length prefix.
|
1292
|
-
if (ssl->version > SSL3_VERSION) {
|
1293
|
-
if (!CBB_add_u16_length_prefixed(&body, &child)) {
|
1294
|
-
return ssl_hs_error;
|
1295
|
-
}
|
1296
|
-
enc_pms = &child;
|
1297
|
-
}
|
1298
|
-
|
1328
|
+
CBB enc_pms;
|
1299
1329
|
uint8_t *ptr;
|
1300
|
-
|
1330
|
+
size_t enc_pms_len;
|
1331
|
+
if (!CBB_add_u16_length_prefixed(&body, &enc_pms) ||
|
1332
|
+
!CBB_reserve(&enc_pms, &ptr, RSA_size(rsa)) ||
|
1301
1333
|
!RSA_encrypt(rsa, &enc_pms_len, ptr, RSA_size(rsa), pms.data(),
|
1302
1334
|
pms.size(), RSA_PKCS1_PADDING) ||
|
1303
|
-
!CBB_did_write(enc_pms, enc_pms_len) ||
|
1335
|
+
!CBB_did_write(&enc_pms, enc_pms_len) ||
|
1304
1336
|
!CBB_flush(&body)) {
|
1305
1337
|
return ssl_hs_error;
|
1306
1338
|
}
|
@@ -1313,7 +1345,7 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1313
1345
|
|
1314
1346
|
// Compute the premaster.
|
1315
1347
|
uint8_t alert = SSL_AD_DECODE_ERROR;
|
1316
|
-
if (!hs->
|
1348
|
+
if (!hs->key_shares[0]->Accept(&child, &pms, &alert, hs->peer_key)) {
|
1317
1349
|
ssl_send_alert(ssl, SSL3_AL_FATAL, alert);
|
1318
1350
|
return ssl_hs_error;
|
1319
1351
|
}
|
@@ -1322,7 +1354,8 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1322
1354
|
}
|
1323
1355
|
|
1324
1356
|
// The key exchange state may now be discarded.
|
1325
|
-
hs->
|
1357
|
+
hs->key_shares[0].reset();
|
1358
|
+
hs->key_shares[1].reset();
|
1326
1359
|
hs->peer_key.Reset();
|
1327
1360
|
} else if (alg_k & SSL_kPSK) {
|
1328
1361
|
// For plain PSK, other_secret is a block of 0s with the same length as
|
@@ -1373,12 +1406,12 @@ static enum ssl_hs_wait_t do_send_client_key_exchange(SSL_HANDSHAKE *hs) {
|
|
1373
1406
|
static enum ssl_hs_wait_t do_send_client_certificate_verify(SSL_HANDSHAKE *hs) {
|
1374
1407
|
SSL *const ssl = hs->ssl;
|
1375
1408
|
|
1376
|
-
if (!hs->cert_request || !ssl_has_certificate(
|
1409
|
+
if (!hs->cert_request || !ssl_has_certificate(hs)) {
|
1377
1410
|
hs->state = state_send_client_finished;
|
1378
1411
|
return ssl_hs_ok;
|
1379
1412
|
}
|
1380
1413
|
|
1381
|
-
assert(ssl_has_private_key(
|
1414
|
+
assert(ssl_has_private_key(hs));
|
1382
1415
|
ScopedCBB cbb;
|
1383
1416
|
CBB body, child;
|
1384
1417
|
if (!ssl->method->init_message(ssl, cbb.get(), &body,
|
@@ -1388,6 +1421,7 @@ static enum ssl_hs_wait_t do_send_client_certificate_verify(SSL_HANDSHAKE *hs) {
|
|
1388
1421
|
|
1389
1422
|
uint16_t signature_algorithm;
|
1390
1423
|
if (!tls1_choose_signature_algorithm(hs, &signature_algorithm)) {
|
1424
|
+
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
|
1391
1425
|
return ssl_hs_error;
|
1392
1426
|
}
|
1393
1427
|
if (ssl_protocol_version(ssl) >= TLS1_2_VERSION) {
|
@@ -1407,39 +1441,16 @@ static enum ssl_hs_wait_t do_send_client_certificate_verify(SSL_HANDSHAKE *hs) {
|
|
1407
1441
|
}
|
1408
1442
|
|
1409
1443
|
size_t sig_len = max_sig_len;
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
}
|
1417
|
-
|
1418
|
-
uint8_t digest[EVP_MAX_MD_SIZE];
|
1419
|
-
size_t digest_len;
|
1420
|
-
if (!hs->transcript.GetSSL3CertVerifyHash(
|
1421
|
-
digest, &digest_len, hs->new_session.get(), signature_algorithm)) {
|
1422
|
-
return ssl_hs_error;
|
1423
|
-
}
|
1424
|
-
|
1425
|
-
UniquePtr<EVP_PKEY_CTX> pctx(EVP_PKEY_CTX_new(ssl->cert->privatekey, NULL));
|
1426
|
-
if (!pctx ||
|
1427
|
-
!EVP_PKEY_sign_init(pctx.get()) ||
|
1428
|
-
!EVP_PKEY_sign(pctx.get(), ptr, &sig_len, digest, digest_len)) {
|
1444
|
+
switch (ssl_private_key_sign(hs, ptr, &sig_len, max_sig_len,
|
1445
|
+
signature_algorithm,
|
1446
|
+
hs->transcript.buffer())) {
|
1447
|
+
case ssl_private_key_success:
|
1448
|
+
break;
|
1449
|
+
case ssl_private_key_failure:
|
1429
1450
|
return ssl_hs_error;
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
signature_algorithm,
|
1434
|
-
hs->transcript.buffer())) {
|
1435
|
-
case ssl_private_key_success:
|
1436
|
-
break;
|
1437
|
-
case ssl_private_key_failure:
|
1438
|
-
return ssl_hs_error;
|
1439
|
-
case ssl_private_key_retry:
|
1440
|
-
hs->state = state_send_client_certificate_verify;
|
1441
|
-
return ssl_hs_private_key_operation;
|
1442
|
-
}
|
1451
|
+
case ssl_private_key_retry:
|
1452
|
+
hs->state = state_send_client_certificate_verify;
|
1453
|
+
return ssl_hs_private_key_operation;
|
1443
1454
|
}
|
1444
1455
|
|
1445
1456
|
if (!CBB_did_write(&child, sig_len) ||
|
@@ -1457,12 +1468,12 @@ static enum ssl_hs_wait_t do_send_client_certificate_verify(SSL_HANDSHAKE *hs) {
|
|
1457
1468
|
static enum ssl_hs_wait_t do_send_client_finished(SSL_HANDSHAKE *hs) {
|
1458
1469
|
SSL *const ssl = hs->ssl;
|
1459
1470
|
// Resolve Channel ID first, before any non-idempotent operations.
|
1460
|
-
if (ssl->s3->
|
1461
|
-
if (!ssl_do_channel_id_callback(
|
1471
|
+
if (ssl->s3->channel_id_valid) {
|
1472
|
+
if (!ssl_do_channel_id_callback(hs)) {
|
1462
1473
|
return ssl_hs_error;
|
1463
1474
|
}
|
1464
1475
|
|
1465
|
-
if (
|
1476
|
+
if (hs->config->channel_id_private == NULL) {
|
1466
1477
|
hs->state = state_send_client_finished;
|
1467
1478
|
return ssl_hs_channel_id_lookup;
|
1468
1479
|
}
|
@@ -1492,7 +1503,7 @@ static enum ssl_hs_wait_t do_send_client_finished(SSL_HANDSHAKE *hs) {
|
|
1492
1503
|
}
|
1493
1504
|
}
|
1494
1505
|
|
1495
|
-
if (ssl->s3->
|
1506
|
+
if (ssl->s3->channel_id_valid) {
|
1496
1507
|
ScopedCBB cbb;
|
1497
1508
|
CBB body;
|
1498
1509
|
if (!ssl->method->init_message(ssl, cbb.get(), &body, SSL3_MT_CHANNEL_ID) ||
|
@@ -1514,18 +1525,32 @@ static enum ssl_hs_wait_t do_send_client_finished(SSL_HANDSHAKE *hs) {
|
|
1514
1525
|
static bool can_false_start(const SSL_HANDSHAKE *hs) {
|
1515
1526
|
SSL *const ssl = hs->ssl;
|
1516
1527
|
|
1517
|
-
// False Start
|
1528
|
+
// False Start bypasses the Finished check's downgrade protection. This can
|
1529
|
+
// enable attacks where we send data under weaker settings than supported
|
1530
|
+
// (e.g. the Logjam attack). Thus we require TLS 1.2 with an ECDHE+AEAD
|
1531
|
+
// cipher, our strongest settings before TLS 1.3.
|
1532
|
+
//
|
1533
|
+
// Now that TLS 1.3 exists, we would like to avoid similar attacks between
|
1534
|
+
// TLS 1.2 and TLS 1.3, but there are too many TLS 1.2 deployments to
|
1535
|
+
// sacrifice False Start on them. TLS 1.3's downgrade signal fixes this, but
|
1536
|
+
// |SSL_CTX_set_ignore_tls13_downgrade| can disable it due to compatibility
|
1537
|
+
// issues.
|
1538
|
+
//
|
1539
|
+
// |SSL_CTX_set_ignore_tls13_downgrade| normally still retains Finished-based
|
1540
|
+
// downgrade protection, but False Start bypasses that. Thus, we disable False
|
1541
|
+
// Start based on the TLS 1.3 downgrade signal, even if otherwise unenforced.
|
1518
1542
|
if (SSL_is_dtls(ssl) ||
|
1519
1543
|
SSL_version(ssl) != TLS1_2_VERSION ||
|
1520
1544
|
hs->new_cipher->algorithm_mkey != SSL_kECDHE ||
|
1521
|
-
hs->new_cipher->algorithm_mac != SSL_AEAD
|
1545
|
+
hs->new_cipher->algorithm_mac != SSL_AEAD ||
|
1546
|
+
ssl->s3->tls13_downgrade) {
|
1522
1547
|
return false;
|
1523
1548
|
}
|
1524
1549
|
|
1525
1550
|
// Additionally require ALPN or NPN by default.
|
1526
1551
|
//
|
1527
1552
|
// TODO(davidben): Can this constraint be relaxed globally now that cipher
|
1528
|
-
// suite requirements have been
|
1553
|
+
// suite requirements have been tightened?
|
1529
1554
|
if (!ssl->ctx->false_start_allowed_without_alpn &&
|
1530
1555
|
ssl->s3->alpn_selected.empty() &&
|
1531
1556
|
ssl->s3->next_proto_negotiated.empty()) {
|
@@ -1582,8 +1607,8 @@ static enum ssl_hs_wait_t do_read_session_ticket(SSL_HANDSHAKE *hs) {
|
|
1582
1607
|
}
|
1583
1608
|
|
1584
1609
|
CBS new_session_ticket = msg.body, ticket;
|
1585
|
-
uint32_t
|
1586
|
-
if (!CBS_get_u32(&new_session_ticket, &
|
1610
|
+
uint32_t ticket_lifetime_hint;
|
1611
|
+
if (!CBS_get_u32(&new_session_ticket, &ticket_lifetime_hint) ||
|
1587
1612
|
!CBS_get_u16_length_prefixed(&new_session_ticket, &ticket) ||
|
1588
1613
|
CBS_len(&new_session_ticket) != 0) {
|
1589
1614
|
ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR);
|
@@ -1608,7 +1633,7 @@ static enum ssl_hs_wait_t do_read_session_ticket(SSL_HANDSHAKE *hs) {
|
|
1608
1633
|
// immutable once established, so duplicate all but the ticket of the
|
1609
1634
|
// existing session.
|
1610
1635
|
renewed_session =
|
1611
|
-
SSL_SESSION_dup(ssl->session, SSL_SESSION_INCLUDE_NONAUTH);
|
1636
|
+
SSL_SESSION_dup(ssl->session.get(), SSL_SESSION_INCLUDE_NONAUTH);
|
1612
1637
|
if (!renewed_session) {
|
1613
1638
|
// This should never happen.
|
1614
1639
|
OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
|
@@ -1617,28 +1642,23 @@ static enum ssl_hs_wait_t do_read_session_ticket(SSL_HANDSHAKE *hs) {
|
|
1617
1642
|
session = renewed_session.get();
|
1618
1643
|
}
|
1619
1644
|
|
1620
|
-
// |
|
1645
|
+
// |ticket_lifetime_hint| is measured from when the ticket was issued.
|
1621
1646
|
ssl_session_rebase_time(ssl, session);
|
1622
1647
|
|
1623
|
-
if (!
|
1624
|
-
OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
|
1648
|
+
if (!session->ticket.CopyFrom(ticket)) {
|
1625
1649
|
return ssl_hs_error;
|
1626
1650
|
}
|
1627
|
-
session->
|
1651
|
+
session->ticket_lifetime_hint = ticket_lifetime_hint;
|
1628
1652
|
|
1629
|
-
// Generate a session ID for this session
|
1630
|
-
//
|
1631
|
-
//
|
1632
|
-
|
1633
|
-
|
1634
|
-
EVP_sha256(), NULL)) {
|
1635
|
-
return ssl_hs_error;
|
1636
|
-
}
|
1653
|
+
// Generate a session ID for this session. Some callers expect all sessions to
|
1654
|
+
// have a session ID. Additionally, it acts as the session ID to signal
|
1655
|
+
// resumption.
|
1656
|
+
SHA256(CBS_data(&ticket), CBS_len(&ticket), session->session_id);
|
1657
|
+
session->session_id_length = SHA256_DIGEST_LENGTH;
|
1637
1658
|
|
1638
1659
|
if (renewed_session) {
|
1639
|
-
session->not_resumable =
|
1640
|
-
|
1641
|
-
ssl->session = renewed_session.release();
|
1660
|
+
session->not_resumable = false;
|
1661
|
+
ssl->session = std::move(renewed_session);
|
1642
1662
|
}
|
1643
1663
|
|
1644
1664
|
ssl->method->next_message(ssl);
|
@@ -1677,8 +1697,7 @@ static enum ssl_hs_wait_t do_finish_client_handshake(SSL_HANDSHAKE *hs) {
|
|
1677
1697
|
ssl->method->on_handshake_complete(ssl);
|
1678
1698
|
|
1679
1699
|
if (ssl->session != NULL) {
|
1680
|
-
|
1681
|
-
ssl->s3->established_session.reset(ssl->session);
|
1700
|
+
ssl->s3->established_session = UpRef(ssl->session);
|
1682
1701
|
} else {
|
1683
1702
|
// We make a copy of the session in order to maintain the immutability
|
1684
1703
|
// of the new established_session due to False Start. The caller may
|
@@ -1690,7 +1709,7 @@ static enum ssl_hs_wait_t do_finish_client_handshake(SSL_HANDSHAKE *hs) {
|
|
1690
1709
|
}
|
1691
1710
|
// Renegotiations do not participate in session resumption.
|
1692
1711
|
if (!ssl->s3->initial_handshake_complete) {
|
1693
|
-
ssl->s3->established_session->not_resumable =
|
1712
|
+
ssl->s3->established_session->not_resumable = false;
|
1694
1713
|
}
|
1695
1714
|
|
1696
1715
|
hs->new_session.reset();
|
@@ -1716,6 +1735,9 @@ enum ssl_hs_wait_t ssl_client_handshake(SSL_HANDSHAKE *hs) {
|
|
1716
1735
|
case state_enter_early_data:
|
1717
1736
|
ret = do_enter_early_data(hs);
|
1718
1737
|
break;
|
1738
|
+
case state_early_reverify_server_certificate:
|
1739
|
+
ret = do_early_reverify_server_certificate(hs);
|
1740
|
+
break;
|
1719
1741
|
case state_read_hello_verify_request:
|
1720
1742
|
ret = do_read_hello_verify_request(hs);
|
1721
1743
|
break;
|
@@ -1734,6 +1756,9 @@ enum ssl_hs_wait_t ssl_client_handshake(SSL_HANDSHAKE *hs) {
|
|
1734
1756
|
case state_verify_server_certificate:
|
1735
1757
|
ret = do_verify_server_certificate(hs);
|
1736
1758
|
break;
|
1759
|
+
case state_reverify_server_certificate:
|
1760
|
+
ret = do_reverify_server_certificate(hs);
|
1761
|
+
break;
|
1737
1762
|
case state_read_server_key_exchange:
|
1738
1763
|
ret = do_read_server_key_exchange(hs);
|
1739
1764
|
break;
|
@@ -1796,6 +1821,8 @@ const char *ssl_client_handshake_state(SSL_HANDSHAKE *hs) {
|
|
1796
1821
|
return "TLS client start_connect";
|
1797
1822
|
case state_enter_early_data:
|
1798
1823
|
return "TLS client enter_early_data";
|
1824
|
+
case state_early_reverify_server_certificate:
|
1825
|
+
return "TLS client early_reverify_server_certificate";
|
1799
1826
|
case state_read_hello_verify_request:
|
1800
1827
|
return "TLS client read_hello_verify_request";
|
1801
1828
|
case state_read_server_hello:
|
@@ -1808,6 +1835,8 @@ const char *ssl_client_handshake_state(SSL_HANDSHAKE *hs) {
|
|
1808
1835
|
return "TLS client read_certificate_status";
|
1809
1836
|
case state_verify_server_certificate:
|
1810
1837
|
return "TLS client verify_server_certificate";
|
1838
|
+
case state_reverify_server_certificate:
|
1839
|
+
return "TLS client reverify_server_certificate";
|
1811
1840
|
case state_read_server_key_exchange:
|
1812
1841
|
return "TLS client read_server_key_exchange";
|
1813
1842
|
case state_read_certificate_request:
|
@@ -1839,4 +1868,4 @@ const char *ssl_client_handshake_state(SSL_HANDSHAKE *hs) {
|
|
1839
1868
|
return "TLS client unknown";
|
1840
1869
|
}
|
1841
1870
|
|
1842
|
-
|
1871
|
+
BSSL_NAMESPACE_END
|