grpc 0.12.0 → 0.13.0.pre1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/Makefile +5707 -22222
 - data/include/grpc/byte_buffer.h +2 -83
 - data/include/grpc/census.h +191 -121
 - data/include/grpc/compression.h +14 -38
 - data/include/grpc/grpc.h +88 -434
 - data/include/grpc/grpc_security.h +76 -46
 - data/include/grpc/grpc_zookeeper.h +1 -1
 - data/include/grpc/impl/codegen/alloc.h +74 -0
 - data/include/grpc/impl/codegen/atm.h +92 -0
 - data/include/grpc/impl/codegen/atm_gcc_atomic.h +72 -0
 - data/include/grpc/impl/codegen/atm_gcc_sync.h +87 -0
 - data/include/grpc/impl/codegen/atm_win32.h +125 -0
 - data/include/grpc/impl/codegen/byte_buffer.h +121 -0
 - data/include/grpc/impl/codegen/compression_types.h +73 -0
 - data/include/grpc/impl/codegen/connectivity_state.h +59 -0
 - data/include/grpc/impl/codegen/grpc_types.h +373 -0
 - data/include/grpc/impl/codegen/log.h +110 -0
 - data/include/grpc/impl/codegen/port_platform.h +362 -0
 - data/include/grpc/impl/codegen/propagation_bits.h +67 -0
 - data/include/grpc/impl/codegen/slice.h +182 -0
 - data/include/grpc/impl/codegen/slice_buffer.h +105 -0
 - data/include/grpc/impl/codegen/status.h +163 -0
 - data/include/grpc/impl/codegen/sync.h +316 -0
 - data/include/grpc/impl/codegen/sync_generic.h +55 -0
 - data/{src/core/census/context.h → include/grpc/impl/codegen/sync_posix.h} +11 -11
 - data/include/grpc/impl/codegen/sync_win32.h +49 -0
 - data/include/grpc/impl/codegen/time.h +132 -0
 - data/include/grpc/status.h +2 -126
 - data/include/grpc/support/alloc.h +2 -35
 - data/include/grpc/support/atm.h +2 -55
 - data/include/grpc/support/atm_gcc_atomic.h +5 -38
 - data/include/grpc/support/atm_gcc_sync.h +2 -50
 - data/include/grpc/support/atm_win32.h +2 -88
 - data/include/grpc/support/avl.h +7 -7
 - data/include/grpc/support/cmdline.h +15 -13
 - data/include/grpc/support/cpu.h +5 -3
 - data/include/grpc/support/histogram.h +23 -20
 - data/include/grpc/support/host_port.h +5 -3
 - data/include/grpc/support/log.h +2 -71
 - data/include/grpc/support/log_win32.h +2 -2
 - data/include/grpc/support/port_platform.h +2 -319
 - data/include/grpc/support/slice.h +2 -145
 - data/include/grpc/support/slice_buffer.h +2 -65
 - data/include/grpc/support/string_util.h +3 -3
 - data/include/grpc/support/subprocess.h +8 -6
 - data/include/grpc/support/sync.h +2 -278
 - data/include/grpc/support/sync_generic.h +2 -18
 - data/include/grpc/support/sync_posix.h +2 -10
 - data/include/grpc/support/sync_win32.h +2 -12
 - data/include/grpc/support/thd.h +11 -11
 - data/include/grpc/support/time.h +2 -91
 - data/include/grpc/support/tls.h +1 -1
 - data/include/grpc/support/tls_gcc.h +1 -1
 - data/include/grpc/support/tls_msvc.h +1 -1
 - data/include/grpc/support/tls_pthread.h +2 -2
 - data/src/boringssl/err_data.c +1252 -0
 - data/src/core/census/context.c +492 -8
 - data/src/core/census/grpc_filter.c +3 -3
 - data/src/core/census/initialize.c +4 -7
 - data/src/core/census/operation.c +2 -2
 - data/src/core/census/placeholders.c +109 -0
 - data/src/core/census/rpc_metric_id.h +6 -6
 - data/src/core/census/tracing.c +1 -1
 - data/src/core/channel/channel_args.c +4 -3
 - data/src/core/channel/channel_stack.c +1 -1
 - data/src/core/channel/client_channel.c +18 -14
 - data/src/core/channel/client_uchannel.c +3 -3
 - data/src/core/channel/compress_filter.c +8 -8
 - data/src/core/channel/http_client_filter.c +2 -2
 - data/src/core/channel/http_server_filter.c +9 -9
 - data/src/core/channel/subchannel_call_holder.c +12 -10
 - data/src/core/client_config/lb_policies/pick_first.c +49 -31
 - data/src/core/client_config/lb_policies/round_robin.c +7 -7
 - data/src/core/client_config/resolvers/dns_resolver.c +3 -3
 - data/src/core/client_config/resolvers/sockaddr_resolver.c +5 -5
 - data/src/core/client_config/subchannel.c +36 -25
 - data/src/core/compression/algorithm.c +3 -3
 - data/src/core/httpcli/format_request.c +1 -1
 - data/src/core/httpcli/httpcli.c +5 -5
 - data/src/core/httpcli/httpcli_security_connector.c +2 -3
 - data/src/core/httpcli/parser.c +7 -7
 - data/src/core/httpcli/parser.h +1 -1
 - data/src/core/iomgr/closure.c +7 -7
 - data/src/core/iomgr/closure.h +6 -5
 - data/src/core/iomgr/exec_ctx.c +12 -8
 - data/src/core/iomgr/exec_ctx.h +12 -5
 - data/src/core/iomgr/executor.c +4 -4
 - data/src/core/iomgr/executor.h +2 -2
 - data/src/core/iomgr/fd_posix.c +28 -17
 - data/src/core/iomgr/fd_posix.h +7 -4
 - data/src/core/iomgr/iocp_windows.c +6 -8
 - data/src/core/iomgr/pollset_multipoller_with_epoll.c +70 -5
 - data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +4 -2
 - data/src/core/iomgr/pollset_posix.c +15 -15
 - data/src/core/iomgr/pollset_posix.h +4 -2
 - data/src/core/iomgr/pollset_windows.c +3 -12
 - data/src/core/iomgr/resolve_address_posix.c +2 -2
 - data/src/core/iomgr/resolve_address_windows.c +2 -2
 - data/src/core/iomgr/sockaddr_utils.c +6 -6
 - data/src/core/iomgr/sockaddr_win32.h +1 -6
 - data/src/core/iomgr/tcp_client_posix.c +7 -7
 - data/src/core/iomgr/tcp_client_windows.c +4 -4
 - data/src/core/iomgr/tcp_posix.c +14 -8
 - data/src/core/iomgr/tcp_posix.h +7 -1
 - data/src/core/iomgr/tcp_server.h +40 -20
 - data/src/core/iomgr/tcp_server_posix.c +106 -49
 - data/src/core/iomgr/tcp_server_windows.c +98 -49
 - data/src/core/iomgr/tcp_windows.c +11 -15
 - data/src/core/iomgr/timer.c +8 -8
 - data/src/core/iomgr/timer.h +1 -1
 - data/src/core/iomgr/timer_heap.c +10 -10
 - data/src/core/iomgr/timer_heap.h +2 -2
 - data/src/core/iomgr/udp_server.c +2 -12
 - data/src/core/iomgr/udp_server.h +1 -9
 - data/src/core/iomgr/workqueue.h +2 -4
 - data/src/core/iomgr/workqueue_posix.c +3 -3
 - data/src/core/json/json_reader.c +11 -12
 - data/src/core/json/json_reader.h +4 -4
 - data/src/core/json/json_string.c +19 -19
 - data/src/core/json/json_writer.c +7 -9
 - data/src/core/profiling/basic_timers.c +1 -1
 - data/src/core/security/base64.c +9 -9
 - data/src/core/security/client_auth_filter.c +4 -4
 - data/src/core/security/credentials.c +5 -5
 - data/src/core/security/google_default_credentials.c +3 -3
 - data/src/core/security/handshake.c +6 -5
 - data/src/core/security/json_token.c +13 -7
 - data/src/core/security/jwt_verifier.c +3 -2
 - data/src/core/security/secure_endpoint.c +16 -16
 - data/src/core/security/security_connector.c +47 -17
 - data/src/core/security/security_connector.h +5 -5
 - data/src/core/security/server_auth_filter.c +3 -3
 - data/src/core/security/server_secure_chttp2.c +30 -31
 - data/src/core/statistics/census_interface.h +2 -2
 - data/src/core/statistics/census_rpc_stats.h +3 -3
 - data/src/core/support/alloc.c +1 -1
 - data/src/core/support/cpu_posix.c +2 -2
 - data/src/core/support/env_linux.c +12 -2
 - data/src/core/support/env_win32.c +15 -7
 - data/src/core/support/histogram.c +5 -5
 - data/src/core/support/log_posix.c +1 -1
 - data/src/core/support/log_win32.c +4 -3
 - data/src/core/support/murmur_hash.c +11 -11
 - data/src/core/support/murmur_hash.h +1 -1
 - data/src/core/support/slice.c +11 -11
 - data/src/core/support/slice_buffer.c +6 -6
 - data/src/core/support/stack_lockfree.c +20 -10
 - data/src/core/support/string.c +15 -15
 - data/src/core/support/string.h +5 -5
 - data/src/core/support/string_win32.c +5 -5
 - data/src/core/support/subprocess_windows.c +141 -0
 - data/src/core/support/sync.c +4 -4
 - data/src/core/support/sync_posix.c +2 -2
 - data/src/core/support/sync_win32.c +10 -5
 - data/src/core/support/time.c +29 -29
 - data/src/core/support/time_posix.c +15 -6
 - data/src/core/support/time_precise.c +2 -2
 - data/src/core/support/time_win32.c +18 -9
 - data/src/core/support/tls_pthread.c +1 -1
 - data/src/core/support/wrap_memcpy.c +53 -0
 - data/src/core/surface/alarm.c +83 -0
 - data/src/core/surface/byte_buffer_reader.c +1 -1
 - data/src/core/surface/call.c +78 -69
 - data/src/core/surface/call.h +2 -2
 - data/src/core/surface/call_test_only.h +2 -2
 - data/src/core/surface/channel.c +9 -9
 - data/src/core/surface/channel.h +1 -1
 - data/src/core/surface/channel_connectivity.c +3 -3
 - data/src/core/surface/channel_create.c +3 -3
 - data/src/core/surface/channel_ping.c +2 -2
 - data/src/core/surface/completion_queue.c +11 -12
 - data/src/core/surface/completion_queue.h +1 -1
 - data/src/core/surface/init.c +7 -5
 - data/src/core/surface/lame_client.c +3 -3
 - data/src/core/surface/secure_channel_create.c +3 -3
 - data/src/core/surface/server.c +28 -28
 - data/src/core/surface/server_chttp2.c +8 -8
 - data/src/core/surface/server_create.c +1 -4
 - data/src/core/surface/validate_metadata.c +3 -3
 - data/src/core/surface/version.c +2 -2
 - data/src/core/transport/byte_stream.c +8 -6
 - data/src/core/transport/byte_stream.h +6 -5
 - data/src/core/transport/chttp2/bin_encoder.c +29 -29
 - data/src/core/transport/chttp2/frame_data.c +29 -26
 - data/src/core/transport/chttp2/frame_data.h +6 -6
 - data/src/core/transport/chttp2/frame_goaway.c +30 -30
 - data/src/core/transport/chttp2/frame_goaway.h +6 -6
 - data/src/core/transport/chttp2/frame_ping.c +6 -6
 - data/src/core/transport/chttp2/frame_ping.h +5 -5
 - data/src/core/transport/chttp2/frame_rst_stream.c +18 -19
 - data/src/core/transport/chttp2/frame_rst_stream.h +4 -4
 - data/src/core/transport/chttp2/frame_settings.c +30 -30
 - data/src/core/transport/chttp2/frame_settings.h +13 -13
 - data/src/core/transport/chttp2/frame_window_update.c +17 -18
 - data/src/core/transport/chttp2/frame_window_update.h +5 -7
 - data/src/core/transport/chttp2/hpack_encoder.c +69 -73
 - data/src/core/transport/chttp2/hpack_encoder.h +16 -16
 - data/src/core/transport/chttp2/hpack_parser.c +167 -167
 - data/src/core/transport/chttp2/hpack_parser.h +16 -16
 - data/src/core/transport/chttp2/hpack_table.c +13 -13
 - data/src/core/transport/chttp2/hpack_table.h +11 -11
 - data/src/core/transport/chttp2/internal.h +97 -86
 - data/src/core/transport/chttp2/parsing.c +25 -25
 - data/src/core/transport/chttp2/stream_lists.c +26 -3
 - data/src/core/transport/chttp2/stream_map.c +13 -14
 - data/src/core/transport/chttp2/stream_map.h +6 -7
 - data/src/core/transport/chttp2/timeout_encoding.c +19 -16
 - data/src/core/transport/chttp2/varint.c +8 -9
 - data/src/core/transport/chttp2/varint.h +7 -8
 - data/src/core/transport/chttp2/writing.c +26 -23
 - data/src/core/transport/chttp2_transport.c +133 -92
 - data/src/core/transport/connectivity_state.c +6 -6
 - data/src/core/transport/metadata.c +18 -18
 - data/src/core/transport/metadata.h +5 -5
 - data/src/core/transport/static_metadata.c +15 -16
 - data/src/core/transport/static_metadata.h +5 -5
 - data/src/core/transport/transport.c +5 -5
 - data/src/core/transport/transport.h +14 -1
 - data/src/core/tsi/fake_transport_security.c +7 -7
 - data/src/core/tsi/ssl_transport_security.c +6 -4
 - data/src/core/tsi/ssl_types.h +55 -0
 - data/src/ruby/ext/grpc/extconf.rb +51 -14
 - data/src/ruby/ext/grpc/rb_byte_buffer.c +3 -1
 - data/src/ruby/ext/grpc/rb_call.c +6 -3
 - data/src/ruby/ext/grpc/rb_call_credentials.c +4 -0
 - data/src/ruby/ext/grpc/rb_channel.c +4 -2
 - data/src/ruby/ext/grpc/rb_channel_args.c +3 -1
 - data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -1
 - data/src/ruby/ext/grpc/rb_completion_queue.c +3 -1
 - data/src/ruby/ext/grpc/rb_event_thread.c +5 -0
 - data/src/ruby/ext/grpc/rb_grpc.c +11 -3
 - data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +560 -0
 - data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +843 -0
 - data/src/ruby/ext/grpc/rb_loader.c +72 -0
 - data/src/ruby/ext/grpc/rb_loader.h +40 -0
 - data/src/ruby/ext/grpc/rb_server.c +3 -1
 - data/src/ruby/ext/grpc/rb_server_credentials.c +4 -2
 - data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
 - data/src/ruby/lib/grpc/generic/rpc_desc.rb +1 -1
 - data/src/ruby/lib/grpc/generic/rpc_server.rb +1 -1
 - data/src/ruby/lib/grpc/grpc.rb +34 -0
 - data/src/ruby/lib/grpc/version.rb +1 -1
 - data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
 - data/third_party/boringssl/crypto/aes/aes.c +1142 -0
 - data/third_party/boringssl/crypto/aes/internal.h +87 -0
 - data/third_party/boringssl/crypto/aes/mode_wrappers.c +108 -0
 - data/third_party/boringssl/crypto/asn1/a_bitstr.c +255 -0
 - data/third_party/boringssl/crypto/asn1/a_bool.c +112 -0
 - data/third_party/boringssl/crypto/asn1/a_bytes.c +317 -0
 - data/third_party/boringssl/crypto/asn1/a_d2i_fp.c +286 -0
 - data/third_party/boringssl/crypto/asn1/a_dup.c +103 -0
 - data/third_party/boringssl/crypto/asn1/a_enum.c +183 -0
 - data/third_party/boringssl/crypto/asn1/a_gentm.c +255 -0
 - data/third_party/boringssl/crypto/asn1/a_i2d_fp.c +154 -0
 - data/third_party/boringssl/crypto/asn1/a_int.c +456 -0
 - data/third_party/boringssl/crypto/asn1/a_mbstr.c +390 -0
 - data/third_party/boringssl/crypto/asn1/a_object.c +412 -0
 - data/third_party/boringssl/crypto/asn1/a_octet.c +70 -0
 - data/third_party/boringssl/crypto/asn1/a_print.c +119 -0
 - data/third_party/boringssl/crypto/asn1/a_strnid.c +286 -0
 - data/third_party/boringssl/crypto/asn1/a_time.c +221 -0
 - data/third_party/boringssl/crypto/asn1/a_type.c +160 -0
 - data/third_party/boringssl/crypto/asn1/a_utctm.c +342 -0
 - data/third_party/boringssl/crypto/asn1/a_utf8.c +210 -0
 - data/third_party/boringssl/crypto/asn1/asn1_lib.c +510 -0
 - data/third_party/boringssl/crypto/asn1/asn1_locl.h +73 -0
 - data/third_party/boringssl/crypto/asn1/asn1_par.c +444 -0
 - data/third_party/boringssl/crypto/asn1/asn_pack.c +104 -0
 - data/third_party/boringssl/crypto/asn1/bio_asn1.c +496 -0
 - data/third_party/boringssl/crypto/asn1/bio_ndef.c +254 -0
 - data/third_party/boringssl/crypto/asn1/f_enum.c +206 -0
 - data/third_party/boringssl/crypto/asn1/f_int.c +210 -0
 - data/third_party/boringssl/crypto/asn1/f_string.c +204 -0
 - data/third_party/boringssl/crypto/asn1/t_bitst.c +102 -0
 - data/third_party/boringssl/crypto/asn1/t_pkey.c +112 -0
 - data/third_party/boringssl/crypto/asn1/tasn_dec.c +1342 -0
 - data/third_party/boringssl/crypto/asn1/tasn_enc.c +695 -0
 - data/third_party/boringssl/crypto/asn1/tasn_fre.c +264 -0
 - data/third_party/boringssl/crypto/asn1/tasn_new.c +398 -0
 - data/third_party/boringssl/crypto/asn1/tasn_prn.c +642 -0
 - data/third_party/boringssl/crypto/asn1/tasn_typ.c +137 -0
 - data/third_party/boringssl/crypto/asn1/tasn_utl.c +266 -0
 - data/third_party/boringssl/crypto/asn1/x_bignum.c +143 -0
 - data/third_party/boringssl/crypto/asn1/x_long.c +182 -0
 - data/third_party/boringssl/crypto/base64/base64.c +478 -0
 - data/third_party/boringssl/crypto/bio/bio.c +608 -0
 - data/third_party/boringssl/crypto/bio/bio_mem.c +327 -0
 - data/third_party/boringssl/crypto/bio/buffer.c +496 -0
 - data/third_party/boringssl/crypto/bio/connect.c +544 -0
 - data/third_party/boringssl/crypto/bio/fd.c +270 -0
 - data/third_party/boringssl/crypto/bio/file.c +349 -0
 - data/third_party/boringssl/crypto/bio/hexdump.c +192 -0
 - data/third_party/boringssl/crypto/bio/internal.h +108 -0
 - data/third_party/boringssl/crypto/bio/pair.c +803 -0
 - data/third_party/boringssl/crypto/bio/printf.c +119 -0
 - data/third_party/boringssl/crypto/bio/socket.c +195 -0
 - data/third_party/boringssl/crypto/bio/socket_helper.c +113 -0
 - data/third_party/boringssl/crypto/bn/add.c +377 -0
 - data/third_party/boringssl/crypto/bn/asm/x86_64-gcc.c +599 -0
 - data/third_party/boringssl/crypto/bn/bn.c +341 -0
 - data/third_party/boringssl/crypto/bn/bn_asn1.c +93 -0
 - data/third_party/boringssl/crypto/bn/cmp.c +200 -0
 - data/third_party/boringssl/crypto/bn/convert.c +597 -0
 - data/third_party/boringssl/crypto/bn/ctx.c +311 -0
 - data/third_party/boringssl/crypto/bn/div.c +625 -0
 - data/third_party/boringssl/crypto/bn/exponentiation.c +1544 -0
 - data/third_party/boringssl/crypto/bn/gcd.c +711 -0
 - data/third_party/boringssl/crypto/bn/generic.c +1019 -0
 - data/third_party/boringssl/crypto/bn/internal.h +294 -0
 - data/third_party/boringssl/crypto/bn/kronecker.c +175 -0
 - data/third_party/boringssl/crypto/bn/montgomery.c +561 -0
 - data/third_party/boringssl/crypto/bn/mul.c +888 -0
 - data/third_party/boringssl/crypto/bn/prime.c +845 -0
 - data/third_party/boringssl/crypto/bn/random.c +326 -0
 - data/third_party/boringssl/crypto/bn/rsaz_exp.c +326 -0
 - data/third_party/boringssl/crypto/bn/rsaz_exp.h +56 -0
 - data/third_party/boringssl/crypto/bn/shift.c +299 -0
 - data/third_party/boringssl/crypto/bn/sqrt.c +505 -0
 - data/third_party/boringssl/crypto/buf/buf.c +235 -0
 - data/third_party/boringssl/crypto/bytestring/ber.c +221 -0
 - data/third_party/boringssl/crypto/bytestring/cbb.c +411 -0
 - data/third_party/boringssl/crypto/bytestring/cbs.c +415 -0
 - data/third_party/boringssl/crypto/bytestring/internal.h +46 -0
 - data/third_party/boringssl/crypto/chacha/chacha_generic.c +140 -0
 - data/third_party/boringssl/crypto/chacha/chacha_vec.c +323 -0
 - data/third_party/boringssl/crypto/cipher/aead.c +167 -0
 - data/third_party/boringssl/crypto/cipher/cipher.c +652 -0
 - data/third_party/boringssl/crypto/cipher/derive_key.c +154 -0
 - data/third_party/boringssl/crypto/cipher/e_aes.c +1767 -0
 - data/third_party/boringssl/crypto/cipher/e_chacha20poly1305.c +311 -0
 - data/third_party/boringssl/crypto/cipher/e_des.c +207 -0
 - data/third_party/boringssl/crypto/cipher/e_null.c +85 -0
 - data/third_party/boringssl/crypto/cipher/e_rc2.c +443 -0
 - data/third_party/boringssl/crypto/cipher/e_rc4.c +87 -0
 - data/third_party/boringssl/crypto/cipher/e_ssl3.c +463 -0
 - data/third_party/boringssl/crypto/cipher/e_tls.c +673 -0
 - data/third_party/boringssl/crypto/cipher/internal.h +164 -0
 - data/third_party/boringssl/crypto/cipher/tls_cbc.c +495 -0
 - data/third_party/boringssl/crypto/cmac/cmac.c +239 -0
 - data/third_party/boringssl/crypto/conf/conf.c +778 -0
 - data/third_party/boringssl/crypto/conf/conf_def.h +127 -0
 - data/third_party/boringssl/crypto/conf/internal.h +31 -0
 - data/third_party/boringssl/crypto/cpu-arm.c +199 -0
 - data/third_party/boringssl/crypto/cpu-intel.c +261 -0
 - data/third_party/boringssl/crypto/crypto.c +140 -0
 - data/third_party/boringssl/crypto/curve25519/curve25519.c +4897 -0
 - data/third_party/boringssl/crypto/des/des.c +771 -0
 - data/third_party/boringssl/crypto/des/internal.h +212 -0
 - data/third_party/boringssl/crypto/dh/check.c +180 -0
 - data/third_party/boringssl/crypto/dh/dh.c +463 -0
 - data/third_party/boringssl/crypto/dh/dh_asn1.c +84 -0
 - data/third_party/boringssl/crypto/dh/internal.h +80 -0
 - data/third_party/boringssl/crypto/dh/params.c +301 -0
 - data/third_party/boringssl/crypto/digest/digest.c +248 -0
 - data/third_party/boringssl/crypto/digest/digests.c +321 -0
 - data/third_party/boringssl/crypto/digest/internal.h +112 -0
 - data/third_party/boringssl/crypto/digest/md32_common.h +322 -0
 - data/third_party/boringssl/crypto/directory.h +66 -0
 - data/third_party/boringssl/crypto/directory_posix.c +108 -0
 - data/third_party/boringssl/crypto/directory_win.c +144 -0
 - data/third_party/boringssl/crypto/dsa/dsa.c +908 -0
 - data/third_party/boringssl/crypto/dsa/dsa_asn1.c +150 -0
 - data/third_party/boringssl/crypto/dsa/internal.h +78 -0
 - data/third_party/boringssl/crypto/ec/ec.c +889 -0
 - data/third_party/boringssl/crypto/ec/ec_asn1.c +586 -0
 - data/third_party/boringssl/crypto/ec/ec_key.c +482 -0
 - data/third_party/boringssl/crypto/ec/ec_montgomery.c +280 -0
 - data/third_party/boringssl/crypto/ec/internal.h +318 -0
 - data/third_party/boringssl/crypto/ec/oct.c +416 -0
 - data/third_party/boringssl/crypto/ec/p224-64.c +1305 -0
 - data/third_party/boringssl/crypto/ec/p256-64.c +1878 -0
 - data/third_party/boringssl/crypto/ec/p256-x86_64-table.h +9548 -0
 - data/third_party/boringssl/crypto/ec/p256-x86_64.c +596 -0
 - data/third_party/boringssl/crypto/ec/simple.c +1313 -0
 - data/third_party/boringssl/crypto/ec/util-64.c +183 -0
 - data/third_party/boringssl/crypto/ec/wnaf.c +449 -0
 - data/third_party/boringssl/crypto/ecdh/ecdh.c +153 -0
 - data/third_party/boringssl/crypto/ecdsa/ecdsa.c +496 -0
 - data/third_party/boringssl/crypto/ecdsa/ecdsa_asn1.c +240 -0
 - data/third_party/boringssl/crypto/engine/engine.c +96 -0
 - data/third_party/boringssl/crypto/err/err.c +756 -0
 - data/third_party/boringssl/crypto/evp/algorithm.c +153 -0
 - data/third_party/boringssl/crypto/evp/digestsign.c +159 -0
 - data/third_party/boringssl/crypto/evp/evp.c +411 -0
 - data/third_party/boringssl/crypto/evp/evp_asn1.c +179 -0
 - data/third_party/boringssl/crypto/evp/evp_ctx.c +477 -0
 - data/third_party/boringssl/crypto/evp/internal.h +278 -0
 - data/third_party/boringssl/crypto/evp/p_dsa_asn1.c +588 -0
 - data/third_party/boringssl/crypto/evp/p_ec.c +283 -0
 - data/third_party/boringssl/crypto/evp/p_ec_asn1.c +562 -0
 - data/third_party/boringssl/crypto/evp/p_rsa.c +596 -0
 - data/third_party/boringssl/crypto/evp/p_rsa_asn1.c +737 -0
 - data/third_party/boringssl/crypto/evp/pbkdf.c +151 -0
 - data/third_party/boringssl/crypto/evp/sign.c +151 -0
 - data/third_party/boringssl/crypto/ex_data.c +294 -0
 - data/third_party/boringssl/crypto/hkdf/hkdf.c +89 -0
 - data/third_party/boringssl/crypto/hmac/hmac.c +213 -0
 - data/third_party/boringssl/crypto/internal.h +532 -0
 - data/third_party/boringssl/crypto/lhash/lhash.c +346 -0
 - data/third_party/boringssl/crypto/md4/md4.c +225 -0
 - data/third_party/boringssl/crypto/md5/md5.c +275 -0
 - data/third_party/boringssl/crypto/mem.c +200 -0
 - data/third_party/boringssl/crypto/modes/cbc.c +216 -0
 - data/third_party/boringssl/crypto/modes/cfb.c +231 -0
 - data/third_party/boringssl/crypto/modes/ctr.c +226 -0
 - data/third_party/boringssl/crypto/modes/gcm.c +1252 -0
 - data/third_party/boringssl/crypto/modes/internal.h +370 -0
 - data/third_party/boringssl/crypto/modes/ofb.c +108 -0
 - data/third_party/boringssl/crypto/obj/obj.c +664 -0
 - data/third_party/boringssl/crypto/obj/obj_dat.h +5257 -0
 - data/third_party/boringssl/crypto/obj/obj_xref.c +124 -0
 - data/third_party/boringssl/crypto/obj/obj_xref.h +96 -0
 - data/third_party/boringssl/crypto/pem/pem_all.c +281 -0
 - data/third_party/boringssl/crypto/pem/pem_info.c +404 -0
 - data/third_party/boringssl/crypto/pem/pem_lib.c +835 -0
 - data/third_party/boringssl/crypto/pem/pem_oth.c +89 -0
 - data/third_party/boringssl/crypto/pem/pem_pk8.c +244 -0
 - data/third_party/boringssl/crypto/pem/pem_pkey.c +312 -0
 - data/third_party/boringssl/crypto/pem/pem_x509.c +65 -0
 - data/third_party/boringssl/crypto/pem/pem_xaux.c +66 -0
 - data/third_party/boringssl/crypto/pkcs8/internal.h +83 -0
 - data/third_party/boringssl/crypto/pkcs8/p5_pbe.c +150 -0
 - data/third_party/boringssl/crypto/pkcs8/p5_pbev2.c +440 -0
 - data/third_party/boringssl/crypto/pkcs8/p8_pkey.c +85 -0
 - data/third_party/boringssl/crypto/pkcs8/pkcs8.c +1217 -0
 - data/third_party/boringssl/crypto/poly1305/poly1305.c +331 -0
 - data/third_party/boringssl/crypto/poly1305/poly1305_arm.c +301 -0
 - data/third_party/boringssl/crypto/poly1305/poly1305_vec.c +892 -0
 - data/third_party/boringssl/crypto/rand/internal.h +32 -0
 - data/third_party/boringssl/crypto/rand/rand.c +239 -0
 - data/third_party/boringssl/crypto/rand/urandom.c +223 -0
 - data/third_party/boringssl/crypto/rand/windows.c +56 -0
 - data/third_party/boringssl/crypto/rc4/rc4.c +283 -0
 - data/third_party/boringssl/crypto/refcount_c11.c +67 -0
 - data/third_party/boringssl/crypto/refcount_lock.c +53 -0
 - data/third_party/boringssl/crypto/rsa/blinding.c +462 -0
 - data/third_party/boringssl/crypto/rsa/internal.h +164 -0
 - data/third_party/boringssl/crypto/rsa/padding.c +711 -0
 - data/third_party/boringssl/crypto/rsa/rsa.c +808 -0
 - data/third_party/boringssl/crypto/rsa/rsa_asn1.c +473 -0
 - data/third_party/boringssl/crypto/rsa/rsa_impl.c +1138 -0
 - data/third_party/boringssl/crypto/sha/sha1.c +337 -0
 - data/third_party/boringssl/crypto/sha/sha256.c +327 -0
 - data/third_party/boringssl/crypto/sha/sha512.c +607 -0
 - data/third_party/boringssl/crypto/stack/stack.c +386 -0
 - data/third_party/boringssl/crypto/test/scoped_types.h +137 -0
 - data/third_party/boringssl/crypto/test/test_util.h +35 -0
 - data/third_party/boringssl/crypto/thread.c +101 -0
 - data/third_party/boringssl/crypto/thread_none.c +55 -0
 - data/third_party/boringssl/crypto/thread_pthread.c +167 -0
 - data/third_party/boringssl/crypto/thread_win.c +282 -0
 - data/third_party/boringssl/crypto/time_support.c +212 -0
 - data/third_party/boringssl/crypto/x509/a_digest.c +97 -0
 - data/third_party/boringssl/crypto/x509/a_sign.c +136 -0
 - data/third_party/boringssl/crypto/x509/a_strex.c +564 -0
 - data/third_party/boringssl/crypto/x509/a_verify.c +133 -0
 - data/third_party/boringssl/crypto/x509/asn1_gen.c +873 -0
 - data/third_party/boringssl/crypto/x509/by_dir.c +491 -0
 - data/third_party/boringssl/crypto/x509/by_file.c +295 -0
 - data/third_party/boringssl/crypto/x509/charmap.h +15 -0
 - data/third_party/boringssl/crypto/x509/i2d_pr.c +84 -0
 - data/third_party/boringssl/crypto/x509/pkcs7.c +353 -0
 - data/third_party/boringssl/crypto/x509/t_crl.c +129 -0
 - data/third_party/boringssl/crypto/x509/t_req.c +246 -0
 - data/third_party/boringssl/crypto/x509/t_x509.c +500 -0
 - data/third_party/boringssl/crypto/x509/t_x509a.c +109 -0
 - data/third_party/boringssl/crypto/x509/vpm_int.h +70 -0
 - data/third_party/boringssl/crypto/x509/x509.c +152 -0
 - data/third_party/boringssl/crypto/x509/x509_att.c +353 -0
 - data/third_party/boringssl/crypto/x509/x509_cmp.c +490 -0
 - data/third_party/boringssl/crypto/x509/x509_d2.c +105 -0
 - data/third_party/boringssl/crypto/x509/x509_def.c +88 -0
 - data/third_party/boringssl/crypto/x509/x509_ext.c +206 -0
 - data/third_party/boringssl/crypto/x509/x509_lu.c +738 -0
 - data/third_party/boringssl/crypto/x509/x509_obj.c +191 -0
 - data/third_party/boringssl/crypto/x509/x509_r2x.c +113 -0
 - data/third_party/boringssl/crypto/x509/x509_req.c +315 -0
 - data/third_party/boringssl/crypto/x509/x509_set.c +154 -0
 - data/third_party/boringssl/crypto/x509/x509_trs.c +304 -0
 - data/third_party/boringssl/crypto/x509/x509_txt.c +209 -0
 - data/third_party/boringssl/crypto/x509/x509_v3.c +271 -0
 - data/third_party/boringssl/crypto/x509/x509_vfy.c +2456 -0
 - data/third_party/boringssl/crypto/x509/x509_vpm.c +672 -0
 - data/third_party/boringssl/crypto/x509/x509cset.c +172 -0
 - data/third_party/boringssl/crypto/x509/x509name.c +381 -0
 - data/third_party/boringssl/crypto/x509/x509rset.c +80 -0
 - data/third_party/boringssl/crypto/x509/x509spki.c +135 -0
 - data/third_party/boringssl/crypto/x509/x509type.c +128 -0
 - data/third_party/boringssl/crypto/x509/x_algor.c +154 -0
 - data/third_party/boringssl/crypto/x509/x_all.c +547 -0
 - data/third_party/boringssl/crypto/x509/x_attrib.c +117 -0
 - data/third_party/boringssl/crypto/x509/x_crl.c +560 -0
 - data/third_party/boringssl/crypto/x509/x_exten.c +75 -0
 - data/third_party/boringssl/crypto/x509/x_info.c +95 -0
 - data/third_party/boringssl/crypto/x509/x_name.c +538 -0
 - data/third_party/boringssl/crypto/x509/x_pkey.c +100 -0
 - data/third_party/boringssl/crypto/x509/x_pubkey.c +384 -0
 - data/third_party/boringssl/crypto/x509/x_req.c +112 -0
 - data/third_party/boringssl/crypto/x509/x_sig.c +69 -0
 - data/third_party/boringssl/crypto/x509/x_spki.c +78 -0
 - data/third_party/boringssl/crypto/x509/x_val.c +69 -0
 - data/third_party/boringssl/crypto/x509/x_x509.c +227 -0
 - data/third_party/boringssl/crypto/x509/x_x509a.c +197 -0
 - data/third_party/boringssl/crypto/x509v3/ext_dat.h +129 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_cache.c +299 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_data.c +137 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_int.h +212 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_lib.c +165 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_map.c +133 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_node.c +197 -0
 - data/third_party/boringssl/crypto/x509v3/pcy_tree.c +876 -0
 - data/third_party/boringssl/crypto/x509v3/v3_akey.c +212 -0
 - data/third_party/boringssl/crypto/x509v3/v3_akeya.c +71 -0
 - data/third_party/boringssl/crypto/x509v3/v3_alt.c +622 -0
 - data/third_party/boringssl/crypto/x509v3/v3_bcons.c +126 -0
 - data/third_party/boringssl/crypto/x509v3/v3_bitst.c +141 -0
 - data/third_party/boringssl/crypto/x509v3/v3_conf.c +459 -0
 - data/third_party/boringssl/crypto/x509v3/v3_cpols.c +475 -0
 - data/third_party/boringssl/crypto/x509v3/v3_crld.c +616 -0
 - data/third_party/boringssl/crypto/x509v3/v3_enum.c +98 -0
 - data/third_party/boringssl/crypto/x509v3/v3_extku.c +145 -0
 - data/third_party/boringssl/crypto/x509v3/v3_genn.c +252 -0
 - data/third_party/boringssl/crypto/x509v3/v3_ia5.c +117 -0
 - data/third_party/boringssl/crypto/x509v3/v3_info.c +200 -0
 - data/third_party/boringssl/crypto/x509v3/v3_int.c +87 -0
 - data/third_party/boringssl/crypto/x509v3/v3_lib.c +335 -0
 - data/third_party/boringssl/crypto/x509v3/v3_ncons.c +510 -0
 - data/third_party/boringssl/crypto/x509v3/v3_pci.c +335 -0
 - data/third_party/boringssl/crypto/x509v3/v3_pcia.c +56 -0
 - data/third_party/boringssl/crypto/x509v3/v3_pcons.c +142 -0
 - data/third_party/boringssl/crypto/x509v3/v3_pku.c +109 -0
 - data/third_party/boringssl/crypto/x509v3/v3_pmaps.c +156 -0
 - data/third_party/boringssl/crypto/x509v3/v3_prn.c +207 -0
 - data/third_party/boringssl/crypto/x509v3/v3_purp.c +805 -0
 - data/third_party/boringssl/crypto/x509v3/v3_skey.c +148 -0
 - data/third_party/boringssl/crypto/x509v3/v3_sxnet.c +266 -0
 - data/third_party/boringssl/crypto/x509v3/v3_utl.c +1322 -0
 - data/third_party/boringssl/include/openssl/aead.h +346 -0
 - data/third_party/boringssl/include/openssl/aes.h +158 -0
 - data/third_party/boringssl/include/openssl/arm_arch.h +127 -0
 - data/third_party/boringssl/include/openssl/asn1.h +1168 -0
 - data/third_party/boringssl/include/openssl/asn1_mac.h +75 -0
 - data/third_party/boringssl/include/openssl/asn1t.h +906 -0
 - data/third_party/boringssl/include/openssl/base.h +261 -0
 - data/third_party/boringssl/include/openssl/base64.h +184 -0
 - data/third_party/boringssl/include/openssl/bio.h +902 -0
 - data/third_party/boringssl/include/openssl/blowfish.h +93 -0
 - data/third_party/boringssl/include/openssl/bn.h +885 -0
 - data/third_party/boringssl/include/openssl/buf.h +118 -0
 - data/third_party/boringssl/include/openssl/buffer.h +18 -0
 - data/third_party/boringssl/include/openssl/bytestring.h +360 -0
 - data/third_party/boringssl/include/openssl/cast.h +96 -0
 - data/third_party/boringssl/include/openssl/chacha.h +37 -0
 - data/third_party/boringssl/include/openssl/cipher.h +571 -0
 - data/third_party/boringssl/include/openssl/cmac.h +76 -0
 - data/third_party/boringssl/include/openssl/conf.h +145 -0
 - data/third_party/boringssl/include/openssl/cpu.h +184 -0
 - data/third_party/boringssl/include/openssl/crypto.h +68 -0
 - data/third_party/boringssl/include/openssl/curve25519.h +88 -0
 - data/third_party/boringssl/include/openssl/des.h +177 -0
 - data/third_party/boringssl/include/openssl/dh.h +238 -0
 - data/third_party/boringssl/include/openssl/digest.h +258 -0
 - data/third_party/boringssl/include/openssl/dsa.h +343 -0
 - data/third_party/boringssl/include/openssl/dtls1.h +16 -0
 - data/third_party/boringssl/include/openssl/ec.h +355 -0
 - data/third_party/boringssl/include/openssl/ec_key.h +280 -0
 - data/third_party/boringssl/include/openssl/ecdh.h +102 -0
 - data/third_party/boringssl/include/openssl/ecdsa.h +206 -0
 - data/third_party/boringssl/include/openssl/engine.h +98 -0
 - data/third_party/boringssl/include/openssl/err.h +487 -0
 - data/third_party/boringssl/include/openssl/evp.h +750 -0
 - data/third_party/boringssl/include/openssl/ex_data.h +213 -0
 - data/third_party/boringssl/include/openssl/hkdf.h +44 -0
 - data/third_party/boringssl/include/openssl/hmac.h +160 -0
 - data/third_party/boringssl/include/openssl/lhash.h +192 -0
 - data/third_party/boringssl/include/openssl/lhash_macros.h +132 -0
 - data/third_party/boringssl/include/openssl/md4.h +102 -0
 - data/third_party/boringssl/include/openssl/md5.h +107 -0
 - data/third_party/boringssl/include/openssl/mem.h +140 -0
 - data/third_party/boringssl/include/openssl/obj.h +198 -0
 - data/third_party/boringssl/include/openssl/obj_mac.h +4140 -0
 - data/third_party/boringssl/include/openssl/objects.h +18 -0
 - data/third_party/boringssl/include/openssl/opensslfeatures.h +60 -0
 - data/third_party/boringssl/include/openssl/opensslv.h +18 -0
 - data/third_party/boringssl/include/openssl/ossl_typ.h +18 -0
 - data/third_party/boringssl/include/openssl/pem.h +521 -0
 - data/third_party/boringssl/include/openssl/pkcs12.h +18 -0
 - data/third_party/boringssl/include/openssl/pkcs7.h +16 -0
 - data/third_party/boringssl/include/openssl/pkcs8.h +220 -0
 - data/third_party/boringssl/include/openssl/poly1305.h +51 -0
 - data/third_party/boringssl/include/openssl/pqueue.h +146 -0
 - data/third_party/boringssl/include/openssl/rand.h +113 -0
 - data/third_party/boringssl/include/openssl/rc4.h +90 -0
 - data/third_party/boringssl/include/openssl/rsa.h +637 -0
 - data/third_party/boringssl/include/openssl/safestack.h +16 -0
 - data/third_party/boringssl/include/openssl/sha.h +256 -0
 - data/third_party/boringssl/include/openssl/srtp.h +18 -0
 - data/third_party/boringssl/include/openssl/ssl.h +4466 -0
 - data/third_party/boringssl/include/openssl/ssl3.h +441 -0
 - data/third_party/boringssl/include/openssl/stack.h +298 -0
 - data/third_party/boringssl/include/openssl/stack_macros.h +4190 -0
 - data/third_party/boringssl/include/openssl/thread.h +173 -0
 - data/third_party/boringssl/include/openssl/time_support.h +90 -0
 - data/third_party/boringssl/include/openssl/tls1.h +653 -0
 - data/third_party/boringssl/include/openssl/type_check.h +91 -0
 - data/third_party/boringssl/include/openssl/x509.h +1258 -0
 - data/third_party/boringssl/include/openssl/x509_vfy.h +611 -0
 - data/third_party/boringssl/include/openssl/x509v3.h +798 -0
 - data/third_party/boringssl/ssl/custom_extensions.c +257 -0
 - data/third_party/boringssl/ssl/d1_both.c +880 -0
 - data/third_party/boringssl/ssl/d1_clnt.c +566 -0
 - data/third_party/boringssl/ssl/d1_lib.c +340 -0
 - data/third_party/boringssl/ssl/d1_meth.c +130 -0
 - data/third_party/boringssl/ssl/d1_pkt.c +578 -0
 - data/third_party/boringssl/ssl/d1_srtp.c +234 -0
 - data/third_party/boringssl/ssl/d1_srvr.c +485 -0
 - data/third_party/boringssl/ssl/dtls_record.c +308 -0
 - data/third_party/boringssl/ssl/internal.h +1276 -0
 - data/third_party/boringssl/ssl/pqueue/pqueue.c +197 -0
 - data/third_party/boringssl/ssl/s3_both.c +571 -0
 - data/third_party/boringssl/ssl/s3_clnt.c +2241 -0
 - data/third_party/boringssl/ssl/s3_enc.c +494 -0
 - data/third_party/boringssl/ssl/s3_lib.c +587 -0
 - data/third_party/boringssl/ssl/s3_meth.c +166 -0
 - data/third_party/boringssl/ssl/s3_pkt.c +732 -0
 - data/third_party/boringssl/ssl/s3_srvr.c +2536 -0
 - data/third_party/boringssl/ssl/ssl_aead_ctx.c +300 -0
 - data/third_party/boringssl/ssl/ssl_asn1.c +718 -0
 - data/third_party/boringssl/ssl/ssl_buffer.c +319 -0
 - data/third_party/boringssl/ssl/ssl_cert.c +539 -0
 - data/third_party/boringssl/ssl/ssl_cipher.c +2003 -0
 - data/third_party/boringssl/ssl/ssl_file.c +633 -0
 - data/third_party/boringssl/ssl/ssl_lib.c +2653 -0
 - data/third_party/boringssl/ssl/ssl_rsa.c +423 -0
 - data/third_party/boringssl/ssl/ssl_session.c +764 -0
 - data/third_party/boringssl/ssl/ssl_stat.c +591 -0
 - data/third_party/boringssl/ssl/t1_enc.c +708 -0
 - data/third_party/boringssl/ssl/t1_lib.c +2905 -0
 - data/third_party/boringssl/ssl/test/async_bio.h +45 -0
 - data/third_party/boringssl/ssl/test/packeted_bio.h +44 -0
 - data/third_party/boringssl/ssl/test/scoped_types.h +28 -0
 - data/third_party/boringssl/ssl/test/test_config.h +108 -0
 - data/third_party/boringssl/ssl/tls_record.c +342 -0
 - data/third_party/zlib/adler32.c +179 -0
 - data/third_party/zlib/compress.c +80 -0
 - data/third_party/zlib/crc32.c +425 -0
 - data/third_party/zlib/crc32.h +441 -0
 - data/third_party/zlib/deflate.c +1967 -0
 - data/third_party/zlib/deflate.h +346 -0
 - data/third_party/zlib/gzclose.c +25 -0
 - data/third_party/zlib/gzguts.h +209 -0
 - data/third_party/zlib/gzlib.c +634 -0
 - data/third_party/zlib/gzread.c +594 -0
 - data/third_party/zlib/gzwrite.c +577 -0
 - data/third_party/zlib/infback.c +640 -0
 - data/third_party/zlib/inffast.c +340 -0
 - data/third_party/zlib/inffast.h +11 -0
 - data/third_party/zlib/inffixed.h +94 -0
 - data/third_party/zlib/inflate.c +1512 -0
 - data/third_party/zlib/inflate.h +122 -0
 - data/third_party/zlib/inftrees.c +306 -0
 - data/third_party/zlib/inftrees.h +62 -0
 - data/third_party/zlib/trees.c +1226 -0
 - data/third_party/zlib/trees.h +128 -0
 - data/third_party/zlib/uncompr.c +59 -0
 - data/third_party/zlib/zconf.h +511 -0
 - data/third_party/zlib/zlib.h +1768 -0
 - data/third_party/zlib/zutil.c +324 -0
 - data/third_party/zlib/zutil.h +253 -0
 - metadata +492 -25
 - data/Rakefile +0 -63
 - data/src/ruby/lib/grpc/grpc.so +0 -0
 
