grpc 0.13.1 → 0.14.1.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 +2098 -828
- data/include/grpc/byte_buffer.h +1 -1
- data/include/grpc/byte_buffer_reader.h +1 -20
- data/include/grpc/census.h +4 -4
- data/include/grpc/compression.h +6 -5
- data/include/grpc/grpc.h +31 -20
- data/include/grpc/grpc_security.h +17 -31
- data/include/grpc/grpc_security_constants.h +114 -0
- data/include/grpc/grpc_zookeeper.h +1 -1
- data/include/grpc/impl/codegen/alloc.h +1 -1
- data/include/grpc/impl/codegen/atm.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_sync.h +1 -1
- data/include/grpc/impl/codegen/atm_win32.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +1 -1
- data/{src/core/client_config/lb_policies/round_robin.h → include/grpc/impl/codegen/byte_buffer_reader.h} +19 -8
- data/include/grpc/impl/codegen/grpc_types.h +20 -3
- data/include/grpc/impl/codegen/log.h +9 -2
- data/include/grpc/impl/codegen/port_platform.h +102 -17
- data/include/grpc/impl/codegen/propagation_bits.h +3 -3
- data/include/grpc/impl/codegen/slice.h +3 -3
- data/include/grpc/impl/codegen/slice_buffer.h +3 -3
- data/include/grpc/impl/codegen/status.h +1 -1
- data/include/grpc/impl/codegen/sync_generic.h +1 -1
- data/include/grpc/impl/codegen/sync_posix.h +1 -1
- data/include/grpc/impl/codegen/sync_win32.h +1 -1
- data/include/grpc/impl/codegen/time.h +3 -3
- data/include/grpc/status.h +1 -1
- data/include/grpc/support/alloc.h +1 -1
- data/include/grpc/support/atm.h +1 -1
- data/include/grpc/support/atm_gcc_atomic.h +4 -4
- data/include/grpc/support/atm_gcc_sync.h +1 -1
- data/include/grpc/support/atm_win32.h +1 -1
- data/include/grpc/support/avl.h +1 -1
- data/include/grpc/support/cmdline.h +1 -1
- data/include/grpc/support/cpu.h +1 -1
- data/include/grpc/support/histogram.h +1 -1
- data/include/grpc/support/host_port.h +1 -1
- data/include/grpc/support/log.h +1 -1
- data/include/grpc/support/log_win32.h +1 -1
- data/include/grpc/support/port_platform.h +1 -1
- data/include/grpc/support/slice.h +1 -1
- data/include/grpc/support/slice_buffer.h +1 -1
- data/include/grpc/support/string_util.h +3 -1
- data/include/grpc/support/subprocess.h +2 -2
- data/include/grpc/support/sync.h +1 -1
- data/include/grpc/support/sync_generic.h +1 -1
- data/include/grpc/support/sync_posix.h +1 -1
- data/include/grpc/support/sync_win32.h +1 -1
- data/include/grpc/support/thd.h +1 -1
- data/include/grpc/support/time.h +1 -1
- data/include/grpc/support/tls.h +1 -1
- data/include/grpc/support/tls_gcc.h +45 -1
- data/include/grpc/support/tls_msvc.h +3 -3
- data/include/grpc/support/tls_pthread.h +1 -1
- data/include/grpc/support/useful.h +1 -1
- data/src/boringssl/err_data.c +258 -252
- data/src/core/{census → ext/census}/aggregation.h +3 -3
- data/src/core/{statistics → ext/census}/census_interface.h +3 -3
- data/src/core/{statistics → ext/census}/census_rpc_stats.h +4 -4
- data/src/core/{census → ext/census}/context.c +2 -2
- data/src/core/{census → ext/census}/grpc_context.c +2 -2
- data/src/core/{census → ext/census}/grpc_filter.c +30 -16
- data/src/core/{census → ext/census}/grpc_filter.h +4 -4
- data/src/core/ext/census/grpc_plugin.c +82 -0
- data/src/core/{census → ext/census}/initialize.c +1 -1
- data/src/core/{census → ext/census}/mlog.c +2 -2
- data/src/core/{census → ext/census}/mlog.h +4 -4
- data/src/core/{census → ext/census}/operation.c +0 -0
- data/src/core/{census → ext/census}/placeholders.c +0 -0
- data/src/core/{census → ext/census}/rpc_metric_id.h +3 -3
- data/src/core/{census → ext/census}/tracing.c +0 -0
- data/src/core/{surface → ext/client_config}/channel_connectivity.c +8 -21
- data/src/core/{channel → ext/client_config}/client_channel.c +80 -35
- data/src/core/{channel → ext/client_config}/client_channel.h +5 -5
- data/src/core/{client_config/subchannel_factory.c → ext/client_config/client_channel_factory.c} +14 -6
- data/src/core/ext/client_config/client_channel_factory.h +85 -0
- data/src/core/{client_config → ext/client_config}/client_config.c +4 -2
- data/src/core/{client_config → ext/client_config}/client_config.h +4 -4
- data/src/core/ext/client_config/client_config_plugin.c +95 -0
- data/src/core/{client_config → ext/client_config}/connector.c +2 -2
- data/src/core/{client_config → ext/client_config}/connector.h +7 -10
- data/src/core/{client_config → ext/client_config}/default_initial_connect_string.c +1 -1
- data/src/core/{client_config → ext/client_config}/initial_connect_string.c +1 -1
- data/src/core/{client_config → ext/client_config}/initial_connect_string.h +4 -4
- data/src/core/{client_config → ext/client_config}/lb_policy.c +12 -3
- data/src/core/{client_config → ext/client_config}/lb_policy.h +19 -6
- data/src/core/{client_config → ext/client_config}/lb_policy_factory.c +4 -3
- data/src/core/{client_config → ext/client_config}/lb_policy_factory.h +14 -9
- data/src/core/{client_config → ext/client_config}/lb_policy_registry.c +4 -9
- data/src/core/{client_config → ext/client_config}/lb_policy_registry.h +7 -6
- data/src/core/ext/client_config/parse_address.c +137 -0
- data/src/core/ext/client_config/parse_address.h +56 -0
- data/src/core/{client_config → ext/client_config}/resolver.c +1 -1
- data/src/core/{client_config → ext/client_config}/resolver.h +6 -6
- data/src/core/{client_config → ext/client_config}/resolver_factory.c +1 -1
- data/src/core/{client_config → ext/client_config}/resolver_factory.h +7 -7
- data/src/core/{client_config → ext/client_config}/resolver_registry.c +25 -11
- data/src/core/{client_config → ext/client_config}/resolver_registry.h +9 -5
- data/src/core/{client_config → ext/client_config}/subchannel.c +90 -126
- data/src/core/{client_config → ext/client_config}/subchannel.h +15 -15
- data/src/core/{channel → ext/client_config}/subchannel_call_holder.c +9 -8
- data/src/core/{channel → ext/client_config}/subchannel_call_holder.h +7 -7
- data/src/core/{client_config → ext/client_config}/subchannel_index.c +3 -2
- data/src/core/{client_config → ext/client_config}/subchannel_index.h +5 -5
- data/src/core/{client_config → ext/client_config}/uri_parser.c +69 -1
- data/src/core/{client_config → ext/client_config}/uri_parser.h +15 -3
- data/src/core/{client_config/lb_policies → ext/lb_policy/grpclb}/load_balancer_api.c +18 -9
- data/src/core/{client_config/lb_policies → ext/lb_policy/grpclb}/load_balancer_api.h +5 -5
- data/src/core/{proto → ext/lb_policy/grpclb/proto}/grpc/lb/v0/load_balancer.pb.c +1 -1
- data/src/core/{proto → ext/lb_policy/grpclb/proto}/grpc/lb/v0/load_balancer.pb.h +0 -0
- data/src/core/{client_config/lb_policies → ext/lb_policy/pick_first}/pick_first.c +95 -32
- data/src/core/{client_config/lb_policies → ext/lb_policy/round_robin}/round_robin.c +98 -34
- data/src/core/{client_config/resolvers → ext/resolver/dns/native}/dns_resolver.c +83 -39
- data/src/core/{client_config/resolvers → ext/resolver/sockaddr}/sockaddr_resolver.c +66 -169
- data/src/core/{transport/chttp2 → ext/transport/chttp2/alpn}/alpn.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/alpn}/alpn.h +3 -3
- data/src/core/{surface → ext/transport/chttp2/client/insecure}/channel_create.c +65 -59
- data/src/core/{surface → ext/transport/chttp2/client/secure}/secure_channel_create.c +77 -69
- data/src/core/{surface → ext/transport/chttp2/server/insecure}/server_chttp2.c +8 -11
- data/src/core/{security → ext/transport/chttp2/server/secure}/server_secure_chttp2.c +14 -17
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/bin_encoder.c +28 -74
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/bin_encoder.h +5 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +46 -0
- data/src/core/{transport → ext/transport/chttp2/transport}/chttp2_transport.c +551 -310
- data/src/core/{transport → ext/transport/chttp2/transport}/chttp2_transport.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_data.c +30 -14
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_data.h +10 -7
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_goaway.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_goaway.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_ping.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_ping.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_rst_stream.c +9 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_rst_stream.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_settings.c +6 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_settings.h +5 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_window_update.c +11 -5
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/frame_window_update.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_encoder.c +21 -12
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_encoder.h +8 -6
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_parser.c +42 -25
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_parser.h +7 -7
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_table.c +21 -11
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/hpack_table.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/http2_errors.h +3 -3
- data/src/core/ext/transport/chttp2/transport/huffsyms.c +105 -0
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/huffsyms.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/incoming_metadata.c +2 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/incoming_metadata.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/internal.h +81 -37
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/parsing.c +54 -21
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/status_conversion.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/status_conversion.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_lists.c +10 -2
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_map.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/stream_map.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/timeout_encoding.c +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/timeout_encoding.h +4 -4
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/varint.c +1 -1
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/varint.h +3 -3
- data/src/core/{transport/chttp2 → ext/transport/chttp2/transport}/writing.c +30 -20
- data/src/core/{channel → lib/channel}/channel_args.c +3 -15
- data/src/core/{channel → lib/channel}/channel_args.h +11 -15
- data/src/core/{channel → lib/channel}/channel_stack.c +5 -3
- data/src/core/{channel → lib/channel}/channel_stack.h +13 -8
- data/src/core/lib/channel/channel_stack_builder.c +277 -0
- data/src/core/lib/channel/channel_stack_builder.h +161 -0
- data/src/core/{channel → lib/channel}/compress_filter.c +51 -16
- data/src/core/{channel → lib/channel}/compress_filter.h +6 -4
- data/src/core/{channel → lib/channel}/connected_channel.c +34 -24
- data/src/core/lib/channel/connected_channel.h +42 -0
- data/src/core/{channel → lib/channel}/context.h +3 -3
- data/src/core/{channel → lib/channel}/http_client_filter.c +24 -13
- data/src/core/{channel → lib/channel}/http_client_filter.h +4 -4
- data/src/core/{channel → lib/channel}/http_server_filter.c +39 -19
- data/src/core/{channel → lib/channel}/http_server_filter.h +4 -4
- data/src/core/{compression → lib/compression}/algorithm_metadata.h +4 -4
- data/src/core/{compression → lib/compression}/compression_algorithm.c +46 -9
- data/src/core/{compression → lib/compression}/message_compress.c +1 -1
- data/src/core/{compression → lib/compression}/message_compress.h +3 -3
- data/src/core/{debug → lib/debug}/trace.c +2 -2
- data/src/core/{debug → lib/debug}/trace.h +3 -3
- data/src/core/{httpcli → lib/http}/format_request.c +8 -8
- data/src/core/{httpcli → lib/http}/format_request.h +4 -4
- data/src/core/{httpcli → lib/http}/httpcli.c +24 -19
- data/src/core/{httpcli → lib/http}/httpcli.h +14 -33
- data/src/core/{httpcli → lib/http}/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +341 -0
- data/src/core/lib/http/parser.h +119 -0
- data/src/core/{iomgr → lib/iomgr}/closure.c +8 -2
- data/src/core/{iomgr → lib/iomgr}/closure.h +7 -4
- data/src/core/{iomgr → lib/iomgr}/endpoint.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/endpoint.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair_posix.c +8 -7
- data/src/core/{iomgr → lib/iomgr}/endpoint_pair_windows.c +4 -4
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +1936 -0
- data/src/core/lib/iomgr/ev_poll_and_epoll_posix.h +41 -0
- data/src/core/lib/iomgr/ev_posix.c +164 -0
- data/src/core/lib/iomgr/ev_posix.h +158 -0
- data/src/core/{iomgr → lib/iomgr}/exec_ctx.c +78 -3
- data/src/core/{iomgr → lib/iomgr}/exec_ctx.h +25 -10
- data/src/core/{iomgr → lib/iomgr}/executor.c +3 -3
- data/src/core/{iomgr → lib/iomgr}/executor.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/iocp_windows.c +6 -6
- data/src/core/{iomgr → lib/iomgr}/iocp_windows.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/iomgr.c +13 -10
- data/src/core/{iomgr → lib/iomgr}/iomgr.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/iomgr_internal.h +5 -9
- data/src/core/{iomgr → lib/iomgr}/iomgr_posix.c +6 -6
- data/src/core/{iomgr → lib/iomgr}/iomgr_posix.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/iomgr_windows.c +7 -4
- data/src/core/{iomgr → lib/iomgr}/pollset.h +11 -11
- data/src/core/{iomgr → lib/iomgr}/pollset_set.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/pollset_set_windows.c +2 -2
- data/src/core/lib/iomgr/pollset_set_windows.h +39 -0
- data/src/core/{iomgr → lib/iomgr}/pollset_windows.c +7 -7
- data/src/core/{iomgr → lib/iomgr}/pollset_windows.h +8 -5
- data/src/core/{iomgr → lib/iomgr}/resolve_address.h +10 -9
- data/src/core/{iomgr → lib/iomgr}/resolve_address_posix.c +22 -22
- data/src/core/{iomgr → lib/iomgr}/resolve_address_windows.c +20 -12
- data/src/core/{iomgr → lib/iomgr}/sockaddr.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/sockaddr_posix.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/sockaddr_utils.c +9 -16
- data/src/core/{iomgr → lib/iomgr}/sockaddr_utils.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/sockaddr_win32.h +6 -4
- data/src/core/{iomgr → lib/iomgr}/socket_utils_common_posix.c +29 -7
- data/src/core/{iomgr → lib/iomgr}/socket_utils_linux.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/socket_utils_posix.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/socket_utils_posix.h +14 -4
- data/src/core/{iomgr → lib/iomgr}/socket_windows.c +7 -5
- data/src/core/{iomgr → lib/iomgr}/socket_windows.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_client.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_client_posix.c +33 -18
- data/src/core/{iomgr → lib/iomgr}/tcp_client_windows.c +30 -20
- data/src/core/{iomgr → lib/iomgr}/tcp_posix.c +9 -10
- data/src/core/{iomgr → lib/iomgr}/tcp_posix.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_server.h +6 -6
- data/src/core/{iomgr → lib/iomgr}/tcp_server_posix.c +24 -37
- data/src/core/{iomgr → lib/iomgr}/tcp_server_windows.c +8 -36
- data/src/core/{iomgr → lib/iomgr}/tcp_windows.c +27 -17
- data/src/core/{iomgr → lib/iomgr}/tcp_windows.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/time_averaged_stats.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/time_averaged_stats.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/timer.c +31 -4
- data/src/core/{iomgr → lib/iomgr}/timer.h +6 -7
- data/src/core/{iomgr → lib/iomgr}/timer_heap.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/timer_heap.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/udp_server.c +13 -37
- data/src/core/{iomgr → lib/iomgr}/udp_server.h +11 -10
- data/src/core/lib/iomgr/unix_sockets_posix.c +89 -0
- data/src/core/{client_config/resolvers/sockaddr_resolver.h → lib/iomgr/unix_sockets_posix.h} +15 -11
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +59 -0
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_eventfd.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_nospecial.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_pipe.c +8 -3
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_pipe.h +4 -4
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_posix.c +2 -2
- data/src/core/{iomgr → lib/iomgr}/wakeup_fd_posix.h +3 -3
- data/src/core/{iomgr → lib/iomgr}/workqueue.h +10 -10
- data/src/core/{iomgr → lib/iomgr}/workqueue_posix.c +5 -6
- data/src/core/{iomgr → lib/iomgr}/workqueue_posix.h +5 -5
- data/src/core/{iomgr → lib/iomgr}/workqueue_windows.c +1 -1
- data/src/core/{iomgr → lib/iomgr}/workqueue_windows.h +3 -3
- data/src/core/{json → lib/json}/json.c +1 -1
- data/src/core/{json → lib/json}/json.h +4 -4
- data/src/core/{json → lib/json}/json_common.h +3 -3
- data/src/core/{json → lib/json}/json_reader.c +16 -4
- data/src/core/{json → lib/json}/json_reader.h +4 -4
- data/src/core/{json → lib/json}/json_string.c +4 -4
- data/src/core/{json → lib/json}/json_writer.c +1 -1
- data/src/core/{json → lib/json}/json_writer.h +4 -4
- data/src/core/{profiling → lib/profiling}/basic_timers.c +3 -2
- data/src/core/{profiling → lib/profiling}/stap_timers.c +2 -2
- data/src/core/{profiling → lib/profiling}/timers.h +3 -3
- data/src/core/{security → lib/security}/auth_filters.h +4 -4
- data/src/core/{security → lib/security}/b64.c +2 -2
- data/src/core/{security → lib/security}/b64.h +4 -4
- data/src/core/{security → lib/security}/client_auth_filter.c +16 -16
- data/src/core/{security → lib/security}/credentials.c +42 -26
- data/src/core/{security → lib/security}/credentials.h +11 -10
- data/src/core/{security → lib/security}/credentials_metadata.c +1 -1
- data/src/core/{security → lib/security}/credentials_posix.c +3 -3
- data/src/core/{security → lib/security}/credentials_win32.c +3 -3
- data/src/core/{security → lib/security}/google_default_credentials.c +10 -9
- data/src/core/{security → lib/security}/handshake.c +4 -4
- data/src/core/{security → lib/security}/handshake.h +6 -6
- data/src/core/{security → lib/security}/json_token.c +4 -4
- data/src/core/{security → lib/security}/json_token.h +4 -4
- data/src/core/{security → lib/security}/jwt_verifier.c +14 -14
- data/src/core/{security → lib/security}/jwt_verifier.h +5 -5
- data/src/core/{security → lib/security}/secure_endpoint.c +9 -8
- data/src/core/{security → lib/security}/secure_endpoint.h +4 -4
- data/src/core/{security → lib/security}/security_connector.c +53 -21
- data/src/core/{security → lib/security}/security_connector.h +8 -8
- data/src/core/{security → lib/security}/security_context.c +5 -5
- data/src/core/{security → lib/security}/security_context.h +5 -5
- data/src/core/{security → lib/security}/server_auth_filter.c +9 -9
- data/src/core/{support → lib/support}/alloc.c +5 -3
- data/src/core/{support → lib/support}/avl.c +1 -1
- data/src/core/lib/support/backoff.c +76 -0
- data/src/core/lib/support/backoff.h +68 -0
- data/src/core/{support → lib/support}/block_annotate.h +3 -3
- data/src/core/{support → lib/support}/cmdline.c +1 -1
- data/src/core/{support → lib/support}/cpu_iphone.c +0 -0
- data/src/core/{support → lib/support}/cpu_linux.c +2 -2
- data/src/core/{support → lib/support}/cpu_posix.c +2 -2
- data/src/core/{support → lib/support}/cpu_windows.c +0 -0
- data/src/core/{support → lib/support}/env.h +3 -3
- data/src/core/{support → lib/support}/env_linux.c +3 -3
- data/src/core/{support → lib/support}/env_posix.c +2 -2
- data/src/core/{support → lib/support}/env_win32.c +27 -21
- data/src/core/{support → lib/support}/histogram.c +1 -1
- data/src/core/{support → lib/support}/host_port.c +1 -1
- data/src/core/{support → lib/support}/load_file.c +4 -4
- data/src/core/{support → lib/support}/load_file.h +4 -4
- data/src/core/{support → lib/support}/log.c +33 -0
- data/src/core/{support → lib/support}/log_android.c +2 -2
- data/src/core/{support → lib/support}/log_linux.c +6 -5
- data/src/core/{support → lib/support}/log_posix.c +3 -3
- data/src/core/{support → lib/support}/log_win32.c +8 -22
- data/src/core/{support → lib/support}/murmur_hash.c +1 -1
- data/src/core/{support → lib/support}/murmur_hash.h +3 -3
- data/src/core/{support → lib/support}/slice.c +0 -0
- data/src/core/{support → lib/support}/slice_buffer.c +0 -0
- data/src/core/{support → lib/support}/stack_lockfree.c +7 -7
- data/src/core/{support → lib/support}/stack_lockfree.h +3 -3
- data/src/core/{support → lib/support}/string.c +1 -1
- data/src/core/{support → lib/support}/string.h +4 -4
- data/src/core/{support → lib/support}/string_posix.c +1 -1
- data/src/core/{support/string_win32.c → lib/support/string_util_win32.c} +23 -38
- data/src/core/lib/support/string_win32.c +83 -0
- data/src/core/{support → lib/support}/string_win32.h +3 -3
- data/src/core/{support → lib/support}/subprocess_posix.c +3 -3
- data/src/core/{support → lib/support}/subprocess_windows.c +3 -3
- data/src/core/{support → lib/support}/sync.c +2 -2
- data/src/core/{support → lib/support}/sync_posix.c +3 -3
- data/src/core/{support → lib/support}/sync_win32.c +1 -1
- data/src/core/{support → lib/support}/thd.c +0 -0
- data/src/core/{support → lib/support}/thd_internal.h +3 -3
- data/src/core/{support → lib/support}/thd_posix.c +4 -3
- data/src/core/{support → lib/support}/thd_win32.c +1 -1
- data/src/core/{support → lib/support}/time.c +2 -2
- data/src/core/{support → lib/support}/time_posix.c +12 -6
- data/src/core/{support → lib/support}/time_precise.c +0 -0
- data/src/core/{support → lib/support}/time_precise.h +3 -3
- data/src/core/{support → lib/support}/time_win32.c +7 -7
- data/src/core/{support → lib/support}/tls_pthread.c +0 -0
- data/src/core/{support → lib/support}/tmpfile.h +4 -4
- data/src/core/lib/support/tmpfile_msys.c +73 -0
- data/src/core/{support → lib/support}/tmpfile_posix.c +5 -5
- data/src/core/{support → lib/support}/tmpfile_win32.c +5 -5
- data/src/core/{support → lib/support}/wrap_memcpy.c +0 -0
- data/src/core/{surface → lib/surface}/alarm.c +3 -3
- data/src/core/{surface → lib/surface}/api_trace.c +1 -1
- data/src/core/{surface → lib/surface}/api_trace.h +4 -4
- data/src/core/{surface → lib/surface}/byte_buffer.c +3 -3
- data/src/core/{surface → lib/surface}/byte_buffer_reader.c +3 -3
- data/src/core/{surface → lib/surface}/call.c +145 -73
- data/src/core/{surface → lib/surface}/call.h +14 -7
- data/src/core/{surface → lib/surface}/call_details.c +1 -1
- data/src/core/{surface → lib/surface}/call_log_batch.c +2 -2
- data/src/core/{surface → lib/surface}/call_test_only.h +3 -3
- data/src/core/{surface → lib/surface}/channel.c +33 -34
- data/src/core/{surface → lib/surface}/channel.h +9 -9
- data/src/core/lib/surface/channel_init.c +140 -0
- data/src/core/lib/surface/channel_init.h +87 -0
- data/src/core/{surface → lib/surface}/channel_ping.c +4 -4
- data/src/core/lib/surface/channel_stack_type.c +54 -0
- data/src/core/{httpcli/parser.h → lib/surface/channel_stack_type.h} +22 -28
- data/src/core/{surface → lib/surface}/completion_queue.c +15 -11
- data/src/core/{surface → lib/surface}/completion_queue.h +4 -4
- data/src/core/{surface → lib/surface}/event_string.c +2 -2
- data/src/core/{surface → lib/surface}/event_string.h +3 -3
- data/src/core/lib/surface/init.c +217 -0
- data/src/core/{surface → lib/surface}/init.h +4 -3
- data/src/core/lib/surface/init_secure.c +89 -0
- data/src/core/{surface → lib/surface}/lame_client.c +31 -19
- data/src/core/{iomgr/pollset_set_windows.h → lib/surface/lame_client.h} +7 -5
- data/src/core/{surface → lib/surface}/metadata_array.c +1 -1
- data/src/core/{surface → lib/surface}/server.c +208 -183
- data/src/core/{surface → lib/surface}/server.h +6 -11
- data/src/core/{surface → lib/surface}/surface_trace.h +5 -5
- data/src/core/{surface → lib/surface}/validate_metadata.c +1 -1
- data/src/core/{surface → lib/surface}/version.c +2 -2
- data/src/core/{transport → lib/transport}/byte_stream.c +1 -1
- data/src/core/{transport → lib/transport}/byte_stream.h +4 -4
- data/src/core/{transport → lib/transport}/connectivity_state.c +2 -2
- data/src/core/{transport → lib/transport}/connectivity_state.h +4 -4
- data/src/core/{transport → lib/transport}/metadata.c +71 -19
- data/src/core/{transport → lib/transport}/metadata.h +11 -4
- data/src/core/{transport → lib/transport}/metadata_batch.c +2 -2
- data/src/core/{transport → lib/transport}/metadata_batch.h +4 -4
- data/src/core/{transport → lib/transport}/static_metadata.c +100 -32
- data/src/core/{transport → lib/transport}/static_metadata.h +58 -58
- data/src/core/{transport → lib/transport}/transport.c +25 -5
- data/src/core/{transport → lib/transport}/transport.h +41 -16
- data/src/core/{transport → lib/transport}/transport_impl.h +8 -5
- data/src/core/{transport → lib/transport}/transport_op_string.c +2 -2
- data/src/core/{tsi → lib/tsi}/fake_transport_security.c +18 -14
- data/src/core/{tsi → lib/tsi}/fake_transport_security.h +4 -4
- data/src/core/{tsi → lib/tsi}/ssl_transport_security.c +173 -63
- data/src/core/{tsi → lib/tsi}/ssl_transport_security.h +24 -6
- data/src/core/{tsi → lib/tsi}/ssl_types.h +3 -3
- data/src/core/{tsi → lib/tsi}/transport_security.c +12 -28
- data/src/core/{tsi → lib/tsi}/transport_security.h +4 -4
- data/src/core/{tsi → lib/tsi}/transport_security_interface.h +12 -3
- data/src/core/plugin_registry/grpc_plugin_registry.c +66 -0
- data/src/ruby/ext/grpc/extconf.rb +14 -20
- data/src/ruby/ext/grpc/rb_byte_buffer.c +2 -3
- data/src/ruby/ext/grpc/rb_call.c +37 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +13 -3
- data/src/ruby/ext/grpc/rb_channel.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_args.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_credentials.c +31 -3
- data/src/ruby/ext/grpc/rb_completion_queue.c +2 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +8 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +14 -2
- data/src/ruby/ext/grpc/rb_server.c +2 -3
- data/src/ruby/ext/grpc/rb_server_credentials.c +16 -13
- data/src/ruby/ext/grpc/rb_signal.c +70 -0
- data/src/ruby/ext/grpc/rb_signal.h +39 -0
- data/src/ruby/lib/grpc.rb +21 -13
- data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
- data/src/ruby/lib/grpc/errors.rb +2 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +10 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +2 -2
- data/src/ruby/lib/grpc/generic/client_stub.rb +10 -7
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +2 -2
- data/src/ruby/lib/grpc/generic/rpc_server.rb +21 -61
- data/src/ruby/lib/grpc/generic/service.rb +5 -15
- data/src/ruby/lib/grpc/grpc.rb +3 -3
- data/src/ruby/{bin/interop/interop_server.rb → lib/grpc/signals.rb} +39 -20
- data/src/ruby/lib/grpc/version.rb +2 -2
- data/src/ruby/pb/generate_proto_ruby.sh +9 -2
- data/src/ruby/pb/grpc/health/checker.rb +1 -1
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics.rb +28 -0
- data/src/ruby/pb/grpc/testing/metrics_services.rb +27 -0
- data/src/ruby/pb/test/client.rb +12 -23
- data/src/ruby/pb/test/server.rb +1 -1
- data/src/ruby/spec/client_server_spec.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +18 -17
- data/src/ruby/spec/generic/rpc_server_spec.rb +23 -7
- data/src/ruby/spec/generic/service_spec.rb +0 -69
- data/src/ruby/{bin/interop/interop_client.rb → spec/pb/duplicate/codegen_spec.rb} +41 -21
- data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
- data/third_party/boringssl/crypto/asn1/a_bitstr.c +184 -176
- data/third_party/boringssl/crypto/asn1/a_bool.c +42 -44
- data/third_party/boringssl/crypto/asn1/a_bytes.c +236 -245
- data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +173 -192
- data/third_party/boringssl/crypto/asn1/a_dup.c +43 -35
- data/third_party/boringssl/crypto/asn1/a_enum.c +107 -109
- data/third_party/boringssl/crypto/asn1/a_gentm.c +180 -181
- data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +73 -80
- data/third_party/boringssl/crypto/asn1/a_int.c +357 -353
- data/third_party/boringssl/crypto/asn1/a_mbstr.c +272 -253
- data/third_party/boringssl/crypto/asn1/a_object.c +293 -309
- data/third_party/boringssl/crypto/asn1/a_octet.c +13 -6
- data/third_party/boringssl/crypto/asn1/a_print.c +54 -52
- data/third_party/boringssl/crypto/asn1/a_strnid.c +179 -157
- data/third_party/boringssl/crypto/asn1/a_time.c +125 -129
- data/third_party/boringssl/crypto/asn1/a_type.c +79 -86
- data/third_party/boringssl/crypto/asn1/a_utctm.c +246 -255
- data/third_party/boringssl/crypto/asn1/a_utf8.c +159 -135
- data/third_party/boringssl/crypto/asn1/asn1_lib.c +361 -368
- data/third_party/boringssl/crypto/asn1/asn1_locl.h +11 -11
- data/third_party/boringssl/crypto/asn1/asn1_par.c +309 -351
- data/third_party/boringssl/crypto/asn1/asn_pack.c +30 -29
- data/third_party/boringssl/crypto/asn1/bio_asn1.c +375 -394
- data/third_party/boringssl/crypto/asn1/bio_ndef.c +146 -149
- data/third_party/boringssl/crypto/asn1/f_enum.c +128 -134
- data/third_party/boringssl/crypto/asn1/f_int.c +131 -139
- data/third_party/boringssl/crypto/asn1/f_string.c +125 -133
- data/third_party/boringssl/crypto/asn1/t_bitst.c +30 -29
- data/third_party/boringssl/crypto/asn1/t_pkey.c +45 -47
- data/third_party/boringssl/crypto/asn1/tasn_dec.c +1099 -1216
- data/third_party/boringssl/crypto/asn1/tasn_enc.c +556 -592
- data/third_party/boringssl/crypto/asn1/tasn_fre.c +175 -193
- data/third_party/boringssl/crypto/asn1/tasn_new.c +271 -288
- data/third_party/boringssl/crypto/asn1/tasn_prn.c +462 -508
- data/third_party/boringssl/crypto/asn1/tasn_typ.c +28 -21
- data/third_party/boringssl/crypto/asn1/x_bignum.c +62 -52
- data/third_party/boringssl/crypto/asn1/x_long.c +101 -86
- data/third_party/boringssl/crypto/bio/buffer.c +3 -3
- data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +8 -68
- data/third_party/boringssl/crypto/bn/bn.c +1 -1
- data/third_party/boringssl/crypto/bn/bn_asn1.c +9 -22
- data/third_party/boringssl/crypto/bn/convert.c +9 -4
- data/third_party/boringssl/crypto/bn/div.c +0 -20
- data/third_party/boringssl/crypto/bn/exponentiation.c +22 -13
- data/third_party/boringssl/crypto/bn/generic.c +6 -242
- data/third_party/boringssl/crypto/bn/internal.h +9 -70
- data/third_party/boringssl/crypto/bn/montgomery.c +1 -2
- data/third_party/boringssl/crypto/bn/mul.c +6 -26
- data/third_party/boringssl/crypto/bn/rsaz_exp.c +21 -28
- data/third_party/boringssl/crypto/bytestring/asn1_compat.c +51 -0
- data/third_party/boringssl/crypto/bytestring/ber.c +128 -87
- data/third_party/boringssl/crypto/bytestring/cbb.c +37 -3
- data/third_party/boringssl/crypto/bytestring/internal.h +39 -10
- data/third_party/boringssl/crypto/chacha/chacha_vec.c +18 -13
- data/third_party/boringssl/crypto/cipher/e_aes.c +2 -2
- data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +4 -9
- data/third_party/boringssl/crypto/cipher/tls_cbc.c +39 -10
- data/third_party/boringssl/crypto/conf/conf.c +9 -0
- data/third_party/boringssl/crypto/cpu-intel.c +1 -1
- data/third_party/boringssl/crypto/crypto.c +2 -0
- data/third_party/boringssl/crypto/curve25519/curve25519.c +125 -120
- data/third_party/boringssl/crypto/curve25519/internal.h +45 -0
- data/third_party/boringssl/crypto/curve25519/x25519-x86_64.c +225 -0
- data/third_party/boringssl/crypto/dh/check.c +32 -10
- data/third_party/boringssl/crypto/dh/dh.c +1 -1
- data/third_party/boringssl/crypto/digest/md32_common.h +0 -60
- data/third_party/boringssl/crypto/dsa/dsa.c +47 -21
- data/third_party/boringssl/crypto/dsa/dsa_asn1.c +249 -64
- data/third_party/boringssl/crypto/ec/ec.c +45 -31
- data/third_party/boringssl/crypto/ec/ec_asn1.c +315 -382
- data/third_party/boringssl/crypto/ec/ec_key.c +1 -4
- data/third_party/boringssl/crypto/ec/ec_montgomery.c +0 -9
- data/third_party/boringssl/crypto/ec/internal.h +1 -19
- data/third_party/boringssl/crypto/ec/oct.c +12 -0
- data/third_party/boringssl/crypto/ec/p224-64.c +4 -65
- data/third_party/boringssl/crypto/ec/p256-64.c +9 -71
- data/third_party/boringssl/crypto/ec/p256-x86_64-table.h +1 -6
- data/third_party/boringssl/crypto/ec/p256-x86_64.c +3 -13
- data/third_party/boringssl/crypto/ec/simple.c +0 -76
- data/third_party/boringssl/crypto/ecdsa/ecdsa.c +1 -1
- data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +10 -24
- data/third_party/boringssl/crypto/evp/evp.c +4 -3
- data/third_party/boringssl/crypto/evp/evp_asn1.c +101 -0
- data/third_party/boringssl/crypto/evp/evp_ctx.c +22 -51
- data/third_party/boringssl/crypto/evp/internal.h +28 -27
- data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +78 -249
- data/third_party/boringssl/crypto/evp/p_ec.c +19 -66
- data/third_party/boringssl/crypto/evp/p_ec_asn1.c +74 -231
- data/third_party/boringssl/crypto/evp/p_rsa.c +90 -13
- data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +49 -48
- data/third_party/boringssl/crypto/internal.h +16 -1
- data/third_party/boringssl/crypto/mem.c +2 -2
- data/third_party/boringssl/crypto/modes/ctr.c +2 -1
- data/third_party/boringssl/crypto/modes/gcm.c +5 -3
- data/third_party/boringssl/crypto/obj/obj_dat.h +6 -3
- data/third_party/boringssl/crypto/pem/pem_all.c +83 -102
- data/third_party/boringssl/crypto/pem/pem_info.c +286 -309
- data/third_party/boringssl/crypto/pem/pem_lib.c +690 -710
- data/third_party/boringssl/crypto/pem/pem_oth.c +15 -16
- data/third_party/boringssl/crypto/pem/pem_pk8.c +132 -119
- data/third_party/boringssl/crypto/pem/pem_pkey.c +144 -220
- data/third_party/boringssl/crypto/pem/pem_x509.c +3 -3
- data/third_party/boringssl/crypto/pem/pem_xaux.c +5 -4
- data/third_party/boringssl/crypto/pkcs8/pkcs8.c +54 -60
- data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +3 -1
- data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +48 -50
- data/third_party/boringssl/crypto/rand/rand.c +2 -0
- data/third_party/boringssl/crypto/rsa/blinding.c +8 -48
- data/third_party/boringssl/crypto/rsa/internal.h +1 -9
- data/third_party/boringssl/crypto/rsa/padding.c +73 -77
- data/third_party/boringssl/crypto/rsa/rsa.c +1 -1
- data/third_party/boringssl/crypto/rsa/rsa_asn1.c +27 -46
- data/third_party/boringssl/crypto/rsa/rsa_impl.c +23 -34
- data/third_party/boringssl/crypto/test/scoped_types.h +3 -0
- data/third_party/boringssl/crypto/thread_win.c +15 -13
- data/third_party/boringssl/crypto/time_support.c +0 -6
- data/third_party/boringssl/crypto/x509/a_digest.c +26 -27
- data/third_party/boringssl/crypto/x509/a_sign.c +63 -64
- data/third_party/boringssl/crypto/x509/a_strex.c +482 -413
- data/third_party/boringssl/crypto/x509/a_verify.c +45 -51
- data/third_party/boringssl/crypto/x509/asn1_gen.c +715 -769
- data/third_party/boringssl/crypto/x509/by_dir.c +355 -393
- data/third_party/boringssl/crypto/x509/by_file.c +186 -206
- data/third_party/boringssl/crypto/x509/charmap.h +11 -11
- data/third_party/boringssl/crypto/x509/i2d_pr.c +21 -22
- data/third_party/boringssl/crypto/x509/t_crl.c +50 -51
- data/third_party/boringssl/crypto/x509/t_x509.c +414 -406
- data/third_party/boringssl/crypto/x509/t_x509a.c +44 -42
- data/third_party/boringssl/crypto/x509/vpm_int.h +13 -13
- data/third_party/boringssl/crypto/x509/x509_att.c +241 -219
- data/third_party/boringssl/crypto/x509/x509_cmp.c +343 -359
- data/third_party/boringssl/crypto/x509/x509_d2.c +36 -35
- data/third_party/boringssl/crypto/x509/x509_def.c +23 -13
- data/third_party/boringssl/crypto/x509/x509_ext.c +75 -75
- data/third_party/boringssl/crypto/x509/x509_lu.c +574 -612
- data/third_party/boringssl/crypto/x509/x509_obj.c +104 -115
- data/third_party/boringssl/crypto/x509/x509_r2x.c +40 -40
- data/third_party/boringssl/crypto/x509/x509_req.c +181 -174
- data/third_party/boringssl/crypto/x509/x509_set.c +71 -76
- data/third_party/boringssl/crypto/x509/x509_trs.c +193 -171
- data/third_party/boringssl/crypto/x509/x509_txt.c +135 -138
- data/third_party/boringssl/crypto/x509/x509_v3.c +174 -167
- data/third_party/boringssl/crypto/x509/x509_vfy.c +2079 -2130
- data/third_party/boringssl/crypto/x509/x509_vpm.c +486 -522
- data/third_party/boringssl/crypto/x509/x509cset.c +96 -99
- data/third_party/boringssl/crypto/x509/x509name.c +280 -275
- data/third_party/boringssl/crypto/x509/x509rset.c +15 -14
- data/third_party/boringssl/crypto/x509/x509spki.c +62 -60
- data/third_party/boringssl/crypto/x509/x509type.c +58 -60
- data/third_party/boringssl/crypto/x509/x_algor.c +70 -73
- data/third_party/boringssl/crypto/x509/x_all.c +282 -328
- data/third_party/boringssl/crypto/x509/x_attrib.c +36 -42
- data/third_party/boringssl/crypto/x509/x_crl.c +397 -418
- data/third_party/boringssl/crypto/x509/x_exten.c +5 -5
- data/third_party/boringssl/crypto/x509/x_info.c +30 -27
- data/third_party/boringssl/crypto/x509/x_name.c +387 -388
- data/third_party/boringssl/crypto/x509/x_pkey.c +32 -29
- data/third_party/boringssl/crypto/x509/x_pubkey.c +261 -280
- data/third_party/boringssl/crypto/x509/x_req.c +30 -33
- data/third_party/boringssl/crypto/x509/x_sig.c +2 -2
- data/third_party/boringssl/crypto/x509/x_spki.c +9 -7
- data/third_party/boringssl/crypto/x509/x_val.c +2 -2
- data/third_party/boringssl/crypto/x509/x_x509.c +120 -119
- data/third_party/boringssl/crypto/x509/x_x509a.c +99 -91
- data/third_party/boringssl/crypto/x509v3/ext_dat.h +57 -51
- data/third_party/boringssl/crypto/x509v3/pcy_cache.c +199 -214
- data/third_party/boringssl/crypto/x509v3/pcy_data.c +57 -64
- data/third_party/boringssl/crypto/x509v3/pcy_int.h +95 -90
- data/third_party/boringssl/crypto/x509v3/pcy_lib.c +86 -87
- data/third_party/boringssl/crypto/x509v3/pcy_map.c +61 -64
- data/third_party/boringssl/crypto/x509v3/pcy_node.c +108 -117
- data/third_party/boringssl/crypto/x509v3/pcy_tree.c +676 -724
- data/third_party/boringssl/crypto/x509v3/v3_akey.c +128 -136
- data/third_party/boringssl/crypto/x509v3/v3_akeya.c +7 -6
- data/third_party/boringssl/crypto/x509v3/v3_alt.c +499 -507
- data/third_party/boringssl/crypto/x509v3/v3_bcons.c +54 -47
- data/third_party/boringssl/crypto/x509v3/v3_bitst.c +67 -67
- data/third_party/boringssl/crypto/x509v3/v3_conf.c +330 -328
- data/third_party/boringssl/crypto/x509v3/v3_cpols.c +354 -338
- data/third_party/boringssl/crypto/x509v3/v3_crld.c +441 -496
- data/third_party/boringssl/crypto/x509v3/v3_enum.c +35 -33
- data/third_party/boringssl/crypto/x509v3/v3_extku.c +66 -63
- data/third_party/boringssl/crypto/x509v3/v3_genn.c +157 -159
- data/third_party/boringssl/crypto/x509v3/v3_ia5.c +45 -43
- data/third_party/boringssl/crypto/x509v3/v3_info.c +124 -112
- data/third_party/boringssl/crypto/x509v3/v3_int.c +30 -26
- data/third_party/boringssl/crypto/x509v3/v3_lib.c +231 -204
- data/third_party/boringssl/crypto/x509v3/v3_ncons.c +353 -381
- data/third_party/boringssl/crypto/x509v3/v3_pci.c +252 -270
- data/third_party/boringssl/crypto/x509v3/v3_pcia.c +9 -8
- data/third_party/boringssl/crypto/x509v3/v3_pcons.c +58 -61
- data/third_party/boringssl/crypto/x509v3/v3_pku.c +35 -34
- data/third_party/boringssl/crypto/x509v3/v3_pmaps.c +72 -74
- data/third_party/boringssl/crypto/x509v3/v3_prn.c +146 -121
- data/third_party/boringssl/crypto/x509v3/v3_purp.c +651 -582
- data/third_party/boringssl/crypto/x509v3/v3_skey.c +76 -72
- data/third_party/boringssl/crypto/x509v3/v3_sxnet.c +139 -131
- data/third_party/boringssl/crypto/x509v3/v3_utl.c +1072 -1068
- data/third_party/boringssl/include/openssl/asn1.h +40 -38
- data/third_party/boringssl/include/openssl/base.h +10 -1
- data/third_party/boringssl/include/openssl/bio.h +10 -11
- data/third_party/boringssl/include/openssl/bn.h +12 -9
- data/third_party/boringssl/include/openssl/buf.h +1 -1
- data/third_party/boringssl/include/openssl/bytestring.h +29 -0
- data/third_party/boringssl/include/openssl/conf.h +25 -0
- data/third_party/boringssl/include/openssl/crypto.h +6 -1
- data/third_party/boringssl/include/openssl/curve25519.h +6 -3
- data/third_party/boringssl/include/openssl/dh.h +7 -3
- data/third_party/boringssl/include/openssl/dsa.h +108 -51
- data/third_party/boringssl/include/openssl/ec.h +46 -21
- data/third_party/boringssl/include/openssl/ec_key.h +78 -42
- data/third_party/boringssl/include/openssl/ecdsa.h +4 -4
- data/third_party/boringssl/include/openssl/err.h +3 -2
- data/third_party/boringssl/include/openssl/evp.h +120 -37
- data/third_party/boringssl/include/openssl/mem.h +4 -13
- data/third_party/boringssl/include/openssl/obj_mac.h +4 -0
- data/third_party/boringssl/include/openssl/pem.h +0 -9
- data/third_party/boringssl/include/openssl/pkcs8.h +6 -2
- data/third_party/boringssl/include/openssl/rand.h +3 -0
- data/third_party/boringssl/include/openssl/rsa.h +42 -42
- data/third_party/boringssl/include/openssl/ssl.h +115 -41
- data/third_party/boringssl/include/openssl/stack.h +0 -3
- data/third_party/boringssl/include/openssl/stack_macros.h +0 -256
- data/third_party/boringssl/include/openssl/tls1.h +1 -1
- data/third_party/boringssl/include/openssl/x509.h +0 -2
- data/third_party/boringssl/include/openssl/x509_vfy.h +5 -0
- data/third_party/boringssl/ssl/d1_both.c +102 -101
- data/third_party/boringssl/ssl/d1_clnt.c +145 -150
- data/third_party/boringssl/ssl/d1_lib.c +63 -62
- data/third_party/boringssl/ssl/d1_pkt.c +73 -71
- data/third_party/boringssl/ssl/d1_srvr.c +116 -125
- data/third_party/boringssl/ssl/dtls_record.c +3 -3
- data/third_party/boringssl/ssl/internal.h +210 -208
- data/third_party/boringssl/ssl/pqueue/pqueue.c +2 -2
- data/third_party/boringssl/ssl/s3_both.c +116 -130
- data/third_party/boringssl/ssl/s3_clnt.c +589 -740
- data/third_party/boringssl/ssl/s3_enc.c +52 -151
- data/third_party/boringssl/ssl/s3_lib.c +70 -76
- data/third_party/boringssl/ssl/s3_pkt.c +105 -144
- data/third_party/boringssl/ssl/s3_srvr.c +542 -806
- data/third_party/boringssl/ssl/ssl_aead_ctx.c +1 -1
- data/third_party/boringssl/ssl/ssl_cert.c +2 -2
- data/third_party/boringssl/ssl/ssl_cipher.c +7 -3
- data/third_party/boringssl/ssl/ssl_ecdh.c +374 -0
- data/third_party/boringssl/ssl/ssl_lib.c +260 -221
- data/third_party/boringssl/ssl/ssl_session.c +17 -17
- data/third_party/boringssl/ssl/t1_enc.c +128 -273
- data/third_party/boringssl/ssl/t1_lib.c +134 -258
- data/third_party/boringssl/ssl/test/test_config.h +2 -0
- data/third_party/boringssl/ssl/tls_record.c +52 -15
- metadata +385 -359
- data/src/core/channel/client_uchannel.c +0 -243
- data/src/core/channel/client_uchannel.h +0 -60
- data/src/core/channel/connected_channel.h +0 -51
- data/src/core/client_config/lb_policies/pick_first.h +0 -43
- data/src/core/client_config/resolvers/dns_resolver.h +0 -42
- data/src/core/client_config/subchannel_factory.h +0 -66
- data/src/core/httpcli/parser.c +0 -211
- data/src/core/iomgr/fd_posix.c +0 -451
- data/src/core/iomgr/fd_posix.h +0 -192
- data/src/core/iomgr/pollset_multipoller_with_epoll.c +0 -324
- data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +0 -234
- data/src/core/iomgr/pollset_posix.c +0 -633
- data/src/core/iomgr/pollset_posix.h +0 -153
- data/src/core/iomgr/pollset_set_posix.c +0 -202
- data/src/core/iomgr/pollset_set_posix.h +0 -45
- data/src/core/surface/init.c +0 -174
- data/src/core/surface/init_secure.c +0 -42
- data/src/core/surface/server_create.c +0 -48
- data/src/core/transport/chttp2/huffsyms.c +0 -297
- data/src/ruby/bin/grpc_ruby_interop_client +0 -33
- data/src/ruby/bin/grpc_ruby_interop_server +0 -33
- data/third_party/boringssl/crypto/dsa/internal.h +0 -78
@@ -60,43 +60,44 @@
|
|
60
60
|
|
61
61
|
#include <openssl/mem.h>
|
62
62
|
|
63
|
-
|
64
63
|
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
|
65
|
-
|
64
|
+
BIT_STRING_BITNAME *tbl, int indent)
|
66
65
|
{
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
66
|
+
BIT_STRING_BITNAME *bnam;
|
67
|
+
char first = 1;
|
68
|
+
BIO_printf(out, "%*s", indent, "");
|
69
|
+
for (bnam = tbl; bnam->lname; bnam++) {
|
70
|
+
if (ASN1_BIT_STRING_get_bit(bs, bnam->bitnum)) {
|
71
|
+
if (!first)
|
72
|
+
BIO_puts(out, ", ");
|
73
|
+
BIO_puts(out, bnam->lname);
|
74
|
+
first = 0;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
BIO_puts(out, "\n");
|
78
|
+
return 1;
|
79
79
|
}
|
80
80
|
|
81
81
|
int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, char *name, int value,
|
82
|
-
|
82
|
+
BIT_STRING_BITNAME *tbl)
|
83
83
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
int bitnum;
|
85
|
+
bitnum = ASN1_BIT_STRING_num_asc(name, tbl);
|
86
|
+
if (bitnum < 0)
|
87
|
+
return 0;
|
88
|
+
if (bs) {
|
89
|
+
if (!ASN1_BIT_STRING_set_bit(bs, bitnum, value))
|
90
|
+
return 0;
|
91
|
+
}
|
92
|
+
return 1;
|
92
93
|
}
|
93
94
|
|
94
95
|
int ASN1_BIT_STRING_num_asc(char *name, BIT_STRING_BITNAME *tbl)
|
95
96
|
{
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
BIT_STRING_BITNAME *bnam;
|
98
|
+
for (bnam = tbl; bnam->lname; bnam++) {
|
99
|
+
if (!strcmp(bnam->sname, name) || !strcmp(bnam->lname, name))
|
100
|
+
return bnam->bitnum;
|
101
|
+
}
|
102
|
+
return -1;
|
102
103
|
}
|
@@ -59,54 +59,52 @@
|
|
59
59
|
#include <openssl/bio.h>
|
60
60
|
#include <openssl/mem.h>
|
61
61
|
|
62
|
-
|
63
62
|
int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
unsigned char *buf, int off)
|
64
|
+
{
|
65
|
+
int n, i;
|
66
|
+
const char *neg;
|
67
|
+
|
68
|
+
if (num == NULL)
|
69
|
+
return (1);
|
70
|
+
neg = (BN_is_negative(num)) ? "-" : "";
|
71
|
+
if (!BIO_indent(bp, off, 128))
|
72
|
+
return 0;
|
73
|
+
if (BN_is_zero(num)) {
|
74
|
+
if (BIO_printf(bp, "%s 0\n", number) <= 0)
|
75
|
+
return 0;
|
76
|
+
return 1;
|
77
|
+
}
|
68
78
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
if (BN_num_bytes(num) <= sizeof(long)) {
|
80
|
+
if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg,
|
81
|
+
(unsigned long)num->d[0], neg,
|
82
|
+
(unsigned long)num->d[0])
|
83
|
+
<= 0)
|
84
|
+
return (0);
|
85
|
+
} else {
|
86
|
+
buf[0] = 0;
|
87
|
+
if (BIO_printf(bp, "%s%s", number,
|
88
|
+
(neg[0] == '-') ? " (Negative)" : "") <= 0)
|
89
|
+
return (0);
|
90
|
+
n = BN_bn2bin(num, &buf[1]);
|
79
91
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
<= 0) return(0);
|
85
|
-
}
|
86
|
-
else
|
87
|
-
{
|
88
|
-
buf[0]=0;
|
89
|
-
if (BIO_printf(bp,"%s%s",number,
|
90
|
-
(neg[0] == '-')?" (Negative)":"") <= 0)
|
91
|
-
return(0);
|
92
|
-
n=BN_bn2bin(num,&buf[1]);
|
93
|
-
|
94
|
-
if (buf[1] & 0x80)
|
95
|
-
n++;
|
96
|
-
else buf++;
|
92
|
+
if (buf[1] & 0x80)
|
93
|
+
n++;
|
94
|
+
else
|
95
|
+
buf++;
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
}
|
97
|
+
for (i = 0; i < n; i++) {
|
98
|
+
if ((i % 15) == 0) {
|
99
|
+
if (BIO_puts(bp, "\n") <= 0 || !BIO_indent(bp, off + 4, 128))
|
100
|
+
return 0;
|
101
|
+
}
|
102
|
+
if (BIO_printf(bp, "%02x%s", buf[i], ((i + 1) == n) ? "" : ":")
|
103
|
+
<= 0)
|
104
|
+
return (0);
|
105
|
+
}
|
106
|
+
if (BIO_write(bp, "\n", 1) <= 0)
|
107
|
+
return (0);
|
108
|
+
}
|
109
|
+
return (1);
|
110
|
+
}
|
@@ -65,1278 +65,1161 @@
|
|
65
65
|
|
66
66
|
#include "../internal.h"
|
67
67
|
|
68
|
-
|
69
68
|
static int asn1_check_eoc(const unsigned char **in, long len);
|
70
69
|
static int asn1_find_end(const unsigned char **in, long len, char inf);
|
71
70
|
|
72
71
|
static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len,
|
73
|
-
|
72
|
+
char inf, int tag, int aclass, int depth);
|
74
73
|
|
75
74
|
static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen);
|
76
75
|
|
77
76
|
static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
ASN1_TLC *ctx);
|
77
|
+
char *inf, char *cst,
|
78
|
+
const unsigned char **in, long len,
|
79
|
+
int exptag, int expclass, char opt, ASN1_TLC *ctx);
|
82
80
|
|
83
81
|
static int asn1_template_ex_d2i(ASN1_VALUE **pval,
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
const unsigned char **in, long len,
|
83
|
+
const ASN1_TEMPLATE *tt, char opt,
|
84
|
+
ASN1_TLC *ctx);
|
87
85
|
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
const unsigned char **in, long len,
|
87
|
+
const ASN1_TEMPLATE *tt, char opt,
|
88
|
+
ASN1_TLC *ctx);
|
91
89
|
static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
92
|
-
|
93
|
-
|
94
|
-
|
90
|
+
const unsigned char **in, long len,
|
91
|
+
const ASN1_ITEM *it,
|
92
|
+
int tag, int aclass, char opt,
|
93
|
+
ASN1_TLC *ctx);
|
95
94
|
|
96
95
|
/* Table to convert tags to bit values, used for MSTRING type */
|
97
96
|
static const unsigned long tag2bit[32] = {
|
98
|
-
0,
|
99
|
-
B_ASN1_OCTET_STRING,
|
100
|
-
B_ASN1_UNKNOWN,
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
97
|
+
0, 0, 0, B_ASN1_BIT_STRING, /* tags 0 - 3 */
|
98
|
+
B_ASN1_OCTET_STRING, 0, 0, B_ASN1_UNKNOWN, /* tags 4- 7 */
|
99
|
+
B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, /* tags
|
100
|
+
* 8-11 */
|
101
|
+
B_ASN1_UTF8STRING, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, B_ASN1_UNKNOWN, /* tags
|
102
|
+
* 12-15
|
103
|
+
*/
|
104
|
+
B_ASN1_SEQUENCE, 0, B_ASN1_NUMERICSTRING, B_ASN1_PRINTABLESTRING, /* tags
|
105
|
+
* 16-19
|
106
|
+
*/
|
107
|
+
B_ASN1_T61STRING, B_ASN1_VIDEOTEXSTRING, B_ASN1_IA5STRING, /* tags 20-22 */
|
108
|
+
B_ASN1_UTCTIME, B_ASN1_GENERALIZEDTIME, /* tags 23-24 */
|
109
|
+
B_ASN1_GRAPHICSTRING, B_ASN1_ISO64STRING, B_ASN1_GENERALSTRING, /* tags
|
110
|
+
* 25-27 */
|
111
|
+
B_ASN1_UNIVERSALSTRING, B_ASN1_UNKNOWN, B_ASN1_BMPSTRING, B_ASN1_UNKNOWN, /* tags
|
112
|
+
* 28-31
|
113
|
+
*/
|
114
|
+
};
|
108
115
|
|
109
116
|
unsigned long ASN1_tag2bit(int tag)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
{
|
118
|
+
if ((tag < 0) || (tag > 30))
|
119
|
+
return 0;
|
120
|
+
return tag2bit[tag];
|
121
|
+
}
|
114
122
|
|
115
123
|
/* Macro to initialize and invalidate the cache */
|
116
124
|
|
117
|
-
#define asn1_tlc_clear(c)
|
125
|
+
#define asn1_tlc_clear(c) if (c) (c)->valid = 0
|
118
126
|
/* Version to avoid compiler warning about 'c' always non-NULL */
|
119
|
-
#define asn1_tlc_clear_nc(c)
|
120
|
-
|
121
|
-
/*
|
122
|
-
* like a standard 'd2i'
|
123
|
-
* a buffer to read the data from, in future we
|
124
|
-
* have more advanced versions that can input data
|
125
|
-
*
|
126
|
-
* case.
|
127
|
+
#define asn1_tlc_clear_nc(c) (c)->valid = 0
|
128
|
+
|
129
|
+
/*
|
130
|
+
* Decode an ASN1 item, this currently behaves just like a standard 'd2i'
|
131
|
+
* function. 'in' points to a buffer to read the data from, in future we
|
132
|
+
* will have more advanced versions that can input data a piece at a time and
|
133
|
+
* this will simply be a special case.
|
127
134
|
*/
|
128
135
|
|
129
136
|
ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
const unsigned char **in, long len,
|
138
|
+
const ASN1_ITEM *it)
|
139
|
+
{
|
140
|
+
ASN1_TLC c;
|
141
|
+
ASN1_VALUE *ptmpval = NULL;
|
142
|
+
if (!pval)
|
143
|
+
pval = &ptmpval;
|
144
|
+
asn1_tlc_clear_nc(&c);
|
145
|
+
if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
|
146
|
+
return *pval;
|
147
|
+
return NULL;
|
148
|
+
}
|
141
149
|
|
142
150
|
int ASN1_template_d2i(ASN1_VALUE **pval,
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
/*
|
152
|
-
*
|
151
|
+
const unsigned char **in, long len,
|
152
|
+
const ASN1_TEMPLATE *tt)
|
153
|
+
{
|
154
|
+
ASN1_TLC c;
|
155
|
+
asn1_tlc_clear_nc(&c);
|
156
|
+
return asn1_template_ex_d2i(pval, in, len, tt, 0, &c);
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
* Decode an item, taking care of IMPLICIT tagging, if any. If 'opt' set and
|
161
|
+
* tag mismatch return -1 to handle OPTIONAL
|
153
162
|
*/
|
154
163
|
|
155
164
|
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
}
|
509
|
-
else
|
510
|
-
{
|
511
|
-
errtt = seqtt;
|
512
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_FIELD_MISSING);
|
513
|
-
goto err;
|
514
|
-
}
|
515
|
-
}
|
516
|
-
/* Save encoding */
|
517
|
-
if (!asn1_enc_save(pval, *in, p - *in, it))
|
518
|
-
goto auxerr;
|
519
|
-
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
|
520
|
-
goto auxerr;
|
521
|
-
*in = p;
|
522
|
-
return 1;
|
523
|
-
|
524
|
-
default:
|
525
|
-
return 0;
|
526
|
-
}
|
527
|
-
auxerr:
|
528
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_AUX_ERROR);
|
529
|
-
err:
|
530
|
-
if (combine == 0)
|
531
|
-
ASN1_item_ex_free(pval, it);
|
532
|
-
if (errtt)
|
533
|
-
ERR_add_error_data(4, "Field=", errtt->field_name,
|
534
|
-
", Type=", it->sname);
|
535
|
-
else
|
536
|
-
ERR_add_error_data(2, "Type=", it->sname);
|
537
|
-
return 0;
|
538
|
-
}
|
539
|
-
|
540
|
-
/* Templates are handled with two separate functions.
|
541
|
-
* One handles any EXPLICIT tag and the other handles the rest.
|
165
|
+
const ASN1_ITEM *it,
|
166
|
+
int tag, int aclass, char opt, ASN1_TLC *ctx)
|
167
|
+
{
|
168
|
+
const ASN1_TEMPLATE *tt, *errtt = NULL;
|
169
|
+
const ASN1_COMPAT_FUNCS *cf;
|
170
|
+
const ASN1_EXTERN_FUNCS *ef;
|
171
|
+
const ASN1_AUX *aux = it->funcs;
|
172
|
+
ASN1_aux_cb *asn1_cb;
|
173
|
+
const unsigned char *p = NULL, *q;
|
174
|
+
unsigned char *wp = NULL; /* BIG FAT WARNING! BREAKS CONST WHERE USED */
|
175
|
+
unsigned char imphack = 0, oclass;
|
176
|
+
char seq_eoc, seq_nolen, cst, isopt;
|
177
|
+
long tmplen;
|
178
|
+
int i;
|
179
|
+
int otag;
|
180
|
+
int ret = 0;
|
181
|
+
ASN1_VALUE **pchptr, *ptmpval;
|
182
|
+
int combine = aclass & ASN1_TFLG_COMBINE;
|
183
|
+
if (!pval)
|
184
|
+
return 0;
|
185
|
+
if (aux && aux->asn1_cb)
|
186
|
+
asn1_cb = aux->asn1_cb;
|
187
|
+
else
|
188
|
+
asn1_cb = 0;
|
189
|
+
|
190
|
+
switch (it->itype) {
|
191
|
+
case ASN1_ITYPE_PRIMITIVE:
|
192
|
+
if (it->templates) {
|
193
|
+
/*
|
194
|
+
* tagging or OPTIONAL is currently illegal on an item template
|
195
|
+
* because the flags can't get passed down. In practice this
|
196
|
+
* isn't a problem: we include the relevant flags from the item
|
197
|
+
* template in the template itself.
|
198
|
+
*/
|
199
|
+
if ((tag != -1) || opt) {
|
200
|
+
OPENSSL_PUT_ERROR(ASN1,
|
201
|
+
ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE);
|
202
|
+
goto err;
|
203
|
+
}
|
204
|
+
return asn1_template_ex_d2i(pval, in, len,
|
205
|
+
it->templates, opt, ctx);
|
206
|
+
}
|
207
|
+
return asn1_d2i_ex_primitive(pval, in, len, it,
|
208
|
+
tag, aclass, opt, ctx);
|
209
|
+
break;
|
210
|
+
|
211
|
+
case ASN1_ITYPE_MSTRING:
|
212
|
+
p = *in;
|
213
|
+
/* Just read in tag and class */
|
214
|
+
ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,
|
215
|
+
&p, len, -1, 0, 1, ctx);
|
216
|
+
if (!ret) {
|
217
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
218
|
+
goto err;
|
219
|
+
}
|
220
|
+
|
221
|
+
/* Must be UNIVERSAL class */
|
222
|
+
if (oclass != V_ASN1_UNIVERSAL) {
|
223
|
+
/* If OPTIONAL, assume this is OK */
|
224
|
+
if (opt)
|
225
|
+
return -1;
|
226
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MSTRING_NOT_UNIVERSAL);
|
227
|
+
goto err;
|
228
|
+
}
|
229
|
+
/* Check tag matches bit map */
|
230
|
+
if (!(ASN1_tag2bit(otag) & it->utype)) {
|
231
|
+
/* If OPTIONAL, assume this is OK */
|
232
|
+
if (opt)
|
233
|
+
return -1;
|
234
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MSTRING_WRONG_TAG);
|
235
|
+
goto err;
|
236
|
+
}
|
237
|
+
return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx);
|
238
|
+
|
239
|
+
case ASN1_ITYPE_EXTERN:
|
240
|
+
/* Use new style d2i */
|
241
|
+
ef = it->funcs;
|
242
|
+
return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx);
|
243
|
+
|
244
|
+
case ASN1_ITYPE_COMPAT:
|
245
|
+
/* we must resort to old style evil hackery */
|
246
|
+
cf = it->funcs;
|
247
|
+
|
248
|
+
/* If OPTIONAL see if it is there */
|
249
|
+
if (opt) {
|
250
|
+
int exptag;
|
251
|
+
p = *in;
|
252
|
+
if (tag == -1)
|
253
|
+
exptag = it->utype;
|
254
|
+
else
|
255
|
+
exptag = tag;
|
256
|
+
/*
|
257
|
+
* Don't care about anything other than presence of expected tag
|
258
|
+
*/
|
259
|
+
|
260
|
+
ret = asn1_check_tlen(NULL, NULL, NULL, NULL, NULL,
|
261
|
+
&p, len, exptag, aclass, 1, ctx);
|
262
|
+
if (!ret) {
|
263
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
264
|
+
goto err;
|
265
|
+
}
|
266
|
+
if (ret == -1)
|
267
|
+
return -1;
|
268
|
+
}
|
269
|
+
|
270
|
+
/*
|
271
|
+
* This is the old style evil hack IMPLICIT handling: since the
|
272
|
+
* underlying code is expecting a tag and class other than the one
|
273
|
+
* present we change the buffer temporarily then change it back
|
274
|
+
* afterwards. This doesn't and never did work for tags > 30. Yes
|
275
|
+
* this is *horrible* but it is only needed for old style d2i which
|
276
|
+
* will hopefully not be around for much longer. FIXME: should copy
|
277
|
+
* the buffer then modify it so the input buffer can be const: we
|
278
|
+
* should *always* copy because the old style d2i might modify the
|
279
|
+
* buffer.
|
280
|
+
*/
|
281
|
+
|
282
|
+
if (tag != -1) {
|
283
|
+
wp = *(unsigned char **)in;
|
284
|
+
imphack = *wp;
|
285
|
+
if (p == NULL) {
|
286
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
287
|
+
goto err;
|
288
|
+
}
|
289
|
+
*wp = (unsigned char)((*p & V_ASN1_CONSTRUCTED)
|
290
|
+
| it->utype);
|
291
|
+
}
|
292
|
+
|
293
|
+
ptmpval = cf->asn1_d2i(pval, in, len);
|
294
|
+
|
295
|
+
if (tag != -1)
|
296
|
+
*wp = imphack;
|
297
|
+
|
298
|
+
if (ptmpval)
|
299
|
+
return 1;
|
300
|
+
|
301
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
302
|
+
goto err;
|
303
|
+
|
304
|
+
case ASN1_ITYPE_CHOICE:
|
305
|
+
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
|
306
|
+
goto auxerr;
|
307
|
+
|
308
|
+
if (*pval) {
|
309
|
+
/* Free up and zero CHOICE value if initialised */
|
310
|
+
i = asn1_get_choice_selector(pval, it);
|
311
|
+
if ((i >= 0) && (i < it->tcount)) {
|
312
|
+
tt = it->templates + i;
|
313
|
+
pchptr = asn1_get_field_ptr(pval, tt);
|
314
|
+
ASN1_template_free(pchptr, tt);
|
315
|
+
asn1_set_choice_selector(pval, -1, it);
|
316
|
+
}
|
317
|
+
} else if (!ASN1_item_ex_new(pval, it)) {
|
318
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
319
|
+
goto err;
|
320
|
+
}
|
321
|
+
/* CHOICE type, try each possibility in turn */
|
322
|
+
p = *in;
|
323
|
+
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
324
|
+
pchptr = asn1_get_field_ptr(pval, tt);
|
325
|
+
/*
|
326
|
+
* We mark field as OPTIONAL so its absence can be recognised.
|
327
|
+
*/
|
328
|
+
ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx);
|
329
|
+
/* If field not present, try the next one */
|
330
|
+
if (ret == -1)
|
331
|
+
continue;
|
332
|
+
/* If positive return, read OK, break loop */
|
333
|
+
if (ret > 0)
|
334
|
+
break;
|
335
|
+
/* Otherwise must be an ASN1 parsing error */
|
336
|
+
errtt = tt;
|
337
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
338
|
+
goto err;
|
339
|
+
}
|
340
|
+
|
341
|
+
/* Did we fall off the end without reading anything? */
|
342
|
+
if (i == it->tcount) {
|
343
|
+
/* If OPTIONAL, this is OK */
|
344
|
+
if (opt) {
|
345
|
+
/* Free and zero it */
|
346
|
+
ASN1_item_ex_free(pval, it);
|
347
|
+
return -1;
|
348
|
+
}
|
349
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NO_MATCHING_CHOICE_TYPE);
|
350
|
+
goto err;
|
351
|
+
}
|
352
|
+
|
353
|
+
asn1_set_choice_selector(pval, i, it);
|
354
|
+
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
|
355
|
+
goto auxerr;
|
356
|
+
*in = p;
|
357
|
+
return 1;
|
358
|
+
|
359
|
+
case ASN1_ITYPE_NDEF_SEQUENCE:
|
360
|
+
case ASN1_ITYPE_SEQUENCE:
|
361
|
+
p = *in;
|
362
|
+
tmplen = len;
|
363
|
+
|
364
|
+
/* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
|
365
|
+
if (tag == -1) {
|
366
|
+
tag = V_ASN1_SEQUENCE;
|
367
|
+
aclass = V_ASN1_UNIVERSAL;
|
368
|
+
}
|
369
|
+
/* Get SEQUENCE length and update len, p */
|
370
|
+
ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst,
|
371
|
+
&p, len, tag, aclass, opt, ctx);
|
372
|
+
if (!ret) {
|
373
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
374
|
+
goto err;
|
375
|
+
} else if (ret == -1)
|
376
|
+
return -1;
|
377
|
+
if (aux && (aux->flags & ASN1_AFLG_BROKEN)) {
|
378
|
+
len = tmplen - (p - *in);
|
379
|
+
seq_nolen = 1;
|
380
|
+
}
|
381
|
+
/* If indefinite we don't do a length check */
|
382
|
+
else
|
383
|
+
seq_nolen = seq_eoc;
|
384
|
+
if (!cst) {
|
385
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_SEQUENCE_NOT_CONSTRUCTED);
|
386
|
+
goto err;
|
387
|
+
}
|
388
|
+
|
389
|
+
if (!*pval && !ASN1_item_ex_new(pval, it)) {
|
390
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
391
|
+
goto err;
|
392
|
+
}
|
393
|
+
|
394
|
+
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))
|
395
|
+
goto auxerr;
|
396
|
+
|
397
|
+
/* Free up and zero any ADB found */
|
398
|
+
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
399
|
+
if (tt->flags & ASN1_TFLG_ADB_MASK) {
|
400
|
+
const ASN1_TEMPLATE *seqtt;
|
401
|
+
ASN1_VALUE **pseqval;
|
402
|
+
seqtt = asn1_do_adb(pval, tt, 1);
|
403
|
+
pseqval = asn1_get_field_ptr(pval, seqtt);
|
404
|
+
ASN1_template_free(pseqval, seqtt);
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
/* Get each field entry */
|
409
|
+
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
410
|
+
const ASN1_TEMPLATE *seqtt;
|
411
|
+
ASN1_VALUE **pseqval;
|
412
|
+
seqtt = asn1_do_adb(pval, tt, 1);
|
413
|
+
if (!seqtt)
|
414
|
+
goto err;
|
415
|
+
pseqval = asn1_get_field_ptr(pval, seqtt);
|
416
|
+
/* Have we ran out of data? */
|
417
|
+
if (!len)
|
418
|
+
break;
|
419
|
+
q = p;
|
420
|
+
if (asn1_check_eoc(&p, len)) {
|
421
|
+
if (!seq_eoc) {
|
422
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
|
423
|
+
goto err;
|
424
|
+
}
|
425
|
+
len -= p - q;
|
426
|
+
seq_eoc = 0;
|
427
|
+
q = p;
|
428
|
+
break;
|
429
|
+
}
|
430
|
+
/*
|
431
|
+
* This determines the OPTIONAL flag value. The field cannot be
|
432
|
+
* omitted if it is the last of a SEQUENCE and there is still
|
433
|
+
* data to be read. This isn't strictly necessary but it
|
434
|
+
* increases efficiency in some cases.
|
435
|
+
*/
|
436
|
+
if (i == (it->tcount - 1))
|
437
|
+
isopt = 0;
|
438
|
+
else
|
439
|
+
isopt = (char)(seqtt->flags & ASN1_TFLG_OPTIONAL);
|
440
|
+
/*
|
441
|
+
* attempt to read in field, allowing each to be OPTIONAL
|
442
|
+
*/
|
443
|
+
|
444
|
+
ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx);
|
445
|
+
if (!ret) {
|
446
|
+
errtt = seqtt;
|
447
|
+
goto err;
|
448
|
+
} else if (ret == -1) {
|
449
|
+
/*
|
450
|
+
* OPTIONAL component absent. Free and zero the field.
|
451
|
+
*/
|
452
|
+
ASN1_template_free(pseqval, seqtt);
|
453
|
+
continue;
|
454
|
+
}
|
455
|
+
/* Update length */
|
456
|
+
len -= p - q;
|
457
|
+
}
|
458
|
+
|
459
|
+
/* Check for EOC if expecting one */
|
460
|
+
if (seq_eoc && !asn1_check_eoc(&p, len)) {
|
461
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
462
|
+
goto err;
|
463
|
+
}
|
464
|
+
/* Check all data read */
|
465
|
+
if (!seq_nolen && len) {
|
466
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_SEQUENCE_LENGTH_MISMATCH);
|
467
|
+
goto err;
|
468
|
+
}
|
469
|
+
|
470
|
+
/*
|
471
|
+
* If we get here we've got no more data in the SEQUENCE, however we
|
472
|
+
* may not have read all fields so check all remaining are OPTIONAL
|
473
|
+
* and clear any that are.
|
474
|
+
*/
|
475
|
+
for (; i < it->tcount; tt++, i++) {
|
476
|
+
const ASN1_TEMPLATE *seqtt;
|
477
|
+
seqtt = asn1_do_adb(pval, tt, 1);
|
478
|
+
if (!seqtt)
|
479
|
+
goto err;
|
480
|
+
if (seqtt->flags & ASN1_TFLG_OPTIONAL) {
|
481
|
+
ASN1_VALUE **pseqval;
|
482
|
+
pseqval = asn1_get_field_ptr(pval, seqtt);
|
483
|
+
ASN1_template_free(pseqval, seqtt);
|
484
|
+
} else {
|
485
|
+
errtt = seqtt;
|
486
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_FIELD_MISSING);
|
487
|
+
goto err;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
/* Save encoding */
|
491
|
+
if (!asn1_enc_save(pval, *in, p - *in, it))
|
492
|
+
goto auxerr;
|
493
|
+
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
|
494
|
+
goto auxerr;
|
495
|
+
*in = p;
|
496
|
+
return 1;
|
497
|
+
|
498
|
+
default:
|
499
|
+
return 0;
|
500
|
+
}
|
501
|
+
auxerr:
|
502
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_AUX_ERROR);
|
503
|
+
err:
|
504
|
+
if (combine == 0)
|
505
|
+
ASN1_item_ex_free(pval, it);
|
506
|
+
if (errtt)
|
507
|
+
ERR_add_error_data(4, "Field=", errtt->field_name,
|
508
|
+
", Type=", it->sname);
|
509
|
+
else
|
510
|
+
ERR_add_error_data(2, "Type=", it->sname);
|
511
|
+
return 0;
|
512
|
+
}
|
513
|
+
|
514
|
+
/*
|
515
|
+
* Templates are handled with two separate functions. One handles any
|
516
|
+
* EXPLICIT tag and the other handles the rest.
|
542
517
|
*/
|
543
518
|
|
544
519
|
static int asn1_template_ex_d2i(ASN1_VALUE **val,
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
else
|
614
|
-
return asn1_template_noexp_d2i(val, in, inlen,
|
615
|
-
tt, opt, ctx);
|
616
|
-
|
617
|
-
*in = p;
|
618
|
-
return 1;
|
619
|
-
|
620
|
-
err:
|
621
|
-
ASN1_template_free(val, tt);
|
622
|
-
return 0;
|
623
|
-
}
|
520
|
+
const unsigned char **in, long inlen,
|
521
|
+
const ASN1_TEMPLATE *tt, char opt,
|
522
|
+
ASN1_TLC *ctx)
|
523
|
+
{
|
524
|
+
int flags, aclass;
|
525
|
+
int ret;
|
526
|
+
long len;
|
527
|
+
const unsigned char *p, *q;
|
528
|
+
char exp_eoc;
|
529
|
+
if (!val)
|
530
|
+
return 0;
|
531
|
+
flags = tt->flags;
|
532
|
+
aclass = flags & ASN1_TFLG_TAG_CLASS;
|
533
|
+
|
534
|
+
p = *in;
|
535
|
+
|
536
|
+
/* Check if EXPLICIT tag expected */
|
537
|
+
if (flags & ASN1_TFLG_EXPTAG) {
|
538
|
+
char cst;
|
539
|
+
/*
|
540
|
+
* Need to work out amount of data available to the inner content and
|
541
|
+
* where it starts: so read in EXPLICIT header to get the info.
|
542
|
+
*/
|
543
|
+
ret = asn1_check_tlen(&len, NULL, NULL, &exp_eoc, &cst,
|
544
|
+
&p, inlen, tt->tag, aclass, opt, ctx);
|
545
|
+
q = p;
|
546
|
+
if (!ret) {
|
547
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
548
|
+
return 0;
|
549
|
+
} else if (ret == -1)
|
550
|
+
return -1;
|
551
|
+
if (!cst) {
|
552
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED);
|
553
|
+
return 0;
|
554
|
+
}
|
555
|
+
/* We've found the field so it can't be OPTIONAL now */
|
556
|
+
ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
|
557
|
+
if (!ret) {
|
558
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
559
|
+
return 0;
|
560
|
+
}
|
561
|
+
/* We read the field in OK so update length */
|
562
|
+
len -= p - q;
|
563
|
+
if (exp_eoc) {
|
564
|
+
/* If NDEF we must have an EOC here */
|
565
|
+
if (!asn1_check_eoc(&p, len)) {
|
566
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
567
|
+
goto err;
|
568
|
+
}
|
569
|
+
} else {
|
570
|
+
/*
|
571
|
+
* Otherwise we must hit the EXPLICIT tag end or its an error
|
572
|
+
*/
|
573
|
+
if (len) {
|
574
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_EXPLICIT_LENGTH_MISMATCH);
|
575
|
+
goto err;
|
576
|
+
}
|
577
|
+
}
|
578
|
+
} else
|
579
|
+
return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
|
580
|
+
|
581
|
+
*in = p;
|
582
|
+
return 1;
|
583
|
+
|
584
|
+
err:
|
585
|
+
ASN1_template_free(val, tt);
|
586
|
+
return 0;
|
587
|
+
}
|
624
588
|
|
625
589
|
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
else if (ret == -1)
|
741
|
-
return -1;
|
742
|
-
}
|
743
|
-
else
|
744
|
-
{
|
745
|
-
/* Nothing special */
|
746
|
-
ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item),
|
747
|
-
-1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx);
|
748
|
-
if (!ret)
|
749
|
-
{
|
750
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
751
|
-
goto err;
|
752
|
-
}
|
753
|
-
else if (ret == -1)
|
754
|
-
return -1;
|
755
|
-
}
|
756
|
-
|
757
|
-
*in = p;
|
758
|
-
return 1;
|
759
|
-
|
760
|
-
err:
|
761
|
-
ASN1_template_free(val, tt);
|
762
|
-
return 0;
|
763
|
-
}
|
590
|
+
const unsigned char **in, long len,
|
591
|
+
const ASN1_TEMPLATE *tt, char opt,
|
592
|
+
ASN1_TLC *ctx)
|
593
|
+
{
|
594
|
+
int flags, aclass;
|
595
|
+
int ret;
|
596
|
+
const unsigned char *p;
|
597
|
+
if (!val)
|
598
|
+
return 0;
|
599
|
+
flags = tt->flags;
|
600
|
+
aclass = flags & ASN1_TFLG_TAG_CLASS;
|
601
|
+
|
602
|
+
p = *in;
|
603
|
+
|
604
|
+
if (flags & ASN1_TFLG_SK_MASK) {
|
605
|
+
/* SET OF, SEQUENCE OF */
|
606
|
+
int sktag, skaclass;
|
607
|
+
char sk_eoc;
|
608
|
+
/* First work out expected inner tag value */
|
609
|
+
if (flags & ASN1_TFLG_IMPTAG) {
|
610
|
+
sktag = tt->tag;
|
611
|
+
skaclass = aclass;
|
612
|
+
} else {
|
613
|
+
skaclass = V_ASN1_UNIVERSAL;
|
614
|
+
if (flags & ASN1_TFLG_SET_OF)
|
615
|
+
sktag = V_ASN1_SET;
|
616
|
+
else
|
617
|
+
sktag = V_ASN1_SEQUENCE;
|
618
|
+
}
|
619
|
+
/* Get the tag */
|
620
|
+
ret = asn1_check_tlen(&len, NULL, NULL, &sk_eoc, NULL,
|
621
|
+
&p, len, sktag, skaclass, opt, ctx);
|
622
|
+
if (!ret) {
|
623
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
624
|
+
return 0;
|
625
|
+
} else if (ret == -1)
|
626
|
+
return -1;
|
627
|
+
if (!*val)
|
628
|
+
*val = (ASN1_VALUE *)sk_new_null();
|
629
|
+
else {
|
630
|
+
/*
|
631
|
+
* We've got a valid STACK: free up any items present
|
632
|
+
*/
|
633
|
+
STACK_OF(ASN1_VALUE) *sktmp = (STACK_OF(ASN1_VALUE) *)*val;
|
634
|
+
ASN1_VALUE *vtmp;
|
635
|
+
while (sk_ASN1_VALUE_num(sktmp) > 0) {
|
636
|
+
vtmp = sk_ASN1_VALUE_pop(sktmp);
|
637
|
+
ASN1_item_ex_free(&vtmp, ASN1_ITEM_ptr(tt->item));
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
641
|
+
if (!*val) {
|
642
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
643
|
+
goto err;
|
644
|
+
}
|
645
|
+
|
646
|
+
/* Read as many items as we can */
|
647
|
+
while (len > 0) {
|
648
|
+
ASN1_VALUE *skfield;
|
649
|
+
const unsigned char *q = p;
|
650
|
+
/* See if EOC found */
|
651
|
+
if (asn1_check_eoc(&p, len)) {
|
652
|
+
if (!sk_eoc) {
|
653
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
|
654
|
+
goto err;
|
655
|
+
}
|
656
|
+
len -= p - q;
|
657
|
+
sk_eoc = 0;
|
658
|
+
break;
|
659
|
+
}
|
660
|
+
skfield = NULL;
|
661
|
+
if (!ASN1_item_ex_d2i(&skfield, &p, len,
|
662
|
+
ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) {
|
663
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
664
|
+
goto err;
|
665
|
+
}
|
666
|
+
len -= p - q;
|
667
|
+
if (!sk_ASN1_VALUE_push((STACK_OF(ASN1_VALUE) *)*val, skfield)) {
|
668
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
669
|
+
goto err;
|
670
|
+
}
|
671
|
+
}
|
672
|
+
if (sk_eoc) {
|
673
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
674
|
+
goto err;
|
675
|
+
}
|
676
|
+
} else if (flags & ASN1_TFLG_IMPTAG) {
|
677
|
+
/* IMPLICIT tagging */
|
678
|
+
ret = ASN1_item_ex_d2i(val, &p, len,
|
679
|
+
ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt,
|
680
|
+
ctx);
|
681
|
+
if (!ret) {
|
682
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
683
|
+
goto err;
|
684
|
+
} else if (ret == -1)
|
685
|
+
return -1;
|
686
|
+
} else {
|
687
|
+
/* Nothing special */
|
688
|
+
ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item),
|
689
|
+
-1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx);
|
690
|
+
if (!ret) {
|
691
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
692
|
+
goto err;
|
693
|
+
} else if (ret == -1)
|
694
|
+
return -1;
|
695
|
+
}
|
696
|
+
|
697
|
+
*in = p;
|
698
|
+
return 1;
|
699
|
+
|
700
|
+
err:
|
701
|
+
ASN1_template_free(val, tt);
|
702
|
+
return 0;
|
703
|
+
}
|
764
704
|
|
765
705
|
static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
buf.data[len] = 0;
|
900
|
-
cont = (const unsigned char *)buf.data;
|
901
|
-
free_cont = 1;
|
902
|
-
}
|
903
|
-
else
|
904
|
-
{
|
905
|
-
cont = p;
|
906
|
-
len = plen;
|
907
|
-
p += plen;
|
908
|
-
}
|
909
|
-
|
910
|
-
/* We now have content length and type: translate into a structure */
|
911
|
-
if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
|
912
|
-
goto err;
|
913
|
-
|
914
|
-
*in = p;
|
915
|
-
ret = 1;
|
916
|
-
err:
|
917
|
-
if (free_cont && buf.data) OPENSSL_free(buf.data);
|
918
|
-
return ret;
|
919
|
-
}
|
706
|
+
const unsigned char **in, long inlen,
|
707
|
+
const ASN1_ITEM *it,
|
708
|
+
int tag, int aclass, char opt, ASN1_TLC *ctx)
|
709
|
+
OPENSSL_SUPPRESS_POTENTIALLY_UNINITIALIZED_WARNINGS
|
710
|
+
{
|
711
|
+
int ret = 0, utype;
|
712
|
+
long plen;
|
713
|
+
char cst, inf, free_cont = 0;
|
714
|
+
const unsigned char *p;
|
715
|
+
BUF_MEM buf;
|
716
|
+
const unsigned char *cont = NULL;
|
717
|
+
long len;
|
718
|
+
if (!pval) {
|
719
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_NULL);
|
720
|
+
return 0; /* Should never happen */
|
721
|
+
}
|
722
|
+
|
723
|
+
if (it->itype == ASN1_ITYPE_MSTRING) {
|
724
|
+
utype = tag;
|
725
|
+
tag = -1;
|
726
|
+
} else
|
727
|
+
utype = it->utype;
|
728
|
+
|
729
|
+
if (utype == V_ASN1_ANY) {
|
730
|
+
/* If type is ANY need to figure out type from tag */
|
731
|
+
unsigned char oclass;
|
732
|
+
if (tag >= 0) {
|
733
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_TAGGED_ANY);
|
734
|
+
return 0;
|
735
|
+
}
|
736
|
+
if (opt) {
|
737
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_OPTIONAL_ANY);
|
738
|
+
return 0;
|
739
|
+
}
|
740
|
+
p = *in;
|
741
|
+
ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL,
|
742
|
+
&p, inlen, -1, 0, 0, ctx);
|
743
|
+
if (!ret) {
|
744
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
745
|
+
return 0;
|
746
|
+
}
|
747
|
+
if (oclass != V_ASN1_UNIVERSAL)
|
748
|
+
utype = V_ASN1_OTHER;
|
749
|
+
}
|
750
|
+
if (tag == -1) {
|
751
|
+
tag = utype;
|
752
|
+
aclass = V_ASN1_UNIVERSAL;
|
753
|
+
}
|
754
|
+
p = *in;
|
755
|
+
/* Check header */
|
756
|
+
ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst,
|
757
|
+
&p, inlen, tag, aclass, opt, ctx);
|
758
|
+
if (!ret) {
|
759
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
760
|
+
return 0;
|
761
|
+
} else if (ret == -1)
|
762
|
+
return -1;
|
763
|
+
ret = 0;
|
764
|
+
/* SEQUENCE, SET and "OTHER" are left in encoded form */
|
765
|
+
if ((utype == V_ASN1_SEQUENCE)
|
766
|
+
|| (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) {
|
767
|
+
/*
|
768
|
+
* Clear context cache for type OTHER because the auto clear when we
|
769
|
+
* have a exact match wont work
|
770
|
+
*/
|
771
|
+
if (utype == V_ASN1_OTHER) {
|
772
|
+
asn1_tlc_clear(ctx);
|
773
|
+
}
|
774
|
+
/* SEQUENCE and SET must be constructed */
|
775
|
+
else if (!cst) {
|
776
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TYPE_NOT_CONSTRUCTED);
|
777
|
+
return 0;
|
778
|
+
}
|
779
|
+
|
780
|
+
cont = *in;
|
781
|
+
/* If indefinite length constructed find the real end */
|
782
|
+
if (inf) {
|
783
|
+
if (!asn1_find_end(&p, plen, inf))
|
784
|
+
goto err;
|
785
|
+
len = p - cont;
|
786
|
+
} else {
|
787
|
+
len = p - cont + plen;
|
788
|
+
p += plen;
|
789
|
+
buf.data = NULL;
|
790
|
+
}
|
791
|
+
} else if (cst) {
|
792
|
+
if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
|
793
|
+
|| utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER
|
794
|
+
|| utype == V_ASN1_ENUMERATED) {
|
795
|
+
/* These types only have primitive encodings. */
|
796
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TYPE_NOT_PRIMITIVE);
|
797
|
+
return 0;
|
798
|
+
}
|
799
|
+
|
800
|
+
buf.length = 0;
|
801
|
+
buf.max = 0;
|
802
|
+
buf.data = NULL;
|
803
|
+
/*
|
804
|
+
* Should really check the internal tags are correct but some things
|
805
|
+
* may get this wrong. The relevant specs say that constructed string
|
806
|
+
* types should be OCTET STRINGs internally irrespective of the type.
|
807
|
+
* So instead just check for UNIVERSAL class and ignore the tag.
|
808
|
+
*/
|
809
|
+
if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) {
|
810
|
+
free_cont = 1;
|
811
|
+
goto err;
|
812
|
+
}
|
813
|
+
len = buf.length;
|
814
|
+
/* Append a final null to string */
|
815
|
+
if (!BUF_MEM_grow_clean(&buf, len + 1)) {
|
816
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
817
|
+
return 0;
|
818
|
+
}
|
819
|
+
buf.data[len] = 0;
|
820
|
+
cont = (const unsigned char *)buf.data;
|
821
|
+
free_cont = 1;
|
822
|
+
} else {
|
823
|
+
cont = p;
|
824
|
+
len = plen;
|
825
|
+
p += plen;
|
826
|
+
}
|
827
|
+
|
828
|
+
/* We now have content length and type: translate into a structure */
|
829
|
+
if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
|
830
|
+
goto err;
|
831
|
+
|
832
|
+
*in = p;
|
833
|
+
ret = 1;
|
834
|
+
err:
|
835
|
+
if (free_cont && buf.data)
|
836
|
+
OPENSSL_free(buf.data);
|
837
|
+
return ret;
|
838
|
+
}
|
920
839
|
|
921
840
|
/* Translate ASN1 content octets into a structure */
|
922
841
|
|
923
842
|
int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
if (typ && (utype == V_ASN1_NULL))
|
1067
|
-
typ->value.ptr = NULL;
|
1068
|
-
|
1069
|
-
ret = 1;
|
1070
|
-
err:
|
1071
|
-
if (!ret)
|
1072
|
-
{
|
1073
|
-
ASN1_TYPE_free(typ);
|
1074
|
-
if (opval)
|
1075
|
-
*opval = NULL;
|
1076
|
-
}
|
1077
|
-
return ret;
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
|
1081
|
-
/* This function finds the end of an ASN1 structure when passed its maximum
|
1082
|
-
* length, whether it is indefinite length and a pointer to the content.
|
1083
|
-
* This is more efficient than calling asn1_collect because it does not
|
1084
|
-
* recurse on each indefinite length header.
|
843
|
+
int utype, char *free_cont, const ASN1_ITEM *it)
|
844
|
+
{
|
845
|
+
ASN1_VALUE **opval = NULL;
|
846
|
+
ASN1_STRING *stmp;
|
847
|
+
ASN1_TYPE *typ = NULL;
|
848
|
+
int ret = 0;
|
849
|
+
const ASN1_PRIMITIVE_FUNCS *pf;
|
850
|
+
ASN1_INTEGER **tint;
|
851
|
+
pf = it->funcs;
|
852
|
+
|
853
|
+
if (pf && pf->prim_c2i)
|
854
|
+
return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
|
855
|
+
/* If ANY type clear type and set pointer to internal value */
|
856
|
+
if (it->utype == V_ASN1_ANY) {
|
857
|
+
if (!*pval) {
|
858
|
+
typ = ASN1_TYPE_new();
|
859
|
+
if (typ == NULL)
|
860
|
+
goto err;
|
861
|
+
*pval = (ASN1_VALUE *)typ;
|
862
|
+
} else
|
863
|
+
typ = (ASN1_TYPE *)*pval;
|
864
|
+
|
865
|
+
if (utype != typ->type)
|
866
|
+
ASN1_TYPE_set(typ, utype, NULL);
|
867
|
+
opval = pval;
|
868
|
+
pval = &typ->value.asn1_value;
|
869
|
+
}
|
870
|
+
switch (utype) {
|
871
|
+
case V_ASN1_OBJECT:
|
872
|
+
if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len))
|
873
|
+
goto err;
|
874
|
+
break;
|
875
|
+
|
876
|
+
case V_ASN1_NULL:
|
877
|
+
if (len) {
|
878
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NULL_IS_WRONG_LENGTH);
|
879
|
+
goto err;
|
880
|
+
}
|
881
|
+
*pval = (ASN1_VALUE *)1;
|
882
|
+
break;
|
883
|
+
|
884
|
+
case V_ASN1_BOOLEAN:
|
885
|
+
if (len != 1) {
|
886
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BOOLEAN_IS_WRONG_LENGTH);
|
887
|
+
goto err;
|
888
|
+
} else {
|
889
|
+
ASN1_BOOLEAN *tbool;
|
890
|
+
tbool = (ASN1_BOOLEAN *)pval;
|
891
|
+
*tbool = *cont;
|
892
|
+
}
|
893
|
+
break;
|
894
|
+
|
895
|
+
case V_ASN1_BIT_STRING:
|
896
|
+
if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len))
|
897
|
+
goto err;
|
898
|
+
break;
|
899
|
+
|
900
|
+
case V_ASN1_INTEGER:
|
901
|
+
case V_ASN1_NEG_INTEGER:
|
902
|
+
case V_ASN1_ENUMERATED:
|
903
|
+
case V_ASN1_NEG_ENUMERATED:
|
904
|
+
tint = (ASN1_INTEGER **)pval;
|
905
|
+
if (!c2i_ASN1_INTEGER(tint, &cont, len))
|
906
|
+
goto err;
|
907
|
+
/* Fixup type to match the expected form */
|
908
|
+
(*tint)->type = utype | ((*tint)->type & V_ASN1_NEG);
|
909
|
+
break;
|
910
|
+
|
911
|
+
case V_ASN1_OCTET_STRING:
|
912
|
+
case V_ASN1_NUMERICSTRING:
|
913
|
+
case V_ASN1_PRINTABLESTRING:
|
914
|
+
case V_ASN1_T61STRING:
|
915
|
+
case V_ASN1_VIDEOTEXSTRING:
|
916
|
+
case V_ASN1_IA5STRING:
|
917
|
+
case V_ASN1_UTCTIME:
|
918
|
+
case V_ASN1_GENERALIZEDTIME:
|
919
|
+
case V_ASN1_GRAPHICSTRING:
|
920
|
+
case V_ASN1_VISIBLESTRING:
|
921
|
+
case V_ASN1_GENERALSTRING:
|
922
|
+
case V_ASN1_UNIVERSALSTRING:
|
923
|
+
case V_ASN1_BMPSTRING:
|
924
|
+
case V_ASN1_UTF8STRING:
|
925
|
+
case V_ASN1_OTHER:
|
926
|
+
case V_ASN1_SET:
|
927
|
+
case V_ASN1_SEQUENCE:
|
928
|
+
default:
|
929
|
+
if (utype == V_ASN1_BMPSTRING && (len & 1)) {
|
930
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BMPSTRING_IS_WRONG_LENGTH);
|
931
|
+
goto err;
|
932
|
+
}
|
933
|
+
if (utype == V_ASN1_UNIVERSALSTRING && (len & 3)) {
|
934
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH);
|
935
|
+
goto err;
|
936
|
+
}
|
937
|
+
/* All based on ASN1_STRING and handled the same */
|
938
|
+
if (!*pval) {
|
939
|
+
stmp = ASN1_STRING_type_new(utype);
|
940
|
+
if (!stmp) {
|
941
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
942
|
+
goto err;
|
943
|
+
}
|
944
|
+
*pval = (ASN1_VALUE *)stmp;
|
945
|
+
} else {
|
946
|
+
stmp = (ASN1_STRING *)*pval;
|
947
|
+
stmp->type = utype;
|
948
|
+
}
|
949
|
+
/* If we've already allocated a buffer use it */
|
950
|
+
if (*free_cont) {
|
951
|
+
if (stmp->data)
|
952
|
+
OPENSSL_free(stmp->data);
|
953
|
+
stmp->data = (unsigned char *)cont; /* UGLY CAST! RL */
|
954
|
+
stmp->length = len;
|
955
|
+
*free_cont = 0;
|
956
|
+
} else {
|
957
|
+
if (!ASN1_STRING_set(stmp, cont, len)) {
|
958
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
959
|
+
ASN1_STRING_free(stmp);
|
960
|
+
*pval = NULL;
|
961
|
+
goto err;
|
962
|
+
}
|
963
|
+
}
|
964
|
+
break;
|
965
|
+
}
|
966
|
+
/* If ASN1_ANY and NULL type fix up value */
|
967
|
+
if (typ && (utype == V_ASN1_NULL))
|
968
|
+
typ->value.ptr = NULL;
|
969
|
+
|
970
|
+
ret = 1;
|
971
|
+
err:
|
972
|
+
if (!ret) {
|
973
|
+
ASN1_TYPE_free(typ);
|
974
|
+
if (opval)
|
975
|
+
*opval = NULL;
|
976
|
+
}
|
977
|
+
return ret;
|
978
|
+
}
|
979
|
+
|
980
|
+
/*
|
981
|
+
* This function finds the end of an ASN1 structure when passed its maximum
|
982
|
+
* length, whether it is indefinite length and a pointer to the content. This
|
983
|
+
* is more efficient than calling asn1_collect because it does not recurse on
|
984
|
+
* each indefinite length header.
|
1085
985
|
*/
|
1086
986
|
|
1087
987
|
static int asn1_find_end(const unsigned char **in, long len, char inf)
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
* type into a buffer. The values of 'in' and 'len' should refer
|
1138
|
-
* to the contents of the constructed type and 'inf' should be set
|
1139
|
-
* if it is indefinite length.
|
988
|
+
{
|
989
|
+
int expected_eoc;
|
990
|
+
long plen;
|
991
|
+
const unsigned char *p = *in, *q;
|
992
|
+
/* If not indefinite length constructed just add length */
|
993
|
+
if (inf == 0) {
|
994
|
+
*in += len;
|
995
|
+
return 1;
|
996
|
+
}
|
997
|
+
expected_eoc = 1;
|
998
|
+
/*
|
999
|
+
* Indefinite length constructed form. Find the end when enough EOCs are
|
1000
|
+
* found. If more indefinite length constructed headers are encountered
|
1001
|
+
* increment the expected eoc count otherwise just skip to the end of the
|
1002
|
+
* data.
|
1003
|
+
*/
|
1004
|
+
while (len > 0) {
|
1005
|
+
if (asn1_check_eoc(&p, len)) {
|
1006
|
+
expected_eoc--;
|
1007
|
+
if (expected_eoc == 0)
|
1008
|
+
break;
|
1009
|
+
len -= 2;
|
1010
|
+
continue;
|
1011
|
+
}
|
1012
|
+
q = p;
|
1013
|
+
/* Just read in a header: only care about the length */
|
1014
|
+
if (!asn1_check_tlen(&plen, NULL, NULL, &inf, NULL, &p, len,
|
1015
|
+
-1, 0, 0, NULL)) {
|
1016
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
1017
|
+
return 0;
|
1018
|
+
}
|
1019
|
+
if (inf)
|
1020
|
+
expected_eoc++;
|
1021
|
+
else
|
1022
|
+
p += plen;
|
1023
|
+
len -= p - q;
|
1024
|
+
}
|
1025
|
+
if (expected_eoc) {
|
1026
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
1027
|
+
return 0;
|
1028
|
+
}
|
1029
|
+
*in = p;
|
1030
|
+
return 1;
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
/*
|
1034
|
+
* This function collects the asn1 data from a constructred string type into
|
1035
|
+
* a buffer. The values of 'in' and 'len' should refer to the contents of the
|
1036
|
+
* constructed type and 'inf' should be set if it is indefinite length.
|
1140
1037
|
*/
|
1141
1038
|
|
1142
1039
|
#ifndef ASN1_MAX_STRING_NEST
|
1143
|
-
/*
|
1144
|
-
*
|
1145
|
-
*
|
1146
|
-
*
|
1040
|
+
/*
|
1041
|
+
* This determines how many levels of recursion are permitted in ASN1 string
|
1042
|
+
* types. If it is not limited stack overflows can occur. If set to zero no
|
1043
|
+
* recursion is allowed at all. Although zero should be adequate examples
|
1044
|
+
* exist that require a value of 1. So 5 should be more than enough.
|
1147
1045
|
*/
|
1148
|
-
#define ASN1_MAX_STRING_NEST 5
|
1046
|
+
# define ASN1_MAX_STRING_NEST 5
|
1149
1047
|
#endif
|
1150
1048
|
|
1151
|
-
|
1152
1049
|
static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len,
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
{
|
1209
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
1210
|
-
return 0;
|
1211
|
-
}
|
1212
|
-
*in = p;
|
1213
|
-
return 1;
|
1214
|
-
}
|
1050
|
+
char inf, int tag, int aclass, int depth)
|
1051
|
+
{
|
1052
|
+
const unsigned char *p, *q;
|
1053
|
+
long plen;
|
1054
|
+
char cst, ininf;
|
1055
|
+
p = *in;
|
1056
|
+
inf &= 1;
|
1057
|
+
/*
|
1058
|
+
* If no buffer and not indefinite length constructed just pass over the
|
1059
|
+
* encoded data
|
1060
|
+
*/
|
1061
|
+
if (!buf && !inf) {
|
1062
|
+
*in += len;
|
1063
|
+
return 1;
|
1064
|
+
}
|
1065
|
+
while (len > 0) {
|
1066
|
+
q = p;
|
1067
|
+
/* Check for EOC */
|
1068
|
+
if (asn1_check_eoc(&p, len)) {
|
1069
|
+
/*
|
1070
|
+
* EOC is illegal outside indefinite length constructed form
|
1071
|
+
*/
|
1072
|
+
if (!inf) {
|
1073
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNEXPECTED_EOC);
|
1074
|
+
return 0;
|
1075
|
+
}
|
1076
|
+
inf = 0;
|
1077
|
+
break;
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
if (!asn1_check_tlen(&plen, NULL, NULL, &ininf, &cst, &p,
|
1081
|
+
len, tag, aclass, 0, NULL)) {
|
1082
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
|
1083
|
+
return 0;
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
/* If indefinite length constructed update max length */
|
1087
|
+
if (cst) {
|
1088
|
+
if (depth >= ASN1_MAX_STRING_NEST) {
|
1089
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_STRING);
|
1090
|
+
return 0;
|
1091
|
+
}
|
1092
|
+
if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, depth + 1))
|
1093
|
+
return 0;
|
1094
|
+
} else if (plen && !collect_data(buf, &p, plen))
|
1095
|
+
return 0;
|
1096
|
+
len -= p - q;
|
1097
|
+
}
|
1098
|
+
if (inf) {
|
1099
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_EOC);
|
1100
|
+
return 0;
|
1101
|
+
}
|
1102
|
+
*in = p;
|
1103
|
+
return 1;
|
1104
|
+
}
|
1215
1105
|
|
1216
1106
|
static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen)
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
return 1;
|
1231
|
-
}
|
1107
|
+
{
|
1108
|
+
int len;
|
1109
|
+
if (buf) {
|
1110
|
+
len = buf->length;
|
1111
|
+
if (!BUF_MEM_grow_clean(buf, len + plen)) {
|
1112
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
1113
|
+
return 0;
|
1114
|
+
}
|
1115
|
+
memcpy(buf->data + len, *p, plen);
|
1116
|
+
}
|
1117
|
+
*p += plen;
|
1118
|
+
return 1;
|
1119
|
+
}
|
1232
1120
|
|
1233
1121
|
/* Check for ASN1 EOC and swallow it if found */
|
1234
1122
|
|
1235
1123
|
static int asn1_check_eoc(const unsigned char **in, long len)
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
/*
|
1249
|
-
*
|
1250
|
-
* form, we don't know the exact
|
1251
|
-
* upper bound to the amount of data available minus
|
1252
|
-
* header length just read.
|
1124
|
+
{
|
1125
|
+
const unsigned char *p;
|
1126
|
+
if (len < 2)
|
1127
|
+
return 0;
|
1128
|
+
p = *in;
|
1129
|
+
if (!p[0] && !p[1]) {
|
1130
|
+
*in += 2;
|
1131
|
+
return 1;
|
1132
|
+
}
|
1133
|
+
return 0;
|
1134
|
+
}
|
1135
|
+
|
1136
|
+
/*
|
1137
|
+
* Check an ASN1 tag and length: a bit like ASN1_get_object but it sets the
|
1138
|
+
* length for indefinite length constructed form, we don't know the exact
|
1139
|
+
* length but we can set an upper bound to the amount of data available minus
|
1140
|
+
* the header length just read.
|
1253
1141
|
*/
|
1254
1142
|
|
1255
1143
|
static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
*otag = ptag;
|
1339
|
-
|
1340
|
-
*in = p;
|
1341
|
-
return 1;
|
1342
|
-
}
|
1144
|
+
char *inf, char *cst,
|
1145
|
+
const unsigned char **in, long len,
|
1146
|
+
int exptag, int expclass, char opt, ASN1_TLC *ctx)
|
1147
|
+
{
|
1148
|
+
int i;
|
1149
|
+
int ptag, pclass;
|
1150
|
+
long plen;
|
1151
|
+
const unsigned char *p, *q;
|
1152
|
+
p = *in;
|
1153
|
+
q = p;
|
1154
|
+
|
1155
|
+
if (ctx && ctx->valid) {
|
1156
|
+
i = ctx->ret;
|
1157
|
+
plen = ctx->plen;
|
1158
|
+
pclass = ctx->pclass;
|
1159
|
+
ptag = ctx->ptag;
|
1160
|
+
p += ctx->hdrlen;
|
1161
|
+
} else {
|
1162
|
+
i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);
|
1163
|
+
if (ctx) {
|
1164
|
+
ctx->ret = i;
|
1165
|
+
ctx->plen = plen;
|
1166
|
+
ctx->pclass = pclass;
|
1167
|
+
ctx->ptag = ptag;
|
1168
|
+
ctx->hdrlen = p - q;
|
1169
|
+
ctx->valid = 1;
|
1170
|
+
/*
|
1171
|
+
* If definite length, and no error, length + header can't exceed
|
1172
|
+
* total amount of data available.
|
1173
|
+
*/
|
1174
|
+
if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) {
|
1175
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
|
1176
|
+
asn1_tlc_clear(ctx);
|
1177
|
+
return 0;
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
if (i & 0x80) {
|
1183
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_OBJECT_HEADER);
|
1184
|
+
asn1_tlc_clear(ctx);
|
1185
|
+
return 0;
|
1186
|
+
}
|
1187
|
+
if (exptag >= 0) {
|
1188
|
+
if ((exptag != ptag) || (expclass != pclass)) {
|
1189
|
+
/*
|
1190
|
+
* If type is OPTIONAL, not an error: indicate missing type.
|
1191
|
+
*/
|
1192
|
+
if (opt)
|
1193
|
+
return -1;
|
1194
|
+
asn1_tlc_clear(ctx);
|
1195
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TAG);
|
1196
|
+
return 0;
|
1197
|
+
}
|
1198
|
+
/*
|
1199
|
+
* We have a tag and class match: assume we are going to do something
|
1200
|
+
* with it
|
1201
|
+
*/
|
1202
|
+
asn1_tlc_clear(ctx);
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
if (i & 1)
|
1206
|
+
plen = len - (p - q);
|
1207
|
+
|
1208
|
+
if (inf)
|
1209
|
+
*inf = i & 1;
|
1210
|
+
|
1211
|
+
if (cst)
|
1212
|
+
*cst = i & V_ASN1_CONSTRUCTED;
|
1213
|
+
|
1214
|
+
if (olen)
|
1215
|
+
*olen = plen;
|
1216
|
+
|
1217
|
+
if (oclass)
|
1218
|
+
*oclass = pclass;
|
1219
|
+
|
1220
|
+
if (otag)
|
1221
|
+
*otag = ptag;
|
1222
|
+
|
1223
|
+
*in = p;
|
1224
|
+
return 1;
|
1225
|
+
}
|