grpc 1.24.0 → 1.25.0
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/ev_poll_posix.cc +3 -1
- 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 +72 -44
- 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
@@ -54,10 +54,11 @@
|
|
54
54
|
#include "internal.h"
|
55
55
|
|
56
56
|
|
57
|
-
|
57
|
+
OPENSSL_STATIC_ASSERT(16 % sizeof(size_t) == 0,
|
58
|
+
"block cannot be divided into size_t");
|
58
59
|
|
59
60
|
void CRYPTO_ofb128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
|
60
|
-
const
|
61
|
+
const AES_KEY *key, uint8_t ivec[16], unsigned *num,
|
61
62
|
block128_f block) {
|
62
63
|
assert(in && out && key && ivec && num);
|
63
64
|
|
@@ -64,8 +64,8 @@ int CTR_DRBG_init(CTR_DRBG_STATE *drbg,
|
|
64
64
|
return 1;
|
65
65
|
}
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
OPENSSL_STATIC_ASSERT(CTR_DRBG_ENTROPY_LEN % AES_BLOCK_SIZE == 0,
|
68
|
+
"not a multiple of AES block size");
|
69
69
|
|
70
70
|
// ctr_inc adds |n| to the last four bytes of |drbg->counter|, treated as a
|
71
71
|
// big-endian number.
|
@@ -16,6 +16,7 @@
|
|
16
16
|
#define OPENSSL_HEADER_CRYPTO_RAND_INTERNAL_H
|
17
17
|
|
18
18
|
#include <openssl/aes.h>
|
19
|
+
#include <openssl/cpu.h>
|
19
20
|
|
20
21
|
#include "../../internal.h"
|
21
22
|
#include "../modes/internal.h"
|
@@ -25,6 +26,11 @@ extern "C" {
|
|
25
26
|
#endif
|
26
27
|
|
27
28
|
|
29
|
+
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_FUCHSIA) && \
|
30
|
+
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && !defined(OPENSSL_TRUSTY)
|
31
|
+
#define OPENSSL_URANDOM
|
32
|
+
#endif
|
33
|
+
|
28
34
|
// RAND_bytes_with_additional_data samples from the RNG after mixing 32 bytes
|
29
35
|
// from |user_additional_data| in.
|
30
36
|
void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
@@ -34,6 +40,19 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
|
34
40
|
// system.
|
35
41
|
void CRYPTO_sysrand(uint8_t *buf, size_t len);
|
36
42
|
|
43
|
+
#if defined(OPENSSL_URANDOM) || defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
44
|
+
// CRYPTO_sysrand_for_seed fills |len| bytes at |buf| with entropy from the
|
45
|
+
// operating system. It may draw from the |GRND_RANDOM| pool on Android,
|
46
|
+
// depending on the vendor's configuration.
|
47
|
+
void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len);
|
48
|
+
|
49
|
+
// CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the
|
50
|
+
// operating system, if the entropy pool is initialized. If it is uninitialized,
|
51
|
+
// it will not block and will instead fill |buf| with all zeros or early
|
52
|
+
// /dev/urandom output.
|
53
|
+
void CRYPTO_sysrand_if_available(uint8_t *buf, size_t len);
|
54
|
+
#endif
|
55
|
+
|
37
56
|
// rand_fork_unsafe_buffering_enabled returns whether fork-unsafe buffering has
|
38
57
|
// been enabled via |RAND_enable_fork_unsafe_buffering|.
|
39
58
|
int rand_fork_unsafe_buffering_enabled(void);
|
@@ -85,6 +104,22 @@ OPENSSL_EXPORT int CTR_DRBG_generate(CTR_DRBG_STATE *drbg, uint8_t *out,
|
|
85
104
|
OPENSSL_EXPORT void CTR_DRBG_clear(CTR_DRBG_STATE *drbg);
|
86
105
|
|
87
106
|
|
107
|
+
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM)
|
108
|
+
OPENSSL_INLINE int have_rdrand(void) {
|
109
|
+
return (OPENSSL_ia32cap_get()[1] & (1u << 30)) != 0;
|
110
|
+
}
|
111
|
+
|
112
|
+
// CRYPTO_rdrand writes eight bytes of random data from the hardware RNG to
|
113
|
+
// |out|. It returns one on success or zero on hardware failure.
|
114
|
+
int CRYPTO_rdrand(uint8_t out[8]);
|
115
|
+
|
116
|
+
// CRYPTO_rdrand_multiple8_buf fills |len| bytes at |buf| with random data from
|
117
|
+
// the hardware RNG. The |len| argument must be a multiple of eight. It returns
|
118
|
+
// one on success and zero on hardware failure.
|
119
|
+
int CRYPTO_rdrand_multiple8_buf(uint8_t *buf, size_t len);
|
120
|
+
#endif // OPENSSL_X86_64 && !OPENSSL_NO_ASM
|
121
|
+
|
122
|
+
|
88
123
|
#if defined(__cplusplus)
|
89
124
|
} // extern C
|
90
125
|
#endif
|
@@ -32,9 +32,9 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
// It's assumed that the operating system always has an unfailing source of
|
35
|
-
// entropy which is accessed via |CRYPTO_sysrand|. (If the operating
|
36
|
-
// entropy source fails, it's up to |CRYPTO_sysrand| to abort the
|
37
|
-
// don't try to handle it.)
|
35
|
+
// entropy which is accessed via |CRYPTO_sysrand[_for_seed]|. (If the operating
|
36
|
+
// system entropy source fails, it's up to |CRYPTO_sysrand| to abort the
|
37
|
+
// process—we don't try to handle it.)
|
38
38
|
//
|
39
39
|
// In addition, the hardware may provide a low-latency RNG. Intel's rdrand
|
40
40
|
// instruction is the canonical example of this. When a hardware RNG is
|
@@ -61,11 +61,11 @@ struct rand_thread_state {
|
|
61
61
|
// (re)seeded. This is bound by |kReseedInterval|.
|
62
62
|
unsigned calls;
|
63
63
|
// last_block_valid is non-zero iff |last_block| contains data from
|
64
|
-
// |
|
64
|
+
// |CRYPTO_sysrand_for_seed|.
|
65
65
|
int last_block_valid;
|
66
66
|
|
67
67
|
#if defined(BORINGSSL_FIPS)
|
68
|
-
// last_block contains the previous block from |
|
68
|
+
// last_block contains the previous block from |CRYPTO_sysrand_for_seed|.
|
69
69
|
uint8_t last_block[CRNGT_BLOCK_SIZE];
|
70
70
|
// next and prev form a NULL-terminated, double-linked list of all states in
|
71
71
|
// a process.
|
@@ -125,15 +125,6 @@ static void rand_thread_state_free(void *state_in) {
|
|
125
125
|
|
126
126
|
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) && \
|
127
127
|
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
128
|
-
|
129
|
-
// These functions are defined in asm/rdrand-x86_64.pl
|
130
|
-
extern int CRYPTO_rdrand(uint8_t out[8]);
|
131
|
-
extern int CRYPTO_rdrand_multiple8_buf(uint8_t *buf, size_t len);
|
132
|
-
|
133
|
-
static int have_rdrand(void) {
|
134
|
-
return (OPENSSL_ia32cap_get()[1] & (1u << 30)) != 0;
|
135
|
-
}
|
136
|
-
|
137
128
|
static int hwrand(uint8_t *buf, const size_t len) {
|
138
129
|
if (!have_rdrand()) {
|
139
130
|
return 0;
|
@@ -178,7 +169,7 @@ static void rand_get_seed(struct rand_thread_state *state,
|
|
178
169
|
uint8_t seed[CTR_DRBG_ENTROPY_LEN]) {
|
179
170
|
if (!state->last_block_valid) {
|
180
171
|
if (!hwrand(state->last_block, sizeof(state->last_block))) {
|
181
|
-
|
172
|
+
CRYPTO_sysrand_for_seed(state->last_block, sizeof(state->last_block));
|
182
173
|
}
|
183
174
|
state->last_block_valid = 1;
|
184
175
|
}
|
@@ -188,15 +179,16 @@ static void rand_get_seed(struct rand_thread_state *state,
|
|
188
179
|
#define FIPS_OVERREAD 10
|
189
180
|
uint8_t entropy[CTR_DRBG_ENTROPY_LEN * FIPS_OVERREAD];
|
190
181
|
|
191
|
-
|
192
|
-
|
182
|
+
int used_hwrand = hwrand(entropy, sizeof(entropy));
|
183
|
+
if (!used_hwrand) {
|
184
|
+
CRYPTO_sysrand_for_seed(entropy, sizeof(entropy));
|
193
185
|
}
|
194
186
|
|
195
187
|
// See FIPS 140-2, section 4.9.2. This is the “continuous random number
|
196
188
|
// generator test” which causes the program to randomly abort. Hopefully the
|
197
189
|
// rate of failure is small enough not to be a problem in practice.
|
198
190
|
if (CRYPTO_memcmp(state->last_block, entropy, CRNGT_BLOCK_SIZE) == 0) {
|
199
|
-
|
191
|
+
fprintf(stderr, "CRNGT failed.\n");
|
200
192
|
BORINGSSL_FIPS_abort();
|
201
193
|
}
|
202
194
|
|
@@ -204,7 +196,7 @@ static void rand_get_seed(struct rand_thread_state *state,
|
|
204
196
|
i += CRNGT_BLOCK_SIZE) {
|
205
197
|
if (CRYPTO_memcmp(entropy + i - CRNGT_BLOCK_SIZE, entropy + i,
|
206
198
|
CRNGT_BLOCK_SIZE) == 0) {
|
207
|
-
|
199
|
+
fprintf(stderr, "CRNGT failed.\n");
|
208
200
|
BORINGSSL_FIPS_abort();
|
209
201
|
}
|
210
202
|
}
|
@@ -219,6 +211,17 @@ static void rand_get_seed(struct rand_thread_state *state,
|
|
219
211
|
seed[j] ^= entropy[CTR_DRBG_ENTROPY_LEN * i + j];
|
220
212
|
}
|
221
213
|
}
|
214
|
+
|
215
|
+
#if defined(OPENSSL_URANDOM)
|
216
|
+
// If we used RDRAND, also opportunistically read from the system. This avoids
|
217
|
+
// solely relying on the hardware once the entropy pool has been initialized.
|
218
|
+
if (used_hwrand) {
|
219
|
+
CRYPTO_sysrand_if_available(entropy, CTR_DRBG_ENTROPY_LEN);
|
220
|
+
for (size_t i = 0; i < CTR_DRBG_ENTROPY_LEN; i++) {
|
221
|
+
seed[i] ^= entropy[i];
|
222
|
+
}
|
223
|
+
}
|
224
|
+
#endif
|
222
225
|
}
|
223
226
|
|
224
227
|
#else
|
@@ -334,6 +337,8 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len,
|
|
334
337
|
|
335
338
|
out += todo;
|
336
339
|
out_len -= todo;
|
340
|
+
// Though we only check before entering the loop, this cannot add enough to
|
341
|
+
// overflow a |size_t|.
|
337
342
|
state->calls++;
|
338
343
|
first_call = 0;
|
339
344
|
}
|
@@ -18,8 +18,9 @@
|
|
18
18
|
|
19
19
|
#include <openssl/rand.h>
|
20
20
|
|
21
|
-
#
|
22
|
-
|
21
|
+
#include "internal.h"
|
22
|
+
|
23
|
+
#if defined(OPENSSL_URANDOM)
|
23
24
|
|
24
25
|
#include <assert.h>
|
25
26
|
#include <errno.h>
|
@@ -34,12 +35,36 @@
|
|
34
35
|
#include <sys/ioctl.h>
|
35
36
|
#endif
|
36
37
|
#include <sys/syscall.h>
|
38
|
+
|
39
|
+
#if defined(OPENSSL_ANDROID)
|
40
|
+
#include <sys/system_properties.h>
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#if !defined(OPENSSL_ANDROID)
|
44
|
+
#define OPENSSL_HAS_GETAUXVAL
|
45
|
+
#endif
|
46
|
+
// glibc prior to 2.16 does not have getauxval and sys/auxv.h. Android has some
|
47
|
+
// host builds (i.e. not building for Android itself, so |OPENSSL_ANDROID| is
|
48
|
+
// unset) which are still using a 2.15 sysroot.
|
49
|
+
//
|
50
|
+
// TODO(davidben): Remove this once Android updates their sysroot.
|
51
|
+
#if defined(__GLIBC_PREREQ)
|
52
|
+
#if !__GLIBC_PREREQ(2, 16)
|
53
|
+
#undef OPENSSL_HAS_GETAUXVAL
|
54
|
+
#endif
|
55
|
+
#endif
|
56
|
+
#if defined(OPENSSL_HAS_GETAUXVAL)
|
57
|
+
#include <sys/auxv.h>
|
58
|
+
#endif
|
59
|
+
#endif // OPENSSL_LINUX
|
60
|
+
|
61
|
+
#if defined(OPENSSL_MACOS)
|
62
|
+
#include <sys/random.h>
|
37
63
|
#endif
|
38
64
|
|
39
65
|
#include <openssl/thread.h>
|
40
66
|
#include <openssl/mem.h>
|
41
67
|
|
42
|
-
#include "internal.h"
|
43
68
|
#include "../delocate.h"
|
44
69
|
#include "../../internal.h"
|
45
70
|
|
@@ -73,16 +98,40 @@
|
|
73
98
|
|
74
99
|
#endif // __NR_getrandom
|
75
100
|
|
101
|
+
#if defined(OPENSSL_MSAN)
|
102
|
+
void __msan_unpoison(void *, size_t);
|
103
|
+
#endif
|
104
|
+
|
105
|
+
static ssize_t boringssl_getrandom(void *buf, size_t buf_len, unsigned flags) {
|
106
|
+
ssize_t ret;
|
107
|
+
do {
|
108
|
+
ret = syscall(__NR_getrandom, buf, buf_len, flags);
|
109
|
+
} while (ret == -1 && errno == EINTR);
|
110
|
+
|
111
|
+
#if defined(OPENSSL_MSAN)
|
112
|
+
if (ret > 0) {
|
113
|
+
// MSAN doesn't recognise |syscall| and thus doesn't notice that we have
|
114
|
+
// initialised the output buffer.
|
115
|
+
__msan_unpoison(buf, ret);
|
116
|
+
}
|
117
|
+
#endif // OPENSSL_MSAN
|
118
|
+
|
119
|
+
return ret;
|
120
|
+
}
|
121
|
+
|
76
122
|
#endif // EXPECTED_NR_getrandom
|
77
123
|
|
78
124
|
#if !defined(GRND_NONBLOCK)
|
79
125
|
#define GRND_NONBLOCK 1
|
80
126
|
#endif
|
127
|
+
#if !defined(GRND_RANDOM)
|
128
|
+
#define GRND_RANDOM 2
|
129
|
+
#endif
|
81
130
|
|
82
131
|
#endif // OPENSSL_LINUX
|
83
132
|
|
84
133
|
// rand_lock is used to protect the |*_requested| variables.
|
85
|
-
DEFINE_STATIC_MUTEX(rand_lock)
|
134
|
+
DEFINE_STATIC_MUTEX(rand_lock)
|
86
135
|
|
87
136
|
// The following constants are magic values of |urandom_fd|.
|
88
137
|
static const int kUnset = 0;
|
@@ -90,24 +139,44 @@ static const int kHaveGetrandom = -3;
|
|
90
139
|
|
91
140
|
// urandom_fd_requested is set by |RAND_set_urandom_fd|. It's protected by
|
92
141
|
// |rand_lock|.
|
93
|
-
DEFINE_BSS_GET(int, urandom_fd_requested)
|
142
|
+
DEFINE_BSS_GET(int, urandom_fd_requested)
|
94
143
|
|
95
144
|
// urandom_fd is a file descriptor to /dev/urandom. It's protected by |once|.
|
96
|
-
DEFINE_BSS_GET(int, urandom_fd)
|
145
|
+
DEFINE_BSS_GET(int, urandom_fd)
|
97
146
|
|
98
|
-
|
147
|
+
#if defined(USE_NR_getrandom)
|
99
148
|
|
100
|
-
|
101
|
-
//
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
149
|
+
// getrandom_ready is one if |getrandom| had been initialized by the time
|
150
|
+
// |init_once| was called and zero otherwise.
|
151
|
+
DEFINE_BSS_GET(int, getrandom_ready)
|
152
|
+
|
153
|
+
// extra_getrandom_flags_for_seed contains a value that is ORed into the flags
|
154
|
+
// for getrandom() when reading entropy for a seed.
|
155
|
+
DEFINE_BSS_GET(int, extra_getrandom_flags_for_seed)
|
156
|
+
|
157
|
+
// On Android, check a system property to decide whether to set
|
158
|
+
// |extra_getrandom_flags_for_seed| otherwise they will default to zero. If
|
159
|
+
// ro.oem_boringcrypto_hwrand is true then |extra_getrandom_flags_for_seed| will
|
160
|
+
// be set to GRND_RANDOM, causing all random data to be drawn from the same
|
161
|
+
// source as /dev/random.
|
162
|
+
static void maybe_set_extra_getrandom_flags(void) {
|
163
|
+
#if defined(BORINGSSL_FIPS) && defined(OPENSSL_ANDROID)
|
164
|
+
char value[PROP_VALUE_MAX + 1];
|
165
|
+
int length = __system_property_get("ro.boringcrypto.hwrand", value);
|
166
|
+
if (length < 0 || length > PROP_VALUE_MAX) {
|
167
|
+
return;
|
168
|
+
}
|
169
|
+
|
170
|
+
value[length] = 0;
|
171
|
+
if (strcasecmp(value, "true") == 0) {
|
172
|
+
*extra_getrandom_flags_for_seed_bss_get() = GRND_RANDOM;
|
173
|
+
}
|
110
174
|
#endif
|
175
|
+
}
|
176
|
+
|
177
|
+
#endif // USE_NR_getrandom
|
178
|
+
|
179
|
+
DEFINE_STATIC_ONCE(rand_once)
|
111
180
|
|
112
181
|
// init_once initializes the state of this module to values previously
|
113
182
|
// requested. This is the only function that modifies |urandom_fd| and
|
@@ -119,31 +188,47 @@ static void init_once(void) {
|
|
119
188
|
CRYPTO_STATIC_MUTEX_unlock_read(rand_lock_bss_get());
|
120
189
|
|
121
190
|
#if defined(USE_NR_getrandom)
|
191
|
+
int have_getrandom;
|
122
192
|
uint8_t dummy;
|
123
|
-
|
124
|
-
|
125
|
-
|
193
|
+
ssize_t getrandom_ret =
|
194
|
+
boringssl_getrandom(&dummy, sizeof(dummy), GRND_NONBLOCK);
|
126
195
|
if (getrandom_ret == 1) {
|
127
|
-
*
|
128
|
-
|
196
|
+
*getrandom_ready_bss_get() = 1;
|
197
|
+
have_getrandom = 1;
|
129
198
|
} else if (getrandom_ret == -1 && errno == EAGAIN) {
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
199
|
+
// We have getrandom, but the entropy pool has not been initialized yet.
|
200
|
+
have_getrandom = 1;
|
201
|
+
} else if (getrandom_ret == -1 && errno == ENOSYS) {
|
202
|
+
// Fallthrough to using /dev/urandom, below.
|
203
|
+
have_getrandom = 0;
|
204
|
+
} else {
|
205
|
+
// Other errors are fatal.
|
206
|
+
perror("getrandom");
|
207
|
+
abort();
|
208
|
+
}
|
139
209
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
210
|
+
if (have_getrandom) {
|
211
|
+
*urandom_fd_bss_get() = kHaveGetrandom;
|
212
|
+
maybe_set_extra_getrandom_flags();
|
213
|
+
return;
|
144
214
|
}
|
145
215
|
#endif // USE_NR_getrandom
|
146
216
|
|
217
|
+
#if defined(OPENSSL_MACOS)
|
218
|
+
// getentropy is available in macOS 10.12 and up. iOS 10 and up may also
|
219
|
+
// support it, but the header is missing. See https://crbug.com/boringssl/287.
|
220
|
+
if (__builtin_available(macos 10.12, *)) {
|
221
|
+
*urandom_fd_bss_get() = kHaveGetrandom;
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
#endif
|
225
|
+
|
226
|
+
// Android FIPS builds must support getrandom.
|
227
|
+
#if defined(BORINGSSL_FIPS) && defined(OPENSSL_ANDROID)
|
228
|
+
perror("getrandom not found");
|
229
|
+
abort();
|
230
|
+
#endif
|
231
|
+
|
147
232
|
if (fd == kUnset) {
|
148
233
|
do {
|
149
234
|
fd = open("/dev/urandom", O_RDONLY);
|
@@ -151,6 +236,7 @@ static void init_once(void) {
|
|
151
236
|
}
|
152
237
|
|
153
238
|
if (fd < 0) {
|
239
|
+
perror("failed to open /dev/urandom");
|
154
240
|
abort();
|
155
241
|
}
|
156
242
|
|
@@ -163,8 +249,73 @@ static void init_once(void) {
|
|
163
249
|
close(kUnset);
|
164
250
|
|
165
251
|
if (fd <= 0) {
|
252
|
+
perror("failed to dup /dev/urandom fd");
|
253
|
+
abort();
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
int flags = fcntl(fd, F_GETFD);
|
258
|
+
if (flags == -1) {
|
259
|
+
// Native Client doesn't implement |fcntl|.
|
260
|
+
if (errno != ENOSYS) {
|
261
|
+
perror("failed to get flags from urandom fd");
|
262
|
+
abort();
|
263
|
+
}
|
264
|
+
} else {
|
265
|
+
flags |= FD_CLOEXEC;
|
266
|
+
if (fcntl(fd, F_SETFD, flags) == -1) {
|
267
|
+
perror("failed to set FD_CLOEXEC on urandom fd");
|
268
|
+
abort();
|
269
|
+
}
|
270
|
+
}
|
271
|
+
*urandom_fd_bss_get() = fd;
|
272
|
+
}
|
273
|
+
|
274
|
+
DEFINE_STATIC_ONCE(wait_for_entropy_once)
|
275
|
+
|
276
|
+
static void wait_for_entropy(void) {
|
277
|
+
int fd = *urandom_fd_bss_get();
|
278
|
+
if (fd == kHaveGetrandom) {
|
279
|
+
// |getrandom| and |getentropy| support blocking in |fill_with_entropy|
|
280
|
+
// directly. For |getrandom|, we first probe with a non-blocking call to aid
|
281
|
+
// debugging.
|
282
|
+
#if defined(USE_NR_getrandom)
|
283
|
+
if (*getrandom_ready_bss_get()) {
|
284
|
+
// The entropy pool was already initialized in |init_once|.
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
|
288
|
+
uint8_t dummy;
|
289
|
+
ssize_t getrandom_ret =
|
290
|
+
boringssl_getrandom(&dummy, sizeof(dummy), GRND_NONBLOCK);
|
291
|
+
if (getrandom_ret == -1 && errno == EAGAIN) {
|
292
|
+
// Attempt to get the path of the current process to aid in debugging when
|
293
|
+
// something blocks.
|
294
|
+
const char *current_process = "<unknown>";
|
295
|
+
#if defined(OPENSSL_HAS_GETAUXVAL)
|
296
|
+
const unsigned long getauxval_ret = getauxval(AT_EXECFN);
|
297
|
+
if (getauxval_ret != 0) {
|
298
|
+
current_process = (const char *)getauxval_ret;
|
299
|
+
}
|
300
|
+
#endif
|
301
|
+
|
302
|
+
fprintf(
|
303
|
+
stderr,
|
304
|
+
"%s: getrandom indicates that the entropy pool has not been "
|
305
|
+
"initialized. Rather than continue with poor entropy, this process "
|
306
|
+
"will block until entropy is available.\n",
|
307
|
+
current_process);
|
308
|
+
|
309
|
+
getrandom_ret =
|
310
|
+
boringssl_getrandom(&dummy, sizeof(dummy), 0 /* no flags */);
|
311
|
+
}
|
312
|
+
|
313
|
+
if (getrandom_ret != 1) {
|
314
|
+
perror("getrandom");
|
166
315
|
abort();
|
167
316
|
}
|
317
|
+
#endif // USE_NR_getrandom
|
318
|
+
return;
|
168
319
|
}
|
169
320
|
|
170
321
|
#if defined(BORINGSSL_FIPS)
|
@@ -175,9 +326,9 @@ static void init_once(void) {
|
|
175
326
|
for (;;) {
|
176
327
|
int entropy_bits;
|
177
328
|
if (ioctl(fd, RNDGETENTCNT, &entropy_bits)) {
|
178
|
-
|
179
|
-
|
180
|
-
|
329
|
+
fprintf(stderr,
|
330
|
+
"RNDGETENTCNT on /dev/urandom failed. We cannot continue in this "
|
331
|
+
"case when in FIPS mode.\n");
|
181
332
|
abort();
|
182
333
|
}
|
183
334
|
|
@@ -188,26 +339,13 @@ static void init_once(void) {
|
|
188
339
|
|
189
340
|
usleep(250000);
|
190
341
|
}
|
191
|
-
#endif
|
192
|
-
|
193
|
-
int flags = fcntl(fd, F_GETFD);
|
194
|
-
if (flags == -1) {
|
195
|
-
// Native Client doesn't implement |fcntl|.
|
196
|
-
if (errno != ENOSYS) {
|
197
|
-
abort();
|
198
|
-
}
|
199
|
-
} else {
|
200
|
-
flags |= FD_CLOEXEC;
|
201
|
-
if (fcntl(fd, F_SETFD, flags) == -1) {
|
202
|
-
abort();
|
203
|
-
}
|
204
|
-
}
|
205
|
-
*urandom_fd_bss_get() = fd;
|
342
|
+
#endif // BORINGSSL_FIPS
|
206
343
|
}
|
207
344
|
|
208
345
|
void RAND_set_urandom_fd(int fd) {
|
209
346
|
fd = dup(fd);
|
210
347
|
if (fd < 0) {
|
348
|
+
perror("failed to dup supplied urandom fd");
|
211
349
|
abort();
|
212
350
|
}
|
213
351
|
|
@@ -220,6 +358,7 @@ void RAND_set_urandom_fd(int fd) {
|
|
220
358
|
close(kUnset);
|
221
359
|
|
222
360
|
if (fd <= 0) {
|
361
|
+
perror("failed to dup supplied urandom fd");
|
223
362
|
abort();
|
224
363
|
}
|
225
364
|
}
|
@@ -232,35 +371,61 @@ void RAND_set_urandom_fd(int fd) {
|
|
232
371
|
if (*urandom_fd_bss_get() == kHaveGetrandom) {
|
233
372
|
close(fd);
|
234
373
|
} else if (*urandom_fd_bss_get() != fd) {
|
235
|
-
|
374
|
+
fprintf(stderr, "RAND_set_urandom_fd called after initialisation.\n");
|
375
|
+
abort();
|
236
376
|
}
|
237
377
|
}
|
238
378
|
|
239
|
-
|
240
|
-
|
379
|
+
// fill_with_entropy writes |len| bytes of entropy into |out|. It returns one
|
380
|
+
// on success and zero on error. If |block| is one, this function will block
|
381
|
+
// until the entropy pool is initialized. Otherwise, this function may fail,
|
382
|
+
// setting |errno| to |EAGAIN| if the entropy pool has not yet been initialized.
|
383
|
+
// If |seed| is one, this function will OR in the value of
|
384
|
+
// |*extra_getrandom_flags_for_seed()| when using |getrandom|.
|
385
|
+
static int fill_with_entropy(uint8_t *out, size_t len, int block, int seed) {
|
386
|
+
if (len == 0) {
|
387
|
+
return 1;
|
388
|
+
}
|
389
|
+
|
390
|
+
#if defined(USE_NR_getrandom)
|
391
|
+
int getrandom_flags = 0;
|
392
|
+
if (!block) {
|
393
|
+
getrandom_flags |= GRND_NONBLOCK;
|
394
|
+
}
|
395
|
+
if (seed) {
|
396
|
+
getrandom_flags |= *extra_getrandom_flags_for_seed_bss_get();
|
397
|
+
}
|
241
398
|
#endif
|
242
399
|
|
243
|
-
|
244
|
-
|
245
|
-
|
400
|
+
CRYPTO_once(rand_once_bss_get(), init_once);
|
401
|
+
if (block) {
|
402
|
+
CRYPTO_once(wait_for_entropy_once_bss_get(), wait_for_entropy);
|
403
|
+
}
|
404
|
+
|
405
|
+
// Clear |errno| so it has defined value if |read| or |getrandom|
|
406
|
+
// "successfully" returns zero.
|
407
|
+
errno = 0;
|
246
408
|
while (len > 0) {
|
247
409
|
ssize_t r;
|
248
410
|
|
249
411
|
if (*urandom_fd_bss_get() == kHaveGetrandom) {
|
250
412
|
#if defined(USE_NR_getrandom)
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
413
|
+
r = boringssl_getrandom(out, len, getrandom_flags);
|
414
|
+
#elif defined(OPENSSL_MACOS)
|
415
|
+
if (__builtin_available(macos 10.12, *)) {
|
416
|
+
// |getentropy| can only request 256 bytes at a time.
|
417
|
+
size_t todo = len <= 256 ? len : 256;
|
418
|
+
if (getentropy(out, todo) != 0) {
|
419
|
+
r = -1;
|
420
|
+
} else {
|
421
|
+
r = (ssize_t)todo;
|
422
|
+
}
|
423
|
+
} else {
|
424
|
+
fprintf(stderr, "urandom fd corrupt.\n");
|
425
|
+
abort();
|
260
426
|
}
|
261
|
-
#endif // OPENSSL_MSAN
|
262
|
-
|
263
427
|
#else // USE_NR_getrandom
|
428
|
+
fprintf(stderr, "urandom fd corrupt.\n");
|
264
429
|
abort();
|
265
430
|
#endif
|
266
431
|
} else {
|
@@ -281,13 +446,16 @@ static char fill_with_entropy(uint8_t *out, size_t len) {
|
|
281
446
|
|
282
447
|
// CRYPTO_sysrand puts |requested| random bytes into |out|.
|
283
448
|
void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
284
|
-
if (requested
|
285
|
-
|
449
|
+
if (!fill_with_entropy(out, requested, /*block=*/1, /*seed=*/0)) {
|
450
|
+
perror("entropy fill failed");
|
451
|
+
abort();
|
286
452
|
}
|
453
|
+
}
|
287
454
|
|
288
|
-
|
289
|
-
|
290
|
-
if (!fill_with_entropy(out, requested)) {
|
455
|
+
#if defined(BORINGSSL_FIPS)
|
456
|
+
void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) {
|
457
|
+
if (!fill_with_entropy(out, requested, /*block=*/1, /*seed=*/1)) {
|
458
|
+
perror("entropy fill failed");
|
291
459
|
abort();
|
292
460
|
}
|
293
461
|
|
@@ -298,5 +466,16 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
|
298
466
|
#endif
|
299
467
|
}
|
300
468
|
|
301
|
-
|
302
|
-
|
469
|
+
void CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) {
|
470
|
+
// Return all zeros if |fill_with_entropy| fails.
|
471
|
+
OPENSSL_memset(out, 0, requested);
|
472
|
+
|
473
|
+
if (!fill_with_entropy(out, requested, /*block=*/0, /*seed=*/0) &&
|
474
|
+
errno != EAGAIN) {
|
475
|
+
perror("opportunistic entropy fill failed");
|
476
|
+
abort();
|
477
|
+
}
|
478
|
+
}
|
479
|
+
#endif // BORINGSSL_FIPS
|
480
|
+
|
481
|
+
#endif // OPENSSL_URANDOM
|