| 
         @@ -0,0 +1,805 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /* v3_purp.c */
         
     | 
| 
      
 2 
     | 
    
         
            +
            /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
         
     | 
| 
      
 3 
     | 
    
         
            +
             * project 2001.
         
     | 
| 
      
 4 
     | 
    
         
            +
             */
         
     | 
| 
      
 5 
     | 
    
         
            +
            /* ====================================================================
         
     | 
| 
      
 6 
     | 
    
         
            +
             * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
         
     | 
| 
      
 7 
     | 
    
         
            +
             *
         
     | 
| 
      
 8 
     | 
    
         
            +
             * Redistribution and use in source and binary forms, with or without
         
     | 
| 
      
 9 
     | 
    
         
            +
             * modification, are permitted provided that the following conditions
         
     | 
| 
      
 10 
     | 
    
         
            +
             * are met:
         
     | 
| 
      
 11 
     | 
    
         
            +
             *
         
     | 
| 
      
 12 
     | 
    
         
            +
             * 1. Redistributions of source code must retain the above copyright
         
     | 
| 
      
 13 
     | 
    
         
            +
             *    notice, this list of conditions and the following disclaimer. 
         
     | 
| 
      
 14 
     | 
    
         
            +
             *
         
     | 
| 
      
 15 
     | 
    
         
            +
             * 2. Redistributions in binary form must reproduce the above copyright
         
     | 
| 
      
 16 
     | 
    
         
            +
             *    notice, this list of conditions and the following disclaimer in
         
     | 
| 
      
 17 
     | 
    
         
            +
             *    the documentation and/or other materials provided with the
         
     | 
| 
      
 18 
     | 
    
         
            +
             *    distribution.
         
     | 
| 
      
 19 
     | 
    
         
            +
             *
         
     | 
| 
      
 20 
     | 
    
         
            +
             * 3. All advertising materials mentioning features or use of this
         
     | 
| 
      
 21 
     | 
    
         
            +
             *    software must display the following acknowledgment:
         
     | 
| 
      
 22 
     | 
    
         
            +
             *    "This product includes software developed by the OpenSSL Project
         
     | 
| 
      
 23 
     | 
    
         
            +
             *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
         
     | 
| 
      
 24 
     | 
    
         
            +
             *
         
     | 
| 
      
 25 
     | 
    
         
            +
             * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
         
     | 
| 
      
 26 
     | 
    
         
            +
             *    endorse or promote products derived from this software without
         
     | 
| 
      
 27 
     | 
    
         
            +
             *    prior written permission. For written permission, please contact
         
     | 
| 
      
 28 
     | 
    
         
            +
             *    licensing@OpenSSL.org.
         
     | 
| 
      
 29 
     | 
    
         
            +
             *
         
     | 
| 
      
 30 
     | 
    
         
            +
             * 5. Products derived from this software may not be called "OpenSSL"
         
     | 
| 
      
 31 
     | 
    
         
            +
             *    nor may "OpenSSL" appear in their names without prior written
         
     | 
| 
      
 32 
     | 
    
         
            +
             *    permission of the OpenSSL Project.
         
     | 
| 
      
 33 
     | 
    
         
            +
             *
         
     | 
| 
      
 34 
     | 
    
         
            +
             * 6. Redistributions of any form whatsoever must retain the following
         
     | 
| 
      
 35 
     | 
    
         
            +
             *    acknowledgment:
         
     | 
| 
      
 36 
     | 
    
         
            +
             *    "This product includes software developed by the OpenSSL Project
         
     | 
| 
      
 37 
     | 
    
         
            +
             *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
         
     | 
| 
      
 38 
     | 
    
         
            +
             *
         
     | 
| 
      
 39 
     | 
    
         
            +
             * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
         
     | 
| 
      
 40 
     | 
    
         
            +
             * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         
     | 
| 
      
 41 
     | 
    
         
            +
             * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
         
     | 
| 
      
 42 
     | 
    
         
            +
             * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
         
     | 
| 
      
 43 
     | 
    
         
            +
             * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
         
     | 
| 
      
 44 
     | 
    
         
            +
             * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
         
     | 
| 
      
 45 
     | 
    
         
            +
             * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
         
     | 
| 
      
 46 
     | 
    
         
            +
             * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
         
     | 
| 
      
 47 
     | 
    
         
            +
             * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
         
     | 
| 
      
 48 
     | 
    
         
            +
             * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
         
     | 
| 
      
 49 
     | 
    
         
            +
             * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
         
     | 
| 
      
 50 
     | 
    
         
            +
             * OF THE POSSIBILITY OF SUCH DAMAGE.
         
     | 
| 
      
 51 
     | 
    
         
            +
             * ====================================================================
         
     | 
| 
      
 52 
     | 
    
         
            +
             *
         
     | 
| 
      
 53 
     | 
    
         
            +
             * This product includes cryptographic software written by Eric Young
         
     | 
| 
      
 54 
     | 
    
         
            +
             * (eay@cryptsoft.com).  This product includes software written by Tim
         
     | 
| 
      
 55 
     | 
    
         
            +
             * Hudson (tjh@cryptsoft.com). */
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            #include <stdio.h>
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            #include <string.h>
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            #include <openssl/buf.h>
         
     | 
