grpc 1.9.1 → 1.10.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +2654 -953
- data/etc/roots.pem +282 -683
- data/include/grpc/compression.h +9 -26
- data/include/grpc/grpc.h +10 -24
- data/include/grpc/grpc_security.h +7 -1
- data/include/grpc/impl/codegen/compression_types.h +5 -62
- data/include/grpc/impl/codegen/grpc_types.h +10 -6
- data/include/grpc/module.modulemap +1 -10
- data/include/grpc/support/alloc.h +3 -2
- data/include/grpc/support/log.h +1 -2
- data/{src/core/lib/gpr/thd_internal.h → include/grpc/support/thd_id.h} +23 -9
- data/src/boringssl/err_data.c +550 -496
- data/src/core/ext/census/grpc_context.cc +2 -1
- data/src/core/ext/filters/client_channel/backup_poller.cc +5 -4
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel.cc +162 -172
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +4 -2
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +10 -10
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +18 -14
- data/src/core/ext/filters/client_channel/http_proxy.cc +3 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +21 -105
- data/src/core/ext/filters/client_channel/lb_policy.h +166 -170
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +41 -36
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1452 -1459
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +7 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +27 -27
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +279 -304
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +358 -330
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +30 -41
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +7 -14
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +8 -21
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +23 -27
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +58 -33
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +25 -12
- data/src/core/ext/filters/client_channel/parse_address.cc +10 -8
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver.cc +6 -52
- data/src/core/ext/filters/client_channel/resolver.h +98 -55
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +266 -237
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +31 -27
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +244 -207
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +161 -148
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +47 -31
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +126 -126
- data/src/core/ext/filters/client_channel/resolver_factory.h +33 -32
- data/src/core/ext/filters/client_channel/resolver_registry.cc +110 -90
- data/src/core/ext/filters/client_channel/resolver_registry.h +49 -36
- data/src/core/ext/filters/client_channel/retry_throttle.cc +29 -22
- data/src/core/ext/filters/client_channel/subchannel.cc +173 -173
- data/src/core/ext/filters/client_channel/subchannel.h +38 -45
- data/src/core/ext/filters/client_channel/subchannel_index.cc +44 -40
- data/src/core/ext/filters/client_channel/uri_parser.cc +3 -3
- data/src/core/ext/filters/deadline/deadline_filter.cc +27 -18
- data/src/core/ext/filters/http/client/http_client_filter.cc +26 -23
- data/src/core/ext/filters/http/http_filters_plugin.cc +3 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +78 -110
- data/src/core/ext/filters/http/server/http_server_filter.cc +29 -26
- data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +9 -11
- data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +2 -1
- data/src/core/ext/filters/max_age/max_age_filter.cc +14 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +20 -18
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +4 -4
- data/src/core/ext/filters/workarounds/workaround_utils.cc +4 -4
- data/src/core/ext/transport/chttp2/alpn/alpn.cc +2 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +10 -10
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +4 -4
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +11 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +16 -13
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +36 -9
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +3 -0
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +17 -14
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +139 -145
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +16 -14
- data/src/core/ext/transport/chttp2/transport/flow_control.h +8 -7
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +35 -33
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +27 -25
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +12 -12
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +16 -15
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +19 -19
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +11 -11
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +23 -22
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +35 -35
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +10 -7
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -1
- data/src/core/ext/transport/chttp2/transport/parsing.cc +35 -39
- data/src/core/ext/transport/chttp2/transport/stream_map.cc +8 -7
- data/src/core/ext/transport/chttp2/transport/varint.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/writing.cc +18 -18
- data/src/core/ext/transport/inproc/inproc_transport.cc +43 -23
- data/src/core/lib/{gpr → avl}/avl.cc +61 -57
- data/{include/grpc/support → src/core/lib/avl}/avl.h +25 -35
- data/src/core/lib/backoff/backoff.cc +6 -5
- data/src/core/lib/channel/channel_args.cc +23 -109
- data/src/core/lib/channel/channel_args.h +5 -31
- data/src/core/lib/channel/channel_stack.cc +11 -8
- data/src/core/lib/channel/channel_stack_builder.cc +10 -7
- data/src/core/lib/channel/connected_channel.cc +18 -17
- data/src/core/lib/channel/handshaker.cc +8 -8
- data/src/core/lib/channel/handshaker_registry.cc +3 -2
- data/src/core/lib/compression/algorithm_metadata.h +13 -6
- data/src/core/lib/compression/compression.cc +72 -183
- data/src/core/lib/compression/compression_internal.cc +274 -0
- data/src/core/lib/compression/compression_internal.h +86 -0
- data/src/core/lib/compression/message_compress.cc +15 -15
- data/src/core/lib/compression/message_compress.h +4 -3
- data/src/core/lib/compression/stream_compression_gzip.cc +8 -8
- data/src/core/lib/compression/stream_compression_identity.cc +1 -1
- data/src/core/lib/debug/stats.cc +10 -8
- data/src/core/lib/debug/stats_data.cc +2 -1
- data/src/core/lib/debug/trace.cc +3 -3
- data/src/core/lib/gpr/alloc.cc +7 -11
- data/src/core/lib/gpr/arena.cc +34 -12
- data/src/core/lib/gpr/atm.cc +2 -1
- data/src/core/lib/gpr/cpu_linux.cc +3 -3
- data/src/core/lib/gpr/cpu_posix.cc +2 -1
- data/src/core/lib/gpr/env.h +1 -1
- data/src/core/lib/gpr/env_linux.cc +1 -1
- data/src/core/lib/gpr/env_windows.cc +4 -4
- data/src/core/lib/gpr/fork.cc +16 -2
- data/src/core/lib/gpr/host_port.cc +5 -4
- data/{include/grpc/support → src/core/lib/gpr}/host_port.h +5 -13
- data/src/core/lib/gpr/log.cc +5 -4
- data/src/core/lib/gpr/log_linux.cc +1 -1
- data/src/core/lib/gpr/mpscq.cc +1 -0
- data/src/core/lib/gpr/murmur_hash.cc +4 -4
- data/src/core/lib/gpr/string.cc +19 -16
- data/src/core/lib/gpr/string_posix.cc +3 -3
- data/src/core/lib/gpr/sync_posix.cc +5 -9
- data/src/core/lib/gpr/thd.cc +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/thd.h +20 -28
- data/src/core/lib/gpr/thd_posix.cc +6 -4
- data/src/core/lib/gpr/thd_windows.cc +3 -1
- data/src/core/lib/gpr/time.cc +6 -4
- data/src/core/lib/gpr/time_posix.cc +2 -2
- data/{include/grpc/support → src/core/lib/gpr}/tls.h +6 -6
- data/{include/grpc/support → src/core/lib/gpr}/tls_gcc.h +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/tls_msvc.h +3 -3
- data/src/core/lib/gpr/tls_pthread.cc +1 -1
- data/{include/grpc/support → src/core/lib/gpr}/tls_pthread.h +3 -3
- data/{include/grpc/support → src/core/lib/gpr}/useful.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/abstract.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/atomic.h +5 -5
- data/src/core/lib/{gpr++ → gprpp}/atomic_with_atm.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/atomic_with_std.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/debug_location.h +3 -3
- data/src/core/lib/{gpr++ → gprpp}/inlined_vector.h +44 -22
- data/src/core/lib/{gpr++ → gprpp}/manual_constructor.h +2 -2
- data/src/core/lib/{gpr++ → gprpp}/memory.h +14 -5
- data/src/core/lib/{gpr++ → gprpp}/orphanable.h +39 -14
- data/src/core/lib/{gpr++ → gprpp}/ref_counted.h +42 -10
- data/src/core/lib/{gpr++ → gprpp}/ref_counted_ptr.h +18 -8
- data/src/core/lib/http/format_request.cc +3 -3
- data/src/core/lib/http/httpcli.cc +6 -7
- data/src/core/lib/http/httpcli_security_connector.cc +10 -10
- data/src/core/lib/http/parser.cc +16 -12
- data/src/core/lib/iomgr/call_combiner.cc +12 -13
- data/src/core/lib/iomgr/closure.h +4 -6
- data/src/core/lib/iomgr/combiner.cc +10 -21
- data/src/core/lib/iomgr/error.cc +50 -55
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +41 -52
- data/src/core/lib/iomgr/ev_epollex_linux.cc +80 -28
- data/src/core/lib/iomgr/ev_epollsig_linux.cc +23 -30
- data/src/core/lib/iomgr/ev_poll_posix.cc +52 -46
- data/src/core/lib/iomgr/ev_posix.cc +47 -6
- data/src/core/lib/iomgr/exec_ctx.cc +10 -10
- data/src/core/lib/iomgr/exec_ctx.h +1 -1
- data/src/core/lib/iomgr/executor.cc +16 -13
- data/src/core/lib/iomgr/fork_posix.cc +1 -3
- data/src/core/lib/iomgr/gethostname_host_name_max.cc +1 -1
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +2 -2
- data/src/core/lib/iomgr/iomgr_uv.cc +2 -0
- data/src/core/lib/iomgr/iomgr_uv.h +1 -1
- data/src/core/lib/iomgr/is_epollexclusive_available.cc +5 -4
- data/src/core/lib/iomgr/load_file.cc +3 -3
- data/src/core/lib/iomgr/pollset_windows.cc +1 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +10 -9
- data/src/core/lib/iomgr/resolve_address_uv.cc +2 -2
- data/src/core/lib/iomgr/resolve_address_windows.cc +3 -2
- data/src/core/lib/iomgr/resource_quota.cc +36 -34
- data/src/core/lib/iomgr/sockaddr_utils.cc +39 -23
- data/src/core/lib/iomgr/socket_factory_posix.cc +5 -5
- data/src/core/lib/iomgr/socket_mutator.cc +7 -7
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +7 -4
- data/src/core/lib/iomgr/socket_utils_linux.cc +3 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +7 -6
- data/src/core/lib/iomgr/tcp_client_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_posix.cc +47 -55
- data/src/core/lib/iomgr/tcp_server_posix.cc +12 -10
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -5
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +4 -3
- data/src/core/lib/iomgr/tcp_windows.cc +1 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -14
- data/src/core/lib/iomgr/timer_heap.cc +8 -7
- data/src/core/lib/iomgr/timer_manager.cc +4 -3
- data/src/core/lib/iomgr/udp_server.cc +24 -16
- data/src/core/lib/iomgr/unix_sockets_posix.cc +15 -10
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +6 -5
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +1 -2
- data/src/core/lib/json/json.cc +1 -1
- data/src/core/lib/json/json_reader.cc +8 -6
- data/src/core/lib/json/json_string.cc +19 -18
- data/src/core/lib/json/json_writer.cc +10 -8
- data/src/core/lib/profiling/basic_timers.cc +1 -1
- data/src/core/lib/profiling/timers.h +3 -20
- data/src/core/lib/security/context/security_context.cc +16 -14
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +17 -14
- data/src/core/lib/security/credentials/credentials.cc +9 -8
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +12 -13
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +7 -4
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +5 -3
- data/src/core/lib/security/credentials/jwt/json_token.cc +4 -3
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -7
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +21 -18
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +23 -18
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +11 -7
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +22 -21
- data/src/core/lib/security/{transport → security_connector}/security_connector.cc +46 -43
- data/src/core/lib/security/{transport → security_connector}/security_connector.h +3 -3
- data/src/core/lib/security/transport/client_auth_filter.cc +32 -34
- data/src/core/lib/security/transport/lb_targets_info.cc +7 -5
- data/src/core/lib/security/transport/secure_endpoint.cc +21 -21
- data/src/core/lib/security/transport/security_handshaker.cc +19 -18
- data/src/core/lib/security/transport/security_handshaker.h +1 -1
- data/src/core/lib/security/transport/server_auth_filter.cc +21 -21
- data/src/core/lib/slice/b64.cc +19 -16
- data/src/core/lib/slice/percent_encoding.cc +5 -5
- data/src/core/lib/slice/slice.cc +35 -33
- data/src/core/lib/slice/slice_buffer.cc +16 -14
- data/src/core/lib/slice/slice_hash_table.cc +3 -2
- data/src/core/lib/slice/slice_intern.cc +21 -25
- data/src/core/lib/slice/slice_string_helpers.cc +45 -9
- data/src/core/lib/slice/slice_string_helpers.h +6 -0
- data/src/core/lib/surface/byte_buffer.cc +2 -2
- data/src/core/lib/surface/byte_buffer_reader.cc +6 -3
- data/src/core/lib/surface/call.cc +171 -260
- data/src/core/lib/surface/call_test_only.h +1 -13
- data/src/core/lib/surface/channel.cc +20 -43
- data/src/core/lib/surface/channel_init.cc +7 -7
- data/src/core/lib/surface/channel_ping.cc +2 -2
- data/src/core/lib/surface/completion_queue.cc +69 -75
- data/src/core/lib/surface/init.cc +4 -5
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +1 -1
- data/src/core/lib/surface/server.cc +64 -59
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +6 -5
- data/src/core/lib/transport/byte_stream.cc +23 -14
- data/src/core/lib/transport/byte_stream.h +1 -1
- data/src/core/lib/transport/connectivity_state.cc +9 -13
- data/src/core/lib/transport/error_utils.cc +10 -7
- data/src/core/lib/transport/metadata.cc +27 -26
- data/src/core/lib/transport/metadata.h +1 -1
- data/src/core/lib/transport/pid_controller.cc +2 -1
- data/src/core/lib/transport/service_config.cc +5 -5
- data/src/core/lib/transport/static_metadata.cc +225 -222
- data/src/core/lib/transport/static_metadata.h +77 -76
- data/src/core/lib/transport/timeout_encoding.cc +3 -2
- data/src/core/lib/transport/transport.cc +6 -5
- data/src/core/lib/transport/transport_op_string.cc +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -4
- data/src/core/tsi/alts_transport_security.cc +61 -0
- data/src/core/tsi/{gts_transport_security.h → alts_transport_security.h} +16 -8
- data/src/core/tsi/fake_transport_security.cc +59 -43
- data/src/core/tsi/ssl_transport_security.cc +122 -107
- data/src/core/tsi/transport_security.cc +3 -3
- data/src/core/tsi/transport_security_adapter.cc +16 -10
- data/src/ruby/bin/apis/pubsub_demo.rb +1 -1
- data/src/ruby/ext/grpc/rb_channel.c +3 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +13 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -76
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -120
- data/src/ruby/ext/grpc/rb_server.c +52 -28
- data/src/ruby/lib/grpc/generic/rpc_server.rb +7 -4
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +1 -1
- data/src/ruby/pb/test/server.rb +1 -1
- data/src/ruby/spec/client_server_spec.rb +4 -2
- data/src/ruby/spec/generic/active_call_spec.rb +2 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +32 -8
- data/src/ruby/spec/server_spec.rb +26 -7
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +7 -2
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +15 -0
- data/third_party/boringssl/crypto/asn1/a_gentm.c +1 -1
- data/third_party/boringssl/crypto/asn1/a_print.c +0 -28
- data/third_party/boringssl/crypto/asn1/a_strnid.c +3 -0
- data/third_party/boringssl/crypto/asn1/a_time.c +17 -9
- data/third_party/boringssl/crypto/asn1/a_utctm.c +1 -1
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +5 -49
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +1 -1
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +9 -9
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +0 -6
- data/third_party/boringssl/crypto/asn1/time_support.c +5 -5
- data/third_party/boringssl/crypto/base64/base64.c +65 -43
- data/third_party/boringssl/crypto/bio/bio.c +134 -110
- data/third_party/boringssl/crypto/bio/bio_mem.c +9 -9
- data/third_party/boringssl/crypto/bio/connect.c +17 -17
- data/third_party/boringssl/crypto/bio/fd.c +2 -1
- data/third_party/boringssl/crypto/bio/file.c +14 -14
- data/third_party/boringssl/crypto/bio/hexdump.c +15 -16
- data/third_party/boringssl/crypto/bio/internal.h +14 -14
- data/third_party/boringssl/crypto/bio/pair.c +45 -45
- data/third_party/boringssl/crypto/bio/printf.c +6 -10
- data/third_party/boringssl/crypto/{bn → bn_extra}/bn_asn1.c +9 -9
- data/third_party/boringssl/crypto/{bn → bn_extra}/convert.c +18 -223
- data/third_party/boringssl/crypto/buf/buf.c +20 -44
- data/third_party/boringssl/crypto/bytestring/ber.c +35 -35
- data/third_party/boringssl/crypto/bytestring/cbb.c +24 -24
- data/third_party/boringssl/crypto/bytestring/cbs.c +33 -37
- data/third_party/boringssl/crypto/bytestring/internal.h +38 -38
- data/third_party/boringssl/crypto/chacha/chacha.c +7 -7
- data/third_party/boringssl/crypto/{asn1/t_bitst.c → cipher_extra/cipher_extra.c} +49 -38
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/derive_key.c +0 -2
- data/third_party/boringssl/crypto/cipher_extra/e_aesctrhmac.c +281 -0
- data/third_party/boringssl/crypto/cipher_extra/e_aesgcmsiv.c +867 -0
- data/third_party/boringssl/crypto/cipher_extra/e_chacha20poly1305.c +326 -0
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_null.c +0 -1
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_rc2.c +22 -10
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_rc4.c +0 -0
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_ssl3.c +120 -64
- data/third_party/boringssl/crypto/{cipher → cipher_extra}/e_tls.c +220 -141
- data/third_party/boringssl/crypto/{asn1/x_bignum.c → cipher_extra/internal.h} +61 -86
- data/third_party/boringssl/crypto/cipher_extra/tls_cbc.c +482 -0
- data/third_party/boringssl/crypto/cmac/cmac.c +20 -20
- data/third_party/boringssl/crypto/conf/conf.c +32 -20
- data/third_party/boringssl/crypto/conf/internal.h +3 -3
- data/third_party/boringssl/crypto/cpu-aarch64-linux.c +5 -5
- data/third_party/boringssl/crypto/cpu-arm-linux.c +44 -41
- data/third_party/boringssl/crypto/cpu-intel.c +68 -43
- data/third_party/boringssl/crypto/cpu-ppc64le.c +5 -7
- data/third_party/boringssl/crypto/crypto.c +54 -32
- data/third_party/boringssl/crypto/curve25519/curve25519.c +269 -269
- data/third_party/boringssl/crypto/curve25519/internal.h +28 -8
- data/third_party/boringssl/crypto/curve25519/spake25519.c +180 -106
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +9 -9
- data/third_party/boringssl/crypto/dh/check.c +33 -34
- data/third_party/boringssl/crypto/dh/dh.c +72 -36
- data/third_party/boringssl/crypto/dh/dh_asn1.c +1 -1
- data/third_party/boringssl/crypto/dh/params.c +1 -161
- data/third_party/boringssl/crypto/digest_extra/digest_extra.c +240 -0
- data/third_party/boringssl/crypto/dsa/dsa.c +127 -87
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +1 -1
- data/third_party/boringssl/crypto/{ec → ec_extra}/ec_asn1.c +83 -70
- data/third_party/boringssl/crypto/ecdh/ecdh.c +1 -1
- data/third_party/boringssl/crypto/{ecdsa → ecdsa_extra}/ecdsa_asn1.c +86 -31
- data/third_party/boringssl/crypto/engine/engine.c +6 -6
- data/third_party/boringssl/crypto/err/err.c +197 -106
- data/third_party/boringssl/crypto/err/internal.h +58 -0
- data/third_party/boringssl/crypto/evp/digestsign.c +86 -14
- data/third_party/boringssl/crypto/evp/evp.c +6 -11
- data/third_party/boringssl/crypto/evp/evp_asn1.c +17 -17
- data/third_party/boringssl/crypto/evp/evp_ctx.c +15 -11
- data/third_party/boringssl/crypto/evp/internal.h +66 -51
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +11 -11
- data/third_party/boringssl/crypto/evp/p_ec.c +10 -8
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +11 -12
- data/third_party/boringssl/crypto/evp/p_ed25519.c +71 -0
- data/third_party/boringssl/crypto/evp/p_ed25519_asn1.c +190 -0
- data/third_party/boringssl/crypto/evp/p_rsa.c +50 -95
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +28 -18
- data/third_party/boringssl/crypto/evp/pbkdf.c +49 -56
- data/third_party/boringssl/crypto/evp/print.c +5 -36
- data/third_party/boringssl/crypto/evp/scrypt.c +209 -0
- data/third_party/boringssl/crypto/ex_data.c +15 -45
- data/third_party/boringssl/crypto/fipsmodule/aes/internal.h +100 -0
- data/third_party/boringssl/crypto/fipsmodule/bcm.c +679 -0
- data/third_party/boringssl/crypto/{bn → fipsmodule/bn}/internal.h +40 -27
- data/third_party/boringssl/crypto/{bn → fipsmodule/bn}/rsaz_exp.h +0 -0
- data/third_party/boringssl/crypto/{cipher → fipsmodule/cipher}/internal.h +34 -67
- data/third_party/boringssl/crypto/fipsmodule/delocate.h +88 -0
- data/third_party/boringssl/crypto/{des → fipsmodule/des}/internal.h +18 -4
- data/third_party/boringssl/crypto/{digest → fipsmodule/digest}/internal.h +18 -18
- data/third_party/boringssl/crypto/{digest → fipsmodule/digest}/md32_common.h +58 -64
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/internal.h +58 -52
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/p256-x86_64-table.h +11 -11
- data/third_party/boringssl/crypto/{ec → fipsmodule/ec}/p256-x86_64.h +32 -32
- data/third_party/boringssl/crypto/{rand/internal.h → fipsmodule/is_fips.c} +10 -15
- data/third_party/boringssl/crypto/{modes → fipsmodule/modes}/internal.h +112 -119
- data/third_party/boringssl/crypto/fipsmodule/rand/internal.h +92 -0
- data/third_party/boringssl/crypto/{rsa → fipsmodule/rsa}/internal.h +36 -49
- data/third_party/boringssl/crypto/hkdf/hkdf.c +6 -6
- data/third_party/boringssl/crypto/internal.h +301 -233
- data/third_party/boringssl/crypto/lhash/lhash.c +26 -45
- data/third_party/boringssl/crypto/mem.c +76 -33
- data/third_party/boringssl/crypto/obj/obj.c +44 -28
- data/third_party/boringssl/crypto/obj/obj_dat.h +102 -34
- data/third_party/boringssl/crypto/obj/obj_xref.c +6 -6
- data/third_party/boringssl/crypto/pem/pem_info.c +3 -5
- data/third_party/boringssl/crypto/pem/pem_lib.c +1 -6
- data/third_party/boringssl/crypto/pem/pem_pk8.c +1 -0
- data/third_party/boringssl/crypto/pem/pem_pkey.c +1 -1
- data/third_party/boringssl/crypto/pem/pem_xaux.c +0 -2
- data/third_party/boringssl/crypto/pkcs7/internal.h +49 -0
- data/third_party/boringssl/crypto/pkcs7/pkcs7.c +166 -0
- data/third_party/boringssl/crypto/{x509/pkcs7.c → pkcs7/pkcs7_x509.c} +27 -147
- data/third_party/boringssl/crypto/pkcs8/internal.h +34 -16
- data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +120 -39
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +144 -857
- data/third_party/boringssl/crypto/pkcs8/pkcs8_x509.c +789 -0
- data/third_party/boringssl/crypto/poly1305/internal.h +4 -3
- data/third_party/boringssl/crypto/poly1305/poly1305.c +14 -14
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +11 -11
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +41 -41
- data/third_party/boringssl/crypto/pool/internal.h +2 -2
- data/third_party/boringssl/crypto/pool/pool.c +15 -15
- data/third_party/boringssl/crypto/{rand → rand_extra}/deterministic.c +7 -7
- data/third_party/boringssl/crypto/rand_extra/forkunsafe.c +46 -0
- data/third_party/boringssl/crypto/{rand → rand_extra}/fuchsia.c +7 -7
- data/third_party/boringssl/crypto/rand_extra/rand_extra.c +70 -0
- data/third_party/boringssl/crypto/{rand → rand_extra}/windows.c +5 -5
- data/third_party/boringssl/crypto/refcount_c11.c +2 -2
- data/third_party/boringssl/crypto/refcount_lock.c +1 -1
- data/third_party/boringssl/crypto/{rsa → rsa_extra}/rsa_asn1.c +12 -120
- data/third_party/boringssl/crypto/stack/stack.c +13 -13
- data/third_party/boringssl/crypto/thread_none.c +1 -1
- data/third_party/boringssl/crypto/thread_pthread.c +1 -1
- data/third_party/boringssl/crypto/thread_win.c +40 -40
- data/third_party/boringssl/crypto/x509/a_sign.c +5 -12
- data/third_party/boringssl/crypto/x509/a_verify.c +6 -18
- data/third_party/boringssl/crypto/x509/algorithm.c +22 -6
- data/third_party/boringssl/crypto/x509/asn1_gen.c +30 -7
- data/third_party/boringssl/crypto/x509/by_dir.c +2 -2
- data/third_party/boringssl/crypto/x509/by_file.c +2 -2
- data/third_party/boringssl/crypto/x509/rsa_pss.c +5 -5
- data/third_party/boringssl/crypto/x509/t_x509.c +2 -1
- data/third_party/boringssl/crypto/x509/x509_def.c +5 -0
- data/third_party/boringssl/crypto/x509/x509_lu.c +35 -4
- data/third_party/boringssl/crypto/x509/x509_set.c +10 -0
- data/third_party/boringssl/crypto/x509/x509_vfy.c +20 -17
- data/third_party/boringssl/crypto/x509/x_name.c +13 -16
- data/third_party/boringssl/crypto/x509/x_x509.c +3 -3
- data/third_party/boringssl/crypto/x509/x_x509a.c +0 -7
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +8 -0
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +2 -2
- data/third_party/boringssl/crypto/x509v3/pcy_lib.c +0 -9
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +1 -1
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +25 -15
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +21 -11
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +9 -3
- data/third_party/boringssl/crypto/x509v3/v3_info.c +22 -14
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +27 -11
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +0 -33
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +4 -4
- data/third_party/boringssl/include/openssl/aead.h +280 -191
- data/third_party/boringssl/include/openssl/aes.h +50 -50
- data/third_party/boringssl/include/openssl/arm_arch.h +12 -12
- data/third_party/boringssl/include/openssl/asn1.h +14 -77
- data/third_party/boringssl/include/openssl/asn1t.h +11 -15
- data/third_party/boringssl/include/openssl/base.h +78 -51
- data/third_party/boringssl/include/openssl/base64.h +68 -68
- data/third_party/boringssl/include/openssl/bio.h +472 -406
- data/third_party/boringssl/include/openssl/blowfish.h +1 -1
- data/third_party/boringssl/include/openssl/bn.h +454 -435
- data/third_party/boringssl/include/openssl/buf.h +27 -27
- data/third_party/boringssl/include/openssl/bytestring.h +282 -267
- data/third_party/boringssl/include/openssl/cast.h +2 -2
- data/third_party/boringssl/include/openssl/chacha.h +5 -5
- data/third_party/boringssl/include/openssl/cipher.h +209 -200
- data/third_party/boringssl/include/openssl/cmac.h +27 -27
- data/third_party/boringssl/include/openssl/conf.h +49 -46
- data/third_party/boringssl/include/openssl/cpu.h +60 -45
- data/third_party/boringssl/include/openssl/crypto.h +59 -35
- data/third_party/boringssl/include/openssl/curve25519.h +97 -92
- data/third_party/boringssl/include/openssl/des.h +25 -25
- data/third_party/boringssl/include/openssl/dh.h +98 -97
- data/third_party/boringssl/include/openssl/digest.h +143 -114
- data/third_party/boringssl/include/openssl/dsa.h +217 -202
- data/third_party/boringssl/include/openssl/ec.h +132 -131
- data/third_party/boringssl/include/openssl/ec_key.h +132 -128
- data/third_party/boringssl/include/openssl/ecdh.h +9 -9
- data/third_party/boringssl/include/openssl/ecdsa.h +66 -66
- data/third_party/boringssl/include/openssl/engine.h +38 -38
- data/third_party/boringssl/include/openssl/err.h +189 -219
- data/third_party/boringssl/include/openssl/evp.h +473 -397
- data/third_party/boringssl/include/openssl/ex_data.h +46 -56
- data/third_party/boringssl/include/openssl/hkdf.h +17 -17
- data/third_party/boringssl/include/openssl/hmac.h +55 -43
- data/third_party/boringssl/include/openssl/is_boringssl.h +16 -0
- data/third_party/boringssl/include/openssl/lhash.h +67 -67
- data/third_party/boringssl/include/openssl/lhash_macros.h +4 -4
- data/third_party/boringssl/include/openssl/md4.h +14 -14
- data/third_party/boringssl/include/openssl/md5.h +14 -14
- data/third_party/boringssl/include/openssl/mem.h +39 -33
- data/third_party/boringssl/include/openssl/nid.h +43 -0
- data/third_party/boringssl/include/openssl/obj.h +93 -87
- data/third_party/boringssl/include/openssl/opensslconf.h +8 -1
- data/third_party/boringssl/include/openssl/pem.h +2 -122
- data/third_party/boringssl/include/openssl/pkcs7.h +68 -2
- data/third_party/boringssl/include/openssl/pkcs8.h +81 -66
- data/third_party/boringssl/include/openssl/poly1305.h +11 -11
- data/third_party/boringssl/include/openssl/pool.h +29 -25
- data/third_party/boringssl/include/openssl/rand.h +48 -45
- data/third_party/boringssl/include/openssl/rc4.h +9 -9
- data/third_party/boringssl/include/openssl/ripemd.h +13 -13
- data/third_party/boringssl/include/openssl/rsa.h +371 -340
- data/third_party/boringssl/include/openssl/sha.h +71 -71
- data/third_party/boringssl/include/openssl/span.h +191 -0
- data/third_party/boringssl/include/openssl/ssl.h +2639 -2519
- data/third_party/boringssl/include/openssl/ssl3.h +39 -122
- data/third_party/boringssl/include/openssl/stack.h +355 -164
- data/third_party/boringssl/include/openssl/thread.h +43 -43
- data/third_party/boringssl/include/openssl/tls1.h +60 -63
- data/third_party/boringssl/include/openssl/type_check.h +10 -14
- data/third_party/boringssl/include/openssl/x509.h +41 -116
- data/third_party/boringssl/include/openssl/x509_vfy.h +17 -25
- data/third_party/boringssl/include/openssl/x509v3.h +27 -21
- data/third_party/boringssl/ssl/{bio_ssl.c → bio_ssl.cc} +9 -5
- data/third_party/boringssl/ssl/{custom_extensions.c → custom_extensions.cc} +19 -12
- data/third_party/boringssl/ssl/{d1_both.c → d1_both.cc} +224 -193
- data/third_party/boringssl/ssl/{d1_lib.c → d1_lib.cc} +86 -79
- data/third_party/boringssl/ssl/{d1_pkt.c → d1_pkt.cc} +55 -87
- data/third_party/boringssl/ssl/{d1_srtp.c → d1_srtp.cc} +12 -16
- data/third_party/boringssl/ssl/{dtls_method.c → dtls_method.cc} +33 -50
- data/third_party/boringssl/ssl/{dtls_record.c → dtls_record.cc} +76 -64
- data/third_party/boringssl/ssl/handshake.cc +547 -0
- data/third_party/boringssl/ssl/handshake_client.cc +1828 -0
- data/third_party/boringssl/ssl/handshake_server.cc +1672 -0
- data/third_party/boringssl/ssl/internal.h +2027 -1280
- data/third_party/boringssl/ssl/s3_both.cc +603 -0
- data/third_party/boringssl/ssl/{s3_lib.c → s3_lib.cc} +22 -10
- data/third_party/boringssl/ssl/{s3_pkt.c → s3_pkt.cc} +171 -75
- data/third_party/boringssl/ssl/ssl_aead_ctx.cc +415 -0
- data/third_party/boringssl/ssl/{ssl_asn1.c → ssl_asn1.cc} +257 -261
- data/third_party/boringssl/ssl/{ssl_buffer.c → ssl_buffer.cc} +81 -97
- data/third_party/boringssl/ssl/{ssl_cert.c → ssl_cert.cc} +304 -414
- data/third_party/boringssl/ssl/{ssl_cipher.c → ssl_cipher.cc} +427 -505
- data/third_party/boringssl/ssl/{ssl_file.c → ssl_file.cc} +24 -16
- data/third_party/boringssl/ssl/ssl_key_share.cc +245 -0
- data/third_party/boringssl/ssl/{ssl_lib.c → ssl_lib.cc} +665 -828
- data/third_party/boringssl/ssl/ssl_privkey.cc +518 -0
- data/third_party/boringssl/ssl/{ssl_session.c → ssl_session.cc} +596 -471
- data/third_party/boringssl/ssl/{ssl_stat.c → ssl_stat.cc} +5 -224
- data/third_party/boringssl/ssl/{ssl_transcript.c → ssl_transcript.cc} +117 -140
- data/third_party/boringssl/ssl/ssl_versions.cc +439 -0
- data/third_party/boringssl/ssl/{ssl_x509.c → ssl_x509.cc} +751 -267
- data/third_party/boringssl/ssl/{t1_enc.c → t1_enc.cc} +120 -161
- data/third_party/boringssl/ssl/{t1_lib.c → t1_lib.cc} +859 -966
- data/third_party/boringssl/ssl/{tls13_both.c → tls13_both.cc} +202 -284
- data/third_party/boringssl/ssl/tls13_client.cc +842 -0
- data/third_party/boringssl/ssl/{tls13_enc.c → tls13_enc.cc} +108 -90
- data/third_party/boringssl/ssl/tls13_server.cc +967 -0
- data/third_party/boringssl/ssl/{tls_method.c → tls_method.cc} +94 -73
- data/third_party/boringssl/ssl/tls_record.cc +675 -0
- metadata +117 -168
- data/include/grpc/support/cmdline.h +0 -88
- data/include/grpc/support/subprocess.h +0 -44
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -29
- data/src/core/ext/filters/client_channel/resolver_factory.cc +0 -40
- data/src/core/lib/gpr/cmdline.cc +0 -330
- data/src/core/lib/gpr/subprocess_posix.cc +0 -99
- data/src/core/lib/gpr/subprocess_windows.cc +0 -126
- data/src/core/lib/surface/alarm.cc +0 -137
- data/src/core/lib/surface/alarm_internal.h +0 -40
- data/src/core/tsi/gts_transport_security.cc +0 -40
- data/third_party/boringssl/crypto/aes/aes.c +0 -1142
- data/third_party/boringssl/crypto/aes/internal.h +0 -87
- data/third_party/boringssl/crypto/aes/key_wrap.c +0 -138
- data/third_party/boringssl/crypto/aes/mode_wrappers.c +0 -112
- data/third_party/boringssl/crypto/asn1/x_long.c +0 -200
- data/third_party/boringssl/crypto/bn/add.c +0 -377
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +0 -532
- data/third_party/boringssl/crypto/bn/bn.c +0 -365
- data/third_party/boringssl/crypto/bn/cmp.c +0 -239
- data/third_party/boringssl/crypto/bn/ctx.c +0 -313
- data/third_party/boringssl/crypto/bn/div.c +0 -728
- data/third_party/boringssl/crypto/bn/exponentiation.c +0 -1240
- data/third_party/boringssl/crypto/bn/gcd.c +0 -635
- data/third_party/boringssl/crypto/bn/generic.c +0 -707
- data/third_party/boringssl/crypto/bn/kronecker.c +0 -176
- data/third_party/boringssl/crypto/bn/montgomery.c +0 -409
- data/third_party/boringssl/crypto/bn/montgomery_inv.c +0 -207
- data/third_party/boringssl/crypto/bn/mul.c +0 -871
- data/third_party/boringssl/crypto/bn/prime.c +0 -861
- data/third_party/boringssl/crypto/bn/random.c +0 -343
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +0 -254
- data/third_party/boringssl/crypto/bn/shift.c +0 -307
- data/third_party/boringssl/crypto/bn/sqrt.c +0 -506
- data/third_party/boringssl/crypto/cipher/aead.c +0 -156
- data/third_party/boringssl/crypto/cipher/cipher.c +0 -657
- data/third_party/boringssl/crypto/cipher/e_aes.c +0 -1771
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +0 -276
- data/third_party/boringssl/crypto/cipher/e_des.c +0 -205
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +0 -482
- data/third_party/boringssl/crypto/des/des.c +0 -771
- data/third_party/boringssl/crypto/digest/digest.c +0 -251
- data/third_party/boringssl/crypto/digest/digests.c +0 -358
- data/third_party/boringssl/crypto/ec/ec.c +0 -847
- data/third_party/boringssl/crypto/ec/ec_key.c +0 -479
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +0 -303
- data/third_party/boringssl/crypto/ec/oct.c +0 -416
- data/third_party/boringssl/crypto/ec/p224-64.c +0 -1143
- data/third_party/boringssl/crypto/ec/p256-64.c +0 -1701
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +0 -561
- data/third_party/boringssl/crypto/ec/simple.c +0 -1118
- data/third_party/boringssl/crypto/ec/util-64.c +0 -109
- data/third_party/boringssl/crypto/ec/wnaf.c +0 -458
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +0 -479
- data/third_party/boringssl/crypto/hmac/hmac.c +0 -215
- data/third_party/boringssl/crypto/md4/md4.c +0 -236
- data/third_party/boringssl/crypto/md5/md5.c +0 -285
- data/third_party/boringssl/crypto/modes/cbc.c +0 -212
- data/third_party/boringssl/crypto/modes/cfb.c +0 -230
- data/third_party/boringssl/crypto/modes/ctr.c +0 -219
- data/third_party/boringssl/crypto/modes/gcm.c +0 -1071
- data/third_party/boringssl/crypto/modes/ofb.c +0 -95
- data/third_party/boringssl/crypto/modes/polyval.c +0 -94
- data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +0 -85
- data/third_party/boringssl/crypto/rand/rand.c +0 -244
- data/third_party/boringssl/crypto/rand/urandom.c +0 -335
- data/third_party/boringssl/crypto/rsa/blinding.c +0 -265
- data/third_party/boringssl/crypto/rsa/padding.c +0 -708
- data/third_party/boringssl/crypto/rsa/rsa.c +0 -830
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +0 -1100
- data/third_party/boringssl/crypto/sha/sha1-altivec.c +0 -346
- data/third_party/boringssl/crypto/sha/sha1.c +0 -355
- data/third_party/boringssl/crypto/sha/sha256.c +0 -329
- data/third_party/boringssl/crypto/sha/sha512.c +0 -609
- data/third_party/boringssl/crypto/x509/x509type.c +0 -126
- data/third_party/boringssl/include/openssl/stack_macros.h +0 -3987
- data/third_party/boringssl/ssl/handshake_client.c +0 -1883
- data/third_party/boringssl/ssl/handshake_server.c +0 -1950
- data/third_party/boringssl/ssl/s3_both.c +0 -895
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +0 -335
- data/third_party/boringssl/ssl/ssl_ecdh.c +0 -465
- data/third_party/boringssl/ssl/ssl_privkey.c +0 -683
- data/third_party/boringssl/ssl/ssl_privkey_cc.cc +0 -76
- data/third_party/boringssl/ssl/tls13_client.c +0 -712
- data/third_party/boringssl/ssl/tls13_server.c +0 -680
- data/third_party/boringssl/ssl/tls_record.c +0 -556
@@ -121,16 +121,16 @@
|
|
121
121
|
#include "internal.h"
|
122
122
|
|
123
123
|
|
124
|
+
DEFINE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
|
125
|
+
|
124
126
|
struct crypto_ex_data_func_st {
|
125
|
-
long argl;
|
126
|
-
void *argp;
|
127
|
+
long argl; // Arbitary long
|
128
|
+
void *argp; // Arbitary void pointer
|
127
129
|
CRYPTO_EX_free *free_func;
|
128
|
-
CRYPTO_EX_dup *dup_func;
|
129
130
|
};
|
130
131
|
|
131
132
|
int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index,
|
132
|
-
long argl, void *argp,
|
133
|
-
CRYPTO_EX_free *free_func) {
|
133
|
+
long argl, void *argp, CRYPTO_EX_free *free_func) {
|
134
134
|
CRYPTO_EX_DATA_FUNCS *funcs;
|
135
135
|
int ret = 0;
|
136
136
|
|
@@ -142,7 +142,6 @@ int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index,
|
|
142
142
|
|
143
143
|
funcs->argl = argl;
|
144
144
|
funcs->argp = argp;
|
145
|
-
funcs->dup_func = dup_func;
|
146
145
|
funcs->free_func = free_func;
|
147
146
|
|
148
147
|
CRYPTO_STATIC_MUTEX_lock_write(&ex_data_class->lock);
|
@@ -180,7 +179,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int index, void *val) {
|
|
180
179
|
|
181
180
|
n = sk_void_num(ad->sk);
|
182
181
|
|
183
|
-
|
182
|
+
// Add NULL values until the stack is long enough.
|
184
183
|
for (i = n; i <= index; i++) {
|
185
184
|
if (!sk_void_push(ad->sk, NULL)) {
|
186
185
|
OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
|
@@ -199,19 +198,19 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) {
|
|
199
198
|
return sk_void_value(ad->sk, idx);
|
200
199
|
}
|
201
200
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
201
|
+
// get_func_pointers takes a copy of the CRYPTO_EX_DATA_FUNCS pointers, if any,
|
202
|
+
// for the given class. If there are some pointers, it sets |*out| to point to
|
203
|
+
// a fresh stack of them. Otherwise it sets |*out| to NULL. It returns one on
|
204
|
+
// success or zero on error.
|
206
205
|
static int get_func_pointers(STACK_OF(CRYPTO_EX_DATA_FUNCS) **out,
|
207
206
|
CRYPTO_EX_DATA_CLASS *ex_data_class) {
|
208
207
|
size_t n;
|
209
208
|
|
210
209
|
*out = NULL;
|
211
210
|
|
212
|
-
|
213
|
-
|
214
|
-
|
211
|
+
// CRYPTO_EX_DATA_FUNCS structures are static once set, so we can take a
|
212
|
+
// shallow copy of the list under lock and then use the structures without
|
213
|
+
// the lock held.
|
215
214
|
CRYPTO_STATIC_MUTEX_lock_read(&ex_data_class->lock);
|
216
215
|
n = sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth);
|
217
216
|
if (n > 0) {
|
@@ -231,45 +230,16 @@ void CRYPTO_new_ex_data(CRYPTO_EX_DATA *ad) {
|
|
231
230
|
ad->sk = NULL;
|
232
231
|
}
|
233
232
|
|
234
|
-
int CRYPTO_dup_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, CRYPTO_EX_DATA *to,
|
235
|
-
const CRYPTO_EX_DATA *from) {
|
236
|
-
if (from->sk == NULL) {
|
237
|
-
/* In this case, |from| is blank, which is also the initial state of |to|,
|
238
|
-
* so there's nothing to do. */
|
239
|
-
return 1;
|
240
|
-
}
|
241
|
-
|
242
|
-
STACK_OF(CRYPTO_EX_DATA_FUNCS) *func_pointers;
|
243
|
-
if (!get_func_pointers(&func_pointers, ex_data_class)) {
|
244
|
-
return 0;
|
245
|
-
}
|
246
|
-
|
247
|
-
for (size_t i = 0; i < sk_CRYPTO_EX_DATA_FUNCS_num(func_pointers); i++) {
|
248
|
-
CRYPTO_EX_DATA_FUNCS *func_pointer =
|
249
|
-
sk_CRYPTO_EX_DATA_FUNCS_value(func_pointers, i);
|
250
|
-
void *ptr = CRYPTO_get_ex_data(from, i + ex_data_class->num_reserved);
|
251
|
-
if (func_pointer->dup_func) {
|
252
|
-
func_pointer->dup_func(to, from, &ptr, i + ex_data_class->num_reserved,
|
253
|
-
func_pointer->argl, func_pointer->argp);
|
254
|
-
}
|
255
|
-
CRYPTO_set_ex_data(to, i + ex_data_class->num_reserved, ptr);
|
256
|
-
}
|
257
|
-
|
258
|
-
sk_CRYPTO_EX_DATA_FUNCS_free(func_pointers);
|
259
|
-
|
260
|
-
return 1;
|
261
|
-
}
|
262
|
-
|
263
233
|
void CRYPTO_free_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, void *obj,
|
264
234
|
CRYPTO_EX_DATA *ad) {
|
265
235
|
if (ad->sk == NULL) {
|
266
|
-
|
236
|
+
// Nothing to do.
|
267
237
|
return;
|
268
238
|
}
|
269
239
|
|
270
240
|
STACK_OF(CRYPTO_EX_DATA_FUNCS) *func_pointers;
|
271
241
|
if (!get_func_pointers(&func_pointers, ex_data_class)) {
|
272
|
-
|
242
|
+
// TODO(davidben): This leaks memory on malloc error.
|
273
243
|
return;
|
274
244
|
}
|
275
245
|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/* Copyright (c) 2017, Google Inc.
|
2
|
+
*
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
6
|
+
*
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
+
|
15
|
+
#ifndef OPENSSL_HEADER_AES_INTERNAL_H
|
16
|
+
#define OPENSSL_HEADER_AES_INTERNAL_H
|
17
|
+
|
18
|
+
#include <stdlib.h>
|
19
|
+
|
20
|
+
#include <openssl/cpu.h>
|
21
|
+
|
22
|
+
#if defined(__cplusplus)
|
23
|
+
extern "C" {
|
24
|
+
#endif
|
25
|
+
|
26
|
+
|
27
|
+
#if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
|
28
|
+
#define HWAES
|
29
|
+
|
30
|
+
static int hwaes_capable(void) {
|
31
|
+
return CRYPTO_is_ARMv8_AES_capable();
|
32
|
+
}
|
33
|
+
#endif // !NO_ASM && (AES || AARCH64)
|
34
|
+
|
35
|
+
#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_PPC64LE)
|
36
|
+
#define HWAES
|
37
|
+
|
38
|
+
static int hwaes_capable(void) {
|
39
|
+
return CRYPTO_is_PPC64LE_vcrypto_capable();
|
40
|
+
}
|
41
|
+
#endif // !NO_ASM && PPC64LE
|
42
|
+
|
43
|
+
|
44
|
+
#if defined(HWAES)
|
45
|
+
|
46
|
+
int aes_hw_set_encrypt_key(const uint8_t *user_key, const int bits,
|
47
|
+
AES_KEY *key);
|
48
|
+
int aes_hw_set_decrypt_key(const uint8_t *user_key, const int bits,
|
49
|
+
AES_KEY *key);
|
50
|
+
void aes_hw_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
|
51
|
+
void aes_hw_decrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key);
|
52
|
+
void aes_hw_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length,
|
53
|
+
const AES_KEY *key, uint8_t *ivec, const int enc);
|
54
|
+
void aes_hw_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len,
|
55
|
+
const AES_KEY *key, const uint8_t ivec[16]);
|
56
|
+
|
57
|
+
#else
|
58
|
+
|
59
|
+
// If HWAES isn't defined then we provide dummy functions for each of the hwaes
|
60
|
+
// functions.
|
61
|
+
static int hwaes_capable(void) { return 0; }
|
62
|
+
|
63
|
+
static int aes_hw_set_encrypt_key(const uint8_t *user_key, int bits,
|
64
|
+
AES_KEY *key) {
|
65
|
+
abort();
|
66
|
+
}
|
67
|
+
|
68
|
+
static int aes_hw_set_decrypt_key(const uint8_t *user_key, int bits,
|
69
|
+
AES_KEY *key) {
|
70
|
+
abort();
|
71
|
+
}
|
72
|
+
|
73
|
+
static void aes_hw_encrypt(const uint8_t *in, uint8_t *out,
|
74
|
+
const AES_KEY *key) {
|
75
|
+
abort();
|
76
|
+
}
|
77
|
+
|
78
|
+
static void aes_hw_decrypt(const uint8_t *in, uint8_t *out,
|
79
|
+
const AES_KEY *key) {
|
80
|
+
abort();
|
81
|
+
}
|
82
|
+
|
83
|
+
static void aes_hw_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length,
|
84
|
+
const AES_KEY *key, uint8_t *ivec, int enc) {
|
85
|
+
abort();
|
86
|
+
}
|
87
|
+
|
88
|
+
static void aes_hw_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out,
|
89
|
+
size_t len, const AES_KEY *key,
|
90
|
+
const uint8_t ivec[16]) {
|
91
|
+
abort();
|
92
|
+
}
|
93
|
+
|
94
|
+
#endif // !HWAES
|
95
|
+
|
96
|
+
#if defined(__cplusplus)
|
97
|
+
} // extern C
|
98
|
+
#endif
|
99
|
+
|
100
|
+
#endif // OPENSSL_HEADER_AES_INTERNAL_H
|
@@ -0,0 +1,679 @@
|
|
1
|
+
/* Copyright (c) 2017, Google Inc.
|
2
|
+
*
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
6
|
+
*
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
10
|
+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
12
|
+
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
13
|
+
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
14
|
+
|
15
|
+
#if !defined(_GNU_SOURCE)
|
16
|
+
#define _GNU_SOURCE // needed for syscall() on Linux.
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#include <openssl/aead.h>
|
20
|
+
#include <openssl/aes.h>
|
21
|
+
#include <openssl/base.h>
|
22
|
+
#include <openssl/bn.h>
|
23
|
+
#include <openssl/crypto.h>
|
24
|
+
#include <openssl/des.h>
|
25
|
+
#include <openssl/ecdsa.h>
|
26
|
+
#include <openssl/ec_key.h>
|
27
|
+
#include <openssl/hmac.h>
|
28
|
+
#include <openssl/nid.h>
|
29
|
+
#include <openssl/rsa.h>
|
30
|
+
#include <openssl/sha.h>
|
31
|
+
|
32
|
+
#include "../internal.h"
|
33
|
+
#include "rand/internal.h"
|
34
|
+
|
35
|
+
#include "aes/aes.c"
|
36
|
+
#include "aes/key_wrap.c"
|
37
|
+
#include "aes/mode_wrappers.c"
|
38
|
+
#include "bn/add.c"
|
39
|
+
#include "bn/asm/x86_64-gcc.c"
|
40
|
+
#include "bn/bn.c"
|
41
|
+
#include "bn/bytes.c"
|
42
|
+
#include "bn/cmp.c"
|
43
|
+
#include "bn/ctx.c"
|
44
|
+
#include "bn/div.c"
|
45
|
+
#include "bn/exponentiation.c"
|
46
|
+
#include "bn/gcd.c"
|
47
|
+
#include "bn/generic.c"
|
48
|
+
#include "bn/jacobi.c"
|
49
|
+
#include "bn/montgomery.c"
|
50
|
+
#include "bn/montgomery_inv.c"
|
51
|
+
#include "bn/mul.c"
|
52
|
+
#include "bn/prime.c"
|
53
|
+
#include "bn/random.c"
|
54
|
+
#include "bn/rsaz_exp.c"
|
55
|
+
#include "bn/shift.c"
|
56
|
+
#include "bn/sqrt.c"
|
57
|
+
#include "cipher/aead.c"
|
58
|
+
#include "cipher/cipher.c"
|
59
|
+
#include "cipher/e_aes.c"
|
60
|
+
#include "cipher/e_des.c"
|
61
|
+
#include "des/des.c"
|
62
|
+
#include "digest/digest.c"
|
63
|
+
#include "digest/digests.c"
|
64
|
+
#include "ecdsa/ecdsa.c"
|
65
|
+
#include "ec/ec.c"
|
66
|
+
#include "ec/ec_key.c"
|
67
|
+
#include "ec/ec_montgomery.c"
|
68
|
+
#include "ec/oct.c"
|
69
|
+
#include "ec/p224-64.c"
|
70
|
+
#include "ec/p256-64.c"
|
71
|
+
#include "ec/p256-x86_64.c"
|
72
|
+
#include "ec/simple.c"
|
73
|
+
#include "ec/util-64.c"
|
74
|
+
#include "ec/wnaf.c"
|
75
|
+
#include "hmac/hmac.c"
|
76
|
+
#include "md4/md4.c"
|
77
|
+
#include "md5/md5.c"
|
78
|
+
#include "modes/cbc.c"
|
79
|
+
#include "modes/cfb.c"
|
80
|
+
#include "modes/ctr.c"
|
81
|
+
#include "modes/gcm.c"
|
82
|
+
#include "modes/ofb.c"
|
83
|
+
#include "modes/polyval.c"
|
84
|
+
#include "rand/ctrdrbg.c"
|
85
|
+
#include "rand/rand.c"
|
86
|
+
#include "rand/urandom.c"
|
87
|
+
#include "rsa/blinding.c"
|
88
|
+
#include "rsa/padding.c"
|
89
|
+
#include "rsa/rsa.c"
|
90
|
+
#include "rsa/rsa_impl.c"
|
91
|
+
#include "sha/sha1-altivec.c"
|
92
|
+
#include "sha/sha1.c"
|
93
|
+
#include "sha/sha256.c"
|
94
|
+
#include "sha/sha512.c"
|
95
|
+
|
96
|
+
|
97
|
+
#if defined(BORINGSSL_FIPS)
|
98
|
+
|
99
|
+
static void hexdump(const uint8_t *in, size_t len) {
|
100
|
+
for (size_t i = 0; i < len; i++) {
|
101
|
+
printf("%02x", in[i]);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
static int check_test(const void *expected, const void *actual,
|
106
|
+
size_t expected_len, const char *name) {
|
107
|
+
if (OPENSSL_memcmp(actual, expected, expected_len) != 0) {
|
108
|
+
printf("%s failed.\nExpected: ", name);
|
109
|
+
hexdump(expected, expected_len);
|
110
|
+
printf("\nCalculated: ");
|
111
|
+
hexdump(actual, expected_len);
|
112
|
+
printf("\n");
|
113
|
+
return 0;
|
114
|
+
}
|
115
|
+
return 1;
|
116
|
+
}
|
117
|
+
|
118
|
+
static int set_bignum(BIGNUM **out, const uint8_t *in, size_t len) {
|
119
|
+
*out = BN_bin2bn(in, len, NULL);
|
120
|
+
return *out != NULL;
|
121
|
+
}
|
122
|
+
|
123
|
+
static RSA *self_test_rsa_key(void) {
|
124
|
+
static const uint8_t kN[] = {
|
125
|
+
0xd3, 0x3a, 0x62, 0x9f, 0x07, 0x77, 0xb0, 0x18, 0xf3, 0xff, 0xfe, 0xcc,
|
126
|
+
0xc9, 0xa2, 0xc2, 0x3a, 0xa6, 0x1d, 0xd8, 0xf0, 0x26, 0x5b, 0x38, 0x90,
|
127
|
+
0x17, 0x48, 0x15, 0xce, 0x21, 0xcd, 0xd6, 0x62, 0x99, 0xe2, 0xd7, 0xda,
|
128
|
+
0x40, 0x80, 0x3c, 0xad, 0x18, 0xb7, 0x26, 0xe9, 0x30, 0x8a, 0x23, 0x3f,
|
129
|
+
0x68, 0x9a, 0x9c, 0x31, 0x34, 0x91, 0x99, 0x06, 0x11, 0x36, 0xb2, 0x9e,
|
130
|
+
0x3a, 0xd0, 0xbc, 0xb9, 0x93, 0x4e, 0xb8, 0x72, 0xa1, 0x9f, 0xb6, 0x8c,
|
131
|
+
0xd5, 0x17, 0x1f, 0x7e, 0xaa, 0x75, 0xbb, 0xdf, 0xa1, 0x70, 0x48, 0xc4,
|
132
|
+
0xec, 0x9a, 0x51, 0xed, 0x41, 0xc9, 0x74, 0xc0, 0x3e, 0x1e, 0x85, 0x2f,
|
133
|
+
0xbe, 0x34, 0xc7, 0x65, 0x34, 0x8b, 0x4d, 0x55, 0x4b, 0xe1, 0x45, 0x54,
|
134
|
+
0x0d, 0x75, 0x7e, 0x89, 0x4d, 0x0c, 0xf6, 0x33, 0xe5, 0xfc, 0xfb, 0x56,
|
135
|
+
0x1b, 0xf2, 0x39, 0x9d, 0xe0, 0xff, 0x55, 0xcf, 0x02, 0x05, 0xb9, 0x74,
|
136
|
+
0xd2, 0x91, 0xfc, 0x87, 0xe1, 0xbb, 0x97, 0x2a, 0xe4, 0xdd, 0x20, 0xc0,
|
137
|
+
0x38, 0x47, 0xc0, 0x76, 0x3f, 0xa1, 0x9b, 0x5c, 0x20, 0xff, 0xff, 0xc7,
|
138
|
+
0x49, 0x3b, 0x4c, 0xaf, 0x99, 0xa6, 0x3e, 0x82, 0x5c, 0x58, 0x27, 0xce,
|
139
|
+
0x01, 0x03, 0xc3, 0x16, 0x35, 0x20, 0xe9, 0xf0, 0x15, 0x7a, 0x41, 0xd5,
|
140
|
+
0x1f, 0x52, 0xea, 0xdf, 0xad, 0x4c, 0xbb, 0x0d, 0xcb, 0x04, 0x91, 0xb0,
|
141
|
+
0x95, 0xa8, 0xce, 0x25, 0xfd, 0xd2, 0x62, 0x47, 0x77, 0xee, 0x13, 0xf1,
|
142
|
+
0x48, 0x72, 0x9e, 0xd9, 0x2d, 0xe6, 0x5f, 0xa4, 0xc6, 0x9e, 0x5a, 0xb2,
|
143
|
+
0xc6, 0xa2, 0xf7, 0x0a, 0x16, 0x17, 0xae, 0x6b, 0x1c, 0x30, 0x7c, 0x63,
|
144
|
+
0x08, 0x83, 0xe7, 0x43, 0xec, 0x54, 0x5e, 0x2c, 0x08, 0x0b, 0x5e, 0x46,
|
145
|
+
0xa7, 0x10, 0x93, 0x43, 0x53, 0x4e, 0xe3, 0x16, 0x73, 0x55, 0xce, 0xf2,
|
146
|
+
0x94, 0xc0, 0xbe, 0xb3,
|
147
|
+
};
|
148
|
+
static const uint8_t kE[] = {0x01, 0x00, 0x01}; // 65537
|
149
|
+
static const uint8_t kD[] = {
|
150
|
+
0x2f, 0x2c, 0x1e, 0xd2, 0x3d, 0x2c, 0xb1, 0x9b, 0x21, 0x02, 0xce, 0xb8,
|
151
|
+
0x95, 0x5f, 0x4f, 0xd9, 0x21, 0x38, 0x11, 0x36, 0xb0, 0x9a, 0x36, 0xab,
|
152
|
+
0x97, 0x47, 0x75, 0xf7, 0x2e, 0xfd, 0x75, 0x1f, 0x58, 0x16, 0x9c, 0xf6,
|
153
|
+
0x14, 0xe9, 0x8e, 0xa3, 0x69, 0x9d, 0x9d, 0x86, 0xfe, 0x5c, 0x1b, 0x3b,
|
154
|
+
0x11, 0xf5, 0x55, 0x64, 0x77, 0xc4, 0xfc, 0x53, 0xaa, 0x8c, 0x78, 0x9f,
|
155
|
+
0x75, 0xab, 0x20, 0x3a, 0xa1, 0x77, 0x37, 0x22, 0x02, 0x8e, 0x54, 0x8a,
|
156
|
+
0x67, 0x1c, 0x5e, 0xe0, 0x3e, 0xd9, 0x44, 0x37, 0xd1, 0x29, 0xee, 0x56,
|
157
|
+
0x6c, 0x30, 0x9a, 0x93, 0x4d, 0xd9, 0xdb, 0xc5, 0x03, 0x1a, 0x75, 0xcc,
|
158
|
+
0x0f, 0xc2, 0x61, 0xb5, 0x6c, 0x62, 0x9f, 0xc6, 0xa8, 0xc7, 0x8a, 0x60,
|
159
|
+
0x17, 0x11, 0x62, 0x4c, 0xef, 0x74, 0x31, 0x97, 0xad, 0x89, 0x2d, 0xe8,
|
160
|
+
0x31, 0x1d, 0x8b, 0x58, 0x82, 0xe3, 0x03, 0x1a, 0x6b, 0xdf, 0x3f, 0x3e,
|
161
|
+
0xa4, 0x27, 0x19, 0xef, 0x46, 0x7a, 0x90, 0xdf, 0xa7, 0xe7, 0xc9, 0x66,
|
162
|
+
0xab, 0x41, 0x1d, 0x65, 0x78, 0x1c, 0x18, 0x40, 0x5c, 0xd6, 0x87, 0xb5,
|
163
|
+
0xea, 0x29, 0x44, 0xb3, 0xf5, 0xb3, 0xd2, 0x4f, 0xce, 0x88, 0x78, 0x49,
|
164
|
+
0x27, 0x4e, 0x0b, 0x30, 0x85, 0xfb, 0x73, 0xfd, 0x8b, 0x32, 0x15, 0xee,
|
165
|
+
0x1f, 0xc9, 0x0e, 0x89, 0xb9, 0x43, 0x2f, 0xe9, 0x60, 0x8d, 0xda, 0xae,
|
166
|
+
0x2b, 0x30, 0x99, 0xee, 0x88, 0x81, 0x20, 0x7b, 0x4a, 0xc3, 0x18, 0xf2,
|
167
|
+
0x94, 0x02, 0x79, 0x94, 0xaa, 0x65, 0xd9, 0x1b, 0x45, 0x2a, 0xac, 0x6e,
|
168
|
+
0x30, 0x48, 0x57, 0xea, 0xbe, 0x79, 0x7d, 0xfc, 0x67, 0xaa, 0x47, 0xc0,
|
169
|
+
0xf7, 0x52, 0xfd, 0x0b, 0x63, 0x4e, 0x3d, 0x2e, 0xcc, 0x36, 0xa0, 0xdb,
|
170
|
+
0x92, 0x0b, 0xa9, 0x1b, 0xeb, 0xc2, 0xd5, 0x08, 0xd3, 0x85, 0x87, 0xf8,
|
171
|
+
0x5d, 0x1a, 0xf6, 0xc1,
|
172
|
+
};
|
173
|
+
static const uint8_t kP[] = {
|
174
|
+
0xf7, 0x06, 0xa3, 0x98, 0x8a, 0x52, 0xf8, 0x63, 0x68, 0x27, 0x4f, 0x68,
|
175
|
+
0x7f, 0x34, 0xec, 0x8e, 0x5d, 0xf8, 0x30, 0x92, 0xb3, 0x62, 0x4c, 0xeb,
|
176
|
+
0xdb, 0x19, 0x6b, 0x09, 0xc5, 0xa3, 0xf0, 0xbb, 0xff, 0x0f, 0xc2, 0xd4,
|
177
|
+
0x9b, 0xc9, 0x54, 0x4f, 0xb9, 0xf9, 0xe1, 0x4c, 0xf0, 0xe3, 0x4c, 0x90,
|
178
|
+
0xda, 0x7a, 0x01, 0xc2, 0x9f, 0xc4, 0xc8, 0x8e, 0xb1, 0x1e, 0x93, 0x75,
|
179
|
+
0x75, 0xc6, 0x13, 0x25, 0xc3, 0xee, 0x3b, 0xcc, 0xb8, 0x72, 0x6c, 0x49,
|
180
|
+
0xb0, 0x09, 0xfb, 0xab, 0x44, 0xeb, 0x4d, 0x40, 0xf0, 0x61, 0x6b, 0xe5,
|
181
|
+
0xe6, 0xfe, 0x3e, 0x0a, 0x77, 0x26, 0x39, 0x76, 0x3d, 0x4c, 0x3e, 0x9b,
|
182
|
+
0x5b, 0xc0, 0xaf, 0xa2, 0x58, 0x76, 0xb0, 0xe9, 0xda, 0x7f, 0x0e, 0x78,
|
183
|
+
0xc9, 0x76, 0x49, 0x5c, 0xfa, 0xb3, 0xb0, 0x15, 0x4b, 0x41, 0xc7, 0x27,
|
184
|
+
0xa4, 0x75, 0x28, 0x5c, 0x30, 0x69, 0x50, 0x29,
|
185
|
+
};
|
186
|
+
static const uint8_t kQ[] = {
|
187
|
+
0xda, 0xe6, 0xd2, 0xbb, 0x44, 0xff, 0x4f, 0xdf, 0x57, 0xc1, 0x11, 0xa3,
|
188
|
+
0x51, 0xba, 0x17, 0x89, 0x4c, 0x01, 0xc0, 0x0c, 0x97, 0x34, 0x50, 0xcf,
|
189
|
+
0x32, 0x1e, 0xc0, 0xbd, 0x7b, 0x35, 0xb5, 0x6a, 0x26, 0xcc, 0xea, 0x4c,
|
190
|
+
0x8e, 0x87, 0x4a, 0x67, 0x8b, 0xd3, 0xe5, 0x4f, 0x3a, 0x60, 0x48, 0x59,
|
191
|
+
0x04, 0x93, 0x39, 0xd7, 0x7c, 0xfb, 0x19, 0x1a, 0x34, 0xd5, 0xe8, 0xaf,
|
192
|
+
0xe7, 0x22, 0x2c, 0x0d, 0xc2, 0x91, 0x69, 0xb6, 0xe9, 0x2a, 0xe9, 0x1c,
|
193
|
+
0x4c, 0x6e, 0x8f, 0x40, 0xf5, 0xa8, 0x3e, 0x82, 0x69, 0x69, 0xbe, 0x9f,
|
194
|
+
0x7d, 0x5c, 0x7f, 0x92, 0x78, 0x17, 0xa3, 0x6d, 0x41, 0x2d, 0x72, 0xed,
|
195
|
+
0x3f, 0x71, 0xfa, 0x97, 0xb4, 0x63, 0xe4, 0x4f, 0xd9, 0x46, 0x03, 0xfb,
|
196
|
+
0x00, 0xeb, 0x30, 0x70, 0xb9, 0x51, 0xd9, 0x0a, 0xd2, 0xf8, 0x50, 0xd4,
|
197
|
+
0xfb, 0x43, 0x84, 0xf8, 0xac, 0x58, 0xc3, 0x7b,
|
198
|
+
};
|
199
|
+
static const uint8_t kDModPMinusOne[] = {
|
200
|
+
0xf5, 0x50, 0x8f, 0x88, 0x7d, 0xdd, 0xb5, 0xb4, 0x2a, 0x8b, 0xd7, 0x4d,
|
201
|
+
0x23, 0xfe, 0xaf, 0xe9, 0x16, 0x22, 0xd2, 0x41, 0xed, 0x88, 0xf2, 0x70,
|
202
|
+
0xcb, 0x4d, 0xeb, 0xc1, 0x71, 0x97, 0xc4, 0x0b, 0x3e, 0x5a, 0x2d, 0x96,
|
203
|
+
0xab, 0xfa, 0xfd, 0x12, 0x8b, 0xd3, 0x3e, 0x4e, 0x05, 0x6f, 0x04, 0xeb,
|
204
|
+
0x59, 0x3c, 0x0e, 0xa1, 0x73, 0xbe, 0x9d, 0x99, 0x2f, 0x05, 0xf9, 0x54,
|
205
|
+
0x8d, 0x98, 0x1e, 0x0d, 0xc4, 0x0c, 0xc3, 0x30, 0x23, 0xff, 0xe5, 0xd0,
|
206
|
+
0x2b, 0xd5, 0x4e, 0x2b, 0xa0, 0xae, 0xb8, 0x32, 0x84, 0x45, 0x8b, 0x3c,
|
207
|
+
0x6d, 0xf0, 0x10, 0x36, 0x9e, 0x6a, 0xc4, 0x67, 0xca, 0xa9, 0xfc, 0x06,
|
208
|
+
0x96, 0xd0, 0xbc, 0xda, 0xd1, 0x55, 0x55, 0x8d, 0x77, 0x21, 0xf4, 0x82,
|
209
|
+
0x39, 0x37, 0x91, 0xd5, 0x97, 0x56, 0x78, 0xc8, 0x3c, 0xcb, 0x5e, 0xf6,
|
210
|
+
0xdc, 0x58, 0x48, 0xb3, 0x7c, 0x94, 0x29, 0x39,
|
211
|
+
};
|
212
|
+
static const uint8_t kDModQMinusOne[] = {
|
213
|
+
0x64, 0x65, 0xbd, 0x7d, 0x1a, 0x96, 0x26, 0xa1, 0xfe, 0xf3, 0x94, 0x0d,
|
214
|
+
0x5d, 0xec, 0x85, 0xe2, 0xf8, 0xb3, 0x4c, 0xcb, 0xf9, 0x85, 0x8b, 0x12,
|
215
|
+
0x9c, 0xa0, 0x32, 0x32, 0x35, 0x92, 0x5a, 0x94, 0x47, 0x1b, 0x70, 0xd2,
|
216
|
+
0x90, 0x04, 0x49, 0x01, 0xd8, 0xc5, 0xe4, 0xc4, 0x43, 0xb7, 0xe9, 0x36,
|
217
|
+
0xba, 0xbc, 0x73, 0xa8, 0xfb, 0xaf, 0x86, 0xc1, 0xd8, 0x3d, 0xcb, 0xac,
|
218
|
+
0xf1, 0xcb, 0x60, 0x7d, 0x27, 0x21, 0xde, 0x64, 0x7f, 0xe8, 0xa8, 0x65,
|
219
|
+
0xcc, 0x40, 0x60, 0xff, 0xa0, 0x2b, 0xfc, 0x0f, 0x80, 0x1d, 0x79, 0xca,
|
220
|
+
0x58, 0x8a, 0xd6, 0x0f, 0xed, 0x78, 0x9a, 0x02, 0x00, 0x04, 0xc2, 0x53,
|
221
|
+
0x41, 0xe8, 0x1a, 0xd0, 0xfd, 0x71, 0x5b, 0x43, 0xac, 0x19, 0x4a, 0xb6,
|
222
|
+
0x12, 0xa3, 0xcb, 0xe1, 0xc7, 0x7d, 0x5c, 0x98, 0x74, 0x4e, 0x63, 0x74,
|
223
|
+
0x6b, 0x91, 0x7a, 0x29, 0x3b, 0x92, 0xb2, 0x85,
|
224
|
+
};
|
225
|
+
static const uint8_t kQInverseModP[] = {
|
226
|
+
0xd0, 0xde, 0x19, 0xda, 0x1e, 0xa2, 0xd8, 0x8f, 0x1c, 0x92, 0x73, 0xb0,
|
227
|
+
0xc9, 0x90, 0xc7, 0xf5, 0xec, 0xc5, 0x89, 0x01, 0x05, 0x78, 0x11, 0x2d,
|
228
|
+
0x74, 0x34, 0x44, 0xad, 0xd5, 0xf7, 0xa4, 0xfe, 0x9f, 0x25, 0x4d, 0x0b,
|
229
|
+
0x92, 0xe3, 0xb8, 0x7d, 0xd3, 0xfd, 0xa5, 0xca, 0x95, 0x60, 0xa3, 0xf9,
|
230
|
+
0x55, 0x42, 0x14, 0xb2, 0x45, 0x51, 0x9f, 0x73, 0x88, 0x43, 0x8a, 0xd1,
|
231
|
+
0x65, 0x9e, 0xd1, 0xf7, 0x82, 0x2a, 0x2a, 0x8d, 0x70, 0x56, 0xe3, 0xef,
|
232
|
+
0xc9, 0x0e, 0x2a, 0x2c, 0x15, 0xaf, 0x7f, 0x97, 0x81, 0x66, 0xf3, 0xb5,
|
233
|
+
0x00, 0xa9, 0x26, 0xcc, 0x1e, 0xc2, 0x98, 0xdd, 0xd3, 0x37, 0x06, 0x79,
|
234
|
+
0xb3, 0x60, 0x58, 0x79, 0x99, 0x3f, 0xa3, 0x15, 0x1f, 0x31, 0xe3, 0x11,
|
235
|
+
0x88, 0x4c, 0x35, 0x57, 0xfa, 0x79, 0xd7, 0xd8, 0x72, 0xee, 0x73, 0x95,
|
236
|
+
0x89, 0x29, 0xc7, 0x05, 0x27, 0x68, 0x90, 0x15,
|
237
|
+
};
|
238
|
+
|
239
|
+
RSA *rsa = RSA_new();
|
240
|
+
if (rsa == NULL ||
|
241
|
+
!set_bignum(&rsa->n, kN, sizeof(kN)) ||
|
242
|
+
!set_bignum(&rsa->e, kE, sizeof(kE)) ||
|
243
|
+
!set_bignum(&rsa->d, kD, sizeof(kD)) ||
|
244
|
+
!set_bignum(&rsa->p, kP, sizeof(kP)) ||
|
245
|
+
!set_bignum(&rsa->q, kQ, sizeof(kQ)) ||
|
246
|
+
!set_bignum(&rsa->dmp1, kDModPMinusOne, sizeof(kDModPMinusOne)) ||
|
247
|
+
!set_bignum(&rsa->dmq1, kDModQMinusOne, sizeof(kDModQMinusOne)) ||
|
248
|
+
!set_bignum(&rsa->iqmp, kQInverseModP, sizeof(kQInverseModP))) {
|
249
|
+
RSA_free(rsa);
|
250
|
+
return NULL;
|
251
|
+
}
|
252
|
+
|
253
|
+
return rsa;
|
254
|
+
}
|
255
|
+
|
256
|
+
static EC_KEY *self_test_ecdsa_key(void) {
|
257
|
+
static const uint8_t kQx[] = {
|
258
|
+
0xc8, 0x15, 0x61, 0xec, 0xf2, 0xe5, 0x4e, 0xde, 0xfe, 0x66, 0x17,
|
259
|
+
0xdb, 0x1c, 0x7a, 0x34, 0xa7, 0x07, 0x44, 0xdd, 0xb2, 0x61, 0xf2,
|
260
|
+
0x69, 0xb8, 0x3d, 0xac, 0xfc, 0xd2, 0xad, 0xe5, 0xa6, 0x81,
|
261
|
+
};
|
262
|
+
static const uint8_t kQy[] = {
|
263
|
+
0xe0, 0xe2, 0xaf, 0xa3, 0xf9, 0xb6, 0xab, 0xe4, 0xc6, 0x98, 0xef,
|
264
|
+
0x64, 0x95, 0xf1, 0xbe, 0x49, 0xa3, 0x19, 0x6c, 0x50, 0x56, 0xac,
|
265
|
+
0xb3, 0x76, 0x3f, 0xe4, 0x50, 0x7e, 0xec, 0x59, 0x6e, 0x88,
|
266
|
+
};
|
267
|
+
static const uint8_t kD[] = {
|
268
|
+
0xc6, 0xc1, 0xaa, 0xda, 0x15, 0xb0, 0x76, 0x61, 0xf8, 0x14, 0x2c,
|
269
|
+
0x6c, 0xaf, 0x0f, 0xdb, 0x24, 0x1a, 0xff, 0x2e, 0xfe, 0x46, 0xc0,
|
270
|
+
0x93, 0x8b, 0x74, 0xf2, 0xbc, 0xc5, 0x30, 0x52, 0xb0, 0x77,
|
271
|
+
};
|
272
|
+
|
273
|
+
EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
|
274
|
+
BIGNUM *qx = BN_bin2bn(kQx, sizeof(kQx), NULL);
|
275
|
+
BIGNUM *qy = BN_bin2bn(kQy, sizeof(kQy), NULL);
|
276
|
+
BIGNUM *d = BN_bin2bn(kD, sizeof(kD), NULL);
|
277
|
+
if (ec_key == NULL || qx == NULL || qy == NULL || d == NULL ||
|
278
|
+
!EC_KEY_set_public_key_affine_coordinates(ec_key, qx, qy) ||
|
279
|
+
!EC_KEY_set_private_key(ec_key, d)) {
|
280
|
+
EC_KEY_free(ec_key);
|
281
|
+
ec_key = NULL;
|
282
|
+
}
|
283
|
+
|
284
|
+
BN_free(qx);
|
285
|
+
BN_free(qy);
|
286
|
+
BN_free(d);
|
287
|
+
return ec_key;
|
288
|
+
}
|
289
|
+
|
290
|
+
#if !defined(OPENSSL_ASAN)
|
291
|
+
// These symbols are filled in by delocate.go. They point to the start and end
|
292
|
+
// of the module, and the location of the integrity hash, respectively.
|
293
|
+
extern const uint8_t BORINGSSL_bcm_text_start[];
|
294
|
+
extern const uint8_t BORINGSSL_bcm_text_end[];
|
295
|
+
extern const uint8_t BORINGSSL_bcm_text_hash[];
|
296
|
+
#endif
|
297
|
+
|
298
|
+
static void __attribute__((constructor))
|
299
|
+
BORINGSSL_bcm_power_on_self_test(void) {
|
300
|
+
CRYPTO_library_init();
|
301
|
+
|
302
|
+
#if !defined(OPENSSL_ASAN)
|
303
|
+
// Integrity tests cannot run under ASAN because it involves reading the full
|
304
|
+
// .text section, which triggers the global-buffer overflow detection.
|
305
|
+
const uint8_t *const start = BORINGSSL_bcm_text_start;
|
306
|
+
const uint8_t *const end = BORINGSSL_bcm_text_end;
|
307
|
+
|
308
|
+
static const uint8_t kHMACKey[64] = {0};
|
309
|
+
uint8_t result[SHA512_DIGEST_LENGTH];
|
310
|
+
|
311
|
+
unsigned result_len;
|
312
|
+
if (!HMAC(EVP_sha512(), kHMACKey, sizeof(kHMACKey), start, end - start,
|
313
|
+
result, &result_len) ||
|
314
|
+
result_len != sizeof(result)) {
|
315
|
+
goto err;
|
316
|
+
}
|
317
|
+
|
318
|
+
const uint8_t *expected = BORINGSSL_bcm_text_hash;
|
319
|
+
|
320
|
+
if (!check_test(expected, result, sizeof(result), "FIPS integrity test")) {
|
321
|
+
goto err;
|
322
|
+
}
|
323
|
+
#endif
|
324
|
+
|
325
|
+
static const uint8_t kAESKey[16] = "BoringCrypto Key";
|
326
|
+
static const uint8_t kAESIV[16] = {0};
|
327
|
+
static const uint8_t kPlaintext[64] =
|
328
|
+
"BoringCryptoModule FIPS KAT Encryption and Decryption Plaintext!";
|
329
|
+
static const uint8_t kAESCBCCiphertext[64] = {
|
330
|
+
0x87, 0x2d, 0x98, 0xc2, 0xcc, 0x31, 0x5b, 0x41, 0xe0, 0xfa, 0x7b,
|
331
|
+
0x0a, 0x71, 0xc0, 0x42, 0xbf, 0x4f, 0x61, 0xd0, 0x0d, 0x58, 0x8c,
|
332
|
+
0xf7, 0x05, 0xfb, 0x94, 0x89, 0xd3, 0xbc, 0xaa, 0x1a, 0x50, 0x45,
|
333
|
+
0x1f, 0xc3, 0x8c, 0xb8, 0x98, 0x86, 0xa3, 0xe3, 0x6c, 0xfc, 0xad,
|
334
|
+
0x3a, 0xb5, 0x59, 0x27, 0x7d, 0x21, 0x07, 0xca, 0x4c, 0x1d, 0x55,
|
335
|
+
0x34, 0xdd, 0x5a, 0x2d, 0xc4, 0xb4, 0xf5, 0xa8,
|
336
|
+
#if !defined(BORINGSSL_FIPS_BREAK_AES_CBC)
|
337
|
+
0x35
|
338
|
+
#else
|
339
|
+
0x00
|
340
|
+
#endif
|
341
|
+
};
|
342
|
+
static const uint8_t kAESGCMCiphertext[80] = {
|
343
|
+
0x4a, 0xd8, 0xe7, 0x7d, 0x78, 0xd7, 0x7d, 0x5e, 0xb2, 0x11, 0xb6, 0xc9,
|
344
|
+
0xa4, 0xbc, 0xb2, 0xae, 0xbe, 0x93, 0xd1, 0xb7, 0xfe, 0x65, 0xc1, 0x82,
|
345
|
+
0x2a, 0xb6, 0x71, 0x5f, 0x1a, 0x7c, 0xe0, 0x1b, 0x2b, 0xe2, 0x53, 0xfa,
|
346
|
+
0xa0, 0x47, 0xfa, 0xd7, 0x8f, 0xb1, 0x4a, 0xc4, 0xdc, 0x89, 0xf9, 0xb4,
|
347
|
+
0x14, 0x4d, 0xde, 0x95, 0xea, 0x29, 0x69, 0x76, 0x81, 0xa3, 0x5c, 0x33,
|
348
|
+
0xd8, 0x37, 0xd8, 0xfa, 0x47, 0x19, 0x46, 0x2f, 0xf1, 0x90, 0xb7, 0x61,
|
349
|
+
0x8f, 0x6f, 0xdd, 0x31, 0x3f, 0x6a, 0x64,
|
350
|
+
#if !defined(BORINGSSL_FIPS_BREAK_AES_GCM)
|
351
|
+
0x0d
|
352
|
+
#else
|
353
|
+
0x00
|
354
|
+
#endif
|
355
|
+
};
|
356
|
+
static const DES_cblock kDESKey1 = {"BCMDESK1"};
|
357
|
+
static const DES_cblock kDESKey2 = {"BCMDESK2"};
|
358
|
+
static const DES_cblock kDESKey3 = {"BCMDESK3"};
|
359
|
+
static const DES_cblock kDESIV = {"BCMDESIV"};
|
360
|
+
static const uint8_t kDESCiphertext[64] = {
|
361
|
+
0xa4, 0x30, 0x7a, 0x4c, 0x1f, 0x60, 0x16, 0xd7, 0x4f, 0x41, 0xe1,
|
362
|
+
0xbb, 0x27, 0xc4, 0x27, 0x37, 0xd4, 0x7f, 0xb9, 0x10, 0xf8, 0xbc,
|
363
|
+
0xaf, 0x93, 0x91, 0xb8, 0x88, 0x24, 0xb1, 0xf6, 0xf8, 0xbd, 0x31,
|
364
|
+
0x96, 0x06, 0x76, 0xde, 0x32, 0xcd, 0x29, 0x29, 0xba, 0x70, 0x5f,
|
365
|
+
0xea, 0xc0, 0xcb, 0xde, 0xc7, 0x75, 0x90, 0xe0, 0x0f, 0x5e, 0x2c,
|
366
|
+
0x0d, 0x49, 0x20, 0xd5, 0x30, 0x83, 0xf8, 0x08,
|
367
|
+
#if !defined(BORINGSSL_FIPS_BREAK_DES)
|
368
|
+
0x5a
|
369
|
+
#else
|
370
|
+
0x00
|
371
|
+
#endif
|
372
|
+
};
|
373
|
+
static const uint8_t kPlaintextSHA1[20] = {
|
374
|
+
0xc6, 0xf8, 0xc9, 0x63, 0x1c, 0x14, 0x23, 0x62, 0x9b, 0xbd,
|
375
|
+
0x55, 0x82, 0xf4, 0xd6, 0x1d, 0xf2, 0xab, 0x7d, 0xc8,
|
376
|
+
#if !defined(BORINGSSL_FIPS_BREAK_SHA_1)
|
377
|
+
0x28
|
378
|
+
#else
|
379
|
+
0x00
|
380
|
+
#endif
|
381
|
+
};
|
382
|
+
static const uint8_t kPlaintextSHA256[32] = {
|
383
|
+
0x37, 0xbd, 0x70, 0x53, 0x72, 0xfc, 0xd4, 0x03, 0x79, 0x70, 0xfb,
|
384
|
+
0x06, 0x95, 0xb1, 0x2a, 0x82, 0x48, 0xe1, 0x3e, 0xf2, 0x33, 0xfb,
|
385
|
+
0xef, 0x29, 0x81, 0x22, 0x45, 0x40, 0x43, 0x70, 0xce,
|
386
|
+
#if !defined(BORINGSSL_FIPS_BREAK_SHA_256)
|
387
|
+
0x0f
|
388
|
+
#else
|
389
|
+
0x00
|
390
|
+
#endif
|
391
|
+
};
|
392
|
+
static const uint8_t kPlaintextSHA512[64] = {
|
393
|
+
0x08, 0x6a, 0x1c, 0x84, 0x61, 0x9d, 0x8e, 0xb3, 0xc0, 0x97, 0x4e,
|
394
|
+
0xa1, 0x9f, 0x9c, 0xdc, 0xaf, 0x3b, 0x5c, 0x31, 0xf0, 0xf2, 0x74,
|
395
|
+
0xc3, 0xbd, 0x6e, 0xd6, 0x1e, 0xb2, 0xbb, 0x34, 0x74, 0x72, 0x5c,
|
396
|
+
0x51, 0x29, 0x8b, 0x87, 0x3a, 0xa3, 0xf2, 0x25, 0x23, 0xd4, 0x1c,
|
397
|
+
0x82, 0x1b, 0xfe, 0xd3, 0xc6, 0xee, 0xb5, 0xd6, 0xaf, 0x07, 0x7b,
|
398
|
+
0x98, 0xca, 0xa7, 0x01, 0xf3, 0x94, 0xf3, 0x68,
|
399
|
+
#if !defined(BORINGSSL_FIPS_BREAK_SHA_512)
|
400
|
+
0x14
|
401
|
+
#else
|
402
|
+
0x00
|
403
|
+
#endif
|
404
|
+
};
|
405
|
+
static const uint8_t kRSASignature[256] = {
|
406
|
+
0x62, 0x66, 0x4b, 0xe3, 0xb1, 0xd2, 0x83, 0xf1, 0xa8, 0x56, 0x2b, 0x33,
|
407
|
+
0x60, 0x1e, 0xdb, 0x1e, 0x06, 0xf7, 0xa7, 0x1e, 0xa8, 0xef, 0x03, 0x4d,
|
408
|
+
0x0c, 0xf6, 0x83, 0x75, 0x7a, 0xf0, 0x14, 0xc7, 0xe2, 0x94, 0x3a, 0xb5,
|
409
|
+
0x67, 0x56, 0xa5, 0x48, 0x7f, 0x3a, 0xa5, 0xbf, 0xf7, 0x1d, 0x44, 0xa6,
|
410
|
+
0x34, 0xed, 0x9b, 0xd6, 0x51, 0xaa, 0x2c, 0x4e, 0xce, 0x60, 0x5f, 0xe9,
|
411
|
+
0x0e, 0xd5, 0xcd, 0xeb, 0x23, 0x27, 0xf8, 0xfb, 0x45, 0xe5, 0x34, 0x63,
|
412
|
+
0x77, 0x7f, 0x2e, 0x80, 0xcf, 0x9d, 0x2e, 0xfc, 0xe2, 0x50, 0x75, 0x29,
|
413
|
+
0x46, 0xf4, 0xaf, 0x91, 0xed, 0x36, 0xe1, 0x5e, 0xef, 0x66, 0xa1, 0xff,
|
414
|
+
0x27, 0xfc, 0x87, 0x7e, 0x60, 0x84, 0x0f, 0x54, 0x51, 0x56, 0x0f, 0x68,
|
415
|
+
0x99, 0xc0, 0x3f, 0xeb, 0xa5, 0xa0, 0x46, 0xb0, 0x86, 0x02, 0xb0, 0xc8,
|
416
|
+
0xe8, 0x46, 0x13, 0x06, 0xcd, 0xb7, 0x8a, 0xd0, 0x3b, 0x46, 0xd0, 0x14,
|
417
|
+
0x64, 0x53, 0x9b, 0x5b, 0x5e, 0x02, 0x45, 0xba, 0x6e, 0x7e, 0x0a, 0xb9,
|
418
|
+
0x9e, 0x62, 0xb7, 0xd5, 0x7a, 0x87, 0xea, 0xd3, 0x24, 0xa5, 0xef, 0xb3,
|
419
|
+
0xdc, 0x05, 0x9c, 0x04, 0x60, 0x4b, 0xde, 0xa8, 0x90, 0x08, 0x7b, 0x6a,
|
420
|
+
0x5f, 0xb4, 0x3f, 0xda, 0xc5, 0x1f, 0x6e, 0xd6, 0x15, 0xde, 0x65, 0xa4,
|
421
|
+
0x6e, 0x62, 0x9d, 0x8f, 0xa8, 0xbe, 0x86, 0xf6, 0x09, 0x90, 0x40, 0xa5,
|
422
|
+
0xf4, 0x23, 0xc5, 0xf6, 0x38, 0x86, 0x0d, 0x1c, 0xed, 0x4a, 0x0a, 0xae,
|
423
|
+
0xa4, 0x26, 0xc2, 0x2e, 0xd3, 0x13, 0x66, 0x61, 0xea, 0x35, 0x01, 0x0e,
|
424
|
+
0x13, 0xda, 0x78, 0x20, 0xae, 0x59, 0x5f, 0x9b, 0xa9, 0x6c, 0xf9, 0x1b,
|
425
|
+
0xdf, 0x76, 0x53, 0xc8, 0xa7, 0xf5, 0x63, 0x6d, 0xf3, 0xff, 0xfd, 0xaf,
|
426
|
+
0x75, 0x4b, 0xac, 0x67, 0xb1, 0x3c, 0xbf, 0x5e, 0xde, 0x73, 0x02, 0x6d,
|
427
|
+
0xd2, 0x0c, 0xb1,
|
428
|
+
#if !defined(BORINGSSL_FIPS_BREAK_RSA_SIG)
|
429
|
+
0x64
|
430
|
+
#else
|
431
|
+
0x00
|
432
|
+
#endif
|
433
|
+
};
|
434
|
+
const uint8_t kDRBGEntropy[48] =
|
435
|
+
"BCM Known Answer Test DBRG Initial Entropy ";
|
436
|
+
const uint8_t kDRBGPersonalization[18] = "BCMPersonalization";
|
437
|
+
const uint8_t kDRBGAD[16] = "BCM DRBG KAT AD ";
|
438
|
+
const uint8_t kDRBGOutput[64] = {
|
439
|
+
0x1d, 0x63, 0xdf, 0x05, 0x51, 0x49, 0x22, 0x46, 0xcd, 0x9b, 0xc5,
|
440
|
+
0xbb, 0xf1, 0x5d, 0x44, 0xae, 0x13, 0x78, 0xb1, 0xe4, 0x7c, 0xf1,
|
441
|
+
0x96, 0x33, 0x3d, 0x60, 0xb6, 0x29, 0xd4, 0xbb, 0x6b, 0x44, 0xf9,
|
442
|
+
0xef, 0xd9, 0xf4, 0xa2, 0xba, 0x48, 0xea, 0x39, 0x75, 0x59, 0x32,
|
443
|
+
0xf7, 0x31, 0x2c, 0x98, 0x14, 0x2b, 0x49, 0xdf, 0x02, 0xb6, 0x5d,
|
444
|
+
0x71, 0x09, 0x50, 0xdb, 0x23, 0xdb, 0xe5, 0x22,
|
445
|
+
#if !defined(BORINGSSL_FIPS_BREAK_DRBG)
|
446
|
+
0x95
|
447
|
+
#else
|
448
|
+
0x00
|
449
|
+
#endif
|
450
|
+
};
|
451
|
+
const uint8_t kDRBGEntropy2[48] =
|
452
|
+
"BCM Known Answer Test DBRG Reseed Entropy ";
|
453
|
+
const uint8_t kDRBGReseedOutput[64] = {
|
454
|
+
0xa4, 0x77, 0x05, 0xdb, 0x14, 0x11, 0x76, 0x71, 0x42, 0x5b, 0xd8,
|
455
|
+
0xd7, 0xa5, 0x4f, 0x8b, 0x39, 0xf2, 0x10, 0x4a, 0x50, 0x5b, 0xa2,
|
456
|
+
0xc8, 0xf0, 0xbb, 0x3e, 0xa1, 0xa5, 0x90, 0x7d, 0x54, 0xd9, 0xc6,
|
457
|
+
0xb0, 0x96, 0xc0, 0x2b, 0x7e, 0x9b, 0xc9, 0xa1, 0xdd, 0x78, 0x2e,
|
458
|
+
0xd5, 0xa8, 0x66, 0x16, 0xbd, 0x18, 0x3c, 0xf2, 0xaa, 0x7a, 0x2b,
|
459
|
+
0x37, 0xf9, 0xab, 0x35, 0x64, 0x15, 0x01, 0x3f, 0xc4,
|
460
|
+
};
|
461
|
+
const uint8_t kECDSASigR[32] = {
|
462
|
+
0x67, 0x80, 0xc5, 0xfc, 0x70, 0x27, 0x5e, 0x2c, 0x70, 0x61, 0xa0,
|
463
|
+
0xe7, 0x87, 0x7b, 0xb1, 0x74, 0xde, 0xad, 0xeb, 0x98, 0x87, 0x02,
|
464
|
+
0x7f, 0x3f, 0xa8, 0x36, 0x54, 0x15, 0x8b, 0xa7, 0xf5,
|
465
|
+
#if !defined(BORINGSSL_FIPS_BREAK_ECDSA_SIG)
|
466
|
+
0x0c,
|
467
|
+
#else
|
468
|
+
0x00,
|
469
|
+
#endif
|
470
|
+
};
|
471
|
+
const uint8_t kECDSASigS[32] = {
|
472
|
+
0xa5, 0x93, 0xe0, 0x23, 0x91, 0xe7, 0x4b, 0x8d, 0x77, 0x25, 0xa6,
|
473
|
+
0xba, 0x4d, 0xd9, 0x86, 0x77, 0xda, 0x7d, 0x8f, 0xef, 0xc4, 0x1a,
|
474
|
+
0xf0, 0xcc, 0x81, 0xe5, 0xea, 0x3f, 0xc2, 0x41, 0x7f, 0xd8,
|
475
|
+
};
|
476
|
+
|
477
|
+
AES_KEY aes_key;
|
478
|
+
uint8_t aes_iv[16];
|
479
|
+
uint8_t output[256];
|
480
|
+
|
481
|
+
// AES-CBC Encryption KAT
|
482
|
+
memcpy(aes_iv, kAESIV, sizeof(kAESIV));
|
483
|
+
if (AES_set_encrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) != 0) {
|
484
|
+
goto err;
|
485
|
+
}
|
486
|
+
AES_cbc_encrypt(kPlaintext, output, sizeof(kPlaintext), &aes_key, aes_iv,
|
487
|
+
AES_ENCRYPT);
|
488
|
+
if (!check_test(kAESCBCCiphertext, output, sizeof(kAESCBCCiphertext),
|
489
|
+
"AES-CBC Encryption KAT")) {
|
490
|
+
goto err;
|
491
|
+
}
|
492
|
+
|
493
|
+
// AES-CBC Decryption KAT
|
494
|
+
memcpy(aes_iv, kAESIV, sizeof(kAESIV));
|
495
|
+
if (AES_set_decrypt_key(kAESKey, 8 * sizeof(kAESKey), &aes_key) != 0) {
|
496
|
+
goto err;
|
497
|
+
}
|
498
|
+
AES_cbc_encrypt(kAESCBCCiphertext, output, sizeof(kAESCBCCiphertext),
|
499
|
+
&aes_key, aes_iv, AES_DECRYPT);
|
500
|
+
if (!check_test(kPlaintext, output, sizeof(kPlaintext),
|
501
|
+
"AES-CBC Decryption KAT")) {
|
502
|
+
goto err;
|
503
|
+
}
|
504
|
+
|
505
|
+
size_t out_len;
|
506
|
+
uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH];
|
507
|
+
OPENSSL_memset(nonce, 0, sizeof(nonce));
|
508
|
+
EVP_AEAD_CTX aead_ctx;
|
509
|
+
if (!EVP_AEAD_CTX_init(&aead_ctx, EVP_aead_aes_128_gcm(), kAESKey,
|
510
|
+
sizeof(kAESKey), 0, NULL)) {
|
511
|
+
goto err;
|
512
|
+
}
|
513
|
+
|
514
|
+
// AES-GCM Encryption KAT
|
515
|
+
if (!EVP_AEAD_CTX_seal(&aead_ctx, output, &out_len, sizeof(output), nonce,
|
516
|
+
EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm()),
|
517
|
+
kPlaintext, sizeof(kPlaintext), NULL, 0) ||
|
518
|
+
!check_test(kAESGCMCiphertext, output, sizeof(kAESGCMCiphertext),
|
519
|
+
"AES-GCM Encryption KAT")) {
|
520
|
+
goto err;
|
521
|
+
}
|
522
|
+
|
523
|
+
// AES-GCM Decryption KAT
|
524
|
+
if (!EVP_AEAD_CTX_open(&aead_ctx, output, &out_len, sizeof(output), nonce,
|
525
|
+
EVP_AEAD_nonce_length(EVP_aead_aes_128_gcm()),
|
526
|
+
kAESGCMCiphertext, sizeof(kAESGCMCiphertext), NULL,
|
527
|
+
0) ||
|
528
|
+
!check_test(kPlaintext, output, sizeof(kPlaintext),
|
529
|
+
"AES-GCM Decryption KAT")) {
|
530
|
+
goto err;
|
531
|
+
}
|
532
|
+
|
533
|
+
EVP_AEAD_CTX_cleanup(&aead_ctx);
|
534
|
+
|
535
|
+
DES_key_schedule des1, des2, des3;
|
536
|
+
DES_cblock des_iv;
|
537
|
+
DES_set_key(&kDESKey1, &des1);
|
538
|
+
DES_set_key(&kDESKey2, &des2);
|
539
|
+
DES_set_key(&kDESKey3, &des3);
|
540
|
+
|
541
|
+
// 3DES Encryption KAT
|
542
|
+
memcpy(&des_iv, &kDESIV, sizeof(des_iv));
|
543
|
+
DES_ede3_cbc_encrypt(kPlaintext, output, sizeof(kPlaintext), &des1, &des2,
|
544
|
+
&des3, &des_iv, DES_ENCRYPT);
|
545
|
+
if (!check_test(kDESCiphertext, output, sizeof(kDESCiphertext),
|
546
|
+
"3DES Encryption KAT")) {
|
547
|
+
goto err;
|
548
|
+
}
|
549
|
+
|
550
|
+
// 3DES Decryption KAT
|
551
|
+
memcpy(&des_iv, &kDESIV, sizeof(des_iv));
|
552
|
+
DES_ede3_cbc_encrypt(kDESCiphertext, output, sizeof(kDESCiphertext), &des1,
|
553
|
+
&des2, &des3, &des_iv, DES_DECRYPT);
|
554
|
+
if (!check_test(kPlaintext, output, sizeof(kPlaintext),
|
555
|
+
"3DES Decryption KAT")) {
|
556
|
+
goto err;
|
557
|
+
}
|
558
|
+
|
559
|
+
// SHA-1 KAT
|
560
|
+
SHA1(kPlaintext, sizeof(kPlaintext), output);
|
561
|
+
if (!check_test(kPlaintextSHA1, output, sizeof(kPlaintextSHA1),
|
562
|
+
"SHA-1 KAT")) {
|
563
|
+
goto err;
|
564
|
+
}
|
565
|
+
|
566
|
+
// SHA-256 KAT
|
567
|
+
SHA256(kPlaintext, sizeof(kPlaintext), output);
|
568
|
+
if (!check_test(kPlaintextSHA256, output, sizeof(kPlaintextSHA256),
|
569
|
+
"SHA-256 KAT")) {
|
570
|
+
goto err;
|
571
|
+
}
|
572
|
+
|
573
|
+
// SHA-512 KAT
|
574
|
+
SHA512(kPlaintext, sizeof(kPlaintext), output);
|
575
|
+
if (!check_test(kPlaintextSHA512, output, sizeof(kPlaintextSHA512),
|
576
|
+
"SHA-512 KAT")) {
|
577
|
+
goto err;
|
578
|
+
}
|
579
|
+
|
580
|
+
RSA *rsa_key = self_test_rsa_key();
|
581
|
+
if (rsa_key == NULL) {
|
582
|
+
printf("RSA KeyGen failed\n");
|
583
|
+
goto err;
|
584
|
+
}
|
585
|
+
|
586
|
+
// RSA Sign KAT
|
587
|
+
unsigned sig_len;
|
588
|
+
|
589
|
+
// Disable blinding for the power-on tests because it's not needed and
|
590
|
+
// triggers an entropy draw.
|
591
|
+
rsa_key->flags |= RSA_FLAG_NO_BLINDING;
|
592
|
+
|
593
|
+
if (!RSA_sign(NID_sha256, kPlaintextSHA256, sizeof(kPlaintextSHA256), output,
|
594
|
+
&sig_len, rsa_key) ||
|
595
|
+
!check_test(kRSASignature, output, sizeof(kRSASignature),
|
596
|
+
"RSA Sign KAT")) {
|
597
|
+
goto err;
|
598
|
+
}
|
599
|
+
|
600
|
+
// RSA Verify KAT
|
601
|
+
if (!RSA_verify(NID_sha256, kPlaintextSHA256, sizeof(kPlaintextSHA256),
|
602
|
+
kRSASignature, sizeof(kRSASignature), rsa_key)) {
|
603
|
+
printf("RSA Verify KAT failed.\n");
|
604
|
+
goto err;
|
605
|
+
}
|
606
|
+
|
607
|
+
RSA_free(rsa_key);
|
608
|
+
|
609
|
+
EC_KEY *ec_key = self_test_ecdsa_key();
|
610
|
+
if (ec_key == NULL) {
|
611
|
+
printf("ECDSA KeyGen failed\n");
|
612
|
+
goto err;
|
613
|
+
}
|
614
|
+
|
615
|
+
// ECDSA Sign/Verify PWCT
|
616
|
+
|
617
|
+
// The 'k' value for ECDSA is fixed to avoid an entropy draw.
|
618
|
+
ec_key->fixed_k = BN_new();
|
619
|
+
if (ec_key->fixed_k == NULL ||
|
620
|
+
!BN_set_word(ec_key->fixed_k, 42)) {
|
621
|
+
printf("Out of memory\n");
|
622
|
+
goto err;
|
623
|
+
}
|
624
|
+
|
625
|
+
ECDSA_SIG *sig =
|
626
|
+
ECDSA_do_sign(kPlaintextSHA256, sizeof(kPlaintextSHA256), ec_key);
|
627
|
+
|
628
|
+
uint8_t ecdsa_r_bytes[sizeof(kECDSASigR)];
|
629
|
+
uint8_t ecdsa_s_bytes[sizeof(kECDSASigS)];
|
630
|
+
if (sig == NULL ||
|
631
|
+
BN_num_bytes(sig->r) != sizeof(ecdsa_r_bytes) ||
|
632
|
+
!BN_bn2bin(sig->r, ecdsa_r_bytes) ||
|
633
|
+
BN_num_bytes(sig->s) != sizeof(ecdsa_s_bytes) ||
|
634
|
+
!BN_bn2bin(sig->s, ecdsa_s_bytes) ||
|
635
|
+
!check_test(kECDSASigR, ecdsa_r_bytes, sizeof(kECDSASigR), "ECDSA R") ||
|
636
|
+
!check_test(kECDSASigS, ecdsa_s_bytes, sizeof(kECDSASigS), "ECDSA S")) {
|
637
|
+
printf("ECDSA KAT failed.\n");
|
638
|
+
goto err;
|
639
|
+
}
|
640
|
+
|
641
|
+
ECDSA_SIG_free(sig);
|
642
|
+
EC_KEY_free(ec_key);
|
643
|
+
|
644
|
+
// DBRG KAT
|
645
|
+
CTR_DRBG_STATE drbg;
|
646
|
+
if (!CTR_DRBG_init(&drbg, kDRBGEntropy, kDRBGPersonalization,
|
647
|
+
sizeof(kDRBGPersonalization)) ||
|
648
|
+
!CTR_DRBG_generate(&drbg, output, sizeof(kDRBGOutput), kDRBGAD,
|
649
|
+
sizeof(kDRBGAD)) ||
|
650
|
+
!check_test(kDRBGOutput, output, sizeof(kDRBGOutput),
|
651
|
+
"DBRG Generate KAT") ||
|
652
|
+
!CTR_DRBG_reseed(&drbg, kDRBGEntropy2, kDRBGAD, sizeof(kDRBGAD)) ||
|
653
|
+
!CTR_DRBG_generate(&drbg, output, sizeof(kDRBGReseedOutput), kDRBGAD,
|
654
|
+
sizeof(kDRBGAD)) ||
|
655
|
+
!check_test(kDRBGReseedOutput, output, sizeof(kDRBGReseedOutput),
|
656
|
+
"DRBG Reseed KAT")) {
|
657
|
+
goto err;
|
658
|
+
}
|
659
|
+
CTR_DRBG_clear(&drbg);
|
660
|
+
|
661
|
+
CTR_DRBG_STATE kZeroDRBG;
|
662
|
+
memset(&kZeroDRBG, 0, sizeof(kZeroDRBG));
|
663
|
+
if (!check_test(&kZeroDRBG, &drbg, sizeof(drbg), "DRBG Clear KAT")) {
|
664
|
+
goto err;
|
665
|
+
}
|
666
|
+
|
667
|
+
return;
|
668
|
+
|
669
|
+
err:
|
670
|
+
BORINGSSL_FIPS_abort();
|
671
|
+
}
|
672
|
+
|
673
|
+
void BORINGSSL_FIPS_abort(void) {
|
674
|
+
for (;;) {
|
675
|
+
abort();
|
676
|
+
exit(1);
|
677
|
+
}
|
678
|
+
}
|
679
|
+
#endif // BORINGSSL_FIPS
|