@fails-components/webtransport 0.0.1 → 0.0.2
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.
- package/package.json +1 -1
- package/readme.md +1 -3
- package/src/http3eventloop.cc +83 -9
- package/src/http3eventloop.h +13 -3
- package/src/http3server.cc +22 -22
- package/src/http3server.h +7 -20
- package/src/http3wtstreamvisitor.cc +31 -10
- package/src/http3wtstreamvisitor.h +38 -11
- package/src/webtransport.js +91 -23
- package/test/echoserver.js +29 -5
- package/test/testsuite.js +242 -220
- package/third_party/boringssl/src/CMakeLists.txt +2 -0
- package/third_party/boringssl/src/crypto/CMakeLists.txt +1 -0
- package/third_party/boringssl/src/crypto/asn1/a_bitstr.c +174 -177
- package/third_party/boringssl/src/crypto/asn1/a_bool.c +46 -48
- package/third_party/boringssl/src/crypto/asn1/a_d2i_fp.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_dup.c +21 -23
- package/third_party/boringssl/src/crypto/asn1/a_gentm.c +84 -187
- package/third_party/boringssl/src/crypto/asn1/a_i2d_fp.c +19 -21
- package/third_party/boringssl/src/crypto/asn1/a_int.c +305 -329
- package/third_party/boringssl/src/crypto/asn1/a_mbstr.c +190 -195
- package/third_party/boringssl/src/crypto/asn1/a_object.c +182 -189
- package/third_party/boringssl/src/crypto/asn1/a_octet.c +6 -9
- package/third_party/boringssl/src/crypto/asn1/a_print.c +15 -16
- package/third_party/boringssl/src/crypto/asn1/a_strex.c +386 -399
- package/third_party/boringssl/src/crypto/asn1/a_strnid.c +110 -131
- package/third_party/boringssl/src/crypto/asn1/a_time.c +118 -111
- package/third_party/boringssl/src/crypto/asn1/a_type.c +59 -60
- package/third_party/boringssl/src/crypto/asn1/a_utctm.c +114 -186
- package/third_party/boringssl/src/crypto/asn1/a_utf8.c +171 -159
- package/third_party/boringssl/src/crypto/asn1/asn1_lib.c +245 -260
- package/third_party/boringssl/src/crypto/asn1/asn1_par.c +41 -40
- package/third_party/boringssl/src/crypto/asn1/asn1_test.cc +31 -0
- package/third_party/boringssl/src/crypto/asn1/asn_pack.c +31 -33
- package/third_party/boringssl/src/crypto/asn1/f_int.c +36 -33
- package/third_party/boringssl/src/crypto/asn1/f_string.c +29 -26
- package/third_party/boringssl/src/crypto/asn1/internal.h +62 -61
- package/third_party/boringssl/src/crypto/asn1/tasn_dec.c +706 -702
- package/third_party/boringssl/src/crypto/asn1/tasn_enc.c +507 -524
- package/third_party/boringssl/src/crypto/asn1/tasn_fre.c +141 -133
- package/third_party/boringssl/src/crypto/asn1/tasn_new.c +207 -199
- package/third_party/boringssl/src/crypto/asn1/tasn_typ.c +19 -22
- package/third_party/boringssl/src/crypto/asn1/tasn_utl.c +24 -24
- package/third_party/boringssl/src/crypto/asn1/time_support.c +13 -13
- package/third_party/boringssl/src/crypto/bio/connect.c +9 -3
- package/third_party/boringssl/src/crypto/bytestring/bytestring_test.cc +125 -1
- package/third_party/boringssl/src/crypto/bytestring/cbb.c +4 -7
- package/third_party/boringssl/src/crypto/bytestring/cbs.c +167 -9
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesctrhmac.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_aesgcmsiv.c +23 -54
- package/third_party/boringssl/src/crypto/cipher_extra/e_chacha20poly1305.c +0 -2
- package/third_party/boringssl/src/crypto/cipher_extra/e_tls.c +0 -2
- package/third_party/boringssl/src/crypto/curve25519/curve25519.c +6 -8
- package/third_party/boringssl/src/crypto/evp/evp_ctx.c +25 -22
- package/third_party/boringssl/src/crypto/evp/internal.h +15 -9
- package/third_party/boringssl/src/crypto/evp/p_dsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ec_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_ed25519.c +3 -3
- package/third_party/boringssl/src/crypto/evp/p_ed25519_asn1.c +10 -7
- package/third_party/boringssl/src/crypto/evp/p_hkdf.c +241 -0
- package/third_party/boringssl/src/crypto/evp/p_rsa_asn1.c +2 -0
- package/third_party/boringssl/src/crypto/evp/p_x25519_asn1.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/aes/aes_nohw.c +9 -10
- package/third_party/boringssl/src/crypto/fipsmodule/aes/key_wrap.c +2 -6
- package/third_party/boringssl/src/crypto/fipsmodule/bn/exponentiation.c +5 -11
- package/third_party/boringssl/src/crypto/fipsmodule/bn/internal.h +1 -1
- package/third_party/boringssl/src/crypto/fipsmodule/bn/prime.c +2 -0
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aes.c +10 -26
- package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aesccm.c +2 -3
- package/third_party/boringssl/src/crypto/fipsmodule/digestsign/digestsign.c +1 -0
- package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz.c +44 -43
- package/third_party/boringssl/src/crypto/fipsmodule/modes/cbc.c +5 -9
- package/third_party/boringssl/src/crypto/fipsmodule/modes/gcm.c +14 -21
- package/third_party/boringssl/src/crypto/fipsmodule/rand/ctrdrbg.c +8 -8
- package/third_party/boringssl/src/crypto/fipsmodule/rand/internal.h +1 -4
- package/third_party/boringssl/src/crypto/hkdf/hkdf_test.cc +104 -0
- package/third_party/boringssl/src/crypto/internal.h +18 -4
- package/third_party/boringssl/src/crypto/lhash/internal.h +13 -1
- package/third_party/boringssl/src/crypto/obj/obj_dat.h +4 -1
- package/third_party/boringssl/src/crypto/obj/obj_mac.num +1 -0
- package/third_party/boringssl/src/crypto/obj/objects.txt +2 -0
- package/third_party/boringssl/src/crypto/pem/pem_all.c +77 -86
- package/third_party/boringssl/src/crypto/pem/pem_info.c +221 -233
- package/third_party/boringssl/src/crypto/pem/pem_lib.c +639 -608
- package/third_party/boringssl/src/crypto/pem/pem_oth.c +17 -16
- package/third_party/boringssl/src/crypto/pem/pem_pk8.c +133 -142
- package/third_party/boringssl/src/crypto/pem/pem_pkey.c +96 -92
- package/third_party/boringssl/src/crypto/poly1305/poly1305_vec.c +12 -28
- package/third_party/boringssl/src/crypto/siphash/siphash.c +8 -11
- package/third_party/boringssl/src/crypto/siphash/siphash_test.cc +5 -7
- package/third_party/boringssl/src/crypto/stack/stack.c +33 -16
- package/third_party/boringssl/src/crypto/thread_pthread.c +0 -2
- package/third_party/boringssl/src/crypto/thread_win.c +0 -2
- package/third_party/boringssl/src/crypto/trust_token/internal.h +14 -0
- package/third_party/boringssl/src/crypto/trust_token/pmbtoken.c +127 -30
- package/third_party/boringssl/src/crypto/trust_token/trust_token.c +40 -0
- package/third_party/boringssl/src/crypto/trust_token/trust_token_test.cc +165 -0
- package/third_party/boringssl/src/crypto/trust_token/voprf.c +55 -6
- package/third_party/boringssl/src/crypto/x509/a_digest.c +23 -24
- package/third_party/boringssl/src/crypto/x509/a_sign.c +52 -55
- package/third_party/boringssl/src/crypto/x509/a_verify.c +33 -34
- package/third_party/boringssl/src/crypto/x509/algorithm.c +17 -18
- package/third_party/boringssl/src/crypto/x509/asn1_gen.c +618 -612
- package/third_party/boringssl/src/crypto/x509/by_dir.c +320 -337
- package/third_party/boringssl/src/crypto/x509/by_file.c +186 -186
- package/third_party/boringssl/src/crypto/x509/i2d_pr.c +11 -14
- package/third_party/boringssl/src/crypto/x509/internal.h +22 -22
- package/third_party/boringssl/src/crypto/x509/name_print.c +155 -150
- package/third_party/boringssl/src/crypto/x509/rsa_pss.c +27 -29
- package/third_party/boringssl/src/crypto/x509/t_crl.c +67 -70
- package/third_party/boringssl/src/crypto/x509/t_req.c +3 -5
- package/third_party/boringssl/src/crypto/x509/t_x509.c +280 -251
- package/third_party/boringssl/src/crypto/x509/t_x509a.c +52 -47
- package/third_party/boringssl/src/crypto/x509/x509.c +3 -4
- package/third_party/boringssl/src/crypto/x509/x509_att.c +234 -223
- package/third_party/boringssl/src/crypto/x509/x509_cmp.c +286 -296
- package/third_party/boringssl/src/crypto/x509/x509_d2.c +37 -32
- package/third_party/boringssl/src/crypto/x509/x509_def.c +14 -30
- package/third_party/boringssl/src/crypto/x509/x509_ext.c +55 -84
- package/third_party/boringssl/src/crypto/x509/x509_lu.c +545 -581
- package/third_party/boringssl/src/crypto/x509/x509_obj.c +131 -121
- package/third_party/boringssl/src/crypto/x509/x509_req.c +120 -139
- package/third_party/boringssl/src/crypto/x509/x509_set.c +128 -142
- package/third_party/boringssl/src/crypto/x509/x509_trs.c +185 -193
- package/third_party/boringssl/src/crypto/x509/x509_txt.c +70 -72
- package/third_party/boringssl/src/crypto/x509/x509_v3.c +172 -161
- package/third_party/boringssl/src/crypto/x509/x509_vfy.c +2041 -2053
- package/third_party/boringssl/src/crypto/x509/x509_vpm.c +441 -461
- package/third_party/boringssl/src/crypto/x509/x509cset.c +152 -170
- package/third_party/boringssl/src/crypto/x509/x509name.c +274 -260
- package/third_party/boringssl/src/crypto/x509/x509rset.c +43 -20
- package/third_party/boringssl/src/crypto/x509/x509spki.c +62 -63
- package/third_party/boringssl/src/crypto/x509/x_algor.c +64 -62
- package/third_party/boringssl/src/crypto/x509/x_all.c +103 -133
- package/third_party/boringssl/src/crypto/x509/x_attrib.c +23 -24
- package/third_party/boringssl/src/crypto/x509/x_crl.c +310 -321
- package/third_party/boringssl/src/crypto/x509/x_exten.c +6 -5
- package/third_party/boringssl/src/crypto/x509/x_info.c +31 -28
- package/third_party/boringssl/src/crypto/x509/x_name.c +361 -365
- package/third_party/boringssl/src/crypto/x509/x_pkey.c +38 -32
- package/third_party/boringssl/src/crypto/x509/x_pubkey.c +114 -117
- package/third_party/boringssl/src/crypto/x509/x_req.c +27 -29
- package/third_party/boringssl/src/crypto/x509/x_sig.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_spki.c +8 -10
- package/third_party/boringssl/src/crypto/x509/x_val.c +2 -2
- package/third_party/boringssl/src/crypto/x509/x_x509.c +212 -226
- package/third_party/boringssl/src/crypto/x509/x_x509a.c +112 -109
- package/third_party/boringssl/src/crypto/x509v3/ext_dat.h +10 -13
- package/third_party/boringssl/src/crypto/x509v3/internal.h +72 -87
- package/third_party/boringssl/src/crypto/x509v3/pcy_cache.c +184 -176
- package/third_party/boringssl/src/crypto/x509v3/pcy_data.c +58 -56
- package/third_party/boringssl/src/crypto/x509v3/pcy_lib.c +71 -70
- package/third_party/boringssl/src/crypto/x509v3/pcy_map.c +56 -58
- package/third_party/boringssl/src/crypto/x509v3/pcy_node.c +89 -91
- package/third_party/boringssl/src/crypto/x509v3/pcy_tree.c +585 -590
- package/third_party/boringssl/src/crypto/x509v3/v3_akey.c +118 -112
- package/third_party/boringssl/src/crypto/x509v3/v3_akeya.c +3 -3
- package/third_party/boringssl/src/crypto/x509v3/v3_alt.c +447 -451
- package/third_party/boringssl/src/crypto/x509v3/v3_bcons.c +44 -38
- package/third_party/boringssl/src/crypto/x509v3/v3_bitst.c +39 -43
- package/third_party/boringssl/src/crypto/x509v3/v3_conf.c +321 -320
- package/third_party/boringssl/src/crypto/x509v3/v3_cpols.c +352 -327
- package/third_party/boringssl/src/crypto/x509v3/v3_crld.c +437 -383
- package/third_party/boringssl/src/crypto/x509v3/v3_enum.c +23 -16
- package/third_party/boringssl/src/crypto/x509v3/v3_extku.c +62 -53
- package/third_party/boringssl/src/crypto/x509v3/v3_genn.c +118 -115
- package/third_party/boringssl/src/crypto/x509v3/v3_ia5.c +30 -31
- package/third_party/boringssl/src/crypto/x509v3/v3_info.c +112 -98
- package/third_party/boringssl/src/crypto/x509v3/v3_int.c +40 -15
- package/third_party/boringssl/src/crypto/x509v3/v3_lib.c +248 -252
- package/third_party/boringssl/src/crypto/x509v3/v3_ncons.c +390 -386
- package/third_party/boringssl/src/crypto/x509v3/v3_ocsp.c +45 -32
- package/third_party/boringssl/src/crypto/x509v3/v3_pci.c +206 -209
- package/third_party/boringssl/src/crypto/x509v3/v3_pcia.c +6 -8
- package/third_party/boringssl/src/crypto/x509v3/v3_pcons.c +54 -50
- package/third_party/boringssl/src/crypto/x509v3/v3_pmaps.c +66 -65
- package/third_party/boringssl/src/crypto/x509v3/v3_prn.c +144 -133
- package/third_party/boringssl/src/crypto/x509v3/v3_purp.c +695 -709
- package/third_party/boringssl/src/crypto/x509v3/v3_skey.c +75 -69
- package/third_party/boringssl/src/crypto/x509v3/v3_utl.c +1102 -1082
- package/third_party/boringssl/src/include/openssl/base.h +3 -1
- package/third_party/boringssl/src/include/openssl/bn.h +3 -0
- package/third_party/boringssl/src/include/openssl/bytestring.h +20 -0
- package/third_party/boringssl/src/include/openssl/evp.h +6 -5
- package/third_party/boringssl/src/include/openssl/kdf.h +91 -0
- package/third_party/boringssl/src/include/openssl/nid.h +4 -0
- package/third_party/boringssl/src/include/openssl/ssl.h +6 -1
- package/third_party/boringssl/src/include/openssl/stack.h +47 -32
- package/third_party/boringssl/src/include/openssl/trust_token.h +18 -3
- package/third_party/boringssl/src/include/openssl/x509.h +18 -0
- package/third_party/boringssl/src/ssl/ssl_file.cc +61 -99
- package/third_party/boringssl/src/ssl/ssl_test.cc +101 -0
- package/third_party/boringssl/src/util/doc.config +2 -1
- package/third_party/boringssl/src/util/fipstools/acvp/acvptool/subprocess/subprocess.go +8 -0
- package/third_party/googleurl/AUTHORS +16 -2
- package/third_party/googleurl/base/BUILD +1 -0
- package/third_party/googleurl/base/compiler_specific.h +16 -17
- package/third_party/googleurl/base/containers/contiguous_iterator.h +13 -9
- package/third_party/googleurl/base/containers/span.h +23 -8
- package/third_party/googleurl/base/memory/raw_ptr.h +17 -25
- package/third_party/googleurl/base/memory/raw_ptr_exclusion.h +21 -0
- package/third_party/googleurl/base/strings/escape.cc +14 -2
- package/third_party/googleurl/base/strings/safe_sprintf.h +1 -1
- package/third_party/googleurl/base/strings/string_number_conversions.cc +5 -3
- package/third_party/googleurl/base/strings/string_number_conversions_internal.h +5 -5
- package/third_party/googleurl/base/strings/string_piece.h +3 -3
- package/third_party/googleurl/base/strings/string_util.cc +4 -27
- package/third_party/googleurl/base/strings/string_util.h +43 -8
- package/third_party/googleurl/base/strings/string_util_internal.h +11 -12
- package/third_party/googleurl/base/strings/string_util_unittest.cc +33 -0
- package/third_party/googleurl/base/strings/string_util_win.cc +0 -5
- package/third_party/googleurl/base/strings/string_util_win.h +9 -1
- package/third_party/googleurl/base/strings/utf_offset_string_conversions.cc +1 -1
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.cc +5 -8
- package/third_party/googleurl/base/strings/utf_string_conversion_utils.h +13 -10
- package/third_party/googleurl/base/strings/utf_string_conversions.cc +32 -25
- package/third_party/googleurl/base/template_util.h +23 -35
- package/third_party/googleurl/build/build_config.h +14 -3
- package/third_party/googleurl/copy.bara.sky +1 -1
- package/third_party/googleurl/url/gurl.cc +8 -4
- package/third_party/googleurl/url/gurl.h +1 -0
- package/third_party/googleurl/url/gurl_unittest.cc +1 -0
- package/third_party/googleurl/url/origin.h +36 -26
- package/third_party/googleurl/url/scheme_host_port.h +4 -1
- package/third_party/googleurl/url/url_canon.h +2 -1
- package/third_party/googleurl/url/url_canon_internal.cc +9 -7
- package/third_party/googleurl/url/url_canon_internal.h +16 -16
- package/third_party/googleurl/url/url_canon_stdstring.h +2 -1
- package/third_party/googleurl/url/url_util.cc +9 -8
- package/third_party/quiche/build/source_list.bzl +7 -0
- package/third_party/quiche/build/source_list.gni +7 -0
- package/third_party/quiche/build/source_list.json +7 -0
- package/third_party/quiche/quiche/common/platform/api/quiche_mem_slice.h +7 -3
- package/third_party/quiche/quiche/http2/adapter/nghttp2_adapter_test.cc +86 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_adapter_test.cc +104 -2
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.cc +23 -0
- package/third_party/quiche/quiche/http2/adapter/oghttp2_session.h +6 -1
- package/third_party/quiche/quiche/quic/core/congestion_control/send_algorithm_test.cc +0 -16
- package/third_party/quiche/quiche/quic/core/crypto/crypto_protocol.h +1 -1
- package/third_party/quiche/quiche/quic/core/http/end_to_end_test.cc +56 -2
- package/third_party/quiche/quiche/quic/core/http/http_constants.cc +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_constants.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder.cc +28 -17
- package/third_party/quiche/quiche/quic/core/http/http_encoder.h +5 -0
- package/third_party/quiche/quiche/quic/core/http/http_encoder_test.cc +26 -30
- package/third_party/quiche/quiche/quic/core/http/http_frames.h +1 -0
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base.cc +4 -4
- package/third_party/quiche/quiche/quic/core/http/quic_server_session_base_test.cc +1 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_client_session.cc +5 -1
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.cc +6 -33
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.h +0 -17
- package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream_test.cc +5 -20
- package/third_party/quiche/quiche/quic/core/io/quic_event_loop.h +81 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.cc +265 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.h +152 -0
- package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop_test.cc +341 -0
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.h +7 -7
- package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store_test.cc +4 -3
- package/third_party/quiche/quiche/quic/core/quic_connection.cc +69 -19
- package/third_party/quiche/quiche/quic/core/quic_connection.h +9 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.cc +29 -10
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.h +5 -3
- package/third_party/quiche/quiche/quic/core/quic_connection_id_manager_test.cc +85 -22
- package/third_party/quiche/quiche/quic/core/quic_connection_test.cc +186 -30
- package/third_party/quiche/quiche/quic/core/quic_crypto_stream.cc +2 -1
- package/third_party/quiche/quiche/quic/core/quic_default_clock.cc +31 -0
- package/third_party/quiche/quiche/quic/core/quic_default_clock.h +34 -0
- package/third_party/quiche/quiche/quic/core/quic_default_connection_helper.h +49 -0
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.cc +53 -37
- package/third_party/quiche/quiche/quic/core/quic_dispatcher.h +19 -11
- package/third_party/quiche/quiche/quic/core/quic_dispatcher_test.cc +15 -2
- package/third_party/quiche/quiche/quic/core/quic_flags_list.h +10 -4
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector.cc +2 -2
- package/third_party/quiche/quiche/quic/core/quic_idle_network_detector_test.cc +4 -4
- package/third_party/quiche/quiche/quic/core/quic_packet_creator.cc +14 -3
- package/third_party/quiche/quiche/quic/core/quic_packet_creator_test.cc +145 -2
- package/third_party/quiche/quiche/quic/core/quic_packets.cc +3 -1
- package/third_party/quiche/quiche/quic/core/quic_packets.h +4 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.cc +13 -11
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.h +9 -0
- package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager_test.cc +6 -0
- package/third_party/quiche/quiche/quic/core/quic_session.cc +3 -2
- package/third_party/quiche/quiche/quic/core/quic_session.h +8 -3
- package/third_party/quiche/quiche/quic/core/quic_types.cc +18 -0
- package/third_party/quiche/quiche/quic/core/quic_types.h +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.cc +3 -0
- package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.h +10 -0
- package/third_party/quiche/quiche/quic/test_tools/mock_quic_session_visitor.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.h +1 -1
- package/third_party/quiche/quiche/quic/test_tools/server_thread.cc +3 -2
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.cc +7 -1
- package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.h +3 -0
- package/third_party/quiche/quiche/quic/test_tools/simulator/quic_endpoint.h +4 -2
- package/certs/ca.cnf +0 -69
- package/certs/generate_certs.sh +0 -53
- package/certs/generate_certs_leaf.sh +0 -53
- package/certs/leaf.cnf +0 -24
- package/certs/readme.txt +0 -2
- package/third_party/quiche/build/BUILD.bazel +0 -7
|
@@ -66,743 +66,707 @@
|
|
|
66
66
|
#include "../internal.h"
|
|
67
67
|
#include "internal.h"
|
|
68
68
|
|
|
69
|
-
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
|
|
70
|
-
|
|
71
|
-
X509_LOOKUP *ret;
|
|
72
|
-
|
|
73
|
-
ret = (X509_LOOKUP *)OPENSSL_malloc(sizeof(X509_LOOKUP));
|
|
74
|
-
if (ret == NULL)
|
|
75
|
-
return NULL;
|
|
76
|
-
|
|
77
|
-
ret->init = 0;
|
|
78
|
-
ret->skip = 0;
|
|
79
|
-
ret->method = method;
|
|
80
|
-
ret->method_data = NULL;
|
|
81
|
-
ret->store_ctx = NULL;
|
|
82
|
-
if ((method->new_item != NULL) && !method->new_item(ret)) {
|
|
83
|
-
OPENSSL_free(ret);
|
|
84
|
-
return NULL;
|
|
85
|
-
}
|
|
86
|
-
return ret;
|
|
87
|
-
}
|
|
69
|
+
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) {
|
|
70
|
+
X509_LOOKUP *ret;
|
|
88
71
|
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
72
|
+
ret = (X509_LOOKUP *)OPENSSL_malloc(sizeof(X509_LOOKUP));
|
|
73
|
+
if (ret == NULL) {
|
|
74
|
+
return NULL;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ret->init = 0;
|
|
78
|
+
ret->skip = 0;
|
|
79
|
+
ret->method = method;
|
|
80
|
+
ret->method_data = NULL;
|
|
81
|
+
ret->store_ctx = NULL;
|
|
82
|
+
if ((method->new_item != NULL) && !method->new_item(ret)) {
|
|
83
|
+
OPENSSL_free(ret);
|
|
84
|
+
return NULL;
|
|
85
|
+
}
|
|
86
|
+
return ret;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void X509_LOOKUP_free(X509_LOOKUP *ctx) {
|
|
90
|
+
if (ctx == NULL) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if ((ctx->method != NULL) && (ctx->method->free != NULL)) {
|
|
94
|
+
(*ctx->method->free)(ctx);
|
|
95
|
+
}
|
|
96
|
+
OPENSSL_free(ctx);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
int X509_LOOKUP_init(X509_LOOKUP *ctx) {
|
|
100
|
+
if (ctx->method == NULL) {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
if (ctx->method->init != NULL) {
|
|
104
|
+
return ctx->method->init(ctx);
|
|
105
|
+
} else {
|
|
106
|
+
return 1;
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
int X509_LOOKUP_shutdown(X509_LOOKUP *ctx)
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
int X509_LOOKUP_shutdown(X509_LOOKUP *ctx) {
|
|
111
|
+
if (ctx->method == NULL) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
if (ctx->method->shutdown != NULL) {
|
|
115
|
+
return ctx->method->shutdown(ctx);
|
|
116
|
+
} else {
|
|
117
|
+
return 1;
|
|
118
|
+
}
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
|
|
119
|
-
char **ret)
|
|
120
|
-
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
char **ret) {
|
|
123
|
+
if (ctx->method == NULL) {
|
|
124
|
+
return -1;
|
|
125
|
+
}
|
|
126
|
+
if (ctx->method->ctrl != NULL) {
|
|
127
|
+
return ctx->method->ctrl(ctx, cmd, argc, argl, ret);
|
|
128
|
+
} else {
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name,
|
|
130
|
-
X509_OBJECT *ret)
|
|
131
|
-
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
X509_OBJECT *ret) {
|
|
135
|
+
if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL)) {
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
if (ctx->skip) {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
return ctx->method->get_by_subject(ctx, type, name, ret) > 0;
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, int type, X509_NAME *name,
|
|
140
|
-
ASN1_INTEGER *serial, X509_OBJECT *ret)
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
ASN1_INTEGER *serial, X509_OBJECT *ret) {
|
|
146
|
+
if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL)) {
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret) > 0;
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret) > 0;
|
|
152
|
+
int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, int type, unsigned char *bytes,
|
|
153
|
+
int len, X509_OBJECT *ret) {
|
|
154
|
+
if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL)) {
|
|
155
|
+
return 0;
|
|
156
|
+
}
|
|
157
|
+
return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret) > 0;
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, int type, char *str, int len,
|
|
157
|
-
X509_OBJECT *ret)
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
X509_OBJECT *ret) {
|
|
162
|
+
if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL)) {
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
return ctx->method->get_by_alias(ctx, type, str, len, ret) > 0;
|
|
162
166
|
}
|
|
163
167
|
|
|
164
|
-
static int x509_object_cmp(const X509_OBJECT **a, const X509_OBJECT **b)
|
|
165
|
-
|
|
166
|
-
int ret;
|
|
168
|
+
static int x509_object_cmp(const X509_OBJECT **a, const X509_OBJECT **b) {
|
|
169
|
+
int ret;
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
ret = ((*a)->type - (*b)->type);
|
|
172
|
+
if (ret) {
|
|
173
|
+
return ret;
|
|
174
|
+
}
|
|
175
|
+
switch ((*a)->type) {
|
|
172
176
|
case X509_LU_X509:
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);
|
|
178
|
+
break;
|
|
175
179
|
case X509_LU_CRL:
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);
|
|
181
|
+
break;
|
|
178
182
|
default:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
X509_STORE *X509_STORE_new(void)
|
|
186
|
-
{
|
|
187
|
-
X509_STORE *ret;
|
|
188
|
-
|
|
189
|
-
if ((ret = (X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL)
|
|
190
|
-
return NULL;
|
|
191
|
-
OPENSSL_memset(ret, 0, sizeof(*ret));
|
|
192
|
-
CRYPTO_MUTEX_init(&ret->objs_lock);
|
|
193
|
-
ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
|
|
194
|
-
if (ret->objs == NULL)
|
|
195
|
-
goto err;
|
|
196
|
-
ret->cache = 1;
|
|
197
|
-
ret->get_cert_methods = sk_X509_LOOKUP_new_null();
|
|
198
|
-
if (ret->get_cert_methods == NULL)
|
|
199
|
-
goto err;
|
|
200
|
-
ret->param = X509_VERIFY_PARAM_new();
|
|
201
|
-
if (ret->param == NULL)
|
|
202
|
-
goto err;
|
|
203
|
-
|
|
204
|
-
ret->references = 1;
|
|
205
|
-
return ret;
|
|
206
|
-
err:
|
|
207
|
-
if (ret) {
|
|
208
|
-
CRYPTO_MUTEX_cleanup(&ret->objs_lock);
|
|
209
|
-
if (ret->param)
|
|
210
|
-
X509_VERIFY_PARAM_free(ret->param);
|
|
211
|
-
if (ret->get_cert_methods)
|
|
212
|
-
sk_X509_LOOKUP_free(ret->get_cert_methods);
|
|
213
|
-
if (ret->objs)
|
|
214
|
-
sk_X509_OBJECT_free(ret->objs);
|
|
215
|
-
OPENSSL_free(ret);
|
|
216
|
-
}
|
|
217
|
-
return NULL;
|
|
183
|
+
// abort();
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
return ret;
|
|
218
187
|
}
|
|
219
188
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
CRYPTO_refcount_inc(&store->references);
|
|
223
|
-
return 1;
|
|
224
|
-
}
|
|
189
|
+
X509_STORE *X509_STORE_new(void) {
|
|
190
|
+
X509_STORE *ret;
|
|
225
191
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
192
|
+
if ((ret = (X509_STORE *)OPENSSL_malloc(sizeof(X509_STORE))) == NULL) {
|
|
193
|
+
return NULL;
|
|
194
|
+
}
|
|
195
|
+
OPENSSL_memset(ret, 0, sizeof(*ret));
|
|
196
|
+
CRYPTO_MUTEX_init(&ret->objs_lock);
|
|
197
|
+
ret->objs = sk_X509_OBJECT_new(x509_object_cmp);
|
|
198
|
+
if (ret->objs == NULL) {
|
|
199
|
+
goto err;
|
|
200
|
+
}
|
|
201
|
+
ret->cache = 1;
|
|
202
|
+
ret->get_cert_methods = sk_X509_LOOKUP_new_null();
|
|
203
|
+
if (ret->get_cert_methods == NULL) {
|
|
204
|
+
goto err;
|
|
205
|
+
}
|
|
206
|
+
ret->param = X509_VERIFY_PARAM_new();
|
|
207
|
+
if (ret->param == NULL) {
|
|
208
|
+
goto err;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
ret->references = 1;
|
|
212
|
+
return ret;
|
|
213
|
+
err:
|
|
214
|
+
if (ret) {
|
|
215
|
+
CRYPTO_MUTEX_cleanup(&ret->objs_lock);
|
|
216
|
+
if (ret->param) {
|
|
217
|
+
X509_VERIFY_PARAM_free(ret->param);
|
|
230
218
|
}
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
} else if (a->type == X509_LU_CRL) {
|
|
234
|
-
X509_CRL_free(a->data.crl);
|
|
235
|
-
} else {
|
|
236
|
-
/* abort(); */
|
|
219
|
+
if (ret->get_cert_methods) {
|
|
220
|
+
sk_X509_LOOKUP_free(ret->get_cert_methods);
|
|
237
221
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
void X509_STORE_free(X509_STORE *vfy)
|
|
243
|
-
{
|
|
244
|
-
size_t j;
|
|
245
|
-
STACK_OF(X509_LOOKUP) *sk;
|
|
246
|
-
X509_LOOKUP *lu;
|
|
247
|
-
|
|
248
|
-
if (vfy == NULL)
|
|
249
|
-
return;
|
|
250
|
-
|
|
251
|
-
if (!CRYPTO_refcount_dec_and_test_zero(&vfy->references)) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
CRYPTO_MUTEX_cleanup(&vfy->objs_lock);
|
|
256
|
-
|
|
257
|
-
sk = vfy->get_cert_methods;
|
|
258
|
-
for (j = 0; j < sk_X509_LOOKUP_num(sk); j++) {
|
|
259
|
-
lu = sk_X509_LOOKUP_value(sk, j);
|
|
260
|
-
X509_LOOKUP_shutdown(lu);
|
|
261
|
-
X509_LOOKUP_free(lu);
|
|
222
|
+
if (ret->objs) {
|
|
223
|
+
sk_X509_OBJECT_free(ret->objs);
|
|
262
224
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
225
|
+
OPENSSL_free(ret);
|
|
226
|
+
}
|
|
227
|
+
return NULL;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
int X509_STORE_up_ref(X509_STORE *store) {
|
|
231
|
+
CRYPTO_refcount_inc(&store->references);
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static void cleanup(X509_OBJECT *a) {
|
|
236
|
+
if (a == NULL) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (a->type == X509_LU_X509) {
|
|
240
|
+
X509_free(a->data.x509);
|
|
241
|
+
} else if (a->type == X509_LU_CRL) {
|
|
242
|
+
X509_CRL_free(a->data.crl);
|
|
243
|
+
} else {
|
|
244
|
+
// abort();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
OPENSSL_free(a);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void X509_STORE_free(X509_STORE *vfy) {
|
|
251
|
+
size_t j;
|
|
252
|
+
STACK_OF(X509_LOOKUP) *sk;
|
|
253
|
+
X509_LOOKUP *lu;
|
|
254
|
+
|
|
255
|
+
if (vfy == NULL) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (!CRYPTO_refcount_dec_and_test_zero(&vfy->references)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
CRYPTO_MUTEX_cleanup(&vfy->objs_lock);
|
|
264
|
+
|
|
265
|
+
sk = vfy->get_cert_methods;
|
|
266
|
+
for (j = 0; j < sk_X509_LOOKUP_num(sk); j++) {
|
|
267
|
+
lu = sk_X509_LOOKUP_value(sk, j);
|
|
268
|
+
X509_LOOKUP_shutdown(lu);
|
|
269
|
+
X509_LOOKUP_free(lu);
|
|
270
|
+
}
|
|
271
|
+
sk_X509_LOOKUP_free(sk);
|
|
272
|
+
sk_X509_OBJECT_pop_free(vfy->objs, cleanup);
|
|
273
|
+
|
|
274
|
+
if (vfy->param) {
|
|
275
|
+
X509_VERIFY_PARAM_free(vfy->param);
|
|
276
|
+
}
|
|
277
|
+
OPENSSL_free(vfy);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m) {
|
|
281
|
+
size_t i;
|
|
282
|
+
STACK_OF(X509_LOOKUP) *sk;
|
|
283
|
+
X509_LOOKUP *lu;
|
|
284
|
+
|
|
285
|
+
sk = v->get_cert_methods;
|
|
286
|
+
for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) {
|
|
287
|
+
lu = sk_X509_LOOKUP_value(sk, i);
|
|
288
|
+
if (m == lu->method) {
|
|
289
|
+
return lu;
|
|
283
290
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
}
|
|
292
|
+
// a new one
|
|
293
|
+
lu = X509_LOOKUP_new(m);
|
|
294
|
+
if (lu == NULL) {
|
|
295
|
+
return NULL;
|
|
296
|
+
} else {
|
|
297
|
+
lu->store_ctx = v;
|
|
298
|
+
if (sk_X509_LOOKUP_push(v->get_cert_methods, lu)) {
|
|
299
|
+
return lu;
|
|
300
|
+
} else {
|
|
301
|
+
X509_LOOKUP_free(lu);
|
|
302
|
+
return NULL;
|
|
296
303
|
}
|
|
304
|
+
}
|
|
297
305
|
}
|
|
298
306
|
|
|
299
307
|
int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
|
|
300
|
-
X509_OBJECT *ret)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return 0;
|
|
308
|
+
X509_OBJECT *ret) {
|
|
309
|
+
X509_STORE *ctx = vs->ctx;
|
|
310
|
+
X509_LOOKUP *lu;
|
|
311
|
+
X509_OBJECT stmp, *tmp;
|
|
312
|
+
int i;
|
|
313
|
+
|
|
314
|
+
CRYPTO_MUTEX_lock_write(&ctx->objs_lock);
|
|
315
|
+
tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
|
|
316
|
+
CRYPTO_MUTEX_unlock_write(&ctx->objs_lock);
|
|
317
|
+
|
|
318
|
+
if (tmp == NULL || type == X509_LU_CRL) {
|
|
319
|
+
for (i = 0; i < (int)sk_X509_LOOKUP_num(ctx->get_cert_methods); i++) {
|
|
320
|
+
lu = sk_X509_LOOKUP_value(ctx->get_cert_methods, i);
|
|
321
|
+
if (X509_LOOKUP_by_subject(lu, type, name, &stmp)) {
|
|
322
|
+
tmp = &stmp;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (tmp == NULL) {
|
|
327
|
+
return 0;
|
|
321
328
|
}
|
|
329
|
+
}
|
|
322
330
|
|
|
323
|
-
|
|
324
|
-
* if (ret->data.ptr != NULL) X509_OBJECT_free_contents(ret);
|
|
325
|
-
*/
|
|
331
|
+
// if (ret->data.ptr != NULL) X509_OBJECT_free_contents(ret);
|
|
326
332
|
|
|
327
|
-
|
|
328
|
-
|
|
333
|
+
ret->type = tmp->type;
|
|
334
|
+
ret->data.ptr = tmp->data.ptr;
|
|
329
335
|
|
|
330
|
-
|
|
336
|
+
X509_OBJECT_up_ref_count(ret);
|
|
331
337
|
|
|
332
|
-
|
|
338
|
+
return 1;
|
|
333
339
|
}
|
|
334
340
|
|
|
335
|
-
static int x509_store_add(X509_STORE *ctx, void *x, int is_crl)
|
|
336
|
-
{
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
341
|
+
static int x509_store_add(X509_STORE *ctx, void *x, int is_crl) {
|
|
342
|
+
if (x == NULL) {
|
|
343
|
+
return 0;
|
|
344
|
+
}
|
|
340
345
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
+
X509_OBJECT *const obj = (X509_OBJECT *)OPENSSL_malloc(sizeof(X509_OBJECT));
|
|
347
|
+
if (obj == NULL) {
|
|
348
|
+
OPENSSL_PUT_ERROR(X509, ERR_R_MALLOC_FAILURE);
|
|
349
|
+
return 0;
|
|
350
|
+
}
|
|
346
351
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
352
|
+
if (is_crl) {
|
|
353
|
+
obj->type = X509_LU_CRL;
|
|
354
|
+
obj->data.crl = (X509_CRL *)x;
|
|
355
|
+
} else {
|
|
356
|
+
obj->type = X509_LU_X509;
|
|
357
|
+
obj->data.x509 = (X509 *)x;
|
|
358
|
+
}
|
|
359
|
+
X509_OBJECT_up_ref_count(obj);
|
|
355
360
|
|
|
356
|
-
|
|
361
|
+
CRYPTO_MUTEX_lock_write(&ctx->objs_lock);
|
|
357
362
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
int ret = 1;
|
|
364
|
+
int added = 0;
|
|
365
|
+
// Duplicates are silently ignored
|
|
366
|
+
if (!X509_OBJECT_retrieve_match(ctx->objs, obj)) {
|
|
367
|
+
ret = added = (sk_X509_OBJECT_push(ctx->objs, obj) != 0);
|
|
368
|
+
}
|
|
364
369
|
|
|
365
|
-
|
|
370
|
+
CRYPTO_MUTEX_unlock_write(&ctx->objs_lock);
|
|
366
371
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
372
|
+
if (!added) {
|
|
373
|
+
X509_OBJECT_free_contents(obj);
|
|
374
|
+
OPENSSL_free(obj);
|
|
375
|
+
}
|
|
371
376
|
|
|
372
|
-
|
|
377
|
+
return ret;
|
|
373
378
|
}
|
|
374
379
|
|
|
375
|
-
int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
|
|
376
|
-
|
|
377
|
-
return x509_store_add(ctx, x, /*is_crl=*/0);
|
|
380
|
+
int X509_STORE_add_cert(X509_STORE *ctx, X509 *x) {
|
|
381
|
+
return x509_store_add(ctx, x, /*is_crl=*/0);
|
|
378
382
|
}
|
|
379
383
|
|
|
380
|
-
int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
|
|
381
|
-
|
|
382
|
-
return x509_store_add(ctx, x, /*is_crl=*/1);
|
|
384
|
+
int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x) {
|
|
385
|
+
return x509_store_add(ctx, x, /*is_crl=*/1);
|
|
383
386
|
}
|
|
384
387
|
|
|
385
|
-
int X509_OBJECT_up_ref_count(X509_OBJECT *a)
|
|
386
|
-
{
|
|
387
|
-
switch (a->type) {
|
|
388
|
+
int X509_OBJECT_up_ref_count(X509_OBJECT *a) {
|
|
389
|
+
switch (a->type) {
|
|
388
390
|
case X509_LU_X509:
|
|
389
|
-
|
|
390
|
-
|
|
391
|
+
X509_up_ref(a->data.x509);
|
|
392
|
+
break;
|
|
391
393
|
case X509_LU_CRL:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
394
|
+
X509_CRL_up_ref(a->data.crl);
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
return 1;
|
|
396
398
|
}
|
|
397
399
|
|
|
398
|
-
void X509_OBJECT_free_contents(X509_OBJECT *a)
|
|
399
|
-
{
|
|
400
|
-
switch (a->type) {
|
|
400
|
+
void X509_OBJECT_free_contents(X509_OBJECT *a) {
|
|
401
|
+
switch (a->type) {
|
|
401
402
|
case X509_LU_X509:
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
X509_free(a->data.x509);
|
|
404
|
+
break;
|
|
404
405
|
case X509_LU_CRL:
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
X509_CRL_free(a->data.crl);
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
408
409
|
}
|
|
409
410
|
|
|
410
|
-
int X509_OBJECT_get_type(const X509_OBJECT *a)
|
|
411
|
-
{
|
|
412
|
-
return a->type;
|
|
413
|
-
}
|
|
411
|
+
int X509_OBJECT_get_type(const X509_OBJECT *a) { return a->type; }
|
|
414
412
|
|
|
415
|
-
X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a)
|
|
416
|
-
{
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return a->data.x509;
|
|
413
|
+
X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a) {
|
|
414
|
+
if (a == NULL || a->type != X509_LU_X509) {
|
|
415
|
+
return NULL;
|
|
416
|
+
}
|
|
417
|
+
return a->data.x509;
|
|
421
418
|
}
|
|
422
419
|
|
|
423
420
|
static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
|
|
424
|
-
X509_NAME *name, int *pnmatch)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
switch (type) {
|
|
421
|
+
X509_NAME *name, int *pnmatch) {
|
|
422
|
+
X509_OBJECT stmp;
|
|
423
|
+
X509 x509_s;
|
|
424
|
+
X509_CINF cinf_s;
|
|
425
|
+
X509_CRL crl_s;
|
|
426
|
+
X509_CRL_INFO crl_info_s;
|
|
427
|
+
|
|
428
|
+
stmp.type = type;
|
|
429
|
+
switch (type) {
|
|
434
430
|
case X509_LU_X509:
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
431
|
+
stmp.data.x509 = &x509_s;
|
|
432
|
+
x509_s.cert_info = &cinf_s;
|
|
433
|
+
cinf_s.subject = name;
|
|
434
|
+
break;
|
|
439
435
|
case X509_LU_CRL:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
436
|
+
stmp.data.crl = &crl_s;
|
|
437
|
+
crl_s.crl = &crl_info_s;
|
|
438
|
+
crl_info_s.issuer = name;
|
|
439
|
+
break;
|
|
444
440
|
default:
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
441
|
+
// abort();
|
|
442
|
+
return -1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
size_t idx;
|
|
446
|
+
sk_X509_OBJECT_sort(h);
|
|
447
|
+
if (!sk_X509_OBJECT_find(h, &idx, &stmp)) {
|
|
448
|
+
return -1;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (pnmatch != NULL) {
|
|
452
|
+
int tidx;
|
|
453
|
+
const X509_OBJECT *tobj, *pstmp;
|
|
454
|
+
*pnmatch = 1;
|
|
455
|
+
pstmp = &stmp;
|
|
456
|
+
for (tidx = idx + 1; tidx < (int)sk_X509_OBJECT_num(h); tidx++) {
|
|
457
|
+
tobj = sk_X509_OBJECT_value(h, tidx);
|
|
458
|
+
if (x509_object_cmp(&tobj, &pstmp)) {
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
(*pnmatch)++;
|
|
465
462
|
}
|
|
463
|
+
}
|
|
466
464
|
|
|
467
|
-
|
|
465
|
+
return idx;
|
|
468
466
|
}
|
|
469
467
|
|
|
470
468
|
int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type,
|
|
471
|
-
X509_NAME *name)
|
|
472
|
-
|
|
473
|
-
return x509_object_idx_cnt(h, type, name, NULL);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
|
|
477
|
-
int type, X509_NAME *name)
|
|
478
|
-
{
|
|
479
|
-
int idx;
|
|
480
|
-
idx = X509_OBJECT_idx_by_subject(h, type, name);
|
|
481
|
-
if (idx == -1)
|
|
482
|
-
return NULL;
|
|
483
|
-
return sk_X509_OBJECT_value(h, idx);
|
|
469
|
+
X509_NAME *name) {
|
|
470
|
+
return x509_object_idx_cnt(h, type, name, NULL);
|
|
484
471
|
}
|
|
485
472
|
|
|
486
|
-
STACK_OF(X509_OBJECT) *
|
|
487
|
-
{
|
|
488
|
-
|
|
473
|
+
X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, int type,
|
|
474
|
+
X509_NAME *name) {
|
|
475
|
+
int idx;
|
|
476
|
+
idx = X509_OBJECT_idx_by_subject(h, type, name);
|
|
477
|
+
if (idx == -1) {
|
|
478
|
+
return NULL;
|
|
479
|
+
}
|
|
480
|
+
return sk_X509_OBJECT_value(h, idx);
|
|
489
481
|
}
|
|
490
482
|
|
|
491
|
-
STACK_OF
|
|
492
|
-
|
|
493
|
-
int i, idx, cnt;
|
|
494
|
-
STACK_OF(X509) *sk;
|
|
495
|
-
X509 *x;
|
|
496
|
-
X509_OBJECT *obj;
|
|
497
|
-
sk = sk_X509_new_null();
|
|
498
|
-
if (sk == NULL)
|
|
499
|
-
return NULL;
|
|
500
|
-
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
501
|
-
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
|
|
502
|
-
if (idx < 0) {
|
|
503
|
-
/*
|
|
504
|
-
* Nothing found in cache: do lookup to possibly add new objects to
|
|
505
|
-
* cache
|
|
506
|
-
*/
|
|
507
|
-
X509_OBJECT xobj;
|
|
508
|
-
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
509
|
-
if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj)) {
|
|
510
|
-
sk_X509_free(sk);
|
|
511
|
-
return NULL;
|
|
512
|
-
}
|
|
513
|
-
X509_OBJECT_free_contents(&xobj);
|
|
514
|
-
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
515
|
-
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
|
|
516
|
-
if (idx < 0) {
|
|
517
|
-
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
518
|
-
sk_X509_free(sk);
|
|
519
|
-
return NULL;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
for (i = 0; i < cnt; i++, idx++) {
|
|
523
|
-
obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
|
|
524
|
-
x = obj->data.x509;
|
|
525
|
-
if (!sk_X509_push(sk, x)) {
|
|
526
|
-
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
527
|
-
sk_X509_pop_free(sk, X509_free);
|
|
528
|
-
return NULL;
|
|
529
|
-
}
|
|
530
|
-
X509_up_ref(x);
|
|
531
|
-
}
|
|
532
|
-
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
533
|
-
return sk;
|
|
534
|
-
|
|
483
|
+
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *st) {
|
|
484
|
+
return st->objs;
|
|
535
485
|
}
|
|
536
486
|
|
|
537
|
-
STACK_OF
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
487
|
+
STACK_OF(X509) *X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm) {
|
|
488
|
+
int i, idx, cnt;
|
|
489
|
+
STACK_OF(X509) *sk;
|
|
490
|
+
X509 *x;
|
|
491
|
+
X509_OBJECT *obj;
|
|
492
|
+
sk = sk_X509_new_null();
|
|
493
|
+
if (sk == NULL) {
|
|
494
|
+
return NULL;
|
|
495
|
+
}
|
|
496
|
+
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
497
|
+
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
|
|
498
|
+
if (idx < 0) {
|
|
499
|
+
// Nothing found in cache: do lookup to possibly add new objects to
|
|
500
|
+
// cache
|
|
501
|
+
X509_OBJECT xobj;
|
|
502
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
503
|
+
if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, nm, &xobj)) {
|
|
504
|
+
sk_X509_free(sk);
|
|
505
|
+
return NULL;
|
|
551
506
|
}
|
|
552
507
|
X509_OBJECT_free_contents(&xobj);
|
|
553
508
|
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
554
|
-
idx = x509_object_idx_cnt(ctx->ctx->objs,
|
|
509
|
+
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
|
|
555
510
|
if (idx < 0) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
511
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
512
|
+
sk_X509_free(sk);
|
|
513
|
+
return NULL;
|
|
559
514
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
sk_X509_CRL_pop_free(sk, X509_CRL_free);
|
|
569
|
-
return NULL;
|
|
570
|
-
}
|
|
515
|
+
}
|
|
516
|
+
for (i = 0; i < cnt; i++, idx++) {
|
|
517
|
+
obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
|
|
518
|
+
x = obj->data.x509;
|
|
519
|
+
if (!sk_X509_push(sk, x)) {
|
|
520
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
521
|
+
sk_X509_pop_free(sk, X509_free);
|
|
522
|
+
return NULL;
|
|
571
523
|
}
|
|
524
|
+
X509_up_ref(x);
|
|
525
|
+
}
|
|
526
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
527
|
+
return sk;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm) {
|
|
531
|
+
int i, idx, cnt;
|
|
532
|
+
STACK_OF(X509_CRL) *sk;
|
|
533
|
+
X509_CRL *x;
|
|
534
|
+
X509_OBJECT *obj, xobj;
|
|
535
|
+
sk = sk_X509_CRL_new_null();
|
|
536
|
+
if (sk == NULL) {
|
|
537
|
+
return NULL;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Always do lookup to possibly add new CRLs to cache.
|
|
541
|
+
if (!X509_STORE_get_by_subject(ctx, X509_LU_CRL, nm, &xobj)) {
|
|
542
|
+
sk_X509_CRL_free(sk);
|
|
543
|
+
return NULL;
|
|
544
|
+
}
|
|
545
|
+
X509_OBJECT_free_contents(&xobj);
|
|
546
|
+
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
547
|
+
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt);
|
|
548
|
+
if (idx < 0) {
|
|
572
549
|
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
573
|
-
|
|
550
|
+
sk_X509_CRL_free(sk);
|
|
551
|
+
return NULL;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
for (i = 0; i < cnt; i++, idx++) {
|
|
555
|
+
obj = sk_X509_OBJECT_value(ctx->ctx->objs, idx);
|
|
556
|
+
x = obj->data.crl;
|
|
557
|
+
X509_CRL_up_ref(x);
|
|
558
|
+
if (!sk_X509_CRL_push(sk, x)) {
|
|
559
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
560
|
+
X509_CRL_free(x);
|
|
561
|
+
sk_X509_CRL_pop_free(sk, X509_CRL_free);
|
|
562
|
+
return NULL;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
566
|
+
return sk;
|
|
574
567
|
}
|
|
575
568
|
|
|
576
569
|
X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
|
|
577
|
-
X509_OBJECT *x)
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
X509_OBJECT *obj;
|
|
581
|
-
|
|
582
|
-
sk_X509_OBJECT_sort(h);
|
|
583
|
-
if (!sk_X509_OBJECT_find(h, &idx, x)) {
|
|
584
|
-
return NULL;
|
|
585
|
-
}
|
|
586
|
-
if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
|
|
587
|
-
return sk_X509_OBJECT_value(h, idx);
|
|
588
|
-
for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
|
|
589
|
-
obj = sk_X509_OBJECT_value(h, i);
|
|
590
|
-
if (x509_object_cmp
|
|
591
|
-
((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x))
|
|
592
|
-
return NULL;
|
|
593
|
-
if (x->type == X509_LU_X509) {
|
|
594
|
-
if (!X509_cmp(obj->data.x509, x->data.x509))
|
|
595
|
-
return obj;
|
|
596
|
-
} else if (x->type == X509_LU_CRL) {
|
|
597
|
-
if (!X509_CRL_match(obj->data.crl, x->data.crl))
|
|
598
|
-
return obj;
|
|
599
|
-
} else
|
|
600
|
-
return obj;
|
|
601
|
-
}
|
|
602
|
-
return NULL;
|
|
603
|
-
}
|
|
570
|
+
X509_OBJECT *x) {
|
|
571
|
+
size_t idx, i;
|
|
572
|
+
X509_OBJECT *obj;
|
|
604
573
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
int idx, ret;
|
|
617
|
-
size_t i;
|
|
618
|
-
xn = X509_get_issuer_name(x);
|
|
619
|
-
if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj))
|
|
620
|
-
return 0;
|
|
621
|
-
/* If certificate matches all OK */
|
|
622
|
-
if (ctx->check_issued(ctx, x, obj.data.x509)) {
|
|
623
|
-
*issuer = obj.data.x509;
|
|
624
|
-
return 1;
|
|
574
|
+
sk_X509_OBJECT_sort(h);
|
|
575
|
+
if (!sk_X509_OBJECT_find(h, &idx, x)) {
|
|
576
|
+
return NULL;
|
|
577
|
+
}
|
|
578
|
+
if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL)) {
|
|
579
|
+
return sk_X509_OBJECT_value(h, idx);
|
|
580
|
+
}
|
|
581
|
+
for (i = idx; i < sk_X509_OBJECT_num(h); i++) {
|
|
582
|
+
obj = sk_X509_OBJECT_value(h, i);
|
|
583
|
+
if (x509_object_cmp((const X509_OBJECT **)&obj, (const X509_OBJECT **)&x)) {
|
|
584
|
+
return NULL;
|
|
625
585
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
|
|
637
|
-
/* See if we've run past the matches */
|
|
638
|
-
if (pobj->type != X509_LU_X509)
|
|
639
|
-
break;
|
|
640
|
-
if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))
|
|
641
|
-
break;
|
|
642
|
-
if (ctx->check_issued(ctx, x, pobj->data.x509)) {
|
|
643
|
-
*issuer = pobj->data.x509;
|
|
644
|
-
X509_OBJECT_up_ref_count(pobj);
|
|
645
|
-
ret = 1;
|
|
646
|
-
break;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
586
|
+
if (x->type == X509_LU_X509) {
|
|
587
|
+
if (!X509_cmp(obj->data.x509, x->data.x509)) {
|
|
588
|
+
return obj;
|
|
589
|
+
}
|
|
590
|
+
} else if (x->type == X509_LU_CRL) {
|
|
591
|
+
if (!X509_CRL_match(obj->data.crl, x->data.crl)) {
|
|
592
|
+
return obj;
|
|
593
|
+
}
|
|
594
|
+
} else {
|
|
595
|
+
return obj;
|
|
649
596
|
}
|
|
650
|
-
|
|
651
|
-
|
|
597
|
+
}
|
|
598
|
+
return NULL;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// Try to get issuer certificate from store. Due to limitations of the API
|
|
602
|
+
// this can only retrieve a single certificate matching a given subject name.
|
|
603
|
+
// However it will fill the cache with all matching certificates, so we can
|
|
604
|
+
// examine the cache for all matches. Return values are: 1 lookup
|
|
605
|
+
// successful. 0 certificate not found. -1 some other error.
|
|
606
|
+
int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x) {
|
|
607
|
+
X509_NAME *xn;
|
|
608
|
+
X509_OBJECT obj, *pobj;
|
|
609
|
+
int idx, ret;
|
|
610
|
+
size_t i;
|
|
611
|
+
xn = X509_get_issuer_name(x);
|
|
612
|
+
if (!X509_STORE_get_by_subject(ctx, X509_LU_X509, xn, &obj)) {
|
|
613
|
+
return 0;
|
|
614
|
+
}
|
|
615
|
+
// If certificate matches all OK
|
|
616
|
+
if (ctx->check_issued(ctx, x, obj.data.x509)) {
|
|
617
|
+
*issuer = obj.data.x509;
|
|
618
|
+
return 1;
|
|
619
|
+
}
|
|
620
|
+
X509_OBJECT_free_contents(&obj);
|
|
621
|
+
|
|
622
|
+
// Else find index of first cert accepted by 'check_issued'
|
|
623
|
+
ret = 0;
|
|
624
|
+
CRYPTO_MUTEX_lock_write(&ctx->ctx->objs_lock);
|
|
625
|
+
idx = X509_OBJECT_idx_by_subject(ctx->ctx->objs, X509_LU_X509, xn);
|
|
626
|
+
if (idx != -1) { // should be true as we've had at least one
|
|
627
|
+
// match
|
|
628
|
+
// Look through all matching certs for suitable issuer
|
|
629
|
+
for (i = idx; i < sk_X509_OBJECT_num(ctx->ctx->objs); i++) {
|
|
630
|
+
pobj = sk_X509_OBJECT_value(ctx->ctx->objs, i);
|
|
631
|
+
// See if we've run past the matches
|
|
632
|
+
if (pobj->type != X509_LU_X509) {
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509))) {
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
if (ctx->check_issued(ctx, x, pobj->data.x509)) {
|
|
639
|
+
*issuer = pobj->data.x509;
|
|
640
|
+
X509_OBJECT_up_ref_count(pobj);
|
|
641
|
+
ret = 1;
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
CRYPTO_MUTEX_unlock_write(&ctx->ctx->objs_lock);
|
|
647
|
+
return ret;
|
|
652
648
|
}
|
|
653
649
|
|
|
654
|
-
int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags)
|
|
655
|
-
|
|
656
|
-
return X509_VERIFY_PARAM_set_flags(ctx->param, flags);
|
|
650
|
+
int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags) {
|
|
651
|
+
return X509_VERIFY_PARAM_set_flags(ctx->param, flags);
|
|
657
652
|
}
|
|
658
653
|
|
|
659
|
-
int X509_STORE_set_depth(X509_STORE *ctx, int depth)
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
return 1;
|
|
654
|
+
int X509_STORE_set_depth(X509_STORE *ctx, int depth) {
|
|
655
|
+
X509_VERIFY_PARAM_set_depth(ctx->param, depth);
|
|
656
|
+
return 1;
|
|
663
657
|
}
|
|
664
658
|
|
|
665
|
-
int X509_STORE_set_purpose(X509_STORE *ctx, int purpose)
|
|
666
|
-
|
|
667
|
-
return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose);
|
|
659
|
+
int X509_STORE_set_purpose(X509_STORE *ctx, int purpose) {
|
|
660
|
+
return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose);
|
|
668
661
|
}
|
|
669
662
|
|
|
670
|
-
int X509_STORE_set_trust(X509_STORE *ctx, int trust)
|
|
671
|
-
|
|
672
|
-
return X509_VERIFY_PARAM_set_trust(ctx->param, trust);
|
|
663
|
+
int X509_STORE_set_trust(X509_STORE *ctx, int trust) {
|
|
664
|
+
return X509_VERIFY_PARAM_set_trust(ctx->param, trust);
|
|
673
665
|
}
|
|
674
666
|
|
|
675
|
-
int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param)
|
|
676
|
-
|
|
677
|
-
return X509_VERIFY_PARAM_set1(ctx->param, param);
|
|
667
|
+
int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param) {
|
|
668
|
+
return X509_VERIFY_PARAM_set1(ctx->param, param);
|
|
678
669
|
}
|
|
679
670
|
|
|
680
|
-
X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx)
|
|
681
|
-
{
|
|
682
|
-
return ctx->param;
|
|
683
|
-
}
|
|
671
|
+
X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx) { return ctx->param; }
|
|
684
672
|
|
|
685
|
-
void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify)
|
|
686
|
-
|
|
687
|
-
ctx->verify = verify;
|
|
673
|
+
void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify) {
|
|
674
|
+
ctx->verify = verify;
|
|
688
675
|
}
|
|
689
676
|
|
|
690
|
-
X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx)
|
|
691
|
-
|
|
692
|
-
return ctx->verify;
|
|
677
|
+
X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx) {
|
|
678
|
+
return ctx->verify;
|
|
693
679
|
}
|
|
694
680
|
|
|
695
681
|
void X509_STORE_set_verify_cb(X509_STORE *ctx,
|
|
696
|
-
X509_STORE_CTX_verify_cb verify_cb)
|
|
697
|
-
|
|
698
|
-
ctx->verify_cb = verify_cb;
|
|
682
|
+
X509_STORE_CTX_verify_cb verify_cb) {
|
|
683
|
+
ctx->verify_cb = verify_cb;
|
|
699
684
|
}
|
|
700
685
|
|
|
701
|
-
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx)
|
|
702
|
-
|
|
703
|
-
return ctx->verify_cb;
|
|
686
|
+
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx) {
|
|
687
|
+
return ctx->verify_cb;
|
|
704
688
|
}
|
|
705
689
|
|
|
706
690
|
void X509_STORE_set_get_issuer(X509_STORE *ctx,
|
|
707
|
-
X509_STORE_CTX_get_issuer_fn get_issuer)
|
|
708
|
-
|
|
709
|
-
ctx->get_issuer = get_issuer;
|
|
691
|
+
X509_STORE_CTX_get_issuer_fn get_issuer) {
|
|
692
|
+
ctx->get_issuer = get_issuer;
|
|
710
693
|
}
|
|
711
694
|
|
|
712
|
-
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx)
|
|
713
|
-
|
|
714
|
-
return ctx->get_issuer;
|
|
695
|
+
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx) {
|
|
696
|
+
return ctx->get_issuer;
|
|
715
697
|
}
|
|
716
698
|
|
|
717
699
|
void X509_STORE_set_check_issued(X509_STORE *ctx,
|
|
718
|
-
X509_STORE_CTX_check_issued_fn check_issued)
|
|
719
|
-
|
|
720
|
-
ctx->check_issued = check_issued;
|
|
700
|
+
X509_STORE_CTX_check_issued_fn check_issued) {
|
|
701
|
+
ctx->check_issued = check_issued;
|
|
721
702
|
}
|
|
722
703
|
|
|
723
|
-
X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx)
|
|
724
|
-
|
|
725
|
-
return ctx->check_issued;
|
|
704
|
+
X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx) {
|
|
705
|
+
return ctx->check_issued;
|
|
726
706
|
}
|
|
727
707
|
|
|
728
|
-
void X509_STORE_set_check_revocation(
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
ctx->check_revocation = check_revocation;
|
|
708
|
+
void X509_STORE_set_check_revocation(
|
|
709
|
+
X509_STORE *ctx, X509_STORE_CTX_check_revocation_fn check_revocation) {
|
|
710
|
+
ctx->check_revocation = check_revocation;
|
|
732
711
|
}
|
|
733
712
|
|
|
734
|
-
X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(
|
|
735
|
-
{
|
|
736
|
-
|
|
713
|
+
X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(
|
|
714
|
+
X509_STORE *ctx) {
|
|
715
|
+
return ctx->check_revocation;
|
|
737
716
|
}
|
|
738
717
|
|
|
739
718
|
void X509_STORE_set_get_crl(X509_STORE *ctx,
|
|
740
|
-
X509_STORE_CTX_get_crl_fn get_crl)
|
|
741
|
-
|
|
742
|
-
ctx->get_crl = get_crl;
|
|
719
|
+
X509_STORE_CTX_get_crl_fn get_crl) {
|
|
720
|
+
ctx->get_crl = get_crl;
|
|
743
721
|
}
|
|
744
722
|
|
|
745
|
-
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx)
|
|
746
|
-
|
|
747
|
-
return ctx->get_crl;
|
|
723
|
+
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx) {
|
|
724
|
+
return ctx->get_crl;
|
|
748
725
|
}
|
|
749
726
|
|
|
750
727
|
void X509_STORE_set_check_crl(X509_STORE *ctx,
|
|
751
|
-
X509_STORE_CTX_check_crl_fn check_crl)
|
|
752
|
-
|
|
753
|
-
ctx->check_crl = check_crl;
|
|
728
|
+
X509_STORE_CTX_check_crl_fn check_crl) {
|
|
729
|
+
ctx->check_crl = check_crl;
|
|
754
730
|
}
|
|
755
731
|
|
|
756
|
-
X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx)
|
|
757
|
-
|
|
758
|
-
return ctx->check_crl;
|
|
732
|
+
X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx) {
|
|
733
|
+
return ctx->check_crl;
|
|
759
734
|
}
|
|
760
735
|
|
|
761
736
|
void X509_STORE_set_cert_crl(X509_STORE *ctx,
|
|
762
|
-
X509_STORE_CTX_cert_crl_fn cert_crl)
|
|
763
|
-
|
|
764
|
-
ctx->cert_crl = cert_crl;
|
|
737
|
+
X509_STORE_CTX_cert_crl_fn cert_crl) {
|
|
738
|
+
ctx->cert_crl = cert_crl;
|
|
765
739
|
}
|
|
766
740
|
|
|
767
|
-
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx)
|
|
768
|
-
|
|
769
|
-
return ctx->cert_crl;
|
|
741
|
+
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx) {
|
|
742
|
+
return ctx->cert_crl;
|
|
770
743
|
}
|
|
771
744
|
|
|
772
745
|
void X509_STORE_set_lookup_certs(X509_STORE *ctx,
|
|
773
|
-
X509_STORE_CTX_lookup_certs_fn lookup_certs)
|
|
774
|
-
|
|
775
|
-
ctx->lookup_certs = lookup_certs;
|
|
746
|
+
X509_STORE_CTX_lookup_certs_fn lookup_certs) {
|
|
747
|
+
ctx->lookup_certs = lookup_certs;
|
|
776
748
|
}
|
|
777
749
|
|
|
778
|
-
X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx)
|
|
779
|
-
|
|
780
|
-
return ctx->lookup_certs;
|
|
750
|
+
X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx) {
|
|
751
|
+
return ctx->lookup_certs;
|
|
781
752
|
}
|
|
782
753
|
|
|
783
754
|
void X509_STORE_set_lookup_crls(X509_STORE *ctx,
|
|
784
|
-
X509_STORE_CTX_lookup_crls_fn lookup_crls)
|
|
785
|
-
|
|
786
|
-
ctx->lookup_crls = lookup_crls;
|
|
755
|
+
X509_STORE_CTX_lookup_crls_fn lookup_crls) {
|
|
756
|
+
ctx->lookup_crls = lookup_crls;
|
|
787
757
|
}
|
|
788
758
|
|
|
789
|
-
X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx)
|
|
790
|
-
|
|
791
|
-
return ctx->lookup_crls;
|
|
759
|
+
X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx) {
|
|
760
|
+
return ctx->lookup_crls;
|
|
792
761
|
}
|
|
793
762
|
|
|
794
763
|
void X509_STORE_set_cleanup(X509_STORE *ctx,
|
|
795
|
-
X509_STORE_CTX_cleanup_fn ctx_cleanup)
|
|
796
|
-
|
|
797
|
-
ctx->cleanup = ctx_cleanup;
|
|
764
|
+
X509_STORE_CTX_cleanup_fn ctx_cleanup) {
|
|
765
|
+
ctx->cleanup = ctx_cleanup;
|
|
798
766
|
}
|
|
799
767
|
|
|
800
|
-
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx)
|
|
801
|
-
|
|
802
|
-
return ctx->cleanup;
|
|
768
|
+
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx) {
|
|
769
|
+
return ctx->cleanup;
|
|
803
770
|
}
|
|
804
771
|
|
|
805
|
-
X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx)
|
|
806
|
-
{
|
|
807
|
-
return ctx->ctx;
|
|
808
|
-
}
|
|
772
|
+
X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx) { return ctx->ctx; }
|