| 
      
 62 
     | 
    
         
            +
            #include <openssl/err.h>
         
     | 
| 
      
 63 
     | 
    
         
            +
            #include <openssl/digest.h>
         
     | 
| 
      
 64 
     | 
    
         
            +
            #include <openssl/mem.h>
         
     | 
| 
      
 65 
     | 
    
         
            +
            #include <openssl/obj.h>
         
     | 
| 
      
 66 
     | 
    
         
            +
            #include <openssl/thread.h>
         
     | 
| 
      
 67 
     | 
    
         
            +
            #include <openssl/x509_vfy.h>
         
     | 
| 
      
 68 
     | 
    
         
            +
            #include <openssl/x509v3.h>
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            #include "../internal.h"
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            #define V1_ROOT (EXFLAG_V1|EXFLAG_SS)
         
     | 
| 
      
 74 
     | 
    
         
            +
            #define ku_reject(x, usage) \
         
     | 
| 
      
 75 
     | 
    
         
            +
            	(((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage)))
         
     | 
| 
      
 76 
     | 
    
         
            +
            #define xku_reject(x, usage) \
         
     | 
| 
      
 77 
     | 
    
         
            +
            	(((x)->ex_flags & EXFLAG_XKUSAGE) && !((x)->ex_xkusage & (usage)))
         
     | 
