grpc 1.0.1 → 1.1.2
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 +3696 -867
- data/etc/roots.pem +39 -111
- data/include/grpc/byte_buffer.h +64 -1
- data/include/grpc/census.h +40 -96
- data/include/grpc/compression.h +2 -1
- data/include/grpc/grpc.h +42 -7
- data/include/grpc/grpc_posix.h +8 -5
- data/include/grpc/impl/codegen/atm.h +3 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +2 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +8 -0
- data/include/grpc/impl/codegen/atm_windows.h +4 -0
- data/include/grpc/impl/codegen/byte_buffer_reader.h +4 -4
- data/include/grpc/impl/codegen/compression_types.h +1 -1
- data/include/grpc/impl/codegen/connectivity_state.h +2 -0
- data/include/grpc/impl/codegen/exec_ctx_fwd.h +41 -0
- data/include/grpc/impl/codegen/gpr_slice.h +84 -0
- data/include/grpc/impl/codegen/{alloc.h → gpr_types.h} +30 -29
- data/include/grpc/impl/codegen/grpc_types.h +91 -9
- data/include/grpc/impl/codegen/port_platform.h +25 -92
- data/include/grpc/impl/codegen/slice.h +54 -97
- data/include/grpc/impl/codegen/sync.h +0 -253
- data/include/grpc/module.modulemap +0 -2
- data/include/grpc/slice.h +132 -0
- data/include/grpc/{impl/codegen/slice_buffer.h → slice_buffer.h} +22 -39
- data/include/grpc/support/alloc.h +40 -1
- data/include/grpc/support/log.h +80 -1
- data/include/grpc/support/log_windows.h +2 -0
- data/include/grpc/support/string_util.h +1 -1
- data/include/grpc/support/sync.h +252 -0
- data/include/grpc/support/time.h +67 -1
- data/src/boringssl/err_data.c +639 -627
- data/src/core/ext/census/base_resources.c +71 -0
- data/src/core/ext/census/base_resources.h +39 -0
- data/src/core/ext/census/gen/census.pb.c +26 -29
- data/src/core/ext/census/gen/census.pb.h +68 -67
- data/src/core/ext/census/gen/trace_context.pb.c +81 -0
- data/src/core/ext/census/gen/trace_context.pb.h +99 -0
- data/src/core/ext/census/grpc_filter.c +22 -16
- data/src/core/ext/census/grpc_plugin.c +2 -1
- data/src/core/ext/census/initialize.c +16 -4
- data/src/core/ext/census/mlog.h +1 -1
- data/src/core/ext/census/placeholders.c +0 -45
- data/src/core/ext/census/resource.c +312 -0
- data/src/core/ext/census/resource.h +63 -0
- data/src/core/ext/census/trace_context.c +86 -0
- data/src/core/ext/census/trace_context.h +68 -0
- data/src/core/ext/census/tracing.c +8 -2
- data/src/core/ext/{client_config → client_channel}/channel_connectivity.c +8 -4
- data/src/core/ext/client_channel/client_channel.c +1218 -0
- data/src/core/ext/{client_config → client_channel}/client_channel.h +8 -11
- data/src/core/ext/{client_config → client_channel}/client_channel_factory.c +33 -3
- data/src/core/ext/{client_config → client_channel}/client_channel_factory.h +15 -8
- data/src/core/ext/{client_config/client_config_plugin.c → client_channel/client_channel_plugin.c} +16 -15
- data/src/core/ext/{client_config → client_channel}/connector.c +1 -1
- data/src/core/ext/{client_config → client_channel}/connector.h +5 -8
- data/{include/grpc/support/slice_buffer.h → src/core/ext/client_channel/default_initial_connect_string.c} +4 -5
- data/src/core/ext/client_channel/http_connect_handshaker.c +399 -0
- data/src/core/ext/client_channel/http_connect_handshaker.h +52 -0
- data/src/core/ext/{client_config → client_channel}/initial_connect_string.c +6 -7
- data/src/core/ext/{client_config → client_channel}/initial_connect_string.h +10 -10
- data/src/core/ext/{client_config → client_channel}/lb_policy.c +11 -11
- data/src/core/ext/{client_config → client_channel}/lb_policy.h +68 -27
- data/src/core/ext/client_channel/lb_policy_factory.c +163 -0
- data/src/core/ext/{client_config → client_channel}/lb_policy_factory.h +64 -9
- data/src/core/ext/{client_config → client_channel}/lb_policy_registry.c +6 -4
- data/src/core/ext/{client_config → client_channel}/lb_policy_registry.h +4 -4
- data/src/core/ext/{client_config → client_channel}/parse_address.c +21 -14
- data/src/core/ext/{client_config → client_channel}/parse_address.h +8 -10
- data/src/core/ext/{client_config → client_channel}/resolver.c +3 -4
- data/src/core/ext/{client_config → client_channel}/resolver.h +11 -15
- data/src/core/ext/{client_config → client_channel}/resolver_factory.c +4 -3
- data/src/core/ext/{client_config → client_channel}/resolver_factory.h +13 -11
- data/src/core/ext/{client_config → client_channel}/resolver_registry.c +54 -34
- data/src/core/ext/{client_config → client_channel}/resolver_registry.h +21 -8
- data/src/core/ext/{client_config → client_channel}/subchannel.c +208 -119
- data/src/core/ext/{client_config → client_channel}/subchannel.h +21 -11
- data/src/core/ext/{client_config → client_channel}/subchannel_index.c +6 -17
- data/src/core/ext/{client_config → client_channel}/subchannel_index.h +7 -7
- data/src/core/ext/{client_config → client_channel}/uri_parser.c +21 -28
- data/src/core/ext/{client_config → client_channel}/uri_parser.h +3 -3
- data/src/core/ext/lb_policy/grpclb/grpclb.c +1406 -0
- data/src/core/ext/lb_policy/grpclb/grpclb.h +44 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +117 -37
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +31 -12
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +6 -36
- data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +22 -42
- data/src/core/ext/lb_policy/pick_first/pick_first.c +64 -46
- data/src/core/ext/lb_policy/round_robin/round_robin.c +324 -160
- data/src/core/ext/load_reporting/load_reporting.c +7 -56
- data/src/core/ext/load_reporting/load_reporting.h +41 -28
- data/src/core/ext/load_reporting/load_reporting_filter.c +132 -42
- data/src/core/ext/load_reporting/load_reporting_filter.h +1 -0
- data/src/core/ext/resolver/dns/native/dns_resolver.c +88 -80
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +57 -102
- data/src/core/ext/transport/chttp2/alpn/alpn.c +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +253 -0
- data/src/core/{lib/iomgr/ev_poll_and_epoll_posix.h → ext/transport/chttp2/client/chttp2_connector.h} +5 -5
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +31 -160
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +5 -5
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +44 -243
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +342 -0
- data/src/core/ext/transport/chttp2/server/chttp2_server.h +47 -0
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +11 -124
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +20 -9
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +28 -236
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +31 -27
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +5 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +25 -22
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +8 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +1345 -1521
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -1
- data/src/core/ext/transport/chttp2/transport/frame.h +3 -5
- data/src/core/ext/transport/chttp2/transport/frame_data.c +50 -47
- data/src/core/ext/transport/chttp2/transport/frame_data.h +8 -9
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +19 -21
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +9 -8
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +13 -12
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +6 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +31 -19
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +8 -7
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +22 -25
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +9 -8
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +26 -18
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +68 -58
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +8 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +327 -214
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +14 -9
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +9 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +284 -436
- data/src/core/ext/transport/chttp2/transport/parsing.c +355 -590
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +36 -309
- data/src/core/ext/transport/chttp2/transport/stream_map.c +13 -34
- data/src/core/ext/transport/chttp2/transport/stream_map.h +3 -4
- data/src/core/ext/transport/chttp2/transport/writing.c +174 -286
- data/src/core/lib/channel/channel_args.c +70 -13
- data/src/core/lib/channel/channel_args.h +28 -2
- data/src/core/lib/channel/channel_stack.c +77 -28
- data/src/core/lib/channel/channel_stack.h +61 -23
- data/src/core/lib/channel/channel_stack_builder.c +33 -25
- data/src/core/lib/channel/channel_stack_builder.h +17 -8
- data/src/core/lib/channel/compress_filter.c +52 -36
- data/src/core/lib/channel/connected_channel.c +20 -12
- data/src/core/lib/channel/connected_channel.h +2 -1
- data/src/core/lib/channel/context.h +13 -1
- data/src/core/lib/channel/deadline_filter.c +344 -0
- data/src/core/lib/channel/deadline_filter.h +99 -0
- data/src/core/lib/channel/handshaker.c +240 -0
- data/src/core/lib/channel/handshaker.h +164 -0
- data/src/core/lib/{security/credentials/google_default/credentials_windows.c → channel/handshaker_factory.c} +16 -23
- data/src/core/lib/channel/handshaker_factory.h +66 -0
- data/src/core/lib/channel/handshaker_registry.c +113 -0
- data/src/core/{ext/client_config/client_config.h → lib/channel/handshaker_registry.h} +26 -16
- data/src/core/lib/channel/http_client_filter.c +248 -46
- data/src/core/lib/channel/http_client_filter.h +3 -0
- data/src/core/lib/channel/http_server_filter.c +136 -24
- data/src/core/lib/channel/message_size_filter.c +261 -0
- data/src/core/lib/channel/message_size_filter.h +39 -0
- data/src/core/lib/compression/message_compress.c +43 -37
- data/src/core/lib/compression/message_compress.h +7 -5
- data/src/core/lib/http/format_request.c +26 -11
- data/src/core/lib/http/format_request.h +7 -5
- data/src/core/lib/http/httpcli.c +45 -27
- data/src/core/lib/http/httpcli.h +4 -4
- data/src/core/lib/http/httpcli_security_connector.c +56 -46
- data/src/core/lib/http/parser.c +17 -14
- data/src/core/lib/http/parser.h +4 -2
- data/src/core/lib/iomgr/closure.c +49 -7
- data/src/core/lib/iomgr/closure.h +56 -14
- data/src/core/lib/iomgr/combiner.c +422 -0
- data/src/core/lib/iomgr/combiner.h +64 -0
- data/src/core/lib/iomgr/endpoint.c +8 -2
- data/src/core/lib/iomgr/endpoint.h +17 -7
- data/src/core/lib/iomgr/endpoint_pair.h +3 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.c +9 -8
- data/src/core/{ext/client_config/lb_policy_factory.c → lib/iomgr/endpoint_pair_uv.c} +18 -13
- data/src/core/lib/iomgr/endpoint_pair_windows.c +7 -6
- data/src/core/lib/iomgr/error.c +72 -6
- data/src/core/lib/iomgr/error.h +30 -3
- data/src/core/lib/iomgr/ev_epoll_linux.c +500 -382
- data/src/core/lib/iomgr/ev_epoll_linux.h +3 -2
- data/src/core/lib/iomgr/ev_poll_posix.c +317 -30
- data/src/core/lib/iomgr/ev_poll_posix.h +1 -0
- data/src/core/lib/iomgr/ev_posix.c +26 -5
- data/src/core/lib/iomgr/ev_posix.h +12 -1
- data/src/core/lib/iomgr/exec_ctx.c +27 -94
- data/src/core/lib/iomgr/exec_ctx.h +19 -22
- data/src/core/lib/iomgr/executor.c +29 -8
- data/src/core/lib/iomgr/executor.h +2 -4
- data/src/core/lib/iomgr/iocp_windows.c +3 -4
- data/src/core/lib/iomgr/iomgr.c +14 -10
- data/src/core/lib/iomgr/iomgr.h +6 -2
- data/src/core/lib/iomgr/iomgr_posix.c +2 -2
- data/src/core/lib/iomgr/iomgr_uv.c +49 -0
- data/src/core/lib/iomgr/iomgr_windows.c +2 -2
- data/src/core/lib/iomgr/load_file.c +3 -3
- data/src/core/lib/iomgr/load_file.h +2 -2
- data/src/core/lib/iomgr/network_status_tracker.c +1 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +62 -0
- data/src/core/lib/iomgr/pollset_set_windows.c +3 -3
- data/src/core/lib/iomgr/pollset_uv.c +142 -0
- data/src/core/lib/iomgr/pollset_uv.h +42 -0
- data/src/core/lib/iomgr/pollset_windows.c +5 -6
- data/src/core/lib/iomgr/port.h +129 -0
- data/src/core/lib/iomgr/resolve_address.h +2 -1
- data/src/core/lib/iomgr/resolve_address_posix.c +14 -13
- data/src/core/lib/iomgr/resolve_address_uv.c +233 -0
- data/src/core/lib/iomgr/resolve_address_windows.c +14 -12
- data/src/core/lib/iomgr/resource_quota.c +832 -0
- data/src/core/lib/iomgr/resource_quota.h +159 -0
- data/src/core/lib/iomgr/sockaddr.h +10 -2
- data/src/core/lib/iomgr/sockaddr_utils.c +63 -36
- data/src/core/lib/iomgr/sockaddr_utils.h +14 -14
- data/src/core/lib/iomgr/socket_mutator.c +98 -0
- data/src/core/lib/iomgr/socket_mutator.h +80 -0
- data/src/core/lib/iomgr/socket_utils.h +42 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +28 -13
- data/src/core/lib/iomgr/socket_utils_linux.c +11 -5
- data/src/core/lib/iomgr/socket_utils_posix.c +10 -7
- data/src/core/lib/iomgr/socket_utils_posix.h +11 -4
- data/src/core/lib/iomgr/socket_utils_uv.c +49 -0
- data/src/core/lib/iomgr/socket_utils_windows.c +52 -0
- data/src/core/lib/iomgr/socket_windows.c +14 -6
- data/src/core/lib/iomgr/socket_windows.h +1 -0
- data/src/core/lib/iomgr/tcp_client.h +8 -2
- data/src/core/lib/iomgr/tcp_client_posix.c +131 -82
- data/src/core/lib/iomgr/tcp_client_posix.h +45 -0
- data/src/core/lib/iomgr/tcp_client_uv.c +190 -0
- data/src/core/lib/iomgr/tcp_client_windows.c +54 -30
- data/src/core/lib/iomgr/tcp_posix.c +135 -56
- data/src/core/lib/iomgr/tcp_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server.h +14 -6
- data/src/core/lib/iomgr/tcp_server_posix.c +154 -118
- data/src/core/lib/iomgr/tcp_server_uv.c +388 -0
- data/src/core/lib/iomgr/tcp_server_windows.c +127 -100
- data/src/core/lib/iomgr/tcp_uv.c +367 -0
- data/src/core/lib/iomgr/tcp_uv.h +59 -0
- data/src/core/lib/iomgr/tcp_windows.c +65 -48
- data/src/core/lib/iomgr/tcp_windows.h +3 -1
- data/src/core/lib/iomgr/timer.h +21 -21
- data/src/core/lib/iomgr/{timer.c → timer_generic.c} +15 -10
- data/src/core/lib/iomgr/timer_generic.h +49 -0
- data/src/core/lib/iomgr/timer_heap.c +6 -0
- data/src/core/lib/iomgr/timer_uv.c +99 -0
- data/src/core/lib/iomgr/timer_uv.h +47 -0
- data/src/core/lib/iomgr/udp_server.c +116 -98
- data/src/core/lib/iomgr/udp_server.h +5 -3
- data/src/core/lib/iomgr/unix_sockets_posix.c +14 -6
- data/src/core/lib/iomgr/unix_sockets_posix.h +6 -5
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -4
- data/src/core/lib/iomgr/wakeup_fd_cv.c +118 -0
- data/src/core/lib/iomgr/wakeup_fd_cv.h +80 -0
- data/src/core/lib/iomgr/wakeup_fd_eventfd.c +3 -3
- data/src/core/lib/iomgr/wakeup_fd_nospecial.c +3 -3
- data/src/core/lib/iomgr/wakeup_fd_pipe.c +12 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.c +34 -5
- data/src/core/lib/iomgr/wakeup_fd_posix.h +5 -0
- data/src/core/lib/iomgr/workqueue.h +12 -20
- data/src/core/{ext/client_config/client_config.c → lib/iomgr/workqueue_uv.c} +24 -33
- data/{include/grpc/support/slice.h → src/core/lib/iomgr/workqueue_uv.h} +4 -6
- data/src/core/lib/iomgr/workqueue_windows.c +9 -8
- data/src/core/lib/json/json.c +3 -3
- data/src/core/lib/json/json.h +11 -11
- data/src/core/lib/json/json_reader.c +9 -5
- data/src/core/lib/profiling/basic_timers.c +10 -1
- data/src/core/lib/profiling/timers.h +2 -0
- data/src/core/lib/security/context/security_context.c +13 -3
- data/src/core/lib/security/context/security_context.h +20 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.c +28 -14
- data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -2
- data/src/core/lib/security/credentials/credentials.c +48 -19
- data/src/core/lib/security/credentials/credentials.h +36 -19
- data/src/core/lib/security/credentials/credentials_metadata.c +11 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.c +15 -11
- data/src/core/lib/security/credentials/google_default/{credentials_posix.c → credentials_generic.c} +7 -14
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +33 -21
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +14 -0
- data/src/core/lib/security/credentials/iam/iam_credentials.c +3 -2
- data/src/core/lib/security/credentials/jwt/json_token.c +1 -0
- data/src/core/lib/security/credentials/jwt/json_token.h +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +54 -19
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +129 -79
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +9 -6
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +63 -28
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +32 -11
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +13 -9
- data/src/core/lib/security/transport/client_auth_filter.c +33 -27
- data/src/core/lib/security/transport/secure_endpoint.c +93 -68
- data/src/core/lib/security/transport/secure_endpoint.h +2 -2
- data/src/core/lib/security/transport/security_connector.c +133 -168
- data/src/core/lib/security/transport/security_connector.h +31 -46
- data/src/core/lib/security/transport/security_handshaker.c +501 -0
- data/src/core/lib/security/transport/{handshake.h → security_handshaker.h} +10 -10
- data/src/core/lib/security/transport/server_auth_filter.c +50 -38
- data/src/core/lib/security/util/b64.c +11 -8
- data/src/core/lib/security/util/b64.h +5 -4
- data/src/core/lib/slice/percent_encoding.c +182 -0
- data/src/core/lib/slice/percent_encoding.h +78 -0
- data/src/core/lib/{support → slice}/slice.c +81 -50
- data/src/core/lib/{support → slice}/slice_buffer.c +78 -60
- data/src/core/lib/slice/slice_internal.h +49 -0
- data/src/core/lib/slice/slice_string_helpers.c +90 -0
- data/src/core/lib/{iomgr/workqueue_posix.h → slice/slice_string_helpers.h} +18 -18
- data/src/core/lib/support/backoff.c +24 -13
- data/src/core/lib/support/backoff.h +5 -2
- data/src/core/lib/support/env.h +0 -2
- data/src/core/lib/support/log.c +5 -4
- data/src/core/lib/support/log_linux.c +0 -1
- data/src/core/lib/support/log_posix.c +1 -1
- data/src/core/lib/support/mpscq.c +83 -0
- data/src/core/lib/support/mpscq.h +65 -0
- data/src/core/lib/support/string.c +58 -49
- data/src/core/lib/support/string.h +11 -8
- data/src/core/lib/support/subprocess_posix.c +5 -2
- data/src/core/lib/support/thd.c +1 -1
- data/src/core/lib/support/time.c +43 -79
- data/src/core/lib/support/time_posix.c +1 -1
- data/src/core/lib/support/tmpfile.h +0 -2
- data/src/core/lib/surface/alarm.c +4 -1
- data/src/core/lib/surface/byte_buffer.c +17 -11
- data/src/core/lib/surface/byte_buffer_reader.c +23 -15
- data/src/core/lib/surface/call.c +294 -276
- data/src/core/lib/surface/call.h +24 -9
- data/src/core/lib/surface/call_log_batch.c +5 -3
- data/src/core/lib/surface/channel.c +127 -111
- data/src/core/lib/surface/channel.h +14 -5
- data/src/core/lib/surface/channel_init.c +1 -1
- data/src/core/lib/surface/channel_init.h +10 -1
- data/src/core/lib/surface/channel_ping.c +7 -6
- data/src/core/lib/surface/completion_queue.c +154 -18
- data/src/core/lib/surface/completion_queue.h +5 -0
- data/src/core/lib/surface/init.c +40 -6
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/init_secure.c +5 -2
- data/src/core/lib/surface/lame_client.c +28 -18
- data/src/core/lib/surface/server.c +134 -87
- data/src/core/lib/surface/server.h +8 -0
- data/src/core/lib/surface/validate_metadata.c +1 -1
- data/src/core/lib/surface/version.c +3 -1
- data/src/core/lib/transport/byte_stream.c +7 -4
- data/src/core/lib/transport/byte_stream.h +6 -10
- data/src/core/lib/transport/connectivity_state.c +21 -12
- data/src/core/lib/transport/connectivity_state.h +4 -1
- data/src/core/lib/transport/mdstr_hash_table.c +118 -0
- data/src/core/lib/transport/mdstr_hash_table.h +77 -0
- data/src/core/lib/transport/metadata.c +83 -60
- data/src/core/lib/transport/metadata.h +41 -23
- data/src/core/lib/transport/metadata_batch.c +17 -11
- data/src/core/lib/transport/metadata_batch.h +20 -6
- data/src/core/lib/transport/pid_controller.c +57 -0
- data/src/core/lib/transport/pid_controller.h +64 -0
- data/src/core/lib/transport/service_config.c +251 -0
- data/src/core/lib/transport/service_config.h +71 -0
- data/src/core/lib/transport/static_metadata.c +18 -16
- data/src/core/lib/transport/static_metadata.h +113 -107
- data/src/core/{ext/transport/chttp2 → lib}/transport/timeout_encoding.c +3 -3
- data/src/core/{ext/transport/chttp2 → lib}/transport/timeout_encoding.h +7 -7
- data/src/core/lib/transport/transport.c +84 -23
- data/src/core/lib/transport/transport.h +53 -8
- data/src/core/lib/transport/transport_impl.h +3 -0
- data/src/core/lib/transport/transport_op_string.c +92 -20
- data/src/core/lib/tsi/ssl_transport_security.c +3 -1
- data/src/core/plugin_registry/grpc_plugin_registry.c +8 -4
- data/src/ruby/ext/grpc/extconf.rb +0 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -7
- data/src/ruby/ext/grpc/rb_call.c +15 -5
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_compression_options.c +466 -0
- data/src/{core/ext/client_config/default_initial_connect_string.c → ruby/ext/grpc/rb_compression_options.h} +10 -5
- data/src/ruby/ext/grpc/rb_grpc.c +3 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +198 -190
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +306 -294
- data/src/ruby/ext/grpc/rb_server.c +18 -12
- data/src/ruby/lib/grpc/errors.rb +154 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +144 -63
- data/src/ruby/lib/grpc/generic/bidi_call.rb +18 -2
- data/src/ruby/lib/grpc/generic/client_stub.rb +7 -5
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +39 -13
- data/src/ruby/lib/grpc/generic/rpc_server.rb +51 -24
- data/src/ruby/lib/grpc/generic/service.rb +3 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +7 -0
- data/src/ruby/pb/test/client.rb +307 -7
- data/src/ruby/pb/test/server.rb +26 -1
- data/src/ruby/spec/compression_options_spec.rb +164 -0
- data/src/ruby/spec/error_sanity_spec.rb +64 -0
- data/src/ruby/spec/generic/active_call_spec.rb +290 -12
- data/src/ruby/spec/generic/client_stub_spec.rb +91 -41
- data/src/ruby/spec/generic/rpc_desc_spec.rb +36 -16
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +22 -28
- data/src/ruby/spec/generic/rpc_server_spec.rb +6 -6
- data/src/ruby/spec/pb/health/checker_spec.rb +27 -19
- data/src/ruby/spec/spec_helper.rb +2 -0
- data/third_party/boringssl/crypto/aes/aes.c +12 -12
- data/third_party/boringssl/crypto/aes/mode_wrappers.c +6 -2
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +28 -13
- data/third_party/boringssl/crypto/asn1/a_gentm.c +2 -0
- data/third_party/boringssl/crypto/asn1/a_object.c +7 -3
- data/third_party/boringssl/crypto/asn1/a_strnid.c +1 -0
- data/third_party/boringssl/crypto/asn1/a_time.c +0 -11
- data/third_party/boringssl/crypto/asn1/a_type.c +0 -2
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -30
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +56 -76
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +0 -10
- data/third_party/boringssl/crypto/asn1/asn1_par.c +0 -322
- data/third_party/boringssl/crypto/asn1/f_enum.c +1 -108
- data/third_party/boringssl/crypto/asn1/f_int.c +1 -106
- data/third_party/boringssl/crypto/asn1/f_string.c +1 -106
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +10 -14
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +17 -11
- data/third_party/boringssl/crypto/asn1/tasn_typ.c +29 -42
- data/third_party/boringssl/crypto/asn1/tasn_utl.c +1 -1
- data/third_party/boringssl/crypto/base64/base64.c +249 -285
- data/third_party/boringssl/crypto/bio/bio.c +13 -23
- data/third_party/boringssl/crypto/bio/bio_mem.c +3 -2
- data/third_party/boringssl/crypto/bio/connect.c +12 -3
- data/third_party/boringssl/crypto/bio/fd.c +22 -15
- data/third_party/boringssl/crypto/bio/file.c +2 -38
- data/third_party/boringssl/crypto/bio/hexdump.c +1 -2
- data/third_party/boringssl/crypto/bio/internal.h +3 -0
- data/third_party/boringssl/crypto/bio/pair.c +1 -1
- data/third_party/boringssl/crypto/bio/socket.c +10 -2
- data/third_party/boringssl/crypto/bio/socket_helper.c +2 -2
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +0 -8
- data/third_party/boringssl/crypto/bn/bn.c +38 -0
- data/third_party/boringssl/crypto/bn/cmp.c +25 -0
- data/third_party/boringssl/crypto/bn/convert.c +73 -76
- data/third_party/boringssl/crypto/bn/div.c +136 -70
- data/third_party/boringssl/crypto/bn/exponentiation.c +86 -381
- data/third_party/boringssl/crypto/bn/gcd.c +213 -296
- data/third_party/boringssl/crypto/bn/generic.c +0 -80
- data/third_party/boringssl/crypto/bn/internal.h +15 -3
- data/third_party/boringssl/crypto/bn/montgomery.c +57 -207
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +160 -0
- data/third_party/boringssl/crypto/bn/mul.c +2 -1
- data/third_party/boringssl/crypto/bn/prime.c +24 -8
- data/third_party/boringssl/crypto/bn/random.c +47 -33
- data/third_party/boringssl/crypto/bn/sqrt.c +4 -5
- data/third_party/boringssl/crypto/buf/buf.c +25 -21
- data/third_party/boringssl/crypto/bytestring/ber.c +1 -0
- data/third_party/boringssl/crypto/bytestring/cbb.c +50 -22
- data/third_party/boringssl/crypto/bytestring/cbs.c +28 -4
- data/third_party/boringssl/crypto/chacha/{chacha_generic.c → chacha.c} +56 -29
- data/third_party/boringssl/crypto/cipher/aead.c +11 -22
- data/third_party/boringssl/crypto/cipher/cipher.c +2 -2
- data/third_party/boringssl/crypto/cipher/e_aes.c +53 -103
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +2 -8
- data/third_party/boringssl/crypto/cipher/e_des.c +3 -5
- data/third_party/boringssl/crypto/cipher/e_null.c +1 -1
- data/third_party/boringssl/crypto/cipher/e_rc2.c +1 -1
- data/third_party/boringssl/crypto/cipher/e_rc4.c +1 -1
- data/third_party/boringssl/crypto/cipher/e_ssl3.c +3 -63
- data/third_party/boringssl/crypto/cipher/e_tls.c +12 -83
- data/third_party/boringssl/crypto/cipher/internal.h +8 -10
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +69 -40
- data/third_party/boringssl/crypto/conf/conf.c +2 -1
- data/third_party/boringssl/crypto/cpu-aarch64-linux.c +61 -0
- data/third_party/boringssl/crypto/cpu-arm-linux.c +360 -0
- data/third_party/boringssl/crypto/cpu-arm.c +0 -161
- data/third_party/boringssl/crypto/cpu-intel.c +5 -3
- data/third_party/boringssl/{ssl/test/scoped_types.h → crypto/cpu-ppc64le.c} +21 -9
- data/third_party/boringssl/crypto/crypto.c +29 -7
- data/third_party/boringssl/crypto/curve25519/curve25519.c +284 -242
- data/third_party/boringssl/crypto/curve25519/internal.h +64 -0
- data/third_party/boringssl/crypto/curve25519/spake25519.c +464 -0
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +21 -0
- data/third_party/boringssl/crypto/dh/check.c +22 -6
- data/third_party/boringssl/crypto/dh/dh.c +45 -21
- data/third_party/boringssl/crypto/dh/dh_asn1.c +96 -20
- data/third_party/boringssl/crypto/dh/params.c +30 -78
- data/third_party/boringssl/crypto/digest/digest.c +3 -3
- data/third_party/boringssl/crypto/dsa/dsa.c +59 -29
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +4 -0
- data/third_party/boringssl/crypto/ec/ec.c +84 -140
- data/third_party/boringssl/crypto/ec/ec_asn1.c +82 -52
- data/third_party/boringssl/crypto/ec/ec_key.c +15 -15
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +87 -50
- data/third_party/boringssl/crypto/ec/internal.h +12 -36
- data/third_party/boringssl/crypto/ec/oct.c +11 -11
- data/third_party/boringssl/crypto/ec/p224-64.c +59 -116
- data/third_party/boringssl/crypto/ec/p256-64.c +88 -163
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +46 -58
- data/third_party/boringssl/crypto/ec/simple.c +81 -201
- data/third_party/boringssl/crypto/ec/util-64.c +0 -74
- data/third_party/boringssl/crypto/ecdh/ecdh.c +7 -1
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +28 -46
- data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +1 -0
- data/third_party/boringssl/crypto/engine/engine.c +1 -1
- data/third_party/boringssl/crypto/err/err.c +3 -3
- data/third_party/boringssl/crypto/evp/evp.c +14 -59
- data/third_party/boringssl/crypto/evp/evp_asn1.c +144 -87
- data/third_party/boringssl/crypto/evp/evp_ctx.c +7 -7
- data/third_party/boringssl/crypto/evp/internal.h +4 -46
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +8 -157
- data/third_party/boringssl/crypto/evp/p_ec.c +1 -1
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +22 -170
- data/third_party/boringssl/crypto/evp/p_rsa.c +1 -1
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +10 -548
- data/third_party/boringssl/crypto/evp/print.c +520 -0
- data/third_party/boringssl/crypto/ex_data.c +4 -6
- data/third_party/boringssl/crypto/hkdf/hkdf.c +38 -17
- data/third_party/boringssl/crypto/hmac/hmac.c +6 -6
- data/third_party/boringssl/crypto/internal.h +57 -77
- data/third_party/boringssl/crypto/lhash/lhash.c +6 -10
- data/third_party/boringssl/crypto/md4/md4.c +9 -0
- data/third_party/boringssl/crypto/mem.c +19 -19
- data/third_party/boringssl/crypto/modes/cfb.c +5 -6
- data/third_party/boringssl/crypto/modes/ctr.c +10 -18
- data/third_party/boringssl/crypto/modes/gcm.c +100 -66
- data/third_party/boringssl/crypto/modes/internal.h +15 -27
- data/third_party/boringssl/crypto/modes/ofb.c +9 -22
- data/third_party/boringssl/crypto/newhope/error_correction.c +131 -0
- data/third_party/boringssl/crypto/newhope/internal.h +71 -0
- data/third_party/boringssl/crypto/newhope/newhope.c +174 -0
- data/third_party/boringssl/crypto/newhope/ntt.c +148 -0
- data/third_party/boringssl/crypto/newhope/poly.c +183 -0
- data/third_party/boringssl/crypto/newhope/precomp.c +306 -0
- data/third_party/boringssl/crypto/newhope/reduce.c +42 -0
- data/third_party/boringssl/crypto/obj/obj.c +111 -135
- data/third_party/boringssl/crypto/obj/obj_dat.h +4 -10
- data/third_party/boringssl/crypto/pem/pem_lib.c +6 -43
- data/third_party/boringssl/crypto/pem/pem_pkey.c +10 -19
- data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +1 -0
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +2 -1
- data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +2 -2
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +95 -87
- data/third_party/boringssl/crypto/{test/test_util.h → poly1305/internal.h} +15 -10
- data/third_party/boringssl/crypto/poly1305/poly1305.c +8 -15
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +1 -0
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +3 -3
- data/third_party/boringssl/crypto/rand/deterministic.c +47 -0
- data/third_party/boringssl/crypto/rand/rand.c +4 -1
- data/third_party/boringssl/crypto/rand/urandom.c +5 -7
- data/third_party/boringssl/crypto/rand/windows.c +5 -8
- data/third_party/boringssl/crypto/rc4/rc4.c +24 -209
- data/third_party/boringssl/crypto/refcount_lock.c +2 -2
- data/third_party/boringssl/crypto/rsa/blinding.c +74 -232
- data/third_party/boringssl/crypto/rsa/internal.h +5 -13
- data/third_party/boringssl/crypto/rsa/padding.c +64 -63
- data/third_party/boringssl/crypto/rsa/rsa.c +50 -28
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +8 -16
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +134 -122
- data/third_party/boringssl/crypto/sha/sha256.c +2 -2
- data/third_party/boringssl/crypto/sha/sha512.c +7 -7
- data/third_party/boringssl/crypto/stack/stack.c +13 -22
- data/third_party/boringssl/crypto/thread.c +21 -12
- data/third_party/boringssl/crypto/thread_none.c +6 -2
- data/third_party/boringssl/crypto/thread_pthread.c +16 -7
- data/third_party/boringssl/crypto/thread_win.c +38 -85
- data/third_party/boringssl/crypto/x509/a_sign.c +3 -3
- data/third_party/boringssl/crypto/x509/a_strex.c +1 -1
- data/third_party/boringssl/crypto/x509/a_verify.c +2 -2
- data/third_party/boringssl/crypto/{evp → x509}/algorithm.c +37 -53
- data/third_party/boringssl/crypto/x509/asn1_gen.c +1 -2
- data/third_party/boringssl/crypto/x509/by_dir.c +6 -6
- data/third_party/boringssl/crypto/x509/internal.h +66 -0
- data/third_party/boringssl/crypto/x509/rsa_pss.c +385 -0
- data/third_party/boringssl/crypto/x509/t_x509.c +10 -12
- data/third_party/boringssl/crypto/x509/x509.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_att.c +9 -3
- data/third_party/boringssl/crypto/x509/x509_lu.c +34 -44
- data/third_party/boringssl/crypto/x509/x509_obj.c +19 -2
- data/third_party/boringssl/crypto/x509/x509_r2x.c +9 -5
- data/third_party/boringssl/crypto/x509/x509_set.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_txt.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_vfy.c +63 -32
- data/third_party/boringssl/crypto/x509/x509_vpm.c +29 -18
- data/third_party/boringssl/crypto/x509/x509cset.c +2 -1
- data/third_party/boringssl/crypto/x509/x_crl.c +2 -2
- data/third_party/boringssl/crypto/x509/x_name.c +14 -17
- data/third_party/boringssl/crypto/x509/x_pubkey.c +10 -7
- data/third_party/boringssl/crypto/x509/x_x509.c +67 -6
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +2 -1
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +4 -3
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +5 -0
- data/third_party/boringssl/crypto/x509v3/v3_prn.c +0 -3
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +2 -2
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +2 -1
- data/third_party/boringssl/include/openssl/aead.h +72 -73
- data/third_party/boringssl/include/openssl/arm_arch.h +0 -6
- data/third_party/boringssl/include/openssl/asn1.h +103 -235
- data/third_party/boringssl/include/openssl/asn1_mac.h +17 -74
- data/third_party/boringssl/include/openssl/asn1t.h +1 -11
- data/third_party/boringssl/include/openssl/base.h +145 -3
- data/third_party/boringssl/include/openssl/base64.h +20 -17
- data/third_party/boringssl/include/openssl/bio.h +59 -34
- data/third_party/boringssl/include/openssl/bn.h +118 -51
- data/third_party/boringssl/include/openssl/buf.h +15 -0
- data/third_party/boringssl/include/openssl/bytestring.h +52 -4
- data/third_party/boringssl/include/openssl/chacha.h +2 -2
- data/third_party/boringssl/include/openssl/cipher.h +18 -1
- data/third_party/boringssl/include/openssl/cmac.h +11 -0
- data/third_party/boringssl/include/openssl/conf.h +13 -2
- data/third_party/boringssl/include/openssl/cpu.h +20 -23
- data/third_party/boringssl/include/openssl/crypto.h +22 -1
- data/third_party/boringssl/include/openssl/curve25519.h +96 -4
- data/third_party/boringssl/include/openssl/dh.h +71 -16
- data/third_party/boringssl/include/openssl/digest.h +38 -11
- data/third_party/boringssl/include/openssl/dsa.h +40 -4
- data/third_party/boringssl/include/openssl/ec.h +44 -18
- data/third_party/boringssl/include/openssl/ec_key.h +27 -6
- data/third_party/boringssl/include/openssl/ecdsa.h +11 -0
- data/third_party/boringssl/include/openssl/engine.h +11 -0
- data/third_party/boringssl/include/openssl/evp.h +52 -88
- data/third_party/boringssl/include/openssl/hkdf.h +24 -4
- data/third_party/boringssl/include/openssl/hmac.h +20 -6
- data/third_party/boringssl/include/openssl/md4.h +4 -0
- data/third_party/boringssl/include/openssl/mem.h +19 -0
- data/third_party/boringssl/include/openssl/newhope.h +158 -0
- data/third_party/boringssl/include/openssl/nid.h +4166 -0
- data/third_party/boringssl/include/openssl/obj.h +31 -3
- data/third_party/boringssl/include/openssl/obj_mac.h +17 -4143
- data/third_party/boringssl/include/openssl/{opensslfeatures.h → opensslconf.h} +3 -3
- data/third_party/boringssl/include/openssl/pem.h +5 -0
- data/third_party/boringssl/include/openssl/pkcs8.h +12 -0
- data/third_party/boringssl/include/openssl/rand.h +6 -0
- data/third_party/boringssl/include/openssl/rc4.h +6 -0
- data/third_party/boringssl/{crypto/dh/internal.h → include/openssl/ripemd.h} +38 -11
- data/third_party/boringssl/include/openssl/rsa.h +127 -65
- data/third_party/boringssl/include/openssl/sha.h +14 -10
- data/third_party/boringssl/include/openssl/ssl.h +561 -275
- data/third_party/boringssl/include/openssl/ssl3.h +18 -25
- data/third_party/boringssl/include/openssl/stack.h +2 -4
- data/third_party/boringssl/include/openssl/stack_macros.h +321 -353
- data/third_party/boringssl/include/openssl/thread.h +31 -13
- data/third_party/boringssl/include/openssl/time_support.h +1 -0
- data/third_party/boringssl/include/openssl/tls1.h +37 -33
- data/third_party/boringssl/include/openssl/x509.h +69 -26
- data/third_party/boringssl/include/openssl/x509_vfy.h +12 -10
- data/third_party/boringssl/include/openssl/x509v3.h +23 -2
- data/third_party/boringssl/ssl/custom_extensions.c +3 -5
- data/third_party/boringssl/ssl/d1_both.c +463 -499
- data/third_party/boringssl/ssl/d1_lib.c +38 -109
- data/third_party/boringssl/ssl/d1_pkt.c +173 -334
- data/third_party/boringssl/ssl/d1_srtp.c +20 -18
- data/third_party/boringssl/ssl/{d1_meth.c → dtls_method.c} +88 -15
- data/third_party/boringssl/ssl/dtls_record.c +27 -26
- data/third_party/boringssl/ssl/{s3_clnt.c → handshake_client.c} +816 -904
- data/third_party/boringssl/ssl/handshake_server.c +1932 -0
- data/third_party/boringssl/ssl/internal.h +712 -439
- data/third_party/boringssl/ssl/s3_both.c +445 -257
- data/third_party/boringssl/ssl/s3_enc.c +53 -36
- data/third_party/boringssl/ssl/s3_lib.c +23 -268
- data/third_party/boringssl/ssl/s3_pkt.c +168 -364
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +46 -17
- data/third_party/boringssl/ssl/ssl_asn1.c +56 -26
- data/third_party/boringssl/ssl/ssl_buffer.c +16 -24
- data/third_party/boringssl/ssl/ssl_cert.c +324 -49
- data/third_party/boringssl/ssl/ssl_cipher.c +205 -150
- data/third_party/boringssl/ssl/ssl_ecdh.c +287 -51
- data/third_party/boringssl/ssl/ssl_file.c +21 -68
- data/third_party/boringssl/ssl/ssl_lib.c +881 -510
- data/third_party/boringssl/ssl/ssl_rsa.c +404 -34
- data/third_party/boringssl/ssl/ssl_session.c +324 -103
- data/third_party/boringssl/ssl/ssl_stat.c +6 -88
- data/third_party/boringssl/ssl/t1_enc.c +23 -39
- data/third_party/boringssl/ssl/t1_lib.c +1120 -622
- data/third_party/boringssl/ssl/tls13_both.c +440 -0
- data/third_party/boringssl/ssl/tls13_client.c +682 -0
- data/third_party/boringssl/ssl/tls13_enc.c +391 -0
- data/third_party/boringssl/ssl/tls13_server.c +672 -0
- data/third_party/boringssl/ssl/{s3_meth.c → tls_method.c} +100 -21
- data/third_party/boringssl/ssl/tls_record.c +159 -77
- data/third_party/nanopb/pb.h +60 -28
- data/third_party/nanopb/pb_decode.c +120 -92
- data/third_party/nanopb/pb_decode.h +3 -3
- data/third_party/nanopb/pb_encode.c +73 -67
- data/third_party/nanopb/pb_encode.h +4 -4
- metadata +155 -89
- data/include/grpc/impl/codegen/byte_buffer.h +0 -122
- data/include/grpc/impl/codegen/log.h +0 -118
- data/include/grpc/impl/codegen/time.h +0 -130
- data/src/core/ext/client_config/client_channel.c +0 -593
- data/src/core/ext/client_config/subchannel_call_holder.c +0 -272
- data/src/core/ext/client_config/subchannel_call_holder.h +0 -99
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +0 -2046
- data/src/core/lib/iomgr/workqueue_posix.c +0 -151
- data/src/core/lib/security/transport/handshake.c +0 -368
- data/third_party/boringssl/crypto/asn1/a_bytes.c +0 -308
- data/third_party/boringssl/crypto/asn1/bio_asn1.c +0 -477
- data/third_party/boringssl/crypto/asn1/bio_ndef.c +0 -251
- data/third_party/boringssl/crypto/asn1/t_pkey.c +0 -110
- data/third_party/boringssl/crypto/asn1/tasn_prn.c +0 -596
- data/third_party/boringssl/crypto/chacha/chacha_vec.c +0 -328
- data/third_party/boringssl/crypto/directory.h +0 -66
- data/third_party/boringssl/crypto/directory_posix.c +0 -108
- data/third_party/boringssl/crypto/directory_win.c +0 -144
- data/third_party/boringssl/crypto/test/scoped_types.h +0 -140
- data/third_party/boringssl/include/openssl/pqueue.h +0 -146
- data/third_party/boringssl/ssl/d1_clnt.c +0 -561
- data/third_party/boringssl/ssl/d1_srvr.c +0 -476
- data/third_party/boringssl/ssl/pqueue/pqueue.c +0 -197
- data/third_party/boringssl/ssl/s3_srvr.c +0 -2272
- data/third_party/boringssl/ssl/test/async_bio.h +0 -45
- data/third_party/boringssl/ssl/test/packeted_bio.h +0 -44
- data/third_party/boringssl/ssl/test/test_config.h +0 -110
@@ -145,19 +145,23 @@
|
|
145
145
|
#include <openssl/base.h>
|
146
146
|
|
147
147
|
#include <openssl/aead.h>
|
148
|
-
#include <openssl/pqueue.h>
|
149
148
|
#include <openssl/ssl.h>
|
150
149
|
#include <openssl/stack.h>
|
151
150
|
|
151
|
+
|
152
152
|
#if defined(OPENSSL_WINDOWS)
|
153
153
|
/* Windows defines struct timeval in winsock2.h. */
|
154
|
-
|
154
|
+
OPENSSL_MSVC_PRAGMA(warning(push, 3))
|
155
155
|
#include <winsock2.h>
|
156
|
-
|
156
|
+
OPENSSL_MSVC_PRAGMA(warning(pop))
|
157
157
|
#else
|
158
158
|
#include <sys/time.h>
|
159
159
|
#endif
|
160
160
|
|
161
|
+
#if defined(__cplusplus)
|
162
|
+
extern "C" {
|
163
|
+
#endif
|
164
|
+
|
161
165
|
|
162
166
|
/* Cipher suites. */
|
163
167
|
|
@@ -167,6 +171,7 @@
|
|
167
171
|
#define SSL_kECDHE 0x00000004L
|
168
172
|
/* SSL_kPSK is only set for plain PSK, not ECDHE_PSK. */
|
169
173
|
#define SSL_kPSK 0x00000008L
|
174
|
+
#define SSL_kCECPQ1 0x00000010L
|
170
175
|
|
171
176
|
/* Bits for |algorithm_auth| (server authentication). */
|
172
177
|
#define SSL_aRSA 0x00000001L
|
@@ -174,16 +179,17 @@
|
|
174
179
|
/* SSL_aPSK is set for both PSK and ECDHE_PSK. */
|
175
180
|
#define SSL_aPSK 0x00000004L
|
176
181
|
|
182
|
+
#define SSL_aCERT (SSL_aRSA | SSL_aECDSA)
|
183
|
+
|
177
184
|
/* Bits for |algorithm_enc| (symmetric encryption). */
|
178
|
-
#define SSL_3DES
|
179
|
-
#define
|
180
|
-
#define
|
181
|
-
#define
|
182
|
-
#define
|
183
|
-
#define
|
184
|
-
#define
|
185
|
-
#define
|
186
|
-
#define SSL_CHACHA20POLY1305 0x00000100L
|
185
|
+
#define SSL_3DES 0x00000001L
|
186
|
+
#define SSL_AES128 0x00000002L
|
187
|
+
#define SSL_AES256 0x00000004L
|
188
|
+
#define SSL_AES128GCM 0x00000008L
|
189
|
+
#define SSL_AES256GCM 0x00000010L
|
190
|
+
#define SSL_CHACHA20POLY1305_OLD 0x00000020L
|
191
|
+
#define SSL_eNULL 0x00000040L
|
192
|
+
#define SSL_CHACHA20POLY1305 0x00000080L
|
187
193
|
|
188
194
|
#define SSL_AES (SSL_AES128 | SSL_AES256 | SSL_AES128GCM | SSL_AES256GCM)
|
189
195
|
|
@@ -235,21 +241,25 @@ ssl_create_cipher_list(const SSL_PROTOCOL_METHOD *ssl_method,
|
|
235
241
|
/* ssl_cipher_get_value returns the cipher suite id of |cipher|. */
|
236
242
|
uint16_t ssl_cipher_get_value(const SSL_CIPHER *cipher);
|
237
243
|
|
244
|
+
/* ssl_cipher_get_resumption_cipher returns the cipher suite id of the cipher
|
245
|
+
* matching |cipher| with PSK enabled. */
|
246
|
+
int ssl_cipher_get_ecdhe_psk_cipher(const SSL_CIPHER *cipher,
|
247
|
+
uint16_t *out_cipher);
|
248
|
+
|
238
249
|
/* ssl_cipher_get_key_type returns the |EVP_PKEY_*| value corresponding to the
|
239
250
|
* server key used in |cipher| or |EVP_PKEY_NONE| if there is none. */
|
240
251
|
int ssl_cipher_get_key_type(const SSL_CIPHER *cipher);
|
241
252
|
|
242
|
-
/*
|
243
|
-
*
|
244
|
-
*
|
245
|
-
int
|
253
|
+
/* ssl_cipher_uses_certificate_auth returns one if |cipher| authenticates the
|
254
|
+
* server and, optionally, the client with a certificate. Otherwise it returns
|
255
|
+
* zero. */
|
256
|
+
int ssl_cipher_uses_certificate_auth(const SSL_CIPHER *cipher);
|
246
257
|
|
247
258
|
/* ssl_cipher_requires_server_key_exchange returns 1 if |cipher| requires a
|
248
259
|
* ServerKeyExchange message. Otherwise it returns 0.
|
249
260
|
*
|
250
|
-
*
|
251
|
-
*
|
252
|
-
* case for plain PSK ciphers. */
|
261
|
+
* This function may return zero while still allowing |cipher| an optional
|
262
|
+
* ServerKeyExchange. This is the case for plain PSK ciphers. */
|
253
263
|
int ssl_cipher_requires_server_key_exchange(const SSL_CIPHER *cipher);
|
254
264
|
|
255
265
|
/* ssl_cipher_get_record_split_len, for TLS 1.0 CBC mode ciphers, returns the
|
@@ -282,6 +292,8 @@ struct ssl_aead_ctx_st {
|
|
282
292
|
/* omit_version_in_ad is non-zero if the version should be omitted
|
283
293
|
* in the AEAD's ad parameter. */
|
284
294
|
char omit_version_in_ad;
|
295
|
+
/* omit_ad is non-zero if the AEAD's ad parameter should be omitted. */
|
296
|
+
char omit_ad;
|
285
297
|
/* xor_fixed_nonce is non-zero if the fixed nonce should be XOR'd into the
|
286
298
|
* variable nonce rather than prepended. */
|
287
299
|
char xor_fixed_nonce;
|
@@ -309,21 +321,19 @@ size_t SSL_AEAD_CTX_explicit_nonce_len(SSL_AEAD_CTX *ctx);
|
|
309
321
|
* |SSL_AEAD_CTX_seal|. |ctx| may be NULL to denote the null cipher. */
|
310
322
|
size_t SSL_AEAD_CTX_max_overhead(SSL_AEAD_CTX *ctx);
|
311
323
|
|
312
|
-
/* SSL_AEAD_CTX_open authenticates and decrypts |in_len| bytes from |in|
|
313
|
-
*
|
314
|
-
*
|
315
|
-
*
|
316
|
-
*
|
317
|
-
|
318
|
-
|
319
|
-
const uint8_t seqnum[8], const uint8_t *in,
|
320
|
-
size_t in_len);
|
324
|
+
/* SSL_AEAD_CTX_open authenticates and decrypts |in_len| bytes from |in|
|
325
|
+
* in-place. On success, it sets |*out| to the plaintext in |in| and returns
|
326
|
+
* one. Otherwise, it returns zero. |ctx| may be NULL to denote the null cipher.
|
327
|
+
* The output will always be |explicit_nonce_len| bytes ahead of |in|. */
|
328
|
+
int SSL_AEAD_CTX_open(SSL_AEAD_CTX *ctx, CBS *out, uint8_t type,
|
329
|
+
uint16_t wire_version, const uint8_t seqnum[8],
|
330
|
+
uint8_t *in, size_t in_len);
|
321
331
|
|
322
332
|
/* SSL_AEAD_CTX_seal encrypts and authenticates |in_len| bytes from |in| and
|
323
333
|
* writes the result to |out|. It returns one on success and zero on
|
324
334
|
* error. |ctx| may be NULL to denote the null cipher.
|
325
335
|
*
|
326
|
-
* If |in| and |out| alias then |out| + |explicit_nonce_len| must be
|
336
|
+
* If |in| and |out| alias then |out| + |explicit_nonce_len| must be == |in|. */
|
327
337
|
int SSL_AEAD_CTX_seal(SSL_AEAD_CTX *ctx, uint8_t *out, size_t *out_len,
|
328
338
|
size_t max_out, uint8_t type, uint16_t wire_version,
|
329
339
|
const uint8_t seqnum[8], const uint8_t *in,
|
@@ -361,52 +371,60 @@ enum ssl_open_record_t {
|
|
361
371
|
ssl_open_record_success,
|
362
372
|
ssl_open_record_discard,
|
363
373
|
ssl_open_record_partial,
|
374
|
+
ssl_open_record_close_notify,
|
375
|
+
ssl_open_record_fatal_alert,
|
364
376
|
ssl_open_record_error,
|
365
377
|
};
|
366
378
|
|
367
|
-
/* tls_open_record decrypts a record from |in
|
368
|
-
*
|
369
|
-
* On success, it returns |ssl_open_record_success|. It sets |*out_type| to the
|
370
|
-
* record type, |*out_len| to the plaintext length, and writes the record body
|
371
|
-
* to |out|. It sets |*out_consumed| to the number of bytes of |in| consumed.
|
372
|
-
* Note that |*out_len| may be zero.
|
373
|
-
*
|
374
|
-
* If a record was successfully processed but should be discarded, it returns
|
375
|
-
* |ssl_open_record_discard| and sets |*out_consumed| to the number of bytes
|
376
|
-
* consumed.
|
379
|
+
/* tls_open_record decrypts a record from |in| in-place.
|
377
380
|
*
|
378
381
|
* If the input did not contain a complete record, it returns
|
379
382
|
* |ssl_open_record_partial|. It sets |*out_consumed| to the total number of
|
380
383
|
* bytes necessary. It is guaranteed that a successful call to |tls_open_record|
|
381
384
|
* will consume at least that many bytes.
|
382
385
|
*
|
383
|
-
*
|
384
|
-
*
|
386
|
+
* Otherwise, it sets |*out_consumed| to the number of bytes of input
|
387
|
+
* consumed. Note that input may be consumed on all return codes if a record was
|
388
|
+
* decrypted.
|
389
|
+
*
|
390
|
+
* On success, it returns |ssl_open_record_success|. It sets |*out_type| to the
|
391
|
+
* record type and |*out| to the record body in |in|. Note that |*out| may be
|
392
|
+
* empty.
|
393
|
+
*
|
394
|
+
* If a record was successfully processed but should be discarded, it returns
|
395
|
+
* |ssl_open_record_discard|.
|
385
396
|
*
|
386
|
-
* If
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
397
|
+
* If a record was successfully processed but is a close_notify or fatal alert,
|
398
|
+
* it returns |ssl_open_record_close_notify| or |ssl_open_record_fatal_alert|.
|
399
|
+
*
|
400
|
+
* On failure, it returns |ssl_open_record_error| and sets |*out_alert| to an
|
401
|
+
* alert to emit. */
|
402
|
+
enum ssl_open_record_t tls_open_record(SSL *ssl, uint8_t *out_type, CBS *out,
|
403
|
+
size_t *out_consumed, uint8_t *out_alert,
|
404
|
+
uint8_t *in, size_t in_len);
|
391
405
|
|
392
406
|
/* dtls_open_record implements |tls_open_record| for DTLS. It never returns
|
393
407
|
* |ssl_open_record_partial| but otherwise behaves analogously. */
|
394
|
-
enum ssl_open_record_t dtls_open_record(
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
/*
|
400
|
-
* when sealing a record with |ssl|.
|
401
|
-
*
|
402
|
-
*
|
408
|
+
enum ssl_open_record_t dtls_open_record(SSL *ssl, uint8_t *out_type, CBS *out,
|
409
|
+
size_t *out_consumed,
|
410
|
+
uint8_t *out_alert, uint8_t *in,
|
411
|
+
size_t in_len);
|
412
|
+
|
413
|
+
/* ssl_seal_align_prefix_len returns the length of the prefix before the start
|
414
|
+
* of the bulk of the ciphertext when sealing a record with |ssl|. Callers may
|
415
|
+
* use this to align buffers.
|
416
|
+
*
|
417
|
+
* Note when TLS 1.0 CBC record-splitting is enabled, this includes the one byte
|
418
|
+
* record and is the offset into second record's ciphertext. Thus this value may
|
419
|
+
* differ from |ssl_record_prefix_len| and sealing a small record may result in
|
420
|
+
* a smaller output than this value.
|
403
421
|
*
|
404
422
|
* TODO(davidben): Expose this as part of public API once the high-level
|
405
423
|
* buffer-free APIs are available. */
|
406
|
-
size_t
|
424
|
+
size_t ssl_seal_align_prefix_len(const SSL *ssl);
|
407
425
|
|
408
426
|
/* ssl_max_seal_overhead returns the maximum overhead of sealing a record with
|
409
|
-
* |ssl|.
|
427
|
+
* |ssl|.
|
410
428
|
*
|
411
429
|
* TODO(davidben): Expose this as part of public API once the high-level
|
412
430
|
* buffer-free APIs are available. */
|
@@ -417,11 +435,12 @@ size_t ssl_max_seal_overhead(const SSL *ssl);
|
|
417
435
|
* and zero on error. If enabled, |tls_seal_record| implements TLS 1.0 CBC 1/n-1
|
418
436
|
* record splitting and may write two records concatenated.
|
419
437
|
*
|
420
|
-
* For a large record, the ciphertext will begin
|
421
|
-
* into out. Aligning |out| appropriately may
|
422
|
-
* most |in_len| + |ssl_max_seal_overhead|
|
438
|
+
* For a large record, the bulk of the ciphertext will begin
|
439
|
+
* |ssl_seal_align_prefix_len| bytes into out. Aligning |out| appropriately may
|
440
|
+
* improve performance. It writes at most |in_len| + |ssl_max_seal_overhead|
|
441
|
+
* bytes to |out|.
|
423
442
|
*
|
424
|
-
*
|
443
|
+
* |in| and |out| may not alias. */
|
425
444
|
int tls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
426
445
|
uint8_t type, const uint8_t *in, size_t in_len);
|
427
446
|
|
@@ -436,20 +455,23 @@ int dtls_seal_record(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
|
436
455
|
uint8_t type, const uint8_t *in, size_t in_len,
|
437
456
|
enum dtls1_use_epoch_t use_epoch);
|
438
457
|
|
439
|
-
/*
|
440
|
-
*
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
*
|
445
|
-
void ssl_set_write_state(SSL *ssl, SSL_AEAD_CTX *aead_ctx);
|
458
|
+
/* ssl_process_alert processes |in| as an alert and updates |ssl|'s shutdown
|
459
|
+
* state. It returns one of |ssl_open_record_discard|, |ssl_open_record_error|,
|
460
|
+
* |ssl_open_record_close_notify|, or |ssl_open_record_fatal_alert| as
|
461
|
+
* appropriate. */
|
462
|
+
enum ssl_open_record_t ssl_process_alert(SSL *ssl, uint8_t *out_alert,
|
463
|
+
const uint8_t *in, size_t in_len);
|
446
464
|
|
447
465
|
|
448
466
|
/* Private key operations. */
|
449
467
|
|
450
468
|
/* ssl_has_private_key returns one if |ssl| has a private key
|
451
469
|
* configured and zero otherwise. */
|
452
|
-
int ssl_has_private_key(SSL *ssl);
|
470
|
+
int ssl_has_private_key(const SSL *ssl);
|
471
|
+
|
472
|
+
/* ssl_is_ecdsa_key_type returns one if |type| is an ECDSA key type and zero
|
473
|
+
* otherwise. */
|
474
|
+
int ssl_is_ecdsa_key_type(int type);
|
453
475
|
|
454
476
|
/* ssl_private_key_* call the corresponding function on the
|
455
477
|
* |SSL_PRIVATE_KEY_METHOD| for |ssl|, if configured. Otherwise, they implement
|
@@ -460,18 +482,28 @@ int ssl_private_key_type(SSL *ssl);
|
|
460
482
|
size_t ssl_private_key_max_signature_len(SSL *ssl);
|
461
483
|
|
462
484
|
enum ssl_private_key_result_t ssl_private_key_sign(
|
463
|
-
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
464
|
-
const uint8_t *in, size_t in_len);
|
465
|
-
|
466
|
-
enum ssl_private_key_result_t ssl_private_key_sign_complete(
|
467
|
-
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out);
|
485
|
+
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
486
|
+
uint16_t signature_algorithm, const uint8_t *in, size_t in_len);
|
468
487
|
|
469
488
|
enum ssl_private_key_result_t ssl_private_key_decrypt(
|
470
489
|
SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out,
|
471
490
|
const uint8_t *in, size_t in_len);
|
472
491
|
|
473
|
-
enum ssl_private_key_result_t
|
474
|
-
|
492
|
+
enum ssl_private_key_result_t ssl_private_key_complete(SSL *ssl, uint8_t *out,
|
493
|
+
size_t *out_len,
|
494
|
+
size_t max_out);
|
495
|
+
|
496
|
+
/* ssl_private_key_supports_signature_algorithm returns one if |ssl|'s private
|
497
|
+
* key supports |signature_algorithm| and zero otherwise. */
|
498
|
+
int ssl_private_key_supports_signature_algorithm(SSL *ssl,
|
499
|
+
uint16_t signature_algorithm);
|
500
|
+
|
501
|
+
/* ssl_public_key_verify verifies that the |signature| is valid for the public
|
502
|
+
* key |pkey| and input |in|, using the |signature_algorithm| specified. */
|
503
|
+
int ssl_public_key_verify(
|
504
|
+
SSL *ssl, const uint8_t *signature, size_t signature_len,
|
505
|
+
uint16_t signature_algorithm, EVP_PKEY *pkey,
|
506
|
+
const uint8_t *in, size_t in_len);
|
475
507
|
|
476
508
|
|
477
509
|
/* Custom extensions */
|
@@ -526,60 +558,133 @@ void ssl3_free_handshake_hash(SSL *ssl);
|
|
526
558
|
int ssl3_update_handshake_hash(SSL *ssl, const uint8_t *in, size_t in_len);
|
527
559
|
|
528
560
|
|
529
|
-
/* ECDH
|
530
|
-
|
531
|
-
#define SSL_CURVE_SECP256R1 23
|
532
|
-
#define SSL_CURVE_SECP384R1 24
|
533
|
-
#define SSL_CURVE_SECP521R1 25
|
534
|
-
#define SSL_CURVE_X25519 29
|
561
|
+
/* ECDH groups. */
|
535
562
|
|
536
563
|
/* An SSL_ECDH_METHOD is an implementation of ECDH-like key exchanges for
|
537
564
|
* TLS. */
|
538
565
|
struct ssl_ecdh_method_st {
|
539
566
|
int nid;
|
540
|
-
uint16_t
|
567
|
+
uint16_t group_id;
|
541
568
|
const char name[8];
|
542
569
|
|
543
570
|
/* cleanup releases state in |ctx|. */
|
544
571
|
void (*cleanup)(SSL_ECDH_CTX *ctx);
|
545
572
|
|
546
|
-
/*
|
573
|
+
/* offer generates a keypair and writes the public value to
|
547
574
|
* |out_public_key|. It returns one on success and zero on error. */
|
548
|
-
int (*
|
549
|
-
|
550
|
-
/*
|
551
|
-
* success, returns one
|
552
|
-
*
|
553
|
-
*
|
554
|
-
*
|
555
|
-
|
556
|
-
|
557
|
-
|
575
|
+
int (*offer)(SSL_ECDH_CTX *ctx, CBB *out_public_key);
|
576
|
+
|
577
|
+
/* accept performs a key exchange against the |peer_key| generated by |offer|.
|
578
|
+
* On success, it returns one, writes the public value to |out_public_key|,
|
579
|
+
* and sets |*out_secret| and |*out_secret_len| to a newly-allocated buffer
|
580
|
+
* containing the shared secret. The caller must release this buffer with
|
581
|
+
* |OPENSSL_free|. On failure, it returns zero and sets |*out_alert| to an
|
582
|
+
* alert to send to the peer. */
|
583
|
+
int (*accept)(SSL_ECDH_CTX *ctx, CBB *out_public_key, uint8_t **out_secret,
|
584
|
+
size_t *out_secret_len, uint8_t *out_alert,
|
585
|
+
const uint8_t *peer_key, size_t peer_key_len);
|
586
|
+
|
587
|
+
/* finish performs a key exchange against the |peer_key| generated by
|
588
|
+
* |accept|. On success, it returns one and sets |*out_secret| and
|
589
|
+
* |*out_secret_len| to a newly-allocated buffer containing the shared
|
590
|
+
* secret. The caller must release this buffer with |OPENSSL_free|. On
|
591
|
+
* failure, it returns zero and sets |*out_alert| to an alert to send to the
|
592
|
+
* peer. */
|
593
|
+
int (*finish)(SSL_ECDH_CTX *ctx, uint8_t **out_secret, size_t *out_secret_len,
|
594
|
+
uint8_t *out_alert, const uint8_t *peer_key,
|
595
|
+
size_t peer_key_len);
|
596
|
+
|
597
|
+
/* get_key initializes |out| with a length-prefixed key from |cbs|. It returns
|
598
|
+
* one on success and zero on error. */
|
599
|
+
int (*get_key)(CBS *cbs, CBS *out);
|
600
|
+
|
601
|
+
/* add_key initializes |out_contents| to receive a key. Typically it will then
|
602
|
+
* be passed to |offer| or |accept|. It returns one on success and zero on
|
603
|
+
* error. */
|
604
|
+
int (*add_key)(CBB *cbb, CBB *out_contents);
|
558
605
|
} /* SSL_ECDH_METHOD */;
|
559
606
|
|
560
|
-
/*
|
561
|
-
* sets |*
|
607
|
+
/* ssl_nid_to_group_id looks up the group corresponding to |nid|. On success, it
|
608
|
+
* sets |*out_group_id| to the group ID and returns one. Otherwise, it returns
|
562
609
|
* zero. */
|
563
|
-
int
|
610
|
+
int ssl_nid_to_group_id(uint16_t *out_group_id, int nid);
|
564
611
|
|
565
|
-
/* SSL_ECDH_CTX_init sets up |ctx| for use with curve |
|
612
|
+
/* SSL_ECDH_CTX_init sets up |ctx| for use with curve |group_id|. It returns one
|
566
613
|
* on success and zero on error. */
|
567
|
-
int SSL_ECDH_CTX_init(SSL_ECDH_CTX *ctx, uint16_t
|
614
|
+
int SSL_ECDH_CTX_init(SSL_ECDH_CTX *ctx, uint16_t group_id);
|
568
615
|
|
569
616
|
/* SSL_ECDH_CTX_init_for_dhe sets up |ctx| for use with legacy DHE-based ciphers
|
570
617
|
* where the server specifies a group. It takes ownership of |params|. */
|
571
618
|
void SSL_ECDH_CTX_init_for_dhe(SSL_ECDH_CTX *ctx, DH *params);
|
572
619
|
|
620
|
+
/* SSL_ECDH_CTX_init_for_cecpq1 sets up |ctx| for use with CECPQ1. */
|
621
|
+
void SSL_ECDH_CTX_init_for_cecpq1(SSL_ECDH_CTX *ctx);
|
622
|
+
|
573
623
|
/* SSL_ECDH_CTX_cleanup releases memory associated with |ctx|. It is legal to
|
574
624
|
* call it in the zero state. */
|
575
625
|
void SSL_ECDH_CTX_cleanup(SSL_ECDH_CTX *ctx);
|
576
626
|
|
577
|
-
/*
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
627
|
+
/* SSL_ECDH_CTX_get_id returns the group ID for |ctx|. */
|
628
|
+
uint16_t SSL_ECDH_CTX_get_id(const SSL_ECDH_CTX *ctx);
|
629
|
+
|
630
|
+
/* SSL_ECDH_CTX_get_key calls the |get_key| method of |SSL_ECDH_METHOD|. */
|
631
|
+
int SSL_ECDH_CTX_get_key(SSL_ECDH_CTX *ctx, CBS *cbs, CBS *out);
|
632
|
+
|
633
|
+
/* SSL_ECDH_CTX_add_key calls the |add_key| method of |SSL_ECDH_METHOD|. */
|
634
|
+
int SSL_ECDH_CTX_add_key(SSL_ECDH_CTX *ctx, CBB *cbb, CBB *out_contents);
|
635
|
+
|
636
|
+
/* SSL_ECDH_CTX_offer calls the |offer| method of |SSL_ECDH_METHOD|. */
|
637
|
+
int SSL_ECDH_CTX_offer(SSL_ECDH_CTX *ctx, CBB *out_public_key);
|
638
|
+
|
639
|
+
/* SSL_ECDH_CTX_accept calls the |accept| method of |SSL_ECDH_METHOD|. */
|
640
|
+
int SSL_ECDH_CTX_accept(SSL_ECDH_CTX *ctx, CBB *out_public_key,
|
641
|
+
uint8_t **out_secret, size_t *out_secret_len,
|
642
|
+
uint8_t *out_alert, const uint8_t *peer_key,
|
643
|
+
size_t peer_key_len);
|
644
|
+
|
645
|
+
/* SSL_ECDH_CTX_finish the |finish| method of |SSL_ECDH_METHOD|. */
|
646
|
+
int SSL_ECDH_CTX_finish(SSL_ECDH_CTX *ctx, uint8_t **out_secret,
|
647
|
+
size_t *out_secret_len, uint8_t *out_alert,
|
648
|
+
const uint8_t *peer_key, size_t peer_key_len);
|
649
|
+
|
650
|
+
/* Handshake messages. */
|
651
|
+
|
652
|
+
/* SSL_MAX_HANDSHAKE_FLIGHT is the number of messages, including
|
653
|
+
* ChangeCipherSpec, in the longest handshake flight. Currently this is the
|
654
|
+
* client's second leg in a full handshake when client certificates, NPN, and
|
655
|
+
* Channel ID, are all enabled. */
|
656
|
+
#define SSL_MAX_HANDSHAKE_FLIGHT 7
|
657
|
+
|
658
|
+
/* ssl_max_handshake_message_len returns the maximum number of bytes permitted
|
659
|
+
* in a handshake message for |ssl|. */
|
660
|
+
size_t ssl_max_handshake_message_len(const SSL *ssl);
|
661
|
+
|
662
|
+
/* dtls_clear_incoming_messages releases all buffered incoming messages. */
|
663
|
+
void dtls_clear_incoming_messages(SSL *ssl);
|
664
|
+
|
665
|
+
/* dtls_has_incoming_messages returns one if there are buffered incoming
|
666
|
+
* messages ahead of the current message and zero otherwise. */
|
667
|
+
int dtls_has_incoming_messages(const SSL *ssl);
|
668
|
+
|
669
|
+
typedef struct dtls_outgoing_message_st {
|
670
|
+
uint8_t *data;
|
671
|
+
uint32_t len;
|
672
|
+
uint16_t epoch;
|
673
|
+
char is_ccs;
|
674
|
+
} DTLS_OUTGOING_MESSAGE;
|
675
|
+
|
676
|
+
/* dtls_clear_outgoing_messages releases all buffered outgoing messages. */
|
677
|
+
void dtls_clear_outgoing_messages(SSL *ssl);
|
678
|
+
|
679
|
+
|
680
|
+
/* Callbacks. */
|
681
|
+
|
682
|
+
/* ssl_do_info_callback calls |ssl|'s info callback, if set. */
|
683
|
+
void ssl_do_info_callback(const SSL *ssl, int type, int value);
|
684
|
+
|
685
|
+
/* ssl_do_msg_callback calls |ssl|'s message callback, if set. */
|
686
|
+
void ssl_do_msg_callback(SSL *ssl, int is_write, int content_type,
|
687
|
+
const void *buf, size_t len);
|
583
688
|
|
584
689
|
|
585
690
|
/* Transport buffers. */
|
@@ -637,117 +742,301 @@ int ssl_write_buffer_flush(SSL *ssl);
|
|
637
742
|
void ssl_write_buffer_clear(SSL *ssl);
|
638
743
|
|
639
744
|
|
745
|
+
/* Certificate functions. */
|
746
|
+
|
747
|
+
/* ssl_has_certificate returns one if a certificate and private key are
|
748
|
+
* configured and zero otherwise. */
|
749
|
+
int ssl_has_certificate(const SSL *ssl);
|
750
|
+
|
751
|
+
/* ssl_parse_cert_chain parses a certificate list from |cbs| in the format used
|
752
|
+
* by a TLS Certificate message. On success, it returns a newly-allocated
|
753
|
+
* |X509| list and advances |cbs|. Otherwise, it returns NULL and sets
|
754
|
+
* |*out_alert| to an alert to send to the peer. If the list is non-empty and
|
755
|
+
* |out_leaf_sha256| is non-NULL, it writes the SHA-256 hash of the leaf to
|
756
|
+
* |out_leaf_sha256|. */
|
757
|
+
STACK_OF(X509) *ssl_parse_cert_chain(SSL *ssl, uint8_t *out_alert,
|
758
|
+
uint8_t *out_leaf_sha256, CBS *cbs);
|
759
|
+
|
760
|
+
/* ssl_add_cert_to_cbb adds |x509| to |cbb|. It returns one on success and zero
|
761
|
+
* on error. */
|
762
|
+
int ssl_add_cert_to_cbb(CBB *cbb, X509 *x509);
|
763
|
+
|
764
|
+
/* ssl_add_cert_chain adds |ssl|'s certificate chain to |cbb| in the format used
|
765
|
+
* by a TLS Certificate message. If there is no certificate chain, it emits an
|
766
|
+
* empty certificate list. It returns one on success and zero on error. */
|
767
|
+
int ssl_add_cert_chain(SSL *ssl, CBB *cbb);
|
768
|
+
|
769
|
+
/* ssl_parse_client_CA_list parses a CA list from |cbs| in the format used by a
|
770
|
+
* TLS CertificateRequest message. On success, it returns a newly-allocated
|
771
|
+
* |X509_NAME| list and advances |cbs|. Otherwise, it returns NULL and sets
|
772
|
+
* |*out_alert| to an alert to send to the peer. */
|
773
|
+
STACK_OF(X509_NAME) *
|
774
|
+
ssl_parse_client_CA_list(SSL *ssl, uint8_t *out_alert, CBS *cbs);
|
775
|
+
|
776
|
+
/* ssl_add_client_CA_list adds the configured CA list to |cbb| in the format
|
777
|
+
* used by a TLS CertificateRequest message. It returns one on success and zero
|
778
|
+
* on error. */
|
779
|
+
int ssl_add_client_CA_list(SSL *ssl, CBB *cbb);
|
780
|
+
|
781
|
+
/* ssl_check_leaf_certificate returns one if |leaf| is a suitable leaf server
|
782
|
+
* certificate for |ssl|. Otherwise, it returns zero and pushes an error on the
|
783
|
+
* error queue. */
|
784
|
+
int ssl_check_leaf_certificate(SSL *ssl, X509 *leaf);
|
785
|
+
|
786
|
+
/* ssl_do_client_cert_cb runs the client_cert_cb, if any, and returns one on
|
787
|
+
* success and zero on error. On error, it sets |*out_should_retry| to one if
|
788
|
+
* the callback failed and should be retried and zero otherwise. */
|
789
|
+
int ssl_do_client_cert_cb(SSL *ssl, int *out_should_retry);
|
790
|
+
|
791
|
+
|
792
|
+
/* TLS 1.3 key derivation. */
|
793
|
+
|
794
|
+
/* tls13_init_key_schedule initializes the handshake hash and key derivation
|
795
|
+
* state with the given resumption context. The cipher suite and PRF hash must
|
796
|
+
* have been selected at this point. It returns one on success and zero on
|
797
|
+
* error. */
|
798
|
+
int tls13_init_key_schedule(SSL *ssl, const uint8_t *resumption_ctx,
|
799
|
+
size_t resumption_ctx_len);
|
800
|
+
|
801
|
+
/* tls13_advance_key_schedule incorporates |in| into the key schedule with
|
802
|
+
* HKDF-Extract. It returns one on success and zero on error. */
|
803
|
+
int tls13_advance_key_schedule(SSL *ssl, const uint8_t *in, size_t len);
|
804
|
+
|
805
|
+
/* tls13_get_context_hashes writes Hash(Handshake Context) +
|
806
|
+
* Hash(resumption_context) to |out| which much have room for at least 2 *
|
807
|
+
* |EVP_MAX_MD_SIZE| bytes. On success, it returns one and sets |*out_len| to
|
808
|
+
* the number of bytes written. Otherwise, it returns zero. */
|
809
|
+
int tls13_get_context_hashes(SSL *ssl, uint8_t *out, size_t *out_len);
|
810
|
+
|
811
|
+
enum tls_record_type_t {
|
812
|
+
type_early_handshake,
|
813
|
+
type_early_data,
|
814
|
+
type_handshake,
|
815
|
+
type_data,
|
816
|
+
};
|
817
|
+
|
818
|
+
/* tls13_set_traffic_key sets the read or write traffic keys to |traffic_secret|
|
819
|
+
* for the given traffic phase |type|. It returns one on success and zero on
|
820
|
+
* error. */
|
821
|
+
int tls13_set_traffic_key(SSL *ssl, enum tls_record_type_t type,
|
822
|
+
enum evp_aead_direction_t direction,
|
823
|
+
const uint8_t *traffic_secret,
|
824
|
+
size_t traffic_secret_len);
|
825
|
+
|
826
|
+
/* tls13_set_handshake_traffic derives the handshake traffic secret and
|
827
|
+
* switches both read and write traffic to it. It returns one on success and
|
828
|
+
* zero on error. */
|
829
|
+
int tls13_set_handshake_traffic(SSL *ssl);
|
830
|
+
|
831
|
+
/* tls13_rotate_traffic_key derives the next read or write traffic secret. It
|
832
|
+
* returns one on success and zero on error. */
|
833
|
+
int tls13_rotate_traffic_key(SSL *ssl, enum evp_aead_direction_t direction);
|
834
|
+
|
835
|
+
/* tls13_derive_traffic_secret_0 derives the initial application data traffic
|
836
|
+
* secret based on the handshake transcripts and |master_secret|. It returns one
|
837
|
+
* on success and zero on error. */
|
838
|
+
int tls13_derive_traffic_secret_0(SSL *ssl);
|
839
|
+
|
840
|
+
/* tls13_finalize_keys derives the |exporter_secret| and |resumption_secret|. */
|
841
|
+
int tls13_finalize_keys(SSL *ssl);
|
842
|
+
|
843
|
+
/* tls13_export_keying_material provides and exporter interface to use the
|
844
|
+
* |exporter_secret|. */
|
845
|
+
int tls13_export_keying_material(SSL *ssl, uint8_t *out, size_t out_len,
|
846
|
+
const char *label, size_t label_len,
|
847
|
+
const uint8_t *context, size_t context_len,
|
848
|
+
int use_context);
|
849
|
+
|
850
|
+
/* tls13_finished_mac calculates the MAC of the handshake transcript to verify
|
851
|
+
* the integrity of the Finished message, and stores the result in |out| and
|
852
|
+
* length in |out_len|. |is_server| is 1 if this is for the Server Finished and
|
853
|
+
* 0 for the Client Finished. */
|
854
|
+
int tls13_finished_mac(SSL *ssl, uint8_t *out, size_t *out_len, int is_server);
|
855
|
+
|
856
|
+
/* tls13_resumption_psk calculates the PSK to use for the resumption of
|
857
|
+
* |session| and stores the result in |out|. It returns one on success, and
|
858
|
+
* zero on failure. */
|
859
|
+
int tls13_resumption_psk(SSL *ssl, uint8_t *out, size_t out_len,
|
860
|
+
const SSL_SESSION *session);
|
861
|
+
|
862
|
+
/* tls13_resumption_context derives the context to be used for the handshake
|
863
|
+
* transcript on the resumption of |session|. It returns one on success, and
|
864
|
+
* zero on failure. */
|
865
|
+
int tls13_resumption_context(SSL *ssl, uint8_t *out, size_t out_len,
|
866
|
+
const SSL_SESSION *session);
|
867
|
+
|
868
|
+
|
869
|
+
/* Handshake functions. */
|
870
|
+
|
871
|
+
enum ssl_hs_wait_t {
|
872
|
+
ssl_hs_error,
|
873
|
+
ssl_hs_ok,
|
874
|
+
ssl_hs_read_message,
|
875
|
+
ssl_hs_write_message,
|
876
|
+
ssl_hs_flush,
|
877
|
+
ssl_hs_flush_and_read_message,
|
878
|
+
ssl_hs_x509_lookup,
|
879
|
+
ssl_hs_private_key_operation,
|
880
|
+
};
|
881
|
+
|
882
|
+
struct ssl_handshake_st {
|
883
|
+
/* wait contains the operation |do_handshake| is currently blocking on or
|
884
|
+
* |ssl_hs_ok| if none. */
|
885
|
+
enum ssl_hs_wait_t wait;
|
886
|
+
|
887
|
+
/* do_handshake runs the handshake. On completion, it returns |ssl_hs_ok|.
|
888
|
+
* Otherwise, it returns a value corresponding to what operation is needed to
|
889
|
+
* progress. */
|
890
|
+
enum ssl_hs_wait_t (*do_handshake)(SSL *ssl);
|
891
|
+
|
892
|
+
int state;
|
893
|
+
|
894
|
+
size_t hash_len;
|
895
|
+
uint8_t resumption_hash[EVP_MAX_MD_SIZE];
|
896
|
+
uint8_t secret[EVP_MAX_MD_SIZE];
|
897
|
+
uint8_t traffic_secret_0[EVP_MAX_MD_SIZE];
|
898
|
+
|
899
|
+
/* ecdh_ctx is the active client ECDH offer in TLS 1.3. */
|
900
|
+
SSL_ECDH_CTX ecdh_ctx;
|
901
|
+
|
902
|
+
/* retry_group is the group ID selected by the server in HelloRetryRequest in
|
903
|
+
* TLS 1.3. */
|
904
|
+
uint16_t retry_group;
|
905
|
+
|
906
|
+
/* key_share_bytes is the value of the previously sent KeyShare extension by
|
907
|
+
* the client in TLS 1.3. */
|
908
|
+
uint8_t *key_share_bytes;
|
909
|
+
size_t key_share_bytes_len;
|
910
|
+
|
911
|
+
/* public_key, for servers, is the key share to be sent to the client in TLS
|
912
|
+
* 1.3. */
|
913
|
+
uint8_t *public_key;
|
914
|
+
size_t public_key_len;
|
915
|
+
|
916
|
+
/* peer_sigalgs are the signature algorithms that the peer supports. These are
|
917
|
+
* taken from the contents of the signature algorithms extension for a server
|
918
|
+
* or from the CertificateRequest for a client. */
|
919
|
+
uint16_t *peer_sigalgs;
|
920
|
+
/* num_peer_sigalgs is the number of entries in |peer_sigalgs|. */
|
921
|
+
size_t num_peer_sigalgs;
|
922
|
+
|
923
|
+
uint8_t session_tickets_sent;
|
924
|
+
|
925
|
+
/* peer_psk_identity_hint, on the client, is the psk_identity_hint sent by the
|
926
|
+
* server when using a TLS 1.2 PSK key exchange. */
|
927
|
+
char *peer_psk_identity_hint;
|
928
|
+
} /* SSL_HANDSHAKE */;
|
929
|
+
|
930
|
+
SSL_HANDSHAKE *ssl_handshake_new(enum ssl_hs_wait_t (*do_handshake)(SSL *ssl));
|
931
|
+
|
932
|
+
/* ssl_handshake_free releases all memory associated with |hs|. */
|
933
|
+
void ssl_handshake_free(SSL_HANDSHAKE *hs);
|
934
|
+
|
935
|
+
/* tls13_handshake runs the TLS 1.3 handshake. It returns one on success and <=
|
936
|
+
* 0 on error. */
|
937
|
+
int tls13_handshake(SSL *ssl);
|
938
|
+
|
939
|
+
/* The following are implementations of |do_handshake| for the client and
|
940
|
+
* server. */
|
941
|
+
enum ssl_hs_wait_t tls13_client_handshake(SSL *ssl);
|
942
|
+
enum ssl_hs_wait_t tls13_server_handshake(SSL *ssl);
|
943
|
+
|
944
|
+
/* tls13_post_handshake processes a post-handshake message. It returns one on
|
945
|
+
* success and zero on failure. */
|
946
|
+
int tls13_post_handshake(SSL *ssl);
|
947
|
+
|
948
|
+
/* tls13_check_message_type checks if the current message has type |type|. If so
|
949
|
+
* it returns one. Otherwise, it sends an alert and returns zero. */
|
950
|
+
int tls13_check_message_type(SSL *ssl, int type);
|
951
|
+
|
952
|
+
int tls13_process_certificate(SSL *ssl, int allow_anonymous);
|
953
|
+
int tls13_process_certificate_verify(SSL *ssl);
|
954
|
+
int tls13_process_finished(SSL *ssl);
|
955
|
+
|
956
|
+
int tls13_prepare_certificate(SSL *ssl);
|
957
|
+
enum ssl_private_key_result_t tls13_prepare_certificate_verify(
|
958
|
+
SSL *ssl, int is_first_run);
|
959
|
+
int tls13_prepare_finished(SSL *ssl);
|
960
|
+
int tls13_process_new_session_ticket(SSL *ssl);
|
961
|
+
|
962
|
+
int ssl_ext_key_share_parse_serverhello(SSL *ssl, uint8_t **out_secret,
|
963
|
+
size_t *out_secret_len,
|
964
|
+
uint8_t *out_alert, CBS *contents);
|
965
|
+
int ssl_ext_key_share_parse_clienthello(SSL *ssl, int *out_found,
|
966
|
+
uint8_t **out_secret,
|
967
|
+
size_t *out_secret_len,
|
968
|
+
uint8_t *out_alert, CBS *contents);
|
969
|
+
int ssl_ext_key_share_add_serverhello(SSL *ssl, CBB *out);
|
970
|
+
|
971
|
+
int ssl_ext_pre_shared_key_parse_serverhello(SSL *ssl, uint8_t *out_alert,
|
972
|
+
CBS *contents);
|
973
|
+
int ssl_ext_pre_shared_key_parse_clienthello(SSL *ssl,
|
974
|
+
SSL_SESSION **out_session,
|
975
|
+
uint8_t *out_alert, CBS *contents);
|
976
|
+
int ssl_ext_pre_shared_key_add_serverhello(SSL *ssl, CBB *out);
|
977
|
+
|
978
|
+
int ssl_add_client_hello_body(SSL *ssl, CBB *body);
|
979
|
+
|
980
|
+
/* ssl_clear_tls13_state releases client state only needed for TLS 1.3. It
|
981
|
+
* should be called once the version is known to be TLS 1.2 or earlier. */
|
982
|
+
void ssl_clear_tls13_state(SSL *ssl);
|
983
|
+
|
984
|
+
|
985
|
+
/* SSLKEYLOGFILE functions. */
|
986
|
+
|
987
|
+
/* ssl_log_rsa_client_key_exchange logs |premaster|, if logging is enabled for
|
988
|
+
* |ssl|. It returns one on success and zero on failure. The entry is identified
|
989
|
+
* by the first 8 bytes of |encrypted_premaster|. */
|
990
|
+
int ssl_log_rsa_client_key_exchange(const SSL *ssl,
|
991
|
+
const uint8_t *encrypted_premaster,
|
992
|
+
size_t encrypted_premaster_len,
|
993
|
+
const uint8_t *premaster,
|
994
|
+
size_t premaster_len);
|
995
|
+
|
996
|
+
/* ssl_log_secret logs |secret| with label |label|, if logging is enabled for
|
997
|
+
* |ssl|. It returns one on success and zero on failure. */
|
998
|
+
int ssl_log_secret(const SSL *ssl, const char *label, const uint8_t *secret,
|
999
|
+
size_t secret_len);
|
1000
|
+
|
1001
|
+
|
1002
|
+
/* ClientHello functions. */
|
1003
|
+
|
1004
|
+
int ssl_early_callback_init(SSL *ssl, struct ssl_early_callback_ctx *ctx,
|
1005
|
+
const uint8_t *in, size_t in_len);
|
1006
|
+
|
1007
|
+
int ssl_early_callback_get_extension(const struct ssl_early_callback_ctx *ctx,
|
1008
|
+
CBS *out, uint16_t extension_type);
|
1009
|
+
|
1010
|
+
STACK_OF(SSL_CIPHER) *
|
1011
|
+
ssl_parse_client_cipher_list(const struct ssl_early_callback_ctx *ctx);
|
1012
|
+
|
1013
|
+
int ssl_client_cipher_list_contains_cipher(
|
1014
|
+
const struct ssl_early_callback_ctx *client_hello, uint16_t id);
|
1015
|
+
|
1016
|
+
|
1017
|
+
/* GREASE. */
|
1018
|
+
|
1019
|
+
enum ssl_grease_index_t {
|
1020
|
+
ssl_grease_cipher = 0,
|
1021
|
+
ssl_grease_group,
|
1022
|
+
ssl_grease_extension1,
|
1023
|
+
ssl_grease_extension2,
|
1024
|
+
ssl_grease_version,
|
1025
|
+
};
|
1026
|
+
|
1027
|
+
/* ssl_get_grease_value returns a GREASE value for |ssl|. For a given
|
1028
|
+
* connection, the values for each index will be deterministic. This allows the
|
1029
|
+
* same ClientHello be sent twice for a HelloRetryRequest or the same group be
|
1030
|
+
* advertised in both supported_groups and key_shares. */
|
1031
|
+
uint16_t ssl_get_grease_value(const SSL *ssl, enum ssl_grease_index_t index);
|
1032
|
+
|
1033
|
+
|
640
1034
|
/* Underdocumented functions.
|
641
1035
|
*
|
642
1036
|
* Functions below here haven't been touched up and may be underdocumented. */
|
643
1037
|
|
644
|
-
#define c2l(c, l) \
|
645
|
-
(l = ((unsigned long)(*((c)++))), l |= (((unsigned long)(*((c)++))) << 8), \
|
646
|
-
l |= (((unsigned long)(*((c)++))) << 16), \
|
647
|
-
l |= (((unsigned long)(*((c)++))) << 24))
|
648
|
-
|
649
|
-
/* NOTE - c is not incremented as per c2l */
|
650
|
-
#define c2ln(c, l1, l2, n) \
|
651
|
-
{ \
|
652
|
-
c += n; \
|
653
|
-
l1 = l2 = 0; \
|
654
|
-
switch (n) { \
|
655
|
-
case 8: \
|
656
|
-
l2 = ((unsigned long)(*(--(c)))) << 24; \
|
657
|
-
case 7: \
|
658
|
-
l2 |= ((unsigned long)(*(--(c)))) << 16; \
|
659
|
-
case 6: \
|
660
|
-
l2 |= ((unsigned long)(*(--(c)))) << 8; \
|
661
|
-
case 5: \
|
662
|
-
l2 |= ((unsigned long)(*(--(c)))); \
|
663
|
-
case 4: \
|
664
|
-
l1 = ((unsigned long)(*(--(c)))) << 24; \
|
665
|
-
case 3: \
|
666
|
-
l1 |= ((unsigned long)(*(--(c)))) << 16; \
|
667
|
-
case 2: \
|
668
|
-
l1 |= ((unsigned long)(*(--(c)))) << 8; \
|
669
|
-
case 1: \
|
670
|
-
l1 |= ((unsigned long)(*(--(c)))); \
|
671
|
-
} \
|
672
|
-
}
|
673
|
-
|
674
|
-
#define l2c(l, c) \
|
675
|
-
(*((c)++) = (uint8_t)(((l)) & 0xff), \
|
676
|
-
*((c)++) = (uint8_t)(((l) >> 8) & 0xff), \
|
677
|
-
*((c)++) = (uint8_t)(((l) >> 16) & 0xff), \
|
678
|
-
*((c)++) = (uint8_t)(((l) >> 24) & 0xff))
|
679
|
-
|
680
|
-
#define n2l(c, l) \
|
681
|
-
(l = ((unsigned long)(*((c)++))) << 24, \
|
682
|
-
l |= ((unsigned long)(*((c)++))) << 16, \
|
683
|
-
l |= ((unsigned long)(*((c)++))) << 8, l |= ((unsigned long)(*((c)++))))
|
684
|
-
|
685
|
-
#define l2n(l, c) \
|
686
|
-
(*((c)++) = (uint8_t)(((l) >> 24) & 0xff), \
|
687
|
-
*((c)++) = (uint8_t)(((l) >> 16) & 0xff), \
|
688
|
-
*((c)++) = (uint8_t)(((l) >> 8) & 0xff), \
|
689
|
-
*((c)++) = (uint8_t)(((l)) & 0xff))
|
690
|
-
|
691
|
-
#define l2n8(l, c) \
|
692
|
-
(*((c)++) = (uint8_t)(((l) >> 56) & 0xff), \
|
693
|
-
*((c)++) = (uint8_t)(((l) >> 48) & 0xff), \
|
694
|
-
*((c)++) = (uint8_t)(((l) >> 40) & 0xff), \
|
695
|
-
*((c)++) = (uint8_t)(((l) >> 32) & 0xff), \
|
696
|
-
*((c)++) = (uint8_t)(((l) >> 24) & 0xff), \
|
697
|
-
*((c)++) = (uint8_t)(((l) >> 16) & 0xff), \
|
698
|
-
*((c)++) = (uint8_t)(((l) >> 8) & 0xff), \
|
699
|
-
*((c)++) = (uint8_t)(((l)) & 0xff))
|
700
|
-
|
701
|
-
/* NOTE - c is not incremented as per l2c */
|
702
|
-
#define l2cn(l1, l2, c, n) \
|
703
|
-
{ \
|
704
|
-
c += n; \
|
705
|
-
switch (n) { \
|
706
|
-
case 8: \
|
707
|
-
*(--(c)) = (uint8_t)(((l2) >> 24) & 0xff); \
|
708
|
-
case 7: \
|
709
|
-
*(--(c)) = (uint8_t)(((l2) >> 16) & 0xff); \
|
710
|
-
case 6: \
|
711
|
-
*(--(c)) = (uint8_t)(((l2) >> 8) & 0xff); \
|
712
|
-
case 5: \
|
713
|
-
*(--(c)) = (uint8_t)(((l2)) & 0xff); \
|
714
|
-
case 4: \
|
715
|
-
*(--(c)) = (uint8_t)(((l1) >> 24) & 0xff); \
|
716
|
-
case 3: \
|
717
|
-
*(--(c)) = (uint8_t)(((l1) >> 16) & 0xff); \
|
718
|
-
case 2: \
|
719
|
-
*(--(c)) = (uint8_t)(((l1) >> 8) & 0xff); \
|
720
|
-
case 1: \
|
721
|
-
*(--(c)) = (uint8_t)(((l1)) & 0xff); \
|
722
|
-
} \
|
723
|
-
}
|
724
|
-
|
725
|
-
#define n2s(c, s) \
|
726
|
-
((s = (((unsigned int)(c[0])) << 8) | (((unsigned int)(c[1])))), c += 2)
|
727
|
-
|
728
|
-
#define s2n(s, c) \
|
729
|
-
((c[0] = (uint8_t)(((s) >> 8) & 0xff), \
|
730
|
-
c[1] = (uint8_t)(((s)) & 0xff)), \
|
731
|
-
c += 2)
|
732
|
-
|
733
|
-
#define n2l3(c, l) \
|
734
|
-
((l = (((unsigned long)(c[0])) << 16) | (((unsigned long)(c[1])) << 8) | \
|
735
|
-
(((unsigned long)(c[2])))), \
|
736
|
-
c += 3)
|
737
|
-
|
738
|
-
#define l2n3(l, c) \
|
739
|
-
((c[0] = (uint8_t)(((l) >> 16) & 0xff), \
|
740
|
-
c[1] = (uint8_t)(((l) >> 8) & 0xff), \
|
741
|
-
c[2] = (uint8_t)(((l)) & 0xff)), \
|
742
|
-
c += 3)
|
743
|
-
|
744
|
-
/* LOCAL STUFF */
|
745
|
-
|
746
1038
|
#define TLSEXT_CHANNEL_ID_SIZE 128
|
747
1039
|
|
748
|
-
/* Check if an SSL structure is using DTLS */
|
749
|
-
#define SSL_IS_DTLS(ssl) (ssl->method->is_dtls)
|
750
|
-
|
751
1040
|
/* From RFC4492, used in encoding the curve type in ECParameters */
|
752
1041
|
#define NAMED_CURVE_TYPE 3
|
753
1042
|
|
@@ -756,12 +1045,6 @@ enum ssl_hash_message_t {
|
|
756
1045
|
ssl_hash_message,
|
757
1046
|
};
|
758
1047
|
|
759
|
-
/* Structure containing decoded values of signature algorithms extension */
|
760
|
-
typedef struct tls_sigalgs_st {
|
761
|
-
uint8_t rsign;
|
762
|
-
uint8_t rhash;
|
763
|
-
} TLS_SIGALGS;
|
764
|
-
|
765
1048
|
typedef struct cert_st {
|
766
1049
|
X509 *x509;
|
767
1050
|
EVP_PKEY *privatekey;
|
@@ -783,17 +1066,10 @@ typedef struct cert_st {
|
|
783
1066
|
DH *dh_tmp;
|
784
1067
|
DH *(*dh_tmp_cb)(SSL *ssl, int is_export, int keysize);
|
785
1068
|
|
786
|
-
/*
|
787
|
-
*
|
788
|
-
|
789
|
-
|
790
|
-
/* peer_sigalgslen is the number of entries in |peer_sigalgs|. */
|
791
|
-
size_t peer_sigalgslen;
|
792
|
-
|
793
|
-
/* digest_nids, if non-NULL, is the set of digests supported by |privatekey|
|
794
|
-
* in decreasing order of preference. */
|
795
|
-
int *digest_nids;
|
796
|
-
size_t num_digest_nids;
|
1069
|
+
/* sigalgs, if non-NULL, is the set of signature algorithms supported by
|
1070
|
+
* |privatekey| in decreasing order of preference. */
|
1071
|
+
uint16_t *sigalgs;
|
1072
|
+
size_t num_sigalgs;
|
797
1073
|
|
798
1074
|
/* Certificate setup callback: if set is called whenever a
|
799
1075
|
* certificate may be required (client or server). the callback
|
@@ -803,6 +1079,10 @@ typedef struct cert_st {
|
|
803
1079
|
* supported signature algorithms or curves. */
|
804
1080
|
int (*cert_cb)(SSL *ssl, void *arg);
|
805
1081
|
void *cert_cb_arg;
|
1082
|
+
|
1083
|
+
/* Optional X509_STORE for certificate validation. If NULL the parent SSL_CTX
|
1084
|
+
* store is used instead. */
|
1085
|
+
X509_STORE *verify_store;
|
806
1086
|
} CERT;
|
807
1087
|
|
808
1088
|
/* SSL_METHOD is a compatibility structure to support the legacy version-locked
|
@@ -820,27 +1100,72 @@ struct ssl_method_st {
|
|
820
1100
|
struct ssl_protocol_method_st {
|
821
1101
|
/* is_dtls is one if the protocol is DTLS and zero otherwise. */
|
822
1102
|
char is_dtls;
|
1103
|
+
/* min_version is the minimum implemented version. */
|
1104
|
+
uint16_t min_version;
|
1105
|
+
/* max_version is the maximum implemented version. */
|
1106
|
+
uint16_t max_version;
|
1107
|
+
/* version_from_wire maps |wire_version| to a protocol version. On success, it
|
1108
|
+
* sets |*out_version| to the result and returns one. If the version is
|
1109
|
+
* unknown, it returns zero. */
|
1110
|
+
int (*version_from_wire)(uint16_t *out_version, uint16_t wire_version);
|
1111
|
+
/* version_to_wire maps |version| to the wire representation. It is an error
|
1112
|
+
* to call it with an invalid version. */
|
1113
|
+
uint16_t (*version_to_wire)(uint16_t version);
|
823
1114
|
int (*ssl_new)(SSL *ssl);
|
824
1115
|
void (*ssl_free)(SSL *ssl);
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
int (*
|
1116
|
+
/* ssl_get_message reads the next handshake message. If |msg_type| is not -1,
|
1117
|
+
* the message must have the specified type. On success, it returns one and
|
1118
|
+
* sets |ssl->s3->tmp.message_type|, |ssl->init_msg|, and |ssl->init_num|.
|
1119
|
+
* Otherwise, it returns <= 0. */
|
1120
|
+
int (*ssl_get_message)(SSL *ssl, int msg_type,
|
1121
|
+
enum ssl_hash_message_t hash_message);
|
1122
|
+
/* hash_current_message incorporates the current handshake message into the
|
1123
|
+
* handshake hash. It returns one on success and zero on allocation
|
1124
|
+
* failure. */
|
1125
|
+
int (*hash_current_message)(SSL *ssl);
|
1126
|
+
/* release_current_message is called to release the current handshake message.
|
1127
|
+
* If |free_buffer| is one, buffers will also be released. */
|
1128
|
+
void (*release_current_message)(SSL *ssl, int free_buffer);
|
1129
|
+
/* read_app_data reads up to |len| bytes of application data into |buf|. On
|
1130
|
+
* success, it returns the number of bytes read. Otherwise, it returns <= 0
|
1131
|
+
* and sets |*out_got_handshake| to whether the failure was due to a
|
1132
|
+
* post-handshake handshake message. If so, it fills in the current message as
|
1133
|
+
* in |ssl_get_message|. */
|
1134
|
+
int (*read_app_data)(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
|
1135
|
+
int peek);
|
1136
|
+
int (*read_change_cipher_spec)(SSL *ssl);
|
1137
|
+
void (*read_close_notify)(SSL *ssl);
|
1138
|
+
int (*write_app_data)(SSL *ssl, const void *buf_, int len);
|
1139
|
+
int (*dispatch_alert)(SSL *ssl);
|
835
1140
|
/* supports_cipher returns one if |cipher| is supported by this protocol and
|
836
1141
|
* zero otherwise. */
|
837
1142
|
int (*supports_cipher)(const SSL_CIPHER *cipher);
|
838
|
-
/*
|
839
|
-
|
840
|
-
|
841
|
-
int (*
|
842
|
-
/*
|
843
|
-
|
1143
|
+
/* init_message begins a new handshake message of type |type|. |cbb| is the
|
1144
|
+
* root CBB to be passed into |finish_message|. |*body| is set to a child CBB
|
1145
|
+
* the caller should write to. It returns one on success and zero on error. */
|
1146
|
+
int (*init_message)(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
|
1147
|
+
/* finish_message finishes a handshake message and prepares it to be
|
1148
|
+
* written. It returns one on success and zero on error. */
|
1149
|
+
int (*finish_message)(SSL *ssl, CBB *cbb);
|
1150
|
+
/* write_message writes the next message to the transport. It returns one on
|
1151
|
+
* success and <= 0 on error. */
|
1152
|
+
int (*write_message)(SSL *ssl);
|
1153
|
+
/* send_change_cipher_spec sends a ChangeCipherSpec message. */
|
1154
|
+
int (*send_change_cipher_spec)(SSL *ssl);
|
1155
|
+
/* expect_flight is called when the handshake expects a flight of messages from
|
1156
|
+
* the peer. */
|
1157
|
+
void (*expect_flight)(SSL *ssl);
|
1158
|
+
/* received_flight is called when the handshake has received a flight of
|
1159
|
+
* messages from the peer. */
|
1160
|
+
void (*received_flight)(SSL *ssl);
|
1161
|
+
/* set_read_state sets |ssl|'s read cipher state to |aead_ctx|. It takes
|
1162
|
+
* ownership of |aead_ctx|. It returns one on success and zero if changing the
|
1163
|
+
* read state is forbidden at this point. */
|
1164
|
+
int (*set_read_state)(SSL *ssl, SSL_AEAD_CTX *aead_ctx);
|
1165
|
+
/* set_write_state sets |ssl|'s write cipher state to |aead_ctx|. It takes
|
1166
|
+
* ownership of |aead_ctx|. It returns one on success and zero if changing the
|
1167
|
+
* write state is forbidden at this point. */
|
1168
|
+
int (*set_write_state)(SSL *ssl, SSL_AEAD_CTX *aead_ctx);
|
844
1169
|
};
|
845
1170
|
|
846
1171
|
/* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit
|
@@ -855,16 +1180,8 @@ struct ssl3_enc_method {
|
|
855
1180
|
size_t label_len, const uint8_t *seed1, size_t seed1_len,
|
856
1181
|
const uint8_t *seed2, size_t seed2_len);
|
857
1182
|
int (*final_finish_mac)(SSL *ssl, int from_server, uint8_t *out);
|
858
|
-
int (*cert_verify_mac)(SSL *, int, uint8_t *);
|
859
1183
|
};
|
860
1184
|
|
861
|
-
#define SSL_HM_HEADER_LENGTH(ssl) ssl->method->hhlen
|
862
|
-
#define ssl_handshake_start(ssl) \
|
863
|
-
(((uint8_t *)ssl->init_buf->data) + ssl->method->hhlen)
|
864
|
-
#define ssl_set_handshake_header(ssl, htype, len) \
|
865
|
-
ssl->method->set_handshake_header(ssl, htype, len)
|
866
|
-
#define ssl_do_write(ssl) ssl->method->do_write(ssl)
|
867
|
-
|
868
1185
|
/* lengths of messages */
|
869
1186
|
#define DTLS1_COOKIE_LENGTH 256
|
870
1187
|
|
@@ -876,27 +1193,27 @@ struct ssl3_enc_method {
|
|
876
1193
|
|
877
1194
|
#define DTLS1_AL_HEADER_LENGTH 2
|
878
1195
|
|
879
|
-
/* TODO(davidben): This structure is used for both incoming messages and
|
880
|
-
* outgoing messages. |is_ccs| and |epoch| are only used in the latter and
|
881
|
-
* should be moved elsewhere. */
|
882
1196
|
struct hm_header_st {
|
883
1197
|
uint8_t type;
|
884
1198
|
uint32_t msg_len;
|
885
1199
|
uint16_t seq;
|
886
1200
|
uint32_t frag_off;
|
887
1201
|
uint32_t frag_len;
|
888
|
-
int is_ccs;
|
889
|
-
/* epoch, for buffered outgoing messages, is the epoch the message was
|
890
|
-
* originally sent in. */
|
891
|
-
uint16_t epoch;
|
892
1202
|
};
|
893
1203
|
|
894
|
-
/*
|
895
|
-
* outgoing messages. |fragment| and |reassembly| are only used in the former
|
896
|
-
* and should be moved elsewhere. */
|
1204
|
+
/* An hm_fragment is an incoming DTLS message, possibly not yet assembled. */
|
897
1205
|
typedef struct hm_fragment_st {
|
898
|
-
|
899
|
-
uint8_t
|
1206
|
+
/* type is the type of the message. */
|
1207
|
+
uint8_t type;
|
1208
|
+
/* seq is the sequence number of this message. */
|
1209
|
+
uint16_t seq;
|
1210
|
+
/* msg_len is the length of the message body. */
|
1211
|
+
uint32_t msg_len;
|
1212
|
+
/* data is a pointer to the message, including message header. It has length
|
1213
|
+
* |DTLS1_HM_HEADER_LENGTH| + |msg_len|. */
|
1214
|
+
uint8_t *data;
|
1215
|
+
/* reassembly is a bitmask of |msg_len| bits corresponding to which parts of
|
1216
|
+
* the message have been received. It is NULL if the message is complete. */
|
900
1217
|
uint8_t *reassembly;
|
901
1218
|
} hm_fragment;
|
902
1219
|
|
@@ -916,34 +1233,25 @@ typedef struct dtls1_state_st {
|
|
916
1233
|
/* records being received in the current epoch */
|
917
1234
|
DTLS1_BITMAP bitmap;
|
918
1235
|
|
919
|
-
/* handshake message numbers.
|
920
|
-
* TODO(davidben): It doesn't make much sense to store both of these. Only
|
921
|
-
* store one. */
|
922
1236
|
uint16_t handshake_write_seq;
|
923
|
-
uint16_t next_handshake_write_seq;
|
924
|
-
|
925
1237
|
uint16_t handshake_read_seq;
|
926
1238
|
|
927
1239
|
/* save last sequence number for retransmissions */
|
928
1240
|
uint8_t last_write_sequence[8];
|
929
1241
|
|
930
|
-
/*
|
931
|
-
*
|
932
|
-
*
|
933
|
-
*
|
934
|
-
|
935
|
-
pqueue buffered_messages;
|
1242
|
+
/* incoming_messages is a ring buffer of incoming handshake messages that have
|
1243
|
+
* yet to be processed. The front of the ring buffer is message number
|
1244
|
+
* |handshake_read_seq|, at position |handshake_read_seq| %
|
1245
|
+
* |SSL_MAX_HANDSHAKE_FLIGHT|. */
|
1246
|
+
hm_fragment *incoming_messages[SSL_MAX_HANDSHAKE_FLIGHT];
|
936
1247
|
|
937
|
-
/*
|
938
|
-
*
|
939
|
-
|
940
|
-
|
941
|
-
pqueue sent_messages;
|
1248
|
+
/* outgoing_messages is the queue of outgoing messages from the last handshake
|
1249
|
+
* flight. */
|
1250
|
+
DTLS_OUTGOING_MESSAGE outgoing_messages[SSL_MAX_HANDSHAKE_FLIGHT];
|
1251
|
+
uint8_t outgoing_messages_len;
|
942
1252
|
|
943
1253
|
unsigned int mtu; /* max DTLS packet size */
|
944
1254
|
|
945
|
-
struct hm_header_st w_msg_hdr;
|
946
|
-
|
947
1255
|
/* num_timeouts is the number of times the retransmit timer has fired since
|
948
1256
|
* the last time it was reset. */
|
949
1257
|
unsigned int num_timeouts;
|
@@ -952,20 +1260,34 @@ typedef struct dtls1_state_st {
|
|
952
1260
|
* timeout. */
|
953
1261
|
struct timeval next_timeout;
|
954
1262
|
|
955
|
-
/*
|
956
|
-
unsigned
|
1263
|
+
/* timeout_duration_ms is the timeout duration in milliseconds. */
|
1264
|
+
unsigned timeout_duration_ms;
|
957
1265
|
} DTLS1_STATE;
|
958
1266
|
|
959
1267
|
extern const SSL3_ENC_METHOD TLSv1_enc_data;
|
960
1268
|
extern const SSL3_ENC_METHOD SSLv3_enc_data;
|
961
|
-
extern const SRTP_PROTECTION_PROFILE kSRTPProfiles[];
|
962
1269
|
|
963
|
-
|
1270
|
+
/* From draft-ietf-tls-tls13-14, used in determining ticket validity. */
|
1271
|
+
#define SSL_TICKET_ALLOW_EARLY_DATA 1
|
1272
|
+
#define SSL_TICKET_ALLOW_DHE_RESUMPTION 2
|
1273
|
+
#define SSL_TICKET_ALLOW_PSK_RESUMPTION 4
|
1274
|
+
|
964
1275
|
CERT *ssl_cert_new(void);
|
965
1276
|
CERT *ssl_cert_dup(CERT *cert);
|
966
1277
|
void ssl_cert_clear_certs(CERT *c);
|
967
1278
|
void ssl_cert_free(CERT *c);
|
968
1279
|
int ssl_get_new_session(SSL *ssl, int is_server);
|
1280
|
+
int ssl_encrypt_ticket(SSL *ssl, CBB *out, const SSL_SESSION *session);
|
1281
|
+
|
1282
|
+
/* ssl_session_is_context_valid returns one if |session|'s session ID context
|
1283
|
+
* matches the one set on |ssl| and zero otherwise. */
|
1284
|
+
int ssl_session_is_context_valid(const SSL *ssl, const SSL_SESSION *session);
|
1285
|
+
|
1286
|
+
/* ssl_session_is_time_valid returns one if |session| is still valid and zero if
|
1287
|
+
* it has expired. */
|
1288
|
+
int ssl_session_is_time_valid(const SSL *ssl, const SSL_SESSION *session);
|
1289
|
+
|
1290
|
+
void ssl_set_session(SSL *ssl, SSL_SESSION *session);
|
969
1291
|
|
970
1292
|
enum ssl_session_result_t {
|
971
1293
|
ssl_session_success,
|
@@ -983,7 +1305,19 @@ enum ssl_session_result_t ssl_get_prev_session(
|
|
983
1305
|
SSL *ssl, SSL_SESSION **out_session, int *out_send_ticket,
|
984
1306
|
const struct ssl_early_callback_ctx *ctx);
|
985
1307
|
|
986
|
-
|
1308
|
+
/* The following flags determine which parts of the session are duplicated. */
|
1309
|
+
#define SSL_SESSION_DUP_AUTH_ONLY 0x0
|
1310
|
+
#define SSL_SESSION_INCLUDE_TICKET 0x1
|
1311
|
+
#define SSL_SESSION_INCLUDE_NONAUTH 0x2
|
1312
|
+
#define SSL_SESSION_DUP_ALL \
|
1313
|
+
(SSL_SESSION_INCLUDE_TICKET | SSL_SESSION_INCLUDE_NONAUTH)
|
1314
|
+
|
1315
|
+
/* SSL_SESSION_dup returns a newly-allocated |SSL_SESSION| with a copy of the
|
1316
|
+
* fields in |session| or NULL on error. The new session is non-resumable and
|
1317
|
+
* must be explicitly marked resumable once it has been filled in. */
|
1318
|
+
OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *session,
|
1319
|
+
int dup_flags);
|
1320
|
+
|
987
1321
|
void ssl_cipher_preference_list_free(
|
988
1322
|
struct ssl_cipher_preference_list_st *cipher_list);
|
989
1323
|
struct ssl_cipher_preference_list_st *ssl_get_cipher_preferences(SSL *ssl);
|
@@ -995,8 +1329,8 @@ int ssl_cert_add1_chain_cert(CERT *cert, X509 *x509);
|
|
995
1329
|
void ssl_cert_set_cert_cb(CERT *cert,
|
996
1330
|
int (*cb)(SSL *ssl, void *arg), void *arg);
|
997
1331
|
|
998
|
-
int ssl_verify_cert_chain(SSL *ssl,
|
999
|
-
|
1332
|
+
int ssl_verify_cert_chain(SSL *ssl, long *out_verify_result,
|
1333
|
+
STACK_OF(X509) * cert_chain);
|
1000
1334
|
void ssl_update_cache(SSL *ssl, int mode);
|
1001
1335
|
|
1002
1336
|
/* ssl_get_compatible_server_ciphers determines the key exchange and
|
@@ -1009,80 +1343,80 @@ void ssl_get_compatible_server_ciphers(SSL *ssl, uint32_t *out_mask_k,
|
|
1009
1343
|
STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *ssl);
|
1010
1344
|
int ssl_verify_alarm_type(long type);
|
1011
1345
|
|
1012
|
-
|
1013
|
-
*
|
1014
|
-
int ssl_fill_hello_random(uint8_t *out, size_t len, int is_server);
|
1015
|
-
|
1016
|
-
int ssl3_send_server_certificate(SSL *ssl);
|
1017
|
-
int ssl3_send_new_session_ticket(SSL *ssl);
|
1018
|
-
int ssl3_send_certificate_status(SSL *ssl);
|
1019
|
-
int ssl3_get_finished(SSL *ssl, int state_a, int state_b);
|
1020
|
-
int ssl3_send_change_cipher_spec(SSL *ssl, int state_a, int state_b);
|
1346
|
+
int ssl3_get_finished(SSL *ssl);
|
1347
|
+
int ssl3_send_change_cipher_spec(SSL *ssl);
|
1021
1348
|
void ssl3_cleanup_key_block(SSL *ssl);
|
1022
|
-
int ssl3_do_write(SSL *ssl, int type);
|
1023
1349
|
int ssl3_send_alert(SSL *ssl, int level, int desc);
|
1024
|
-
int
|
1025
|
-
|
1026
|
-
long max, enum ssl_hash_message_t hash_message, int *ok);
|
1027
|
-
|
1028
|
-
/* ssl3_hash_current_message incorporates the current handshake message into the
|
1029
|
-
* handshake hash. It returns one on success and zero on allocation failure. */
|
1350
|
+
int ssl3_get_message(SSL *ssl, int msg_type,
|
1351
|
+
enum ssl_hash_message_t hash_message);
|
1030
1352
|
int ssl3_hash_current_message(SSL *ssl);
|
1353
|
+
void ssl3_release_current_message(SSL *ssl, int free_buffer);
|
1031
1354
|
|
1032
|
-
/* ssl3_cert_verify_hash writes the CertificateVerify hash into the
|
1033
|
-
* pointed to by |out| and writes the number of bytes to |*out_len|. |out|
|
1034
|
-
* have room for EVP_MAX_MD_SIZE bytes.
|
1035
|
-
*
|
1036
|
-
*
|
1037
|
-
*
|
1038
|
-
int ssl3_cert_verify_hash(SSL *ssl, uint8_t *out, size_t *out_len,
|
1039
|
-
const EVP_MD **out_md, int pkey_type);
|
1355
|
+
/* ssl3_cert_verify_hash writes the SSL 3.0 CertificateVerify hash into the
|
1356
|
+
* bytes pointed to by |out| and writes the number of bytes to |*out_len|. |out|
|
1357
|
+
* must have room for |EVP_MAX_MD_SIZE| bytes. It sets |*out_md| to the hash
|
1358
|
+
* function used. It returns one on success and zero on failure. */
|
1359
|
+
int ssl3_cert_verify_hash(SSL *ssl, const EVP_MD **out_md, uint8_t *out,
|
1360
|
+
size_t *out_len, uint16_t signature_algorithm);
|
1040
1361
|
|
1041
1362
|
int ssl3_send_finished(SSL *ssl, int a, int b);
|
1042
1363
|
int ssl3_supports_cipher(const SSL_CIPHER *cipher);
|
1043
1364
|
int ssl3_dispatch_alert(SSL *ssl);
|
1044
|
-
int ssl3_read_app_data(SSL *ssl, uint8_t *buf, int len,
|
1365
|
+
int ssl3_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
|
1366
|
+
int peek);
|
1045
1367
|
int ssl3_read_change_cipher_spec(SSL *ssl);
|
1046
1368
|
void ssl3_read_close_notify(SSL *ssl);
|
1047
|
-
int
|
1369
|
+
int ssl3_read_handshake_bytes(SSL *ssl, uint8_t *buf, int len);
|
1048
1370
|
int ssl3_write_app_data(SSL *ssl, const void *buf, int len);
|
1049
1371
|
int ssl3_write_bytes(SSL *ssl, int type, const void *buf, int len);
|
1050
1372
|
int ssl3_output_cert_chain(SSL *ssl);
|
1051
1373
|
const SSL_CIPHER *ssl3_choose_cipher(
|
1052
|
-
SSL *ssl,
|
1053
|
-
struct ssl_cipher_preference_list_st *srvr);
|
1374
|
+
SSL *ssl, const struct ssl_early_callback_ctx *client_hello,
|
1375
|
+
const struct ssl_cipher_preference_list_st *srvr);
|
1054
1376
|
|
1055
1377
|
int ssl3_new(SSL *ssl);
|
1056
1378
|
void ssl3_free(SSL *ssl);
|
1057
1379
|
int ssl3_accept(SSL *ssl);
|
1058
1380
|
int ssl3_connect(SSL *ssl);
|
1059
1381
|
|
1060
|
-
int
|
1061
|
-
int
|
1382
|
+
int ssl3_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
|
1383
|
+
int ssl3_finish_message(SSL *ssl, CBB *cbb);
|
1384
|
+
int ssl3_write_message(SSL *ssl);
|
1385
|
+
|
1386
|
+
void ssl3_expect_flight(SSL *ssl);
|
1387
|
+
void ssl3_received_flight(SSL *ssl);
|
1388
|
+
|
1389
|
+
int dtls1_init_message(SSL *ssl, CBB *cbb, CBB *body, uint8_t type);
|
1390
|
+
int dtls1_finish_message(SSL *ssl, CBB *cbb);
|
1391
|
+
int dtls1_write_message(SSL *ssl);
|
1062
1392
|
|
1063
|
-
|
1064
|
-
|
1393
|
+
/* dtls1_get_record reads a new input record. On success, it places it in
|
1394
|
+
* |ssl->s3->rrec| and returns one. Otherwise it returns <= 0 on error or if
|
1395
|
+
* more data is needed. */
|
1396
|
+
int dtls1_get_record(SSL *ssl);
|
1397
|
+
|
1398
|
+
int dtls1_read_app_data(SSL *ssl, int *out_got_handshake, uint8_t *buf, int len,
|
1399
|
+
int peek);
|
1065
1400
|
int dtls1_read_change_cipher_spec(SSL *ssl);
|
1066
1401
|
void dtls1_read_close_notify(SSL *ssl);
|
1067
|
-
int dtls1_read_bytes(SSL *ssl, int type, uint8_t *buf, int len, int peek);
|
1068
|
-
void dtls1_set_message_header(SSL *ssl, uint8_t mt, unsigned long len,
|
1069
|
-
unsigned short seq_num, unsigned long frag_off,
|
1070
|
-
unsigned long frag_len);
|
1071
1402
|
|
1072
1403
|
int dtls1_write_app_data(SSL *ssl, const void *buf, int len);
|
1073
|
-
int dtls1_write_bytes(SSL *ssl, int type, const void *buf, int len,
|
1074
|
-
enum dtls1_use_epoch_t use_epoch);
|
1075
1404
|
|
1076
|
-
|
1405
|
+
/* dtls1_write_record sends a record. It returns one on success and <= 0 on
|
1406
|
+
* error. */
|
1407
|
+
int dtls1_write_record(SSL *ssl, int type, const uint8_t *buf, size_t len,
|
1408
|
+
enum dtls1_use_epoch_t use_epoch);
|
1409
|
+
|
1410
|
+
int dtls1_send_change_cipher_spec(SSL *ssl);
|
1077
1411
|
int dtls1_send_finished(SSL *ssl, int a, int b, const char *sender, int slen);
|
1078
|
-
int
|
1079
|
-
int dtls1_buffer_message(SSL *ssl);
|
1080
|
-
int dtls1_retransmit_buffered_messages(SSL *ssl);
|
1412
|
+
int dtls1_retransmit_outgoing_messages(SSL *ssl);
|
1081
1413
|
void dtls1_clear_record_buffer(SSL *ssl);
|
1082
|
-
|
1414
|
+
int dtls1_parse_fragment(CBS *cbs, struct hm_header_st *out_hdr,
|
1415
|
+
CBS *out_body);
|
1083
1416
|
int dtls1_check_timeout_num(SSL *ssl);
|
1084
|
-
int dtls1_set_handshake_header(SSL *ssl, int type, unsigned long len);
|
1085
1417
|
int dtls1_handshake_write(SSL *ssl);
|
1418
|
+
void dtls1_expect_flight(SSL *ssl);
|
1419
|
+
void dtls1_received_flight(SSL *ssl);
|
1086
1420
|
|
1087
1421
|
int dtls1_supports_cipher(const SSL_CIPHER *cipher);
|
1088
1422
|
void dtls1_start_timer(SSL *ssl);
|
@@ -1090,49 +1424,22 @@ void dtls1_stop_timer(SSL *ssl);
|
|
1090
1424
|
int dtls1_is_timer_expired(SSL *ssl);
|
1091
1425
|
void dtls1_double_timeout(SSL *ssl);
|
1092
1426
|
unsigned int dtls1_min_mtu(void);
|
1093
|
-
void dtls1_hm_fragment_free(hm_fragment *frag);
|
1094
|
-
|
1095
|
-
/* some client-only functions */
|
1096
|
-
int ssl3_send_client_hello(SSL *ssl);
|
1097
|
-
int ssl3_get_server_hello(SSL *ssl);
|
1098
|
-
int ssl3_get_certificate_request(SSL *ssl);
|
1099
|
-
int ssl3_get_new_session_ticket(SSL *ssl);
|
1100
|
-
int ssl3_get_cert_status(SSL *ssl);
|
1101
|
-
int ssl3_get_server_done(SSL *ssl);
|
1102
|
-
int ssl3_send_cert_verify(SSL *ssl);
|
1103
|
-
int ssl3_send_client_certificate(SSL *ssl);
|
1104
|
-
int ssl_do_client_cert_cb(SSL *ssl, X509 **px509, EVP_PKEY **ppkey);
|
1105
|
-
int ssl3_send_client_key_exchange(SSL *ssl);
|
1106
|
-
int ssl3_get_server_key_exchange(SSL *ssl);
|
1107
|
-
int ssl3_get_server_certificate(SSL *ssl);
|
1108
|
-
int ssl3_send_next_proto(SSL *ssl);
|
1109
|
-
int ssl3_send_channel_id(SSL *ssl);
|
1110
|
-
int ssl3_verify_server_cert(SSL *ssl);
|
1111
|
-
|
1112
|
-
/* some server-only functions */
|
1113
|
-
int ssl3_get_initial_bytes(SSL *ssl);
|
1114
|
-
int ssl3_get_v2_client_hello(SSL *ssl);
|
1115
|
-
int ssl3_get_client_hello(SSL *ssl);
|
1116
|
-
int ssl3_send_server_hello(SSL *ssl);
|
1117
|
-
int ssl3_send_server_key_exchange(SSL *ssl);
|
1118
|
-
int ssl3_send_certificate_request(SSL *ssl);
|
1119
|
-
int ssl3_send_server_done(SSL *ssl);
|
1120
|
-
int ssl3_get_client_certificate(SSL *ssl);
|
1121
|
-
int ssl3_get_client_key_exchange(SSL *ssl);
|
1122
|
-
int ssl3_get_cert_verify(SSL *ssl);
|
1123
|
-
int ssl3_get_next_proto(SSL *ssl);
|
1124
|
-
int ssl3_get_channel_id(SSL *ssl);
|
1125
1427
|
|
1126
1428
|
int dtls1_new(SSL *ssl);
|
1127
1429
|
int dtls1_accept(SSL *ssl);
|
1128
1430
|
int dtls1_connect(SSL *ssl);
|
1129
1431
|
void dtls1_free(SSL *ssl);
|
1130
1432
|
|
1131
|
-
|
1132
|
-
|
1433
|
+
int dtls1_get_message(SSL *ssl, int mt, enum ssl_hash_message_t hash_message);
|
1434
|
+
int dtls1_hash_current_message(SSL *ssl);
|
1435
|
+
void dtls1_release_current_message(SSL *ssl, int free_buffer);
|
1133
1436
|
int dtls1_dispatch_alert(SSL *ssl);
|
1134
1437
|
|
1135
|
-
|
1438
|
+
/* ssl_is_wbio_buffered returns one if |ssl|'s write BIO is buffered and zero
|
1439
|
+
* otherwise. */
|
1440
|
+
int ssl_is_wbio_buffered(const SSL *ssl);
|
1441
|
+
|
1442
|
+
int ssl_init_wbio_buffer(SSL *ssl);
|
1136
1443
|
void ssl_free_wbio_buffer(SSL *ssl);
|
1137
1444
|
|
1138
1445
|
int tls1_change_cipher_state(SSL *ssl, int which);
|
@@ -1141,23 +1448,28 @@ int tls1_handshake_digest(SSL *ssl, uint8_t *out, size_t out_len);
|
|
1141
1448
|
int tls1_generate_master_secret(SSL *ssl, uint8_t *out, const uint8_t *premaster,
|
1142
1449
|
size_t premaster_len);
|
1143
1450
|
|
1144
|
-
|
1451
|
+
/* tls1_get_grouplist sets |*out_group_ids| and |*out_group_ids_len| to the
|
1452
|
+
* list of allowed group IDs. If |get_peer_groups| is non-zero, return the
|
1453
|
+
* peer's group list. Otherwise, return the preferred list. */
|
1454
|
+
void tls1_get_grouplist(SSL *ssl, int get_peer_groups,
|
1455
|
+
const uint16_t **out_group_ids,
|
1456
|
+
size_t *out_group_ids_len);
|
1145
1457
|
|
1146
|
-
/*
|
1147
|
-
* and the peer's
|
1458
|
+
/* tls1_check_group_id returns one if |group_id| is consistent with both our
|
1459
|
+
* and the peer's group preferences. Note: if called as the client, only our
|
1148
1460
|
* preferences are checked; the peer (the server) does not send preferences. */
|
1149
|
-
int
|
1461
|
+
int tls1_check_group_id(SSL *ssl, uint16_t group_id);
|
1150
1462
|
|
1151
|
-
/*
|
1152
|
-
*
|
1463
|
+
/* tls1_get_shared_group sets |*out_group_id| to the first preferred shared
|
1464
|
+
* group between client and server preferences and returns one. If none may be
|
1153
1465
|
* found, it returns zero. */
|
1154
|
-
int
|
1466
|
+
int tls1_get_shared_group(SSL *ssl, uint16_t *out_group_id);
|
1155
1467
|
|
1156
1468
|
/* tls1_set_curves converts the array of |ncurves| NIDs pointed to by |curves|
|
1157
|
-
* into a newly allocated array of TLS
|
1158
|
-
* returns one and writes the array to |*
|
1159
|
-
* |*
|
1160
|
-
int tls1_set_curves(uint16_t **
|
1469
|
+
* into a newly allocated array of TLS group IDs. On success, the function
|
1470
|
+
* returns one and writes the array to |*out_group_ids| and its size to
|
1471
|
+
* |*out_group_ids_len|. Otherwise, it returns zero. */
|
1472
|
+
int tls1_set_curves(uint16_t **out_group_ids, size_t *out_group_ids_len,
|
1161
1473
|
const int *curves, size_t ncurves);
|
1162
1474
|
|
1163
1475
|
/* tls1_check_ec_cert returns one if |x| is an ECC certificate with curve and
|
@@ -1172,7 +1484,8 @@ int tls1_check_ec_cert(SSL *ssl, X509 *x);
|
|
1172
1484
|
int ssl_add_clienthello_tlsext(SSL *ssl, CBB *out, size_t header_len);
|
1173
1485
|
|
1174
1486
|
int ssl_add_serverhello_tlsext(SSL *ssl, CBB *out);
|
1175
|
-
int ssl_parse_clienthello_tlsext(
|
1487
|
+
int ssl_parse_clienthello_tlsext(
|
1488
|
+
SSL *ssl, const struct ssl_early_callback_ctx *client_hello);
|
1176
1489
|
int ssl_parse_serverhello_tlsext(SSL *ssl, CBS *cbs);
|
1177
1490
|
|
1178
1491
|
#define tlsext_tick_md EVP_sha256
|
@@ -1187,14 +1500,6 @@ int tls_process_ticket(SSL *ssl, SSL_SESSION **out_session,
|
|
1187
1500
|
size_t ticket_len, const uint8_t *session_id,
|
1188
1501
|
size_t session_id_len);
|
1189
1502
|
|
1190
|
-
/* tls12_add_sigandhash assembles the SignatureAndHashAlgorithm corresponding to
|
1191
|
-
* |ssl|'s private key and |md|. The two-byte value is written to |out|. It
|
1192
|
-
* returns one on success and zero on failure. */
|
1193
|
-
int tls12_add_sigandhash(SSL *ssl, CBB *out, const EVP_MD *md);
|
1194
|
-
|
1195
|
-
int tls12_get_sigid(int pkey_type);
|
1196
|
-
const EVP_MD *tls12_get_hash(uint8_t hash_alg);
|
1197
|
-
|
1198
1503
|
/* tls1_channel_id_hash computes the hash to be signed by Channel ID and writes
|
1199
1504
|
* it to |out|, which must contain at least |EVP_MAX_MD_SIZE| bytes. It returns
|
1200
1505
|
* one on success and zero on failure. */
|
@@ -1202,22 +1507,6 @@ int tls1_channel_id_hash(SSL *ssl, uint8_t *out, size_t *out_len);
|
|
1202
1507
|
|
1203
1508
|
int tls1_record_handshake_hashes_for_channel_id(SSL *ssl);
|
1204
1509
|
|
1205
|
-
/* ssl_log_rsa_client_key_exchange logs |premaster|, if logging is enabled for
|
1206
|
-
* |ssl|. It returns one on success and zero on failure. The entry is identified
|
1207
|
-
* by the first 8 bytes of |encrypted_premaster|. */
|
1208
|
-
int ssl_log_rsa_client_key_exchange(const SSL *ssl,
|
1209
|
-
const uint8_t *encrypted_premaster,
|
1210
|
-
size_t encrypted_premaster_len,
|
1211
|
-
const uint8_t *premaster,
|
1212
|
-
size_t premaster_len);
|
1213
|
-
|
1214
|
-
/* ssl_log_master_secret logs |master|, if logging is enabled for |ssl|. It
|
1215
|
-
* returns one on success and zero on failure. The entry is identified by
|
1216
|
-
* |client_random|. */
|
1217
|
-
int ssl_log_master_secret(const SSL *ssl, const uint8_t *client_random,
|
1218
|
-
size_t client_random_len, const uint8_t *master,
|
1219
|
-
size_t master_len);
|
1220
|
-
|
1221
1510
|
/* ssl3_can_false_start returns one if |ssl| is allowed to False Start and zero
|
1222
1511
|
* otherwise. */
|
1223
1512
|
int ssl3_can_false_start(const SSL *ssl);
|
@@ -1226,33 +1515,10 @@ int ssl3_can_false_start(const SSL *ssl);
|
|
1226
1515
|
* |version|. */
|
1227
1516
|
const SSL3_ENC_METHOD *ssl3_get_enc_method(uint16_t version);
|
1228
1517
|
|
1229
|
-
/*
|
1230
|
-
*
|
1231
|
-
|
1232
|
-
|
1233
|
-
/* ssl3_get_mutual_version selects the protocol version on |ssl| for a client
|
1234
|
-
* which advertises |client_version|. If no suitable version exists, it returns
|
1235
|
-
* zero. */
|
1236
|
-
uint16_t ssl3_get_mutual_version(SSL *ssl, uint16_t client_version);
|
1237
|
-
|
1238
|
-
/* ssl3_get_max_client_version returns the maximum protocol version configured
|
1239
|
-
* for the client. It is guaranteed that the set of allowed versions at or below
|
1240
|
-
* this maximum version is contiguous. If all versions are disabled, it returns
|
1241
|
-
* zero. */
|
1242
|
-
uint16_t ssl3_get_max_client_version(SSL *ssl);
|
1243
|
-
|
1244
|
-
/* ssl3_is_version_enabled returns one if |version| is an enabled protocol
|
1245
|
-
* version for |ssl| and zero otherwise. */
|
1246
|
-
int ssl3_is_version_enabled(SSL *ssl, uint16_t version);
|
1247
|
-
|
1248
|
-
/* ssl3_version_from_wire maps |wire_version| to a protocol version. For
|
1249
|
-
* SSLv3/TLS, the version is returned as-is. For DTLS, the corresponding TLS
|
1250
|
-
* version is used. Note that this mapping is not injective but preserves
|
1251
|
-
* comparisons.
|
1252
|
-
*
|
1253
|
-
* TODO(davidben): To normalize some DTLS-specific code, move away from using
|
1254
|
-
* the wire version except at API boundaries. */
|
1255
|
-
uint16_t ssl3_version_from_wire(const SSL *ssl, uint16_t wire_version);
|
1518
|
+
/* ssl_get_version_range sets |*out_min_version| and |*out_max_version| to the
|
1519
|
+
* minimum and maximum enabled protocol versions, respectively. */
|
1520
|
+
int ssl_get_version_range(const SSL *ssl, uint16_t *out_min_version,
|
1521
|
+
uint16_t *out_max_version);
|
1256
1522
|
|
1257
1523
|
/* ssl3_protocol_version returns |ssl|'s protocol version. It is an error to
|
1258
1524
|
* call this function before the version is determined. */
|
@@ -1261,18 +1527,25 @@ uint16_t ssl3_protocol_version(const SSL *ssl);
|
|
1261
1527
|
uint32_t ssl_get_algorithm_prf(const SSL *ssl);
|
1262
1528
|
int tls1_parse_peer_sigalgs(SSL *ssl, const CBS *sigalgs);
|
1263
1529
|
|
1264
|
-
/*
|
1265
|
-
* based on the peer's preferences the digests
|
1266
|
-
|
1530
|
+
/* tls1_choose_signature_algorithm sets |*out| to a signature algorithm for use
|
1531
|
+
* with |ssl|'s private key based on the peer's preferences and the digests
|
1532
|
+
* supported. It returns one on success and zero on error. */
|
1533
|
+
int tls1_choose_signature_algorithm(SSL *ssl, uint16_t *out);
|
1267
1534
|
|
1268
|
-
size_t tls12_get_psigalgs(SSL *ssl, const
|
1535
|
+
size_t tls12_get_psigalgs(SSL *ssl, const uint16_t **psigs);
|
1269
1536
|
|
1270
|
-
/* tls12_check_peer_sigalg checks that |
|
1271
|
-
*
|
1272
|
-
* writes the relevant digest into |*out_md| and returns 1. Otherwise it
|
1537
|
+
/* tls12_check_peer_sigalg checks that |signature_algorithm| is consistent with
|
1538
|
+
* |ssl|'s sent, supported signature algorithms and returns 1. Otherwise it
|
1273
1539
|
* returns 0 and writes an alert into |*out_alert|. */
|
1274
|
-
int tls12_check_peer_sigalg(SSL *ssl,
|
1275
|
-
|
1540
|
+
int tls12_check_peer_sigalg(SSL *ssl, int *out_alert,
|
1541
|
+
uint16_t signature_algorithm);
|
1276
1542
|
void ssl_set_client_disabled(SSL *ssl);
|
1277
1543
|
|
1544
|
+
void ssl_get_current_time(const SSL *ssl, struct timeval *out_clock);
|
1545
|
+
|
1546
|
+
|
1547
|
+
#if defined(__cplusplus)
|
1548
|
+
} /* extern C */
|
1549
|
+
#endif
|
1550
|
+
|
1278
1551
|
#endif /* OPENSSL_HEADER_SSL_INTERNAL_H */
|