| 
      
 78 
     | 
    
         
            +
            #define ns_reject(x, usage) \
         
     | 
| 
      
 79 
     | 
    
         
            +
            	(((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage)))
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            static void x509v3_cache_extensions(X509 *x);
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            static int check_ssl_ca(const X509 *x);
         
     | 
| 
      
 84 
     | 
    
         
            +
            static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 85 
     | 
    
         
            +
            static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 86 
     | 
    
         
            +
            static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 87 
     | 
    
         
            +
            static int purpose_smime(const X509 *x, int ca);
         
     | 
| 
      
 88 
     | 
    
         
            +
            static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 89 
     | 
    
         
            +
            static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 90 
     | 
    
         
            +
            static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 91 
     | 
    
         
            +
            static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 92 
     | 
    
         
            +
            static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 93 
     | 
    
         
            +
            static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca);
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            static int xp_cmp(const X509_PURPOSE **a, const X509_PURPOSE **b);
         
     | 
| 
      
 96 
     | 
    
         
            +
            static void xptable_free(X509_PURPOSE *p);
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            static X509_PURPOSE xstandard[] = {
         
     | 
| 
      
 99 
     | 
    
         
            +
            	{X509_PURPOSE_SSL_CLIENT, X509_TRUST_SSL_CLIENT, 0, check_purpose_ssl_client, (char *) "SSL client", (char *) "sslclient", NULL},
         
     | 
| 
      
 100 
     | 
    
         
            +
            	{X509_PURPOSE_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ssl_server, (char *) "SSL server", (char *) "sslserver", NULL},
         
     | 
| 
      
 101 
     | 
    
         
            +
            	{X509_PURPOSE_NS_SSL_SERVER, X509_TRUST_SSL_SERVER, 0, check_purpose_ns_ssl_server, (char *) "Netscape SSL server", (char *) "nssslserver", NULL},
         
     | 
| 
      
 102 
     | 
    
         
            +
            	{X509_PURPOSE_SMIME_SIGN, X509_TRUST_EMAIL, 0, check_purpose_smime_sign, (char *) "S/MIME signing", (char *) "smimesign", NULL},
         
     | 
| 
      
 103 
     | 
    
         
            +
            	{X509_PURPOSE_SMIME_ENCRYPT, X509_TRUST_EMAIL, 0, check_purpose_smime_encrypt, (char *) "S/MIME encryption", (char *) "smimeencrypt", NULL},
         
     | 
| 
      
 104 
     | 
    
         
            +
            	{X509_PURPOSE_CRL_SIGN, X509_TRUST_COMPAT, 0, check_purpose_crl_sign, (char *) "CRL signing", (char *) "crlsign", NULL},
         
     | 
| 
      
 105 
     | 
    
         
            +
            	{X509_PURPOSE_ANY, X509_TRUST_DEFAULT, 0, no_check, (char *) "Any Purpose", (char *) "any", NULL},
         
     | 
| 
      
 106 
     | 
    
         
            +
            	{X509_PURPOSE_OCSP_HELPER, X509_TRUST_COMPAT, 0, ocsp_helper, (char *) "OCSP helper", (char *) "ocsphelper", NULL},
         
     | 
| 
      
 107 
     | 
    
         
            +
            	{X509_PURPOSE_TIMESTAMP_SIGN, X509_TRUST_TSA, 0, check_purpose_timestamp_sign, (char *) "Time Stamp signing", (char *) "timestampsign", NULL},
         
     | 
| 
      
 108 
     | 
    
         
            +
            };
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
            #define X509_PURPOSE_COUNT (sizeof(xstandard)/sizeof(X509_PURPOSE))
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            static STACK_OF(X509_PURPOSE) *xptable = NULL;
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            static int xp_cmp(const X509_PURPOSE **a, const X509_PURPOSE **b)
         
     | 
| 
      
 115 
     | 
    
         
            +
            {
         
     | 
| 
      
 116 
     | 
    
         
            +
            	return (*a)->purpose - (*b)->purpose;
         
     | 
| 
      
 117 
     | 
    
         
            +
            }
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            /* As much as I'd like to make X509_check_purpose use a "const" X509*
         
     | 
| 
      
 120 
     | 
    
         
            +
             * I really can't because it does recalculate hashes and do other non-const
         
     | 
| 
      
 121 
     | 
    
         
            +
             * things. */
         
     | 
| 
      
 122 
     | 
    
         
            +
            int X509_check_purpose(X509 *x, int id, int ca)
         
     | 
| 
      
 123 
     | 
    
         
            +
            {
         
     | 
| 
      
 124 
     | 
    
         
            +
            	int idx;
         
     | 
| 
      
 125 
     | 
    
         
            +
            	const X509_PURPOSE *pt;
         
     | 
| 
      
 126 
     | 
    
         
            +
            	if(!(x->ex_flags & EXFLAG_SET)) {
         
     | 
| 
      
 127 
     | 
    
         
            +
            		x509v3_cache_extensions(x);
         
     | 
| 
      
 128 
     | 
    
         
            +
            	}
         
     | 
| 
      
 129 
     | 
    
         
            +
            	if(id == -1) return 1;
         
     | 
| 
      
 130 
     | 
    
         
            +
            	idx = X509_PURPOSE_get_by_id(id);
         
     | 
| 
      
 131 
     | 
    
         
            +
            	if(idx == -1) return -1;
         
     | 
| 
      
 132 
     | 
    
         
            +
            	pt = X509_PURPOSE_get0(idx);
         
     | 
| 
      
 133 
     | 
    
         
            +
            	return pt->check_purpose(pt, x, ca);
         
     | 
| 
      
 134 
     | 
    
         
            +
            }
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
            int X509_PURPOSE_set(int *p, int purpose)
         
     | 
| 
      
 137 
     | 
    
         
            +
            {
         
     | 
| 
      
 138 
     | 
    
         
            +
            	if(X509_PURPOSE_get_by_id(purpose) == -1) {
         
     | 
| 
      
 139 
     | 
    
         
            +
            		OPENSSL_PUT_ERROR(X509V3, X509V3_R_INVALID_PURPOSE);
         
     | 
| 
      
 140 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 141 
     | 
    
         
            +
            	}
         
     | 
| 
      
 142 
     | 
    
         
            +
            	*p = purpose;
         
     | 
| 
      
 143 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 144 
     | 
    
         
            +
            }
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
            int X509_PURPOSE_get_count(void)
         
     | 
| 
      
 147 
     | 
    
         
            +
            {
         
     | 
| 
      
 148 
     | 
    
         
            +
            	if(!xptable) return X509_PURPOSE_COUNT;
         
     | 
| 
      
 149 
     | 
    
         
            +
            	return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT;
         
     | 
| 
      
 150 
     | 
    
         
            +
            }
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
            X509_PURPOSE * X509_PURPOSE_get0(int idx)
         
     | 
| 
      
 153 
     | 
    
         
            +
            {
         
     | 
| 
      
 154 
     | 
    
         
            +
            	if(idx < 0) return NULL;
         
     | 
| 
      
 155 
     | 
    
         
            +
            	if(idx < (int)X509_PURPOSE_COUNT) return xstandard + idx;
         
     | 
| 
      
 156 
     | 
    
         
            +
            	return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT);
         
     | 
| 
      
 157 
     | 
    
         
            +
            }
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            int X509_PURPOSE_get_by_sname(char *sname)
         
     | 
| 
      
 160 
     | 
    
         
            +
            {
         
     | 
| 
      
 161 
     | 
    
         
            +
            	int i;
         
     | 
| 
      
 162 
     | 
    
         
            +
            	X509_PURPOSE *xptmp;
         
     | 
| 
      
 163 
     | 
    
         
            +
            	for(i = 0; i < X509_PURPOSE_get_count(); i++) {
         
     | 
| 
      
 164 
     | 
    
         
            +
            		xptmp = X509_PURPOSE_get0(i);
         
     | 
| 
      
 165 
     | 
    
         
            +
            		if(!strcmp(xptmp->sname, sname)) return i;
         
     | 
| 
      
 166 
     | 
    
         
            +
            	}
         
     | 
| 
      
 167 
     | 
    
         
            +
            	return -1;
         
     | 
| 
      
 168 
     | 
    
         
            +
            }
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            int X509_PURPOSE_get_by_id(int purpose)
         
     | 
| 
      
 171 
     | 
    
         
            +
            {
         
     | 
| 
      
 172 
     | 
    
         
            +
            	X509_PURPOSE tmp;
         
     | 
| 
      
 173 
     | 
    
         
            +
            	size_t idx;
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            	if((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
         
     | 
| 
      
 176 
     | 
    
         
            +
            		return purpose - X509_PURPOSE_MIN;
         
     | 
| 
      
 177 
     | 
    
         
            +
            	tmp.purpose = purpose;
         
     | 
| 
      
 178 
     | 
    
         
            +
            	if(!xptable) return -1;
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
            	if (!sk_X509_PURPOSE_find(xptable, &idx, &tmp))
         
     | 
| 
      
 181 
     | 
    
         
            +
            		return -1;
         
     | 
| 
      
 182 
     | 
    
         
            +
            	return idx + X509_PURPOSE_COUNT;
         
     | 
| 
      
 183 
     | 
    
         
            +
            }
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            int X509_PURPOSE_add(int id, int trust, int flags,
         
     | 
| 
      
 186 
     | 
    
         
            +
            			int (*ck)(const X509_PURPOSE *, const X509 *, int),
         
     | 
| 
      
 187 
     | 
    
         
            +
            					char *name, char *sname, void *arg)
         
     | 
| 
      
 188 
     | 
    
         
            +
            {
         
     | 
| 
      
 189 
     | 
    
         
            +
            	int idx;
         
     | 
| 
      
 190 
     | 
    
         
            +
            	X509_PURPOSE *ptmp;
         
     | 
| 
      
 191 
     | 
    
         
            +
            	char *name_dup, *sname_dup;
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            	/* This is set according to what we change: application can't set it */
         
     | 
| 
      
 194 
     | 
    
         
            +
            	flags &= ~X509_PURPOSE_DYNAMIC;
         
     | 
| 
      
 195 
     | 
    
         
            +
            	/* This will always be set for application modified trust entries */
         
     | 
| 
      
 196 
     | 
    
         
            +
            	flags |= X509_PURPOSE_DYNAMIC_NAME;
         
     | 
| 
      
 197 
     | 
    
         
            +
            	/* Get existing entry if any */
         
     | 
| 
      
 198 
     | 
    
         
            +
            	idx = X509_PURPOSE_get_by_id(id);
         
     | 
| 
      
 199 
     | 
    
         
            +
            	/* Need a new entry */
         
     | 
| 
      
 200 
     | 
    
         
            +
            	if(idx == -1) {
         
     | 
| 
      
 201 
     | 
    
         
            +
            		if(!(ptmp = OPENSSL_malloc(sizeof(X509_PURPOSE)))) {
         
     | 
| 
      
 202 
     | 
    
         
            +
            			OPENSSL_PUT_ERROR(X509V3, ERR_R_MALLOC_FAILURE);
         
     | 
| 
      
 203 
     | 
    
         
            +
            			return 0;
         
     | 
| 
      
 204 
     | 
    
         
            +
            		}
         
     | 
| 
      
 205 
     | 
    
         
            +
            		ptmp->flags = X509_PURPOSE_DYNAMIC;
         
     | 
| 
      
 206 
     | 
    
         
            +
            	} else ptmp = X509_PURPOSE_get0(idx);
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
            	/* Duplicate the supplied names. */
         
     | 
| 
      
 209 
     | 
    
         
            +
            	name_dup = BUF_strdup(name);
         
     | 
| 
      
 210 
     | 
    
         
            +
            	sname_dup = BUF_strdup(sname);
         
     | 
| 
      
 211 
     | 
    
         
            +
            	if (name_dup == NULL || sname_dup == NULL) {
         
     | 
| 
      
 212 
     | 
    
         
            +
            		OPENSSL_PUT_ERROR(X509V3, ERR_R_MALLOC_FAILURE);
         
     | 
| 
      
 213 
     | 
    
         
            +
            		if (name_dup != NULL)
         
     | 
| 
      
 214 
     | 
    
         
            +
            			OPENSSL_free(name_dup);
         
     | 
| 
      
 215 
     | 
    
         
            +
            		if (sname_dup != NULL)
         
     | 
| 
      
 216 
     | 
    
         
            +
            			OPENSSL_free(sname_dup);
         
     | 
| 
      
 217 
     | 
    
         
            +
            		if (idx == -1)
         
     | 
| 
      
 218 
     | 
    
         
            +
            			OPENSSL_free(ptmp);
         
     | 
| 
      
 219 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 220 
     | 
    
         
            +
            	}
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
            	/* OPENSSL_free existing name if dynamic */
         
     | 
| 
      
 223 
     | 
    
         
            +
            	if(ptmp->flags & X509_PURPOSE_DYNAMIC_NAME) {
         
     | 
| 
      
 224 
     | 
    
         
            +
            		OPENSSL_free(ptmp->name);
         
     | 
| 
      
 225 
     | 
    
         
            +
            		OPENSSL_free(ptmp->sname);
         
     | 
| 
      
 226 
     | 
    
         
            +
            	}
         
     | 
| 
      
 227 
     | 
    
         
            +
            	/* dup supplied name */
         
     | 
| 
      
 228 
     | 
    
         
            +
            	ptmp->name = name_dup;
         
     | 
| 
      
 229 
     | 
    
         
            +
            	ptmp->sname = sname_dup;
         
     | 
| 
      
 230 
     | 
    
         
            +
            	/* Keep the dynamic flag of existing entry */
         
     | 
| 
      
 231 
     | 
    
         
            +
            	ptmp->flags &= X509_PURPOSE_DYNAMIC;
         
     | 
| 
      
 232 
     | 
    
         
            +
            	/* Set all other flags */
         
     | 
| 
      
 233 
     | 
    
         
            +
            	ptmp->flags |= flags;
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
            	ptmp->purpose = id;
         
     | 
| 
      
 236 
     | 
    
         
            +
            	ptmp->trust = trust;
         
     | 
| 
      
 237 
     | 
    
         
            +
            	ptmp->check_purpose = ck;
         
     | 
| 
      
 238 
     | 
    
         
            +
            	ptmp->usr_data = arg;
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
            	/* If its a new entry manage the dynamic table */
         
     | 
| 
      
 241 
     | 
    
         
            +
            	if(idx == -1) {
         
     | 
| 
      
 242 
     | 
    
         
            +
            		if(!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) {
         
     | 
| 
      
 243 
     | 
    
         
            +
            			OPENSSL_PUT_ERROR(X509V3, ERR_R_MALLOC_FAILURE);
         
     | 
| 
      
 244 
     | 
    
         
            +
            			xptable_free(ptmp);
         
     | 
| 
      
 245 
     | 
    
         
            +
            			return 0;
         
     | 
| 
      
 246 
     | 
    
         
            +
            		}
         
     | 
| 
      
 247 
     | 
    
         
            +
            		if (!sk_X509_PURPOSE_push(xptable, ptmp)) {
         
     | 
| 
      
 248 
     | 
    
         
            +
            			OPENSSL_PUT_ERROR(X509V3, ERR_R_MALLOC_FAILURE);
         
     | 
| 
      
 249 
     | 
    
         
            +
            			xptable_free(ptmp);
         
     | 
| 
      
 250 
     | 
    
         
            +
            			return 0;
         
     | 
| 
      
 251 
     | 
    
         
            +
            		}
         
     | 
| 
      
 252 
     | 
    
         
            +
            	}
         
     | 
| 
      
 253 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 254 
     | 
    
         
            +
            }
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
            static void xptable_free(X509_PURPOSE *p)
         
     | 
| 
      
 257 
     | 
    
         
            +
            	{
         
     | 
| 
      
 258 
     | 
    
         
            +
            	if(!p) return;
         
     | 
| 
      
 259 
     | 
    
         
            +
            	if (p->flags & X509_PURPOSE_DYNAMIC) 
         
     | 
| 
      
 260 
     | 
    
         
            +
            		{
         
     | 
| 
      
 261 
     | 
    
         
            +
            		if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
         
     | 
| 
      
 262 
     | 
    
         
            +
            			OPENSSL_free(p->name);
         
     | 
| 
      
 263 
     | 
    
         
            +
            			OPENSSL_free(p->sname);
         
     | 
| 
      
 264 
     | 
    
         
            +
            		}
         
     | 
| 
      
 265 
     | 
    
         
            +
            		OPENSSL_free(p);
         
     | 
| 
      
 266 
     | 
    
         
            +
            		}
         
     | 
| 
      
 267 
     | 
    
         
            +
            	}
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
            void X509_PURPOSE_cleanup(void)
         
     | 
| 
      
 270 
     | 
    
         
            +
            {
         
     | 
| 
      
 271 
     | 
    
         
            +
            	unsigned int i;
         
     | 
| 
      
 272 
     | 
    
         
            +
            	sk_X509_PURPOSE_pop_free(xptable, xptable_free);
         
     | 
| 
      
 273 
     | 
    
         
            +
            	for(i = 0; i < X509_PURPOSE_COUNT; i++) xptable_free(xstandard + i);
         
     | 
| 
      
 274 
     | 
    
         
            +
            	xptable = NULL;
         
     | 
| 
      
 275 
     | 
    
         
            +
            }
         
     | 
| 
      
 276 
     | 
    
         
            +
             
     | 
| 
      
 277 
     | 
    
         
            +
            int X509_PURPOSE_get_id(X509_PURPOSE *xp)
         
     | 
| 
      
 278 
     | 
    
         
            +
            {
         
     | 
| 
      
 279 
     | 
    
         
            +
            	return xp->purpose;
         
     | 
| 
      
 280 
     | 
    
         
            +
            }
         
     | 
| 
      
 281 
     | 
    
         
            +
             
     | 
| 
      
 282 
     | 
    
         
            +
            char *X509_PURPOSE_get0_name(X509_PURPOSE *xp)
         
     | 
| 
      
 283 
     | 
    
         
            +
            {
         
     | 
| 
      
 284 
     | 
    
         
            +
            	return xp->name;
         
     | 
| 
      
 285 
     | 
    
         
            +
            }
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
            char *X509_PURPOSE_get0_sname(X509_PURPOSE *xp)
         
     | 
| 
      
 288 
     | 
    
         
            +
            {
         
     | 
| 
      
 289 
     | 
    
         
            +
            	return xp->sname;
         
     | 
| 
      
 290 
     | 
    
         
            +
            }
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
            int X509_PURPOSE_get_trust(X509_PURPOSE *xp)
         
     | 
| 
      
 293 
     | 
    
         
            +
            {
         
     | 
| 
      
 294 
     | 
    
         
            +
            	return xp->trust;
         
     | 
| 
      
 295 
     | 
    
         
            +
            }
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
            static int nid_cmp(const void *void_a, const void *void_b)
         
     | 
| 
      
 298 
     | 
    
         
            +
            	{
         
     | 
| 
      
 299 
     | 
    
         
            +
            	const int *a = void_a, *b = void_b;
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
            	return *a - *b;
         
     | 
| 
      
 302 
     | 
    
         
            +
            	}
         
     | 
| 
      
 303 
     | 
    
         
            +
             
     | 
| 
      
 304 
     | 
    
         
            +
            int X509_supported_extension(X509_EXTENSION *ex)
         
     | 
| 
      
 305 
     | 
    
         
            +
            	{
         
     | 
| 
      
 306 
     | 
    
         
            +
            	/* This table is a list of the NIDs of supported extensions:
         
     | 
| 
      
 307 
     | 
    
         
            +
            	 * that is those which are used by the verify process. If
         
     | 
| 
      
 308 
     | 
    
         
            +
            	 * an extension is critical and doesn't appear in this list
         
     | 
| 
      
 309 
     | 
    
         
            +
            	 * then the verify process will normally reject the certificate.
         
     | 
| 
      
 310 
     | 
    
         
            +
            	 * The list must be kept in numerical order because it will be
         
     | 
| 
      
 311 
     | 
    
         
            +
            	 * searched using bsearch.
         
     | 
| 
      
 312 
     | 
    
         
            +
            	 */
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
            	static const int supported_nids[] = {
         
     | 
| 
      
 315 
     | 
    
         
            +
            		NID_netscape_cert_type, /* 71 */
         
     | 
| 
      
 316 
     | 
    
         
            +
                    	NID_key_usage,		/* 83 */
         
     | 
| 
      
 317 
     | 
    
         
            +
            		NID_subject_alt_name,	/* 85 */
         
     | 
| 
      
 318 
     | 
    
         
            +
            		NID_basic_constraints,	/* 87 */
         
     | 
| 
      
 319 
     | 
    
         
            +
            		NID_certificate_policies, /* 89 */
         
     | 
| 
      
 320 
     | 
    
         
            +
                    	NID_ext_key_usage,	/* 126 */
         
     | 
| 
      
 321 
     | 
    
         
            +
            		NID_policy_constraints,	/* 401 */
         
     | 
| 
      
 322 
     | 
    
         
            +
            		NID_proxyCertInfo,	/* 663 */
         
     | 
| 
      
 323 
     | 
    
         
            +
            		NID_name_constraints,	/* 666 */
         
     | 
| 
      
 324 
     | 
    
         
            +
            		NID_policy_mappings,	/* 747 */
         
     | 
| 
      
 325 
     | 
    
         
            +
            		NID_inhibit_any_policy	/* 748 */
         
     | 
| 
      
 326 
     | 
    
         
            +
            	};
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
            	int ex_nid = OBJ_obj2nid(X509_EXTENSION_get_object(ex));
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
            	if (ex_nid == NID_undef) 
         
     | 
| 
      
 331 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
            	if (bsearch(&ex_nid, supported_nids, sizeof(supported_nids)/sizeof(int), sizeof(int), nid_cmp) != NULL)
         
     | 
| 
      
 334 
     | 
    
         
            +
            		return 1;
         
     | 
| 
      
 335 
     | 
    
         
            +
            	return 0;
         
     | 
| 
      
 336 
     | 
    
         
            +
            	}
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
            static void setup_dp(X509 *x, DIST_POINT *dp)
         
     | 
| 
      
 339 
     | 
    
         
            +
            	{
         
     | 
| 
      
 340 
     | 
    
         
            +
            	X509_NAME *iname = NULL;
         
     | 
| 
      
 341 
     | 
    
         
            +
            	size_t i;
         
     | 
| 
      
 342 
     | 
    
         
            +
            	if (dp->reasons)
         
     | 
| 
      
 343 
     | 
    
         
            +
            		{
         
     | 
| 
      
 344 
     | 
    
         
            +
            		if (dp->reasons->length > 0)
         
     | 
| 
      
 345 
     | 
    
         
            +
            			dp->dp_reasons = dp->reasons->data[0];
         
     | 
| 
      
 346 
     | 
    
         
            +
            		if (dp->reasons->length > 1)
         
     | 
| 
      
 347 
     | 
    
         
            +
            			dp->dp_reasons |= (dp->reasons->data[1] << 8);
         
     | 
| 
      
 348 
     | 
    
         
            +
            		dp->dp_reasons &= CRLDP_ALL_REASONS;
         
     | 
| 
      
 349 
     | 
    
         
            +
            		}
         
     | 
| 
      
 350 
     | 
    
         
            +
            	else
         
     | 
| 
      
 351 
     | 
    
         
            +
            		dp->dp_reasons = CRLDP_ALL_REASONS;
         
     | 
| 
      
 352 
     | 
    
         
            +
            	if (!dp->distpoint || (dp->distpoint->type != 1))
         
     | 
| 
      
 353 
     | 
    
         
            +
            		return;
         
     | 
| 
      
 354 
     | 
    
         
            +
            	for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++)
         
     | 
| 
      
 355 
     | 
    
         
            +
            		{
         
     | 
| 
      
 356 
     | 
    
         
            +
            		GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
         
     | 
| 
      
 357 
     | 
    
         
            +
            		if (gen->type == GEN_DIRNAME)
         
     | 
| 
      
 358 
     | 
    
         
            +
            			{
         
     | 
| 
      
 359 
     | 
    
         
            +
            			iname = gen->d.directoryName;
         
     | 
| 
      
 360 
     | 
    
         
            +
            			break;
         
     | 
| 
      
 361 
     | 
    
         
            +
            			}
         
     | 
| 
      
 362 
     | 
    
         
            +
            		}
         
     | 
| 
      
 363 
     | 
    
         
            +
            	if (!iname)
         
     | 
| 
      
 364 
     | 
    
         
            +
            		iname = X509_get_issuer_name(x);
         
     | 
| 
      
 365 
     | 
    
         
            +
             
     | 
| 
      
 366 
     | 
    
         
            +
            	DIST_POINT_set_dpname(dp->distpoint, iname);
         
     | 
| 
      
 367 
     | 
    
         
            +
             
     | 
| 
      
 368 
     | 
    
         
            +
            	}
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
      
 370 
     | 
    
         
            +
            static void setup_crldp(X509 *x)
         
     | 
| 
      
 371 
     | 
    
         
            +
            	{
         
     | 
| 
      
 372 
     | 
    
         
            +
            	size_t i;
         
     | 
| 
      
 373 
     | 
    
         
            +
            	x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
         
     | 
| 
      
 374 
     | 
    
         
            +
            	for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
         
     | 
| 
      
 375 
     | 
    
         
            +
            		setup_dp(x, sk_DIST_POINT_value(x->crldp, i));
         
     | 
| 
      
 376 
     | 
    
         
            +
            	}
         
     | 
| 
      
 377 
     | 
    
         
            +
             
     | 
| 
      
 378 
     | 
    
         
            +
            /* g_x509_cache_extensions_lock is used to protect against concurrent calls to
         
     | 
| 
      
 379 
     | 
    
         
            +
             * |x509v3_cache_extensions|. Ideally this would be done with a |CRYPTO_once_t|
         
     | 
| 
      
 380 
     | 
    
         
            +
             * in the |X509| structure, but |CRYPTO_once_t| isn't public.
         
     | 
| 
      
 381 
     | 
    
         
            +
             *
         
     | 
| 
      
 382 
     | 
    
         
            +
             * Note: it's not entirely clear whether this lock is needed. Not all paths to
         
     | 
| 
      
 383 
     | 
    
         
            +
             * this function took a lock in OpenSSL. */
         
     | 
| 
      
 384 
     | 
    
         
            +
            static struct CRYPTO_STATIC_MUTEX g_x509_cache_extensions_lock =
         
     | 
| 
      
 385 
     | 
    
         
            +
                CRYPTO_STATIC_MUTEX_INIT;
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
            static void x509v3_cache_extensions(X509 *x)
         
     | 
| 
      
 388 
     | 
    
         
            +
            {
         
     | 
| 
      
 389 
     | 
    
         
            +
            	BASIC_CONSTRAINTS *bs;
         
     | 
| 
      
 390 
     | 
    
         
            +
            	PROXY_CERT_INFO_EXTENSION *pci;
         
     | 
| 
      
 391 
     | 
    
         
            +
            	ASN1_BIT_STRING *usage;
         
     | 
| 
      
 392 
     | 
    
         
            +
            	ASN1_BIT_STRING *ns;
         
     | 
| 
      
 393 
     | 
    
         
            +
            	EXTENDED_KEY_USAGE *extusage;
         
     | 
| 
      
 394 
     | 
    
         
            +
            	X509_EXTENSION *ex;
         
     | 
| 
      
 395 
     | 
    
         
            +
            	size_t i;
         
     | 
| 
      
 396 
     | 
    
         
            +
            	int j;
         
     | 
| 
      
 397 
     | 
    
         
            +
             
     | 
| 
      
 398 
     | 
    
         
            +
            	CRYPTO_STATIC_MUTEX_lock_write(&g_x509_cache_extensions_lock);
         
     | 
| 
      
 399 
     | 
    
         
            +
             
     | 
| 
      
 400 
     | 
    
         
            +
            	if(x->ex_flags & EXFLAG_SET)
         
     | 
| 
      
 401 
     | 
    
         
            +
            		{
         
     | 
| 
      
 402 
     | 
    
         
            +
            		CRYPTO_STATIC_MUTEX_unlock(&g_x509_cache_extensions_lock);
         
     | 
| 
      
 403 
     | 
    
         
            +
            		return;
         
     | 
| 
      
 404 
     | 
    
         
            +
            		}
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
            	X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
         
     | 
| 
      
 407 
     | 
    
         
            +
            	/* V1 should mean no extensions ... */
         
     | 
| 
      
 408 
     | 
    
         
            +
            	if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1;
         
     | 
| 
      
 409 
     | 
    
         
            +
            	/* Handle basic constraints */
         
     | 
| 
      
 410 
     | 
    
         
            +
            	if((bs=X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) {
         
     | 
| 
      
 411 
     | 
    
         
            +
            		if(bs->ca) x->ex_flags |= EXFLAG_CA;
         
     | 
| 
      
 412 
     | 
    
         
            +
            		if(bs->pathlen) {
         
     | 
| 
      
 413 
     | 
    
         
            +
            			if((bs->pathlen->type == V_ASN1_NEG_INTEGER)
         
     | 
| 
      
 414 
     | 
    
         
            +
            						|| !bs->ca) {
         
     | 
| 
      
 415 
     | 
    
         
            +
            				x->ex_flags |= EXFLAG_INVALID;
         
     | 
| 
      
 416 
     | 
    
         
            +
            				x->ex_pathlen = 0;
         
     | 
| 
      
 417 
     | 
    
         
            +
            			} else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen);
         
     | 
| 
      
 418 
     | 
    
         
            +
            		} else x->ex_pathlen = -1;
         
     | 
| 
      
 419 
     | 
    
         
            +
            		BASIC_CONSTRAINTS_free(bs);
         
     | 
| 
      
 420 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_BCONS;
         
     | 
| 
      
 421 
     | 
    
         
            +
            	}
         
     | 
| 
      
 422 
     | 
    
         
            +
            	/* Handle proxy certificates */
         
     | 
| 
      
 423 
     | 
    
         
            +
            	if((pci=X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) {
         
     | 
| 
      
 424 
     | 
    
         
            +
            		if (x->ex_flags & EXFLAG_CA
         
     | 
| 
      
 425 
     | 
    
         
            +
            		    || X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0
         
     | 
| 
      
 426 
     | 
    
         
            +
            		    || X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) {
         
     | 
| 
      
 427 
     | 
    
         
            +
            			x->ex_flags |= EXFLAG_INVALID;
         
     | 
| 
      
 428 
     | 
    
         
            +
            		}
         
     | 
| 
      
 429 
     | 
    
         
            +
            		if (pci->pcPathLengthConstraint) {
         
     | 
| 
      
 430 
     | 
    
         
            +
            			x->ex_pcpathlen =
         
     | 
| 
      
 431 
     | 
    
         
            +
            				ASN1_INTEGER_get(pci->pcPathLengthConstraint);
         
     | 
| 
      
 432 
     | 
    
         
            +
            		} else x->ex_pcpathlen = -1;
         
     | 
| 
      
 433 
     | 
    
         
            +
            		PROXY_CERT_INFO_EXTENSION_free(pci);
         
     | 
| 
      
 434 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_PROXY;
         
     | 
| 
      
 435 
     | 
    
         
            +
            	}
         
     | 
| 
      
 436 
     | 
    
         
            +
            	/* Handle key usage */
         
     | 
| 
      
 437 
     | 
    
         
            +
            	if((usage=X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) {
         
     | 
| 
      
 438 
     | 
    
         
            +
            		if(usage->length > 0) {
         
     | 
| 
      
 439 
     | 
    
         
            +
            			x->ex_kusage = usage->data[0];
         
     | 
| 
      
 440 
     | 
    
         
            +
            			if(usage->length > 1) 
         
     | 
| 
      
 441 
     | 
    
         
            +
            				x->ex_kusage |= usage->data[1] << 8;
         
     | 
| 
      
 442 
     | 
    
         
            +
            		} else x->ex_kusage = 0;
         
     | 
| 
      
 443 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_KUSAGE;
         
     | 
| 
      
 444 
     | 
    
         
            +
            		ASN1_BIT_STRING_free(usage);
         
     | 
| 
      
 445 
     | 
    
         
            +
            	}
         
     | 
| 
      
 446 
     | 
    
         
            +
            	x->ex_xkusage = 0;
         
     | 
| 
      
 447 
     | 
    
         
            +
            	if((extusage=X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) {
         
     | 
| 
      
 448 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_XKUSAGE;
         
     | 
| 
      
 449 
     | 
    
         
            +
            		for(i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) {
         
     | 
| 
      
 450 
     | 
    
         
            +
            			switch(OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage,i))) {
         
     | 
| 
      
 451 
     | 
    
         
            +
            				case NID_server_auth:
         
     | 
| 
      
 452 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_SSL_SERVER;
         
     | 
| 
      
 453 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
      
 455 
     | 
    
         
            +
            				case NID_client_auth:
         
     | 
| 
      
 456 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_SSL_CLIENT;
         
     | 
| 
      
 457 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 458 
     | 
    
         
            +
             
     | 
| 
      
 459 
     | 
    
         
            +
            				case NID_email_protect:
         
     | 
| 
      
 460 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_SMIME;
         
     | 
| 
      
 461 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 462 
     | 
    
         
            +
             
     | 
| 
      
 463 
     | 
    
         
            +
            				case NID_code_sign:
         
     | 
| 
      
 464 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_CODE_SIGN;
         
     | 
| 
      
 465 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 466 
     | 
    
         
            +
             
     | 
| 
      
 467 
     | 
    
         
            +
            				case NID_ms_sgc:
         
     | 
| 
      
 468 
     | 
    
         
            +
            				case NID_ns_sgc:
         
     | 
| 
      
 469 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_SGC;
         
     | 
| 
      
 470 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
            				case NID_OCSP_sign:
         
     | 
| 
      
 473 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_OCSP_SIGN;
         
     | 
| 
      
 474 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 475 
     | 
    
         
            +
             
     | 
| 
      
 476 
     | 
    
         
            +
            				case NID_time_stamp:
         
     | 
| 
      
 477 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_TIMESTAMP;
         
     | 
| 
      
 478 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 479 
     | 
    
         
            +
             
     | 
| 
      
 480 
     | 
    
         
            +
            				case NID_dvcs:
         
     | 
| 
      
 481 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_DVCS;
         
     | 
| 
      
 482 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 483 
     | 
    
         
            +
             
     | 
| 
      
 484 
     | 
    
         
            +
            				case NID_anyExtendedKeyUsage:
         
     | 
| 
      
 485 
     | 
    
         
            +
            				x->ex_xkusage |= XKU_ANYEKU;
         
     | 
| 
      
 486 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 487 
     | 
    
         
            +
            			}
         
     | 
| 
      
 488 
     | 
    
         
            +
            		}
         
     | 
| 
      
 489 
     | 
    
         
            +
            		sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
         
     | 
| 
      
 490 
     | 
    
         
            +
            	}
         
     | 
| 
      
 491 
     | 
    
         
            +
             
     | 
| 
      
 492 
     | 
    
         
            +
            	if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) {
         
     | 
| 
      
 493 
     | 
    
         
            +
            		if(ns->length > 0) x->ex_nscert = ns->data[0];
         
     | 
| 
      
 494 
     | 
    
         
            +
            		else x->ex_nscert = 0;
         
     | 
| 
      
 495 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_NSCERT;
         
     | 
| 
      
 496 
     | 
    
         
            +
            		ASN1_BIT_STRING_free(ns);
         
     | 
| 
      
 497 
     | 
    
         
            +
            	}
         
     | 
| 
      
 498 
     | 
    
         
            +
            	x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
         
     | 
| 
      
 499 
     | 
    
         
            +
            	x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
         
     | 
| 
      
 500 
     | 
    
         
            +
            	/* Does subject name match issuer ? */
         
     | 
| 
      
 501 
     | 
    
         
            +
            	if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x)))
         
     | 
| 
      
 502 
     | 
    
         
            +
            			{
         
     | 
| 
      
 503 
     | 
    
         
            +
            			x->ex_flags |= EXFLAG_SI;
         
     | 
| 
      
 504 
     | 
    
         
            +
            			/* If SKID matches AKID also indicate self signed */
         
     | 
| 
      
 505 
     | 
    
         
            +
            			if (X509_check_akid(x, x->akid) == X509_V_OK &&
         
     | 
| 
      
 506 
     | 
    
         
            +
            				!ku_reject(x, KU_KEY_CERT_SIGN))
         
     | 
| 
      
 507 
     | 
    
         
            +
            				x->ex_flags |= EXFLAG_SS;
         
     | 
| 
      
 508 
     | 
    
         
            +
            			}
         
     | 
| 
      
 509 
     | 
    
         
            +
            	x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
         
     | 
| 
      
 510 
     | 
    
         
            +
            	x->nc = X509_get_ext_d2i(x, NID_name_constraints, &j, NULL);
         
     | 
| 
      
 511 
     | 
    
         
            +
            	if (!x->nc && (j != -1))
         
     | 
| 
      
 512 
     | 
    
         
            +
            		x->ex_flags |= EXFLAG_INVALID;
         
     | 
| 
      
 513 
     | 
    
         
            +
            	setup_crldp(x);
         
     | 
| 
      
 514 
     | 
    
         
            +
             
     | 
| 
      
 515 
     | 
    
         
            +
            	for (j = 0; j < X509_get_ext_count(x); j++)
         
     | 
| 
      
 516 
     | 
    
         
            +
            		{
         
     | 
| 
      
 517 
     | 
    
         
            +
            		ex = X509_get_ext(x, j);
         
     | 
| 
      
 518 
     | 
    
         
            +
            		if (OBJ_obj2nid(X509_EXTENSION_get_object(ex))
         
     | 
| 
      
 519 
     | 
    
         
            +
            					== NID_freshest_crl)
         
     | 
| 
      
 520 
     | 
    
         
            +
            			x->ex_flags |= EXFLAG_FRESHEST;
         
     | 
| 
      
 521 
     | 
    
         
            +
            		if (!X509_EXTENSION_get_critical(ex))
         
     | 
| 
      
 522 
     | 
    
         
            +
            			continue;
         
     | 
| 
      
 523 
     | 
    
         
            +
            		if (!X509_supported_extension(ex))
         
     | 
| 
      
 524 
     | 
    
         
            +
            			{
         
     | 
| 
      
 525 
     | 
    
         
            +
            			x->ex_flags |= EXFLAG_CRITICAL;
         
     | 
| 
      
 526 
     | 
    
         
            +
            			break;
         
     | 
| 
      
 527 
     | 
    
         
            +
            			}
         
     | 
| 
      
 528 
     | 
    
         
            +
            		}
         
     | 
| 
      
 529 
     | 
    
         
            +
            	x->ex_flags |= EXFLAG_SET;
         
     | 
| 
      
 530 
     | 
    
         
            +
             
     | 
| 
      
 531 
     | 
    
         
            +
            	CRYPTO_STATIC_MUTEX_unlock(&g_x509_cache_extensions_lock);
         
     | 
| 
      
 532 
     | 
    
         
            +
            }
         
     | 
| 
      
 533 
     | 
    
         
            +
             
     | 
| 
      
 534 
     | 
    
         
            +
            /* CA checks common to all purposes
         
     | 
| 
      
 535 
     | 
    
         
            +
             * return codes:
         
     | 
| 
      
 536 
     | 
    
         
            +
             * 0 not a CA
         
     | 
| 
      
 537 
     | 
    
         
            +
             * 1 is a CA
         
     | 
| 
      
 538 
     | 
    
         
            +
             * 2 basicConstraints absent so "maybe" a CA
         
     | 
| 
      
 539 
     | 
    
         
            +
             * 3 basicConstraints absent but self signed V1.
         
     | 
| 
      
 540 
     | 
    
         
            +
             * 4 basicConstraints absent but keyUsage present and keyCertSign asserted.
         
     | 
| 
      
 541 
     | 
    
         
            +
             */
         
     | 
| 
      
 542 
     | 
    
         
            +
             
     | 
| 
      
 543 
     | 
    
         
            +
            static int check_ca(const X509 *x)
         
     | 
| 
      
 544 
     | 
    
         
            +
            {
         
     | 
| 
      
 545 
     | 
    
         
            +
            	/* keyUsage if present should allow cert signing */
         
     | 
| 
      
 546 
     | 
    
         
            +
            	if(ku_reject(x, KU_KEY_CERT_SIGN)) return 0;
         
     | 
| 
      
 547 
     | 
    
         
            +
            	if(x->ex_flags & EXFLAG_BCONS) {
         
     | 
| 
      
 548 
     | 
    
         
            +
            		if(x->ex_flags & EXFLAG_CA) return 1;
         
     | 
| 
      
 549 
     | 
    
         
            +
            		/* If basicConstraints says not a CA then say so */
         
     | 
| 
      
 550 
     | 
    
         
            +
            		else return 0;
         
     | 
| 
      
 551 
     | 
    
         
            +
            	} else {
         
     | 
| 
      
 552 
     | 
    
         
            +
            		/* we support V1 roots for...  uh, I don't really know why. */
         
     | 
| 
      
 553 
     | 
    
         
            +
            		if((x->ex_flags & V1_ROOT) == V1_ROOT) return 3;
         
     | 
| 
      
 554 
     | 
    
         
            +
            		/* If key usage present it must have certSign so tolerate it */
         
     | 
| 
      
 555 
     | 
    
         
            +
            		else if (x->ex_flags & EXFLAG_KUSAGE) return 4;
         
     | 
| 
      
 556 
     | 
    
         
            +
            		/* Older certificates could have Netscape-specific CA types */
         
     | 
| 
      
 557 
     | 
    
         
            +
            		else if (x->ex_flags & EXFLAG_NSCERT
         
     | 
| 
      
 558 
     | 
    
         
            +
            			 && x->ex_nscert & NS_ANY_CA) return 5;
         
     | 
| 
      
 559 
     | 
    
         
            +
            		/* can this still be regarded a CA certificate?  I doubt it */
         
     | 
| 
      
 560 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 561 
     | 
    
         
            +
            	}
         
     | 
| 
      
 562 
     | 
    
         
            +
            }
         
     | 
| 
      
 563 
     | 
    
         
            +
             
     | 
| 
      
 564 
     | 
    
         
            +
            int X509_check_ca(X509 *x)
         
     | 
| 
      
 565 
     | 
    
         
            +
            {
         
     | 
| 
      
 566 
     | 
    
         
            +
            	if(!(x->ex_flags & EXFLAG_SET)) {
         
     | 
| 
      
 567 
     | 
    
         
            +
            		x509v3_cache_extensions(x);
         
     | 
| 
      
 568 
     | 
    
         
            +
            	}
         
     | 
| 
      
 569 
     | 
    
         
            +
             
     | 
| 
      
 570 
     | 
    
         
            +
            	return check_ca(x);
         
     | 
| 
      
 571 
     | 
    
         
            +
            }
         
     | 
| 
      
 572 
     | 
    
         
            +
             
     | 
| 
      
 573 
     | 
    
         
            +
            /* Check SSL CA: common checks for SSL client and server */
         
     | 
| 
      
 574 
     | 
    
         
            +
            static int check_ssl_ca(const X509 *x)
         
     | 
| 
      
 575 
     | 
    
         
            +
            {
         
     | 
| 
      
 576 
     | 
    
         
            +
            	int ca_ret;
         
     | 
| 
      
 577 
     | 
    
         
            +
            	ca_ret = check_ca(x);
         
     | 
| 
      
 578 
     | 
    
         
            +
            	if(!ca_ret) return 0;
         
     | 
| 
      
 579 
     | 
    
         
            +
            	/* check nsCertType if present */
         
     | 
| 
      
 580 
     | 
    
         
            +
            	if(ca_ret != 5 || x->ex_nscert & NS_SSL_CA) return ca_ret;
         
     | 
| 
      
 581 
     | 
    
         
            +
            	else return 0;
         
     | 
| 
      
 582 
     | 
    
         
            +
            }
         
     | 
| 
      
 583 
     | 
    
         
            +
             
     | 
| 
      
 584 
     | 
    
         
            +
             
     | 
| 
      
 585 
     | 
    
         
            +
            static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 586 
     | 
    
         
            +
            {
         
     | 
| 
      
 587 
     | 
    
         
            +
            	if(xku_reject(x,XKU_SSL_CLIENT)) return 0;
         
     | 
| 
      
 588 
     | 
    
         
            +
            	if(ca) return check_ssl_ca(x);
         
     | 
| 
      
 589 
     | 
    
         
            +
            	/* We need to do digital signatures or key agreement */
         
     | 
| 
      
 590 
     | 
    
         
            +
            	if(ku_reject(x,KU_DIGITAL_SIGNATURE|KU_KEY_AGREEMENT)) return 0;
         
     | 
| 
      
 591 
     | 
    
         
            +
            	/* nsCertType if present should allow SSL client use */	
         
     | 
| 
      
 592 
     | 
    
         
            +
            	if(ns_reject(x, NS_SSL_CLIENT)) return 0;
         
     | 
| 
      
 593 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 594 
     | 
    
         
            +
            }
         
     | 
| 
      
 595 
     | 
    
         
            +
            /* Key usage needed for TLS/SSL server: digital signature, encipherment or
         
     | 
| 
      
 596 
     | 
    
         
            +
             * key agreement. The ssl code can check this more thoroughly for individual
         
     | 
| 
      
 597 
     | 
    
         
            +
             * key types.
         
     | 
| 
      
 598 
     | 
    
         
            +
             */
         
     | 
| 
      
 599 
     | 
    
         
            +
            #define KU_TLS \
         
     | 
| 
      
 600 
     | 
    
         
            +
            	KU_DIGITAL_SIGNATURE|KU_KEY_ENCIPHERMENT|KU_KEY_AGREEMENT
         
     | 
| 
      
 601 
     | 
    
         
            +
             
     | 
| 
      
 602 
     | 
    
         
            +
            static int check_purpose_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 603 
     | 
    
         
            +
            {
         
     | 
| 
      
 604 
     | 
    
         
            +
            	if(xku_reject(x,XKU_SSL_SERVER|XKU_SGC)) return 0;
         
     | 
| 
      
 605 
     | 
    
         
            +
            	if(ca) return check_ssl_ca(x);
         
     | 
| 
      
 606 
     | 
    
         
            +
             
     | 
| 
      
 607 
     | 
    
         
            +
            	if(ns_reject(x, NS_SSL_SERVER)) return 0;
         
     | 
| 
      
 608 
     | 
    
         
            +
            	if(ku_reject(x, KU_TLS)) return 0;
         
     | 
| 
      
 609 
     | 
    
         
            +
            	
         
     | 
| 
      
 610 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 611 
     | 
    
         
            +
             
     | 
| 
      
 612 
     | 
    
         
            +
            }
         
     | 
| 
      
 613 
     | 
    
         
            +
             
     | 
| 
      
 614 
     | 
    
         
            +
            static int check_purpose_ns_ssl_server(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 615 
     | 
    
         
            +
            {
         
     | 
| 
      
 616 
     | 
    
         
            +
            	int ret;
         
     | 
| 
      
 617 
     | 
    
         
            +
            	ret = check_purpose_ssl_server(xp, x, ca);
         
     | 
| 
      
 618 
     | 
    
         
            +
            	if(!ret || ca) return ret;
         
     | 
| 
      
 619 
     | 
    
         
            +
            	/* We need to encipher or Netscape complains */
         
     | 
| 
      
 620 
     | 
    
         
            +
            	if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
         
     | 
| 
      
 621 
     | 
    
         
            +
            	return ret;
         
     | 
| 
      
 622 
     | 
    
         
            +
            }
         
     | 
| 
      
 623 
     | 
    
         
            +
             
     | 
| 
      
 624 
     | 
    
         
            +
            /* common S/MIME checks */
         
     | 
| 
      
 625 
     | 
    
         
            +
            static int purpose_smime(const X509 *x, int ca)
         
     | 
| 
      
 626 
     | 
    
         
            +
            {
         
     | 
| 
      
 627 
     | 
    
         
            +
            	if(xku_reject(x,XKU_SMIME)) return 0;
         
     | 
| 
      
 628 
     | 
    
         
            +
            	if(ca) {
         
     | 
| 
      
 629 
     | 
    
         
            +
            		int ca_ret;
         
     | 
| 
      
 630 
     | 
    
         
            +
            		ca_ret = check_ca(x);
         
     | 
| 
      
 631 
     | 
    
         
            +
            		if(!ca_ret) return 0;
         
     | 
| 
      
 632 
     | 
    
         
            +
            		/* check nsCertType if present */
         
     | 
| 
      
 633 
     | 
    
         
            +
            		if(ca_ret != 5 || x->ex_nscert & NS_SMIME_CA) return ca_ret;
         
     | 
| 
      
 634 
     | 
    
         
            +
            		else return 0;
         
     | 
| 
      
 635 
     | 
    
         
            +
            	}
         
     | 
| 
      
 636 
     | 
    
         
            +
            	if(x->ex_flags & EXFLAG_NSCERT) {
         
     | 
| 
      
 637 
     | 
    
         
            +
            		if(x->ex_nscert & NS_SMIME) return 1;
         
     | 
| 
      
 638 
     | 
    
         
            +
            		/* Workaround for some buggy certificates */
         
     | 
| 
      
 639 
     | 
    
         
            +
            		if(x->ex_nscert & NS_SSL_CLIENT) return 2;
         
     | 
| 
      
 640 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 641 
     | 
    
         
            +
            	}
         
     | 
| 
      
 642 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 643 
     | 
    
         
            +
            }
         
     | 
| 
      
 644 
     | 
    
         
            +
             
     | 
| 
      
 645 
     | 
    
         
            +
            static int check_purpose_smime_sign(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 646 
     | 
    
         
            +
            {
         
     | 
| 
      
 647 
     | 
    
         
            +
            	int ret;
         
     | 
| 
      
 648 
     | 
    
         
            +
            	ret = purpose_smime(x, ca);
         
     | 
| 
      
 649 
     | 
    
         
            +
            	if(!ret || ca) return ret;
         
     | 
| 
      
 650 
     | 
    
         
            +
            	if(ku_reject(x, KU_DIGITAL_SIGNATURE|KU_NON_REPUDIATION)) return 0;
         
     | 
| 
      
 651 
     | 
    
         
            +
            	return ret;
         
     | 
| 
      
 652 
     | 
    
         
            +
            }
         
     | 
| 
      
 653 
     | 
    
         
            +
             
     | 
| 
      
 654 
     | 
    
         
            +
            static int check_purpose_smime_encrypt(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 655 
     | 
    
         
            +
            {
         
     | 
| 
      
 656 
     | 
    
         
            +
            	int ret;
         
     | 
| 
      
 657 
     | 
    
         
            +
            	ret = purpose_smime(x, ca);
         
     | 
| 
      
 658 
     | 
    
         
            +
            	if(!ret || ca) return ret;
         
     | 
| 
      
 659 
     | 
    
         
            +
            	if(ku_reject(x, KU_KEY_ENCIPHERMENT)) return 0;
         
     | 
| 
      
 660 
     | 
    
         
            +
            	return ret;
         
     | 
| 
      
 661 
     | 
    
         
            +
            }
         
     | 
| 
      
 662 
     | 
    
         
            +
             
     | 
| 
      
 663 
     | 
    
         
            +
            static int check_purpose_crl_sign(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 664 
     | 
    
         
            +
            {
         
     | 
| 
      
 665 
     | 
    
         
            +
            	if(ca) {
         
     | 
| 
      
 666 
     | 
    
         
            +
            		int ca_ret;
         
     | 
| 
      
 667 
     | 
    
         
            +
            		if((ca_ret = check_ca(x)) != 2) return ca_ret;
         
     | 
| 
      
 668 
     | 
    
         
            +
            		else return 0;
         
     | 
| 
      
 669 
     | 
    
         
            +
            	}
         
     | 
| 
      
 670 
     | 
    
         
            +
            	if(ku_reject(x, KU_CRL_SIGN)) return 0;
         
     | 
| 
      
 671 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 672 
     | 
    
         
            +
            }
         
     | 
| 
      
 673 
     | 
    
         
            +
             
     | 
| 
      
 674 
     | 
    
         
            +
            /* OCSP helper: this is *not* a full OCSP check. It just checks that
         
     | 
| 
      
 675 
     | 
    
         
            +
             * each CA is valid. Additional checks must be made on the chain.
         
     | 
| 
      
 676 
     | 
    
         
            +
             */
         
     | 
| 
      
 677 
     | 
    
         
            +
             
     | 
| 
      
 678 
     | 
    
         
            +
            static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 679 
     | 
    
         
            +
            {
         
     | 
| 
      
 680 
     | 
    
         
            +
            	/* Must be a valid CA.  Should we really support the "I don't know"
         
     | 
| 
      
 681 
     | 
    
         
            +
            	   value (2)? */
         
     | 
| 
      
 682 
     | 
    
         
            +
            	if(ca) return check_ca(x);
         
     | 
| 
      
 683 
     | 
    
         
            +
            	/* leaf certificate is checked in OCSP_verify() */
         
     | 
| 
      
 684 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 685 
     | 
    
         
            +
            }
         
     | 
| 
      
 686 
     | 
    
         
            +
             
     | 
| 
      
 687 
     | 
    
         
            +
            static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x,
         
     | 
| 
      
 688 
     | 
    
         
            +
            					int ca)
         
     | 
| 
      
 689 
     | 
    
         
            +
            {
         
     | 
| 
      
 690 
     | 
    
         
            +
            	int i_ext;
         
     | 
| 
      
 691 
     | 
    
         
            +
             
     | 
| 
      
 692 
     | 
    
         
            +
            	/* If ca is true we must return if this is a valid CA certificate. */
         
     | 
| 
      
 693 
     | 
    
         
            +
            	if (ca) return check_ca(x);
         
     | 
| 
      
 694 
     | 
    
         
            +
             
     | 
| 
      
 695 
     | 
    
         
            +
            	/* 
         
     | 
| 
      
 696 
     | 
    
         
            +
            	 * Check the optional key usage field:
         
     | 
| 
      
 697 
     | 
    
         
            +
            	 * if Key Usage is present, it must be one of digitalSignature 
         
     | 
| 
      
 698 
     | 
    
         
            +
            	 * and/or nonRepudiation (other values are not consistent and shall
         
     | 
| 
      
 699 
     | 
    
         
            +
            	 * be rejected).
         
     | 
| 
      
 700 
     | 
    
         
            +
            	 */
         
     | 
| 
      
 701 
     | 
    
         
            +
            	if ((x->ex_flags & EXFLAG_KUSAGE)
         
     | 
| 
      
 702 
     | 
    
         
            +
            	    && ((x->ex_kusage & ~(KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE)) ||
         
     | 
| 
      
 703 
     | 
    
         
            +
            		!(x->ex_kusage & (KU_NON_REPUDIATION | KU_DIGITAL_SIGNATURE))))
         
     | 
| 
      
 704 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 705 
     | 
    
         
            +
             
     | 
| 
      
 706 
     | 
    
         
            +
            	/* Only time stamp key usage is permitted and it's required. */
         
     | 
| 
      
 707 
     | 
    
         
            +
            	if (!(x->ex_flags & EXFLAG_XKUSAGE) || x->ex_xkusage != XKU_TIMESTAMP)
         
     | 
| 
      
 708 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 709 
     | 
    
         
            +
             
     | 
| 
      
 710 
     | 
    
         
            +
            	/* Extended Key Usage MUST be critical */
         
     | 
| 
      
 711 
     | 
    
         
            +
            	i_ext = X509_get_ext_by_NID((X509 *) x, NID_ext_key_usage, -1);
         
     | 
| 
      
 712 
     | 
    
         
            +
            	if (i_ext >= 0)
         
     | 
| 
      
 713 
     | 
    
         
            +
            		{
         
     | 
| 
      
 714 
     | 
    
         
            +
            		X509_EXTENSION *ext = X509_get_ext((X509 *) x, i_ext);
         
     | 
| 
      
 715 
     | 
    
         
            +
            		if (!X509_EXTENSION_get_critical(ext))
         
     | 
| 
      
 716 
     | 
    
         
            +
            			return 0;
         
     | 
| 
      
 717 
     | 
    
         
            +
            		}
         
     | 
| 
      
 718 
     | 
    
         
            +
             
     | 
| 
      
 719 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 720 
     | 
    
         
            +
            }
         
     | 
| 
      
 721 
     | 
    
         
            +
             
     | 
| 
      
 722 
     | 
    
         
            +
            static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca)
         
     | 
| 
      
 723 
     | 
    
         
            +
            {
         
     | 
| 
      
 724 
     | 
    
         
            +
            	return 1;
         
     | 
| 
      
 725 
     | 
    
         
            +
            }
         
     | 
| 
      
 726 
     | 
    
         
            +
             
     | 
| 
      
 727 
     | 
    
         
            +
            /* Various checks to see if one certificate issued the second.
         
     | 
| 
      
 728 
     | 
    
         
            +
             * This can be used to prune a set of possible issuer certificates
         
     | 
| 
      
 729 
     | 
    
         
            +
             * which have been looked up using some simple method such as by
         
     | 
| 
      
 730 
     | 
    
         
            +
             * subject name.
         
     | 
| 
      
 731 
     | 
    
         
            +
             * These are:
         
     | 
| 
      
 732 
     | 
    
         
            +
             * 1. Check issuer_name(subject) == subject_name(issuer)
         
     | 
| 
      
 733 
     | 
    
         
            +
             * 2. If akid(subject) exists check it matches issuer
         
     | 
| 
      
 734 
     | 
    
         
            +
             * 3. If key_usage(issuer) exists check it supports certificate signing
         
     | 
| 
      
 735 
     | 
    
         
            +
             * returns 0 for OK, positive for reason for mismatch, reasons match
         
     | 
| 
      
 736 
     | 
    
         
            +
             * codes for X509_verify_cert()
         
     | 
| 
      
 737 
     | 
    
         
            +
             */
         
     | 
| 
      
 738 
     | 
    
         
            +
             
     | 
| 
      
 739 
     | 
    
         
            +
            int X509_check_issued(X509 *issuer, X509 *subject)
         
     | 
| 
      
 740 
     | 
    
         
            +
            {
         
     | 
| 
      
 741 
     | 
    
         
            +
            	if(X509_NAME_cmp(X509_get_subject_name(issuer),
         
     | 
| 
      
 742 
     | 
    
         
            +
            			X509_get_issuer_name(subject)))
         
     | 
| 
      
 743 
     | 
    
         
            +
            				return X509_V_ERR_SUBJECT_ISSUER_MISMATCH;
         
     | 
| 
      
 744 
     | 
    
         
            +
            	x509v3_cache_extensions(issuer);
         
     | 
| 
      
 745 
     | 
    
         
            +
            	x509v3_cache_extensions(subject);
         
     | 
| 
      
 746 
     | 
    
         
            +
             
     | 
| 
      
 747 
     | 
    
         
            +
            	if(subject->akid)
         
     | 
| 
      
 748 
     | 
    
         
            +
            		{
         
     | 
| 
      
 749 
     | 
    
         
            +
            		int ret = X509_check_akid(issuer, subject->akid);
         
     | 
| 
      
 750 
     | 
    
         
            +
            		if (ret != X509_V_OK)
         
     | 
| 
      
 751 
     | 
    
         
            +
            			return ret;
         
     | 
| 
      
 752 
     | 
    
         
            +
            		}
         
     | 
| 
      
 753 
     | 
    
         
            +
             
     | 
| 
      
 754 
     | 
    
         
            +
            	if(subject->ex_flags & EXFLAG_PROXY)
         
     | 
| 
      
 755 
     | 
    
         
            +
            		{
         
     | 
| 
      
 756 
     | 
    
         
            +
            		if(ku_reject(issuer, KU_DIGITAL_SIGNATURE))
         
     | 
| 
      
 757 
     | 
    
         
            +
            			return X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE;
         
     | 
| 
      
 758 
     | 
    
         
            +
            		}
         
     | 
| 
      
 759 
     | 
    
         
            +
            	else if(ku_reject(issuer, KU_KEY_CERT_SIGN))
         
     | 
| 
      
 760 
     | 
    
         
            +
            		return X509_V_ERR_KEYUSAGE_NO_CERTSIGN;
         
     | 
| 
      
 761 
     | 
    
         
            +
            	return X509_V_OK;
         
     | 
| 
      
 762 
     | 
    
         
            +
            }
         
     | 
| 
      
 763 
     | 
    
         
            +
             
     | 
| 
      
 764 
     | 
    
         
            +
            int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid)
         
     | 
| 
      
 765 
     | 
    
         
            +
            	{
         
     | 
| 
      
 766 
     | 
    
         
            +
             
     | 
| 
      
 767 
     | 
    
         
            +
            	if(!akid)
         
     | 
| 
      
 768 
     | 
    
         
            +
            		return X509_V_OK;
         
     | 
| 
      
 769 
     | 
    
         
            +
             
     | 
| 
      
 770 
     | 
    
         
            +
            	/* Check key ids (if present) */
         
     | 
| 
      
 771 
     | 
    
         
            +
            	if(akid->keyid && issuer->skid &&
         
     | 
| 
      
 772 
     | 
    
         
            +
            		 ASN1_OCTET_STRING_cmp(akid->keyid, issuer->skid) )
         
     | 
| 
      
 773 
     | 
    
         
            +
            				return X509_V_ERR_AKID_SKID_MISMATCH;
         
     | 
| 
      
 774 
     | 
    
         
            +
            	/* Check serial number */
         
     | 
| 
      
 775 
     | 
    
         
            +
            	if(akid->serial &&
         
     | 
| 
      
 776 
     | 
    
         
            +
            		ASN1_INTEGER_cmp(X509_get_serialNumber(issuer), akid->serial))
         
     | 
| 
      
 777 
     | 
    
         
            +
            				return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
         
     | 
| 
      
 778 
     | 
    
         
            +
            	/* Check issuer name */
         
     | 
| 
      
 779 
     | 
    
         
            +
            	if(akid->issuer)
         
     | 
| 
      
 780 
     | 
    
         
            +
            		{
         
     | 
| 
      
 781 
     | 
    
         
            +
            		/* Ugh, for some peculiar reason AKID includes
         
     | 
| 
      
 782 
     | 
    
         
            +
            		 * SEQUENCE OF GeneralName. So look for a DirName.
         
     | 
| 
      
 783 
     | 
    
         
            +
            		 * There may be more than one but we only take any
         
     | 
| 
      
 784 
     | 
    
         
            +
            		 * notice of the first.
         
     | 
| 
      
 785 
     | 
    
         
            +
            		 */
         
     | 
| 
      
 786 
     | 
    
         
            +
            		GENERAL_NAMES *gens;
         
     | 
| 
      
 787 
     | 
    
         
            +
            		GENERAL_NAME *gen;
         
     | 
| 
      
 788 
     | 
    
         
            +
            		X509_NAME *nm = NULL;
         
     | 
| 
      
 789 
     | 
    
         
            +
            		size_t i;
         
     | 
| 
      
 790 
     | 
    
         
            +
            		gens = akid->issuer;
         
     | 
| 
      
 791 
     | 
    
         
            +
            		for(i = 0; i < sk_GENERAL_NAME_num(gens); i++)
         
     | 
| 
      
 792 
     | 
    
         
            +
            			{
         
     | 
| 
      
 793 
     | 
    
         
            +
            			gen = sk_GENERAL_NAME_value(gens, i);
         
     | 
| 
      
 794 
     | 
    
         
            +
            			if(gen->type == GEN_DIRNAME)
         
     | 
| 
      
 795 
     | 
    
         
            +
            				{
         
     | 
| 
      
 796 
     | 
    
         
            +
            				nm = gen->d.dirn;
         
     | 
| 
      
 797 
     | 
    
         
            +
            				break;
         
     | 
| 
      
 798 
     | 
    
         
            +
            				}
         
     | 
| 
      
 799 
     | 
    
         
            +
            			}
         
     | 
| 
      
 800 
     | 
    
         
            +
            		if(nm && X509_NAME_cmp(nm, X509_get_issuer_name(issuer)))
         
     | 
| 
      
 801 
     | 
    
         
            +
            			return X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH;
         
     | 
| 
      
 802 
     | 
    
         
            +
            		}
         
     | 
| 
      
 803 
     | 
    
         
            +
            	return X509_V_OK;
         
     | 
| 
      
 804 
     | 
    
         
            +
            	}
         
     | 
| 
      
 805 
     | 
    
         
            +
             
     |