@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
|
@@ -69,406 +69,397 @@
|
|
|
69
69
|
#include "../x509/internal.h"
|
|
70
70
|
#include "internal.h"
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* evaluation.
|
|
75
|
-
*/
|
|
72
|
+
// Enable this to print out the complete policy tree at various point during
|
|
73
|
+
// evaluation.
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
* #define OPENSSL_POLICY_DEBUG
|
|
79
|
-
*/
|
|
75
|
+
// #define OPENSSL_POLICY_DEBUG
|
|
80
76
|
|
|
81
77
|
#ifdef OPENSSL_POLICY_DEBUG
|
|
82
78
|
|
|
83
79
|
static void expected_print(BIO *err, X509_POLICY_LEVEL *lev,
|
|
84
|
-
X509_POLICY_NODE *node, int indent)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
BIO_puts(err, "\n");
|
|
80
|
+
X509_POLICY_NODE *node, int indent) {
|
|
81
|
+
if ((lev->flags & X509_V_FLAG_INHIBIT_MAP) ||
|
|
82
|
+
!(node->data->flags & POLICY_DATA_FLAG_MAP_MASK)) {
|
|
83
|
+
BIO_puts(err, " Not Mapped\n");
|
|
84
|
+
} else {
|
|
85
|
+
int i;
|
|
86
|
+
STACK_OF(ASN1_OBJECT) *pset = node->data->expected_policy_set;
|
|
87
|
+
ASN1_OBJECT *oid;
|
|
88
|
+
BIO_puts(err, " Expected: ");
|
|
89
|
+
for (i = 0; i < sk_ASN1_OBJECT_num(pset); i++) {
|
|
90
|
+
oid = sk_ASN1_OBJECT_value(pset, i);
|
|
91
|
+
if (i) {
|
|
92
|
+
BIO_puts(err, ", ");
|
|
93
|
+
}
|
|
94
|
+
i2a_ASN1_OBJECT(err, oid);
|
|
101
95
|
}
|
|
96
|
+
BIO_puts(err, "\n");
|
|
97
|
+
}
|
|
102
98
|
}
|
|
103
99
|
|
|
104
100
|
static void tree_print(char *str, X509_POLICY_TREE *tree,
|
|
105
|
-
X509_POLICY_LEVEL *curr)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
if (plev->anyPolicy)
|
|
128
|
-
X509_POLICY_NODE_print(err, plev->anyPolicy, 2);
|
|
101
|
+
X509_POLICY_LEVEL *curr) {
|
|
102
|
+
X509_POLICY_LEVEL *plev;
|
|
103
|
+
X509_POLICY_NODE *node;
|
|
104
|
+
int i;
|
|
105
|
+
BIO *err;
|
|
106
|
+
err = BIO_new_fp(stderr, BIO_NOCLOSE);
|
|
107
|
+
if (!curr) {
|
|
108
|
+
curr = tree->levels + tree->nlevel;
|
|
109
|
+
} else {
|
|
110
|
+
curr++;
|
|
111
|
+
}
|
|
112
|
+
BIO_printf(err, "Level print after %s\n", str);
|
|
113
|
+
BIO_printf(err, "Printing Up to Level %ld\n", curr - tree->levels);
|
|
114
|
+
for (plev = tree->levels; plev != curr; plev++) {
|
|
115
|
+
BIO_printf(err, "Level %ld, flags = %x\n", plev - tree->levels,
|
|
116
|
+
plev->flags);
|
|
117
|
+
for (i = 0; i < sk_X509_POLICY_NODE_num(plev->nodes); i++) {
|
|
118
|
+
node = sk_X509_POLICY_NODE_value(plev->nodes, i);
|
|
119
|
+
X509_POLICY_NODE_print(err, node, 2);
|
|
120
|
+
expected_print(err, plev, node, 2);
|
|
121
|
+
BIO_printf(err, " Flags: %x\n", node->data->flags);
|
|
129
122
|
}
|
|
123
|
+
if (plev->anyPolicy) {
|
|
124
|
+
X509_POLICY_NODE_print(err, plev->anyPolicy, 2);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
BIO_free(err);
|
|
133
129
|
}
|
|
134
130
|
#else
|
|
135
131
|
|
|
136
|
-
#
|
|
132
|
+
#define tree_print(a, b, c) //
|
|
137
133
|
|
|
138
134
|
#endif
|
|
139
135
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
*/
|
|
136
|
+
//-
|
|
137
|
+
// Initialize policy tree. Return values:
|
|
138
|
+
// 0 Some internal error occurred.
|
|
139
|
+
// -1 Inconsistent or invalid extensions in certificates.
|
|
140
|
+
// 1 Tree initialized OK.
|
|
141
|
+
// 2 Policy tree is empty.
|
|
142
|
+
// 5 Tree OK and requireExplicitPolicy true.
|
|
143
|
+
// 6 Tree empty and requireExplicitPolicy true.
|
|
149
144
|
|
|
150
145
|
static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
|
151
|
-
unsigned int flags)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
n = sk_X509_num(certs);
|
|
146
|
+
unsigned int flags) {
|
|
147
|
+
X509_POLICY_TREE *tree;
|
|
148
|
+
X509_POLICY_LEVEL *level;
|
|
149
|
+
const X509_POLICY_CACHE *cache;
|
|
150
|
+
X509_POLICY_DATA *data = NULL;
|
|
151
|
+
X509 *x;
|
|
152
|
+
int ret = 1;
|
|
153
|
+
int i, n;
|
|
154
|
+
int explicit_policy;
|
|
155
|
+
int any_skip;
|
|
156
|
+
int map_skip;
|
|
157
|
+
*ptree = NULL;
|
|
158
|
+
n = sk_X509_num(certs);
|
|
165
159
|
|
|
166
160
|
#if 0
|
|
167
|
-
|
|
161
|
+
// Disable policy mapping for now...
|
|
168
162
|
flags |= X509_V_FLAG_INHIBIT_MAP;
|
|
169
163
|
#endif
|
|
170
164
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*/
|
|
204
|
-
if (x->ex_flags & EXFLAG_INVALID_POLICY)
|
|
205
|
-
ret = -1;
|
|
206
|
-
/*
|
|
207
|
-
* Otherwise if we have no data (hence no CertificatePolicies) and
|
|
208
|
-
* haven't already set an inconsistent code note it.
|
|
209
|
-
*/
|
|
210
|
-
else if ((ret == 1) && !cache->data)
|
|
211
|
-
ret = 2;
|
|
212
|
-
if (explicit_policy > 0) {
|
|
213
|
-
if (!(x->ex_flags & EXFLAG_SI))
|
|
214
|
-
explicit_policy--;
|
|
215
|
-
if ((cache->explicit_skip != -1)
|
|
216
|
-
&& (cache->explicit_skip < explicit_policy))
|
|
217
|
-
explicit_policy = cache->explicit_skip;
|
|
218
|
-
}
|
|
165
|
+
if (flags & X509_V_FLAG_EXPLICIT_POLICY) {
|
|
166
|
+
explicit_policy = 0;
|
|
167
|
+
} else {
|
|
168
|
+
explicit_policy = n + 1;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (flags & X509_V_FLAG_INHIBIT_ANY) {
|
|
172
|
+
any_skip = 0;
|
|
173
|
+
} else {
|
|
174
|
+
any_skip = n + 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (flags & X509_V_FLAG_INHIBIT_MAP) {
|
|
178
|
+
map_skip = 0;
|
|
179
|
+
} else {
|
|
180
|
+
map_skip = n + 1;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Can't do anything with just a trust anchor
|
|
184
|
+
if (n == 1) {
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
// First setup policy cache in all certificates apart from the trust
|
|
188
|
+
// anchor. Note any bad cache results on the way. Also can calculate
|
|
189
|
+
// explicit_policy value at this point.
|
|
190
|
+
for (i = n - 2; i >= 0; i--) {
|
|
191
|
+
x = sk_X509_value(certs, i);
|
|
192
|
+
X509_check_purpose(x, -1, -1);
|
|
193
|
+
cache = policy_cache_set(x);
|
|
194
|
+
// If cache NULL something bad happened: return immediately
|
|
195
|
+
if (cache == NULL) {
|
|
196
|
+
return 0;
|
|
219
197
|
}
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
return 6;
|
|
224
|
-
return ret;
|
|
198
|
+
// If inconsistent extensions keep a note of it but continue
|
|
199
|
+
if (x->ex_flags & EXFLAG_INVALID_POLICY) {
|
|
200
|
+
ret = -1;
|
|
225
201
|
}
|
|
202
|
+
// Otherwise if we have no data (hence no CertificatePolicies) and
|
|
203
|
+
// haven't already set an inconsistent code note it.
|
|
204
|
+
else if ((ret == 1) && !cache->data) {
|
|
205
|
+
ret = 2;
|
|
206
|
+
}
|
|
207
|
+
if (explicit_policy > 0) {
|
|
208
|
+
if (!(x->ex_flags & EXFLAG_SI)) {
|
|
209
|
+
explicit_policy--;
|
|
210
|
+
}
|
|
211
|
+
if ((cache->explicit_skip != -1) &&
|
|
212
|
+
(cache->explicit_skip < explicit_policy)) {
|
|
213
|
+
explicit_policy = cache->explicit_skip;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
226
217
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
218
|
+
if (ret != 1) {
|
|
219
|
+
if (ret == 2 && !explicit_policy) {
|
|
220
|
+
return 6;
|
|
221
|
+
}
|
|
222
|
+
return ret;
|
|
223
|
+
}
|
|
230
224
|
|
|
231
|
-
|
|
232
|
-
return 0;
|
|
225
|
+
// If we get this far initialize the tree
|
|
233
226
|
|
|
234
|
-
|
|
235
|
-
tree->levels = OPENSSL_malloc(sizeof(X509_POLICY_LEVEL) * n);
|
|
236
|
-
tree->nlevel = 0;
|
|
237
|
-
tree->extra_data = NULL;
|
|
238
|
-
tree->auth_policies = NULL;
|
|
239
|
-
tree->user_policies = NULL;
|
|
227
|
+
tree = OPENSSL_malloc(sizeof(X509_POLICY_TREE));
|
|
240
228
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
229
|
+
if (!tree) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
245
232
|
|
|
246
|
-
|
|
233
|
+
tree->flags = 0;
|
|
234
|
+
tree->levels = OPENSSL_malloc(sizeof(X509_POLICY_LEVEL) * n);
|
|
235
|
+
tree->nlevel = 0;
|
|
236
|
+
tree->extra_data = NULL;
|
|
237
|
+
tree->auth_policies = NULL;
|
|
238
|
+
tree->user_policies = NULL;
|
|
247
239
|
|
|
248
|
-
|
|
240
|
+
if (!tree->levels) {
|
|
241
|
+
OPENSSL_free(tree);
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
249
244
|
|
|
250
|
-
|
|
245
|
+
OPENSSL_memset(tree->levels, 0, n * sizeof(X509_POLICY_LEVEL));
|
|
251
246
|
|
|
252
|
-
|
|
247
|
+
tree->nlevel = n;
|
|
253
248
|
|
|
254
|
-
|
|
249
|
+
level = tree->levels;
|
|
255
250
|
|
|
256
|
-
|
|
257
|
-
goto bad_tree;
|
|
251
|
+
// Root data: initialize to anyPolicy
|
|
258
252
|
|
|
259
|
-
|
|
260
|
-
level++;
|
|
261
|
-
x = sk_X509_value(certs, i);
|
|
262
|
-
cache = policy_cache_set(x);
|
|
263
|
-
X509_up_ref(x);
|
|
264
|
-
level->cert = x;
|
|
253
|
+
data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0);
|
|
265
254
|
|
|
266
|
-
|
|
267
|
-
|
|
255
|
+
if (!data || !level_add_node(level, data, NULL, tree)) {
|
|
256
|
+
goto bad_tree;
|
|
257
|
+
}
|
|
268
258
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (!(x->ex_flags & EXFLAG_SI) || (i == 0))
|
|
276
|
-
level->flags |= X509_V_FLAG_INHIBIT_ANY;
|
|
277
|
-
} else {
|
|
278
|
-
if (!(x->ex_flags & EXFLAG_SI))
|
|
279
|
-
any_skip--;
|
|
280
|
-
if ((cache->any_skip >= 0)
|
|
281
|
-
&& (cache->any_skip < any_skip))
|
|
282
|
-
any_skip = cache->any_skip;
|
|
283
|
-
}
|
|
259
|
+
for (i = n - 2; i >= 0; i--) {
|
|
260
|
+
level++;
|
|
261
|
+
x = sk_X509_value(certs, i);
|
|
262
|
+
cache = policy_cache_set(x);
|
|
263
|
+
X509_up_ref(x);
|
|
264
|
+
level->cert = x;
|
|
284
265
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (!(x->ex_flags & EXFLAG_SI))
|
|
289
|
-
map_skip--;
|
|
290
|
-
if ((cache->map_skip >= 0)
|
|
291
|
-
&& (cache->map_skip < map_skip))
|
|
292
|
-
map_skip = cache->map_skip;
|
|
293
|
-
}
|
|
266
|
+
if (!cache->anyPolicy) {
|
|
267
|
+
level->flags |= X509_V_FLAG_INHIBIT_ANY;
|
|
268
|
+
}
|
|
294
269
|
|
|
270
|
+
// Determine inhibit any and inhibit map flags
|
|
271
|
+
if (any_skip == 0) {
|
|
272
|
+
// Any matching allowed if certificate is self issued and not the
|
|
273
|
+
// last in the chain.
|
|
274
|
+
if (!(x->ex_flags & EXFLAG_SI) || (i == 0)) {
|
|
275
|
+
level->flags |= X509_V_FLAG_INHIBIT_ANY;
|
|
276
|
+
}
|
|
277
|
+
} else {
|
|
278
|
+
if (!(x->ex_flags & EXFLAG_SI)) {
|
|
279
|
+
any_skip--;
|
|
280
|
+
}
|
|
281
|
+
if ((cache->any_skip >= 0) && (cache->any_skip < any_skip)) {
|
|
282
|
+
any_skip = cache->any_skip;
|
|
283
|
+
}
|
|
295
284
|
}
|
|
296
285
|
|
|
297
|
-
|
|
286
|
+
if (map_skip == 0) {
|
|
287
|
+
level->flags |= X509_V_FLAG_INHIBIT_MAP;
|
|
288
|
+
} else {
|
|
289
|
+
if (!(x->ex_flags & EXFLAG_SI)) {
|
|
290
|
+
map_skip--;
|
|
291
|
+
}
|
|
292
|
+
if ((cache->map_skip >= 0) && (cache->map_skip < map_skip)) {
|
|
293
|
+
map_skip = cache->map_skip;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
298
297
|
|
|
299
|
-
|
|
300
|
-
return 1;
|
|
301
|
-
else
|
|
302
|
-
return 5;
|
|
298
|
+
*ptree = tree;
|
|
303
299
|
|
|
304
|
-
|
|
300
|
+
if (explicit_policy) {
|
|
301
|
+
return 1;
|
|
302
|
+
} else {
|
|
303
|
+
return 5;
|
|
304
|
+
}
|
|
305
305
|
|
|
306
|
-
|
|
306
|
+
bad_tree:
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
X509_policy_tree_free(tree);
|
|
309
309
|
|
|
310
|
+
return 0;
|
|
310
311
|
}
|
|
311
312
|
|
|
312
313
|
static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
|
313
|
-
X509_POLICY_DATA *data)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
314
|
+
X509_POLICY_DATA *data) {
|
|
315
|
+
X509_POLICY_LEVEL *last = curr - 1;
|
|
316
|
+
X509_POLICY_NODE *node;
|
|
317
|
+
int matched = 0;
|
|
318
|
+
size_t i;
|
|
319
|
+
// Iterate through all in nodes linking matches
|
|
320
|
+
for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++) {
|
|
321
|
+
node = sk_X509_POLICY_NODE_value(last->nodes, i);
|
|
322
|
+
if (policy_node_match(last, node, data->valid_policy)) {
|
|
323
|
+
if (!level_add_node(curr, data, node, NULL)) {
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
matched = 1;
|
|
327
327
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
}
|
|
329
|
+
if (!matched && last->anyPolicy) {
|
|
330
|
+
if (!level_add_node(curr, data, last->anyPolicy, NULL)) {
|
|
331
|
+
return 0;
|
|
331
332
|
}
|
|
332
|
-
|
|
333
|
+
}
|
|
334
|
+
return 1;
|
|
333
335
|
}
|
|
334
336
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
* CertificatePolicies onto matching parent or anyPolicy if no match.
|
|
338
|
-
*/
|
|
337
|
+
// This corresponds to RFC 3280 6.1.3(d)(1): link any data from
|
|
338
|
+
// CertificatePolicies onto matching parent or anyPolicy if no match.
|
|
339
339
|
|
|
340
340
|
static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
|
341
|
-
const X509_POLICY_CACHE *cache)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
* because then it will have the mapping flags right and we can prune
|
|
354
|
-
* it later.
|
|
355
|
-
*/
|
|
341
|
+
const X509_POLICY_CACHE *cache) {
|
|
342
|
+
size_t i;
|
|
343
|
+
X509_POLICY_DATA *data;
|
|
344
|
+
|
|
345
|
+
for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) {
|
|
346
|
+
data = sk_X509_POLICY_DATA_value(cache->data, i);
|
|
347
|
+
// If a node is mapped any it doesn't have a corresponding
|
|
348
|
+
// CertificatePolicies entry. However such an identical node would
|
|
349
|
+
// be created if anyPolicy matching is enabled because there would be
|
|
350
|
+
// no match with the parent valid_policy_set. So we create link
|
|
351
|
+
// because then it will have the mapping flags right and we can prune
|
|
352
|
+
// it later.
|
|
356
353
|
#if 0
|
|
357
354
|
if ((data->flags & POLICY_DATA_FLAG_MAPPED_ANY)
|
|
358
355
|
&& !(curr->flags & X509_V_FLAG_INHIBIT_ANY))
|
|
359
356
|
continue;
|
|
360
357
|
#endif
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
358
|
+
// Look for matching nodes in previous level
|
|
359
|
+
if (!tree_link_matching_nodes(curr, data)) {
|
|
360
|
+
return 0;
|
|
364
361
|
}
|
|
365
|
-
|
|
362
|
+
}
|
|
363
|
+
return 1;
|
|
366
364
|
}
|
|
367
365
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
* policies in the parent and link to anyPolicy.
|
|
371
|
-
*/
|
|
366
|
+
// This corresponds to RFC 3280 6.1.3(d)(2): Create new data for any unmatched
|
|
367
|
+
// policies in the parent and link to anyPolicy.
|
|
372
368
|
|
|
373
369
|
static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
|
|
374
370
|
const X509_POLICY_CACHE *cache,
|
|
375
|
-
const ASN1_OBJECT *id,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
371
|
+
const ASN1_OBJECT *id, X509_POLICY_NODE *node,
|
|
372
|
+
X509_POLICY_TREE *tree) {
|
|
373
|
+
X509_POLICY_DATA *data;
|
|
374
|
+
if (id == NULL) {
|
|
375
|
+
id = node->data->valid_policy;
|
|
376
|
+
}
|
|
377
|
+
// Create a new node with qualifiers from anyPolicy and id from unmatched
|
|
378
|
+
// node.
|
|
379
|
+
data = policy_data_new(NULL, id, node_critical(node));
|
|
380
|
+
|
|
381
|
+
if (data == NULL) {
|
|
382
|
+
return 0;
|
|
383
|
+
}
|
|
384
|
+
// Curr may not have anyPolicy
|
|
385
|
+
data->qualifier_set = cache->anyPolicy->qualifier_set;
|
|
386
|
+
data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
|
|
387
|
+
if (!level_add_node(curr, data, node, tree)) {
|
|
388
|
+
policy_data_free(data);
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
396
391
|
|
|
397
|
-
|
|
392
|
+
return 1;
|
|
398
393
|
}
|
|
399
394
|
|
|
400
395
|
static int tree_link_unmatched(X509_POLICY_LEVEL *curr,
|
|
401
396
|
const X509_POLICY_CACHE *cache,
|
|
402
|
-
X509_POLICY_NODE *node, X509_POLICY_TREE *tree)
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return 1;
|
|
412
|
-
if (!tree_add_unmatched(curr, cache, NULL, node, tree))
|
|
413
|
-
return 0;
|
|
414
|
-
/* Add it */
|
|
415
|
-
} else {
|
|
416
|
-
/* If mapping: matched if one child per expected policy set */
|
|
417
|
-
STACK_OF(ASN1_OBJECT) *expset = node->data->expected_policy_set;
|
|
418
|
-
if ((size_t)node->nchild == sk_ASN1_OBJECT_num(expset))
|
|
419
|
-
return 1;
|
|
420
|
-
/* Locate unmatched nodes */
|
|
421
|
-
for (i = 0; i < sk_ASN1_OBJECT_num(expset); i++) {
|
|
422
|
-
ASN1_OBJECT *oid = sk_ASN1_OBJECT_value(expset, i);
|
|
423
|
-
if (level_find_node(curr, node, oid))
|
|
424
|
-
continue;
|
|
425
|
-
if (!tree_add_unmatched(curr, cache, oid, node, tree))
|
|
426
|
-
return 0;
|
|
427
|
-
}
|
|
428
|
-
|
|
397
|
+
X509_POLICY_NODE *node, X509_POLICY_TREE *tree) {
|
|
398
|
+
const X509_POLICY_LEVEL *last = curr - 1;
|
|
399
|
+
size_t i;
|
|
400
|
+
|
|
401
|
+
if ((last->flags & X509_V_FLAG_INHIBIT_MAP) ||
|
|
402
|
+
!(node->data->flags & POLICY_DATA_FLAG_MAPPED)) {
|
|
403
|
+
// If no policy mapping: matched if one child present
|
|
404
|
+
if (node->nchild) {
|
|
405
|
+
return 1;
|
|
429
406
|
}
|
|
407
|
+
if (!tree_add_unmatched(curr, cache, NULL, node, tree)) {
|
|
408
|
+
return 0;
|
|
409
|
+
}
|
|
410
|
+
// Add it
|
|
411
|
+
} else {
|
|
412
|
+
// If mapping: matched if one child per expected policy set
|
|
413
|
+
STACK_OF(ASN1_OBJECT) *expset = node->data->expected_policy_set;
|
|
414
|
+
if ((size_t)node->nchild == sk_ASN1_OBJECT_num(expset)) {
|
|
415
|
+
return 1;
|
|
416
|
+
}
|
|
417
|
+
// Locate unmatched nodes
|
|
418
|
+
for (i = 0; i < sk_ASN1_OBJECT_num(expset); i++) {
|
|
419
|
+
ASN1_OBJECT *oid = sk_ASN1_OBJECT_value(expset, i);
|
|
420
|
+
if (level_find_node(curr, node, oid)) {
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (!tree_add_unmatched(curr, cache, oid, node, tree)) {
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
430
428
|
|
|
431
|
-
|
|
432
|
-
|
|
429
|
+
return 1;
|
|
433
430
|
}
|
|
434
431
|
|
|
435
432
|
static int tree_link_any(X509_POLICY_LEVEL *curr,
|
|
436
433
|
const X509_POLICY_CACHE *cache,
|
|
437
|
-
X509_POLICY_TREE *tree)
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (!tree_link_unmatched(curr, cache, node, tree))
|
|
450
|
-
return 0;
|
|
434
|
+
X509_POLICY_TREE *tree) {
|
|
435
|
+
size_t i;
|
|
436
|
+
// X509_POLICY_DATA *data;
|
|
437
|
+
X509_POLICY_NODE *node;
|
|
438
|
+
X509_POLICY_LEVEL *last = curr - 1;
|
|
439
|
+
|
|
440
|
+
for (i = 0; i < sk_X509_POLICY_NODE_num(last->nodes); i++) {
|
|
441
|
+
node = sk_X509_POLICY_NODE_value(last->nodes, i);
|
|
442
|
+
|
|
443
|
+
if (!tree_link_unmatched(curr, cache, node, tree)) {
|
|
444
|
+
return 0;
|
|
445
|
+
}
|
|
451
446
|
|
|
452
447
|
#if 0
|
|
453
448
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
* may have multiple children
|
|
458
|
-
*/
|
|
449
|
+
// Skip any node with any children: we only want unmathced nodes.
|
|
450
|
+
// Note: need something better for policy mapping because each node
|
|
451
|
+
// may have multiple children
|
|
459
452
|
if (node->nchild)
|
|
460
453
|
continue;
|
|
461
454
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
* unmatched node.
|
|
465
|
-
*/
|
|
455
|
+
// Create a new node with qualifiers from anyPolicy and id from
|
|
456
|
+
// unmatched node.
|
|
466
457
|
data = policy_data_new(NULL, node->data->valid_policy,
|
|
467
458
|
node_critical(node));
|
|
468
459
|
|
|
469
460
|
if (data == NULL)
|
|
470
461
|
return 0;
|
|
471
|
-
|
|
462
|
+
// Curr may not have anyPolicy
|
|
472
463
|
data->qualifier_set = cache->anyPolicy->qualifier_set;
|
|
473
464
|
data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
|
|
474
465
|
if (!level_add_node(curr, data, node, tree)) {
|
|
@@ -476,368 +467,372 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
|
|
|
476
467
|
return 0;
|
|
477
468
|
}
|
|
478
469
|
#endif
|
|
479
|
-
|
|
470
|
+
}
|
|
471
|
+
// Finally add link to anyPolicy
|
|
472
|
+
if (last->anyPolicy) {
|
|
473
|
+
if (!level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL)) {
|
|
474
|
+
return 0;
|
|
480
475
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
if (!level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL))
|
|
484
|
-
return 0;
|
|
485
|
-
}
|
|
486
|
-
return 1;
|
|
476
|
+
}
|
|
477
|
+
return 1;
|
|
487
478
|
}
|
|
488
479
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
480
|
+
// Prune the tree: delete any child mapped child data on the current level
|
|
481
|
+
// then proceed up the tree deleting any data with no children. If we ever
|
|
482
|
+
// have no data on a level we can halt because the tree will be empty.
|
|
483
|
+
|
|
484
|
+
static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) {
|
|
485
|
+
STACK_OF(X509_POLICY_NODE) *nodes;
|
|
486
|
+
X509_POLICY_NODE *node;
|
|
487
|
+
int i;
|
|
488
|
+
nodes = curr->nodes;
|
|
489
|
+
if (curr->flags & X509_V_FLAG_INHIBIT_MAP) {
|
|
490
|
+
for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--) {
|
|
491
|
+
node = sk_X509_POLICY_NODE_value(nodes, i);
|
|
492
|
+
// Delete any mapped data: see RFC 3280 XXXX
|
|
493
|
+
if (node->data->flags & POLICY_DATA_FLAG_MAP_MASK) {
|
|
494
|
+
node->parent->nchild--;
|
|
495
|
+
OPENSSL_free(node);
|
|
496
|
+
(void)sk_X509_POLICY_NODE_delete(nodes, i);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
494
500
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
STACK_OF(X509_POLICY_NODE) *nodes;
|
|
498
|
-
X509_POLICY_NODE *node;
|
|
499
|
-
int i;
|
|
501
|
+
for (;;) {
|
|
502
|
+
--curr;
|
|
500
503
|
nodes = curr->nodes;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
(void)sk_X509_POLICY_NODE_delete(nodes, i);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
504
|
+
for (i = sk_X509_POLICY_NODE_num(nodes) - 1; i >= 0; i--) {
|
|
505
|
+
node = sk_X509_POLICY_NODE_value(nodes, i);
|
|
506
|
+
if (node->nchild == 0) {
|
|
507
|
+
node->parent->nchild--;
|
|
508
|
+
OPENSSL_free(node);
|
|
509
|
+
(void)sk_X509_POLICY_NODE_delete(nodes, i);
|
|
510
|
+
}
|
|
511
511
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (node->nchild == 0) {
|
|
519
|
-
node->parent->nchild--;
|
|
520
|
-
OPENSSL_free(node);
|
|
521
|
-
(void)sk_X509_POLICY_NODE_delete(nodes, i);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
if (curr->anyPolicy && !curr->anyPolicy->nchild) {
|
|
525
|
-
if (curr->anyPolicy->parent)
|
|
526
|
-
curr->anyPolicy->parent->nchild--;
|
|
527
|
-
OPENSSL_free(curr->anyPolicy);
|
|
528
|
-
curr->anyPolicy = NULL;
|
|
529
|
-
}
|
|
530
|
-
if (curr == tree->levels) {
|
|
531
|
-
/* If we zapped anyPolicy at top then tree is empty */
|
|
532
|
-
if (!curr->anyPolicy)
|
|
533
|
-
return 2;
|
|
534
|
-
return 1;
|
|
535
|
-
}
|
|
512
|
+
if (curr->anyPolicy && !curr->anyPolicy->nchild) {
|
|
513
|
+
if (curr->anyPolicy->parent) {
|
|
514
|
+
curr->anyPolicy->parent->nchild--;
|
|
515
|
+
}
|
|
516
|
+
OPENSSL_free(curr->anyPolicy);
|
|
517
|
+
curr->anyPolicy = NULL;
|
|
536
518
|
}
|
|
537
|
-
|
|
519
|
+
if (curr == tree->levels) {
|
|
520
|
+
// If we zapped anyPolicy at top then tree is empty
|
|
521
|
+
if (!curr->anyPolicy) {
|
|
522
|
+
return 2;
|
|
523
|
+
}
|
|
524
|
+
return 1;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
538
527
|
}
|
|
539
528
|
|
|
540
529
|
static int tree_add_auth_node(STACK_OF(X509_POLICY_NODE) **pnodes,
|
|
541
|
-
X509_POLICY_NODE *pcy)
|
|
542
|
-
{
|
|
530
|
+
X509_POLICY_NODE *pcy) {
|
|
531
|
+
if (!*pnodes) {
|
|
532
|
+
*pnodes = policy_node_cmp_new();
|
|
543
533
|
if (!*pnodes) {
|
|
544
|
-
|
|
545
|
-
if (!*pnodes)
|
|
546
|
-
return 0;
|
|
547
|
-
} else {
|
|
548
|
-
sk_X509_POLICY_NODE_sort(*pnodes);
|
|
549
|
-
if (sk_X509_POLICY_NODE_find(*pnodes, NULL, pcy))
|
|
550
|
-
return 1;
|
|
534
|
+
return 0;
|
|
551
535
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
536
|
+
} else {
|
|
537
|
+
sk_X509_POLICY_NODE_sort(*pnodes);
|
|
538
|
+
if (sk_X509_POLICY_NODE_find(*pnodes, NULL, pcy)) {
|
|
539
|
+
return 1;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (!sk_X509_POLICY_NODE_push(*pnodes, pcy)) {
|
|
543
|
+
return 0;
|
|
544
|
+
}
|
|
556
545
|
|
|
546
|
+
return 1;
|
|
557
547
|
}
|
|
558
548
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
* value of '2' is used in this case to indicate that pnodes should be freed.
|
|
566
|
-
*/
|
|
549
|
+
// Calculate the authority set based on policy tree. The 'pnodes' parameter
|
|
550
|
+
// is used as a store for the set of policy nodes used to calculate the user
|
|
551
|
+
// set. If the authority set is not anyPolicy then pnodes will just point to
|
|
552
|
+
// the authority set. If however the authority set is anyPolicy then the set
|
|
553
|
+
// of valid policies (other than anyPolicy) is store in pnodes. The return
|
|
554
|
+
// value of '2' is used in this case to indicate that pnodes should be freed.
|
|
567
555
|
|
|
568
556
|
static int tree_calculate_authority_set(X509_POLICY_TREE *tree,
|
|
569
|
-
STACK_OF(X509_POLICY_NODE) **pnodes)
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (curr->anyPolicy) {
|
|
580
|
-
|
|
581
|
-
return 0;
|
|
582
|
-
addnodes = pnodes;
|
|
583
|
-
} else
|
|
584
|
-
/* Add policies to authority set */
|
|
585
|
-
addnodes = &tree->auth_policies;
|
|
586
|
-
|
|
587
|
-
curr = tree->levels;
|
|
588
|
-
for (i = 1; i < tree->nlevel; i++) {
|
|
589
|
-
/*
|
|
590
|
-
* If no anyPolicy node on this this level it can't appear on lower
|
|
591
|
-
* levels so end search.
|
|
592
|
-
*/
|
|
593
|
-
if (!(anyptr = curr->anyPolicy))
|
|
594
|
-
break;
|
|
595
|
-
curr++;
|
|
596
|
-
for (j = 0; j < sk_X509_POLICY_NODE_num(curr->nodes); j++) {
|
|
597
|
-
node = sk_X509_POLICY_NODE_value(curr->nodes, j);
|
|
598
|
-
if ((node->parent == anyptr)
|
|
599
|
-
&& !tree_add_auth_node(addnodes, node))
|
|
600
|
-
return 0;
|
|
601
|
-
}
|
|
557
|
+
STACK_OF(X509_POLICY_NODE) **pnodes) {
|
|
558
|
+
X509_POLICY_LEVEL *curr;
|
|
559
|
+
X509_POLICY_NODE *node, *anyptr;
|
|
560
|
+
STACK_OF(X509_POLICY_NODE) **addnodes;
|
|
561
|
+
int i;
|
|
562
|
+
size_t j;
|
|
563
|
+
curr = tree->levels + tree->nlevel - 1;
|
|
564
|
+
|
|
565
|
+
// If last level contains anyPolicy set is anyPolicy
|
|
566
|
+
if (curr->anyPolicy) {
|
|
567
|
+
if (!tree_add_auth_node(&tree->auth_policies, curr->anyPolicy)) {
|
|
568
|
+
return 0;
|
|
602
569
|
}
|
|
570
|
+
addnodes = pnodes;
|
|
571
|
+
} else {
|
|
572
|
+
// Add policies to authority set
|
|
573
|
+
addnodes = &tree->auth_policies;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
curr = tree->levels;
|
|
577
|
+
for (i = 1; i < tree->nlevel; i++) {
|
|
578
|
+
// If no anyPolicy node on this this level it can't appear on lower
|
|
579
|
+
// levels so end search.
|
|
580
|
+
if (!(anyptr = curr->anyPolicy)) {
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
curr++;
|
|
584
|
+
for (j = 0; j < sk_X509_POLICY_NODE_num(curr->nodes); j++) {
|
|
585
|
+
node = sk_X509_POLICY_NODE_value(curr->nodes, j);
|
|
586
|
+
if ((node->parent == anyptr) && !tree_add_auth_node(addnodes, node)) {
|
|
587
|
+
return 0;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
603
591
|
|
|
604
|
-
|
|
605
|
-
|
|
592
|
+
if (addnodes == pnodes) {
|
|
593
|
+
return 2;
|
|
594
|
+
}
|
|
606
595
|
|
|
607
|
-
|
|
596
|
+
*pnodes = tree->auth_policies;
|
|
608
597
|
|
|
609
|
-
|
|
598
|
+
return 1;
|
|
610
599
|
}
|
|
611
600
|
|
|
612
601
|
static int tree_calculate_user_set(X509_POLICY_TREE *tree,
|
|
613
602
|
STACK_OF(ASN1_OBJECT) *policy_oids,
|
|
614
|
-
STACK_OF(X509_POLICY_NODE) *auth_nodes)
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
ASN1_OBJECT *oid;
|
|
603
|
+
STACK_OF(X509_POLICY_NODE) *auth_nodes) {
|
|
604
|
+
size_t i;
|
|
605
|
+
X509_POLICY_NODE *node;
|
|
606
|
+
ASN1_OBJECT *oid;
|
|
619
607
|
|
|
620
|
-
|
|
621
|
-
|
|
608
|
+
X509_POLICY_NODE *anyPolicy;
|
|
609
|
+
X509_POLICY_DATA *extra;
|
|
622
610
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
* will happen if it is a leaf node.
|
|
626
|
-
*/
|
|
611
|
+
// Check if anyPolicy present in authority constrained policy set: this
|
|
612
|
+
// will happen if it is a leaf node.
|
|
627
613
|
|
|
628
|
-
|
|
629
|
-
|
|
614
|
+
if (sk_ASN1_OBJECT_num(policy_oids) <= 0) {
|
|
615
|
+
return 1;
|
|
616
|
+
}
|
|
630
617
|
|
|
631
|
-
|
|
618
|
+
anyPolicy = tree->levels[tree->nlevel - 1].anyPolicy;
|
|
632
619
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
620
|
+
for (i = 0; i < sk_ASN1_OBJECT_num(policy_oids); i++) {
|
|
621
|
+
oid = sk_ASN1_OBJECT_value(policy_oids, i);
|
|
622
|
+
if (OBJ_obj2nid(oid) == NID_any_policy) {
|
|
623
|
+
tree->flags |= POLICY_FLAG_ANY_POLICY;
|
|
624
|
+
return 1;
|
|
639
625
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (!tree->user_policies) {
|
|
660
|
-
tree->user_policies = sk_X509_POLICY_NODE_new_null();
|
|
661
|
-
if (!tree->user_policies)
|
|
662
|
-
return 1;
|
|
663
|
-
}
|
|
664
|
-
if (!sk_X509_POLICY_NODE_push(tree->user_policies, node))
|
|
665
|
-
return 0;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
for (i = 0; i < sk_ASN1_OBJECT_num(policy_oids); i++) {
|
|
629
|
+
oid = sk_ASN1_OBJECT_value(policy_oids, i);
|
|
630
|
+
node = tree_find_sk(auth_nodes, oid);
|
|
631
|
+
if (!node) {
|
|
632
|
+
if (!anyPolicy) {
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
// Create a new node with policy ID from user set and qualifiers
|
|
636
|
+
// from anyPolicy.
|
|
637
|
+
extra = policy_data_new(NULL, oid, node_critical(anyPolicy));
|
|
638
|
+
if (!extra) {
|
|
639
|
+
return 0;
|
|
640
|
+
}
|
|
641
|
+
extra->qualifier_set = anyPolicy->data->qualifier_set;
|
|
642
|
+
extra->flags =
|
|
643
|
+
POLICY_DATA_FLAG_SHARED_QUALIFIERS | POLICY_DATA_FLAG_EXTRA_NODE;
|
|
644
|
+
node = level_add_node(NULL, extra, anyPolicy->parent, tree);
|
|
666
645
|
}
|
|
667
|
-
|
|
668
|
-
|
|
646
|
+
if (!tree->user_policies) {
|
|
647
|
+
tree->user_policies = sk_X509_POLICY_NODE_new_null();
|
|
648
|
+
if (!tree->user_policies) {
|
|
649
|
+
return 1;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
if (!sk_X509_POLICY_NODE_push(tree->user_policies, node)) {
|
|
653
|
+
return 0;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
return 1;
|
|
669
657
|
}
|
|
670
658
|
|
|
671
|
-
static int tree_evaluate(X509_POLICY_TREE *tree)
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const X509_POLICY_CACHE *cache;
|
|
676
|
-
|
|
677
|
-
for (i = 1; i < tree->nlevel; i++, curr++) {
|
|
678
|
-
cache = policy_cache_set(curr->cert);
|
|
679
|
-
if (!tree_link_nodes(curr, cache))
|
|
680
|
-
return 0;
|
|
659
|
+
static int tree_evaluate(X509_POLICY_TREE *tree) {
|
|
660
|
+
int ret, i;
|
|
661
|
+
X509_POLICY_LEVEL *curr = tree->levels + 1;
|
|
662
|
+
const X509_POLICY_CACHE *cache;
|
|
681
663
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
ret = tree_prune(tree, curr);
|
|
687
|
-
if (ret != 1)
|
|
688
|
-
return ret;
|
|
664
|
+
for (i = 1; i < tree->nlevel; i++, curr++) {
|
|
665
|
+
cache = policy_cache_set(curr->cert);
|
|
666
|
+
if (!tree_link_nodes(curr, cache)) {
|
|
667
|
+
return 0;
|
|
689
668
|
}
|
|
690
669
|
|
|
691
|
-
|
|
670
|
+
if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY) &&
|
|
671
|
+
!tree_link_any(curr, cache, tree)) {
|
|
672
|
+
return 0;
|
|
673
|
+
}
|
|
674
|
+
tree_print("before tree_prune()", tree, curr);
|
|
675
|
+
ret = tree_prune(tree, curr);
|
|
676
|
+
if (ret != 1) {
|
|
677
|
+
return ret;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
692
680
|
|
|
681
|
+
return 1;
|
|
693
682
|
}
|
|
694
683
|
|
|
695
|
-
static void exnode_free(X509_POLICY_NODE *node)
|
|
696
|
-
{
|
|
697
|
-
|
|
698
|
-
|
|
684
|
+
static void exnode_free(X509_POLICY_NODE *node) {
|
|
685
|
+
if (node->data && (node->data->flags & POLICY_DATA_FLAG_EXTRA_NODE)) {
|
|
686
|
+
OPENSSL_free(node);
|
|
687
|
+
}
|
|
699
688
|
}
|
|
700
689
|
|
|
701
|
-
void X509_policy_tree_free(X509_POLICY_TREE *tree)
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
int i;
|
|
690
|
+
void X509_policy_tree_free(X509_POLICY_TREE *tree) {
|
|
691
|
+
X509_POLICY_LEVEL *curr;
|
|
692
|
+
int i;
|
|
705
693
|
|
|
706
|
-
|
|
707
|
-
|
|
694
|
+
if (!tree) {
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
708
697
|
|
|
709
|
-
|
|
710
|
-
|
|
698
|
+
sk_X509_POLICY_NODE_free(tree->auth_policies);
|
|
699
|
+
sk_X509_POLICY_NODE_pop_free(tree->user_policies, exnode_free);
|
|
711
700
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
if (curr->nodes)
|
|
716
|
-
sk_X509_POLICY_NODE_pop_free(curr->nodes, policy_node_free);
|
|
717
|
-
if (curr->anyPolicy)
|
|
718
|
-
policy_node_free(curr->anyPolicy);
|
|
701
|
+
for (i = 0, curr = tree->levels; i < tree->nlevel; i++, curr++) {
|
|
702
|
+
if (curr->cert) {
|
|
703
|
+
X509_free(curr->cert);
|
|
719
704
|
}
|
|
705
|
+
if (curr->nodes) {
|
|
706
|
+
sk_X509_POLICY_NODE_pop_free(curr->nodes, policy_node_free);
|
|
707
|
+
}
|
|
708
|
+
if (curr->anyPolicy) {
|
|
709
|
+
policy_node_free(curr->anyPolicy);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
720
712
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
OPENSSL_free(tree->levels);
|
|
725
|
-
OPENSSL_free(tree);
|
|
713
|
+
if (tree->extra_data) {
|
|
714
|
+
sk_X509_POLICY_DATA_pop_free(tree->extra_data, policy_data_free);
|
|
715
|
+
}
|
|
726
716
|
|
|
717
|
+
OPENSSL_free(tree->levels);
|
|
718
|
+
OPENSSL_free(tree);
|
|
727
719
|
}
|
|
728
720
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
*/
|
|
721
|
+
//-
|
|
722
|
+
// Application policy checking function.
|
|
723
|
+
// Return codes:
|
|
724
|
+
// 0 Internal Error.
|
|
725
|
+
// 1 Successful.
|
|
726
|
+
// -1 One or more certificates contain invalid or inconsistent extensions
|
|
727
|
+
// -2 User constrained policy set empty and requireExplicit true.
|
|
737
728
|
|
|
738
729
|
int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,
|
|
739
|
-
STACK_OF(X509) *certs,
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
/* Tree empty requireExplicit False: OK */
|
|
730
|
+
STACK_OF(X509) *certs, STACK_OF(ASN1_OBJECT) *policy_oids,
|
|
731
|
+
unsigned int flags) {
|
|
732
|
+
int ret;
|
|
733
|
+
int calc_ret;
|
|
734
|
+
X509_POLICY_TREE *tree = NULL;
|
|
735
|
+
STACK_OF(X509_POLICY_NODE) *nodes, *auth_nodes = NULL;
|
|
736
|
+
*ptree = NULL;
|
|
737
|
+
|
|
738
|
+
*pexplicit_policy = 0;
|
|
739
|
+
ret = tree_init(&tree, certs, flags);
|
|
740
|
+
|
|
741
|
+
switch (ret) {
|
|
742
|
+
// Tree empty requireExplicit False: OK
|
|
754
743
|
case 2:
|
|
755
|
-
|
|
744
|
+
return 1;
|
|
756
745
|
|
|
757
|
-
|
|
746
|
+
// Some internal error
|
|
758
747
|
case -1:
|
|
759
|
-
|
|
748
|
+
return -1;
|
|
760
749
|
|
|
761
|
-
|
|
750
|
+
// Some internal error
|
|
762
751
|
case 0:
|
|
763
|
-
|
|
752
|
+
return 0;
|
|
764
753
|
|
|
765
|
-
|
|
754
|
+
// Tree empty requireExplicit True: Error
|
|
766
755
|
|
|
767
756
|
case 6:
|
|
768
|
-
|
|
769
|
-
|
|
757
|
+
*pexplicit_policy = 1;
|
|
758
|
+
return -2;
|
|
770
759
|
|
|
771
|
-
|
|
760
|
+
// Tree OK requireExplicit True: OK and continue
|
|
772
761
|
case 5:
|
|
773
|
-
|
|
774
|
-
|
|
762
|
+
*pexplicit_policy = 1;
|
|
763
|
+
break;
|
|
775
764
|
|
|
776
|
-
|
|
765
|
+
// Tree OK: continue
|
|
777
766
|
|
|
778
767
|
case 1:
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
768
|
+
if (!tree) {
|
|
769
|
+
// tree_init() returns success and a null tree
|
|
770
|
+
// if it's just looking at a trust anchor.
|
|
771
|
+
// I'm not sure that returning success here is
|
|
772
|
+
// correct, but I'm sure that reporting this
|
|
773
|
+
// as an internal error which our caller
|
|
774
|
+
// interprets as a malloc failure is wrong.
|
|
775
|
+
return 1;
|
|
776
|
+
}
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
791
779
|
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
780
|
+
if (!tree) {
|
|
781
|
+
goto error;
|
|
782
|
+
}
|
|
783
|
+
ret = tree_evaluate(tree);
|
|
795
784
|
|
|
796
|
-
|
|
785
|
+
tree_print("tree_evaluate()", tree, NULL);
|
|
797
786
|
|
|
798
|
-
|
|
799
|
-
|
|
787
|
+
if (ret <= 0) {
|
|
788
|
+
goto error;
|
|
789
|
+
}
|
|
800
790
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
791
|
+
// Return value 2 means tree empty
|
|
792
|
+
if (ret == 2) {
|
|
793
|
+
X509_policy_tree_free(tree);
|
|
794
|
+
if (*pexplicit_policy) {
|
|
795
|
+
return -2;
|
|
796
|
+
} else {
|
|
797
|
+
return 1;
|
|
808
798
|
}
|
|
799
|
+
}
|
|
809
800
|
|
|
810
|
-
|
|
801
|
+
// Tree is not empty: continue
|
|
811
802
|
|
|
812
|
-
|
|
803
|
+
calc_ret = tree_calculate_authority_set(tree, &auth_nodes);
|
|
813
804
|
|
|
814
|
-
|
|
815
|
-
|
|
805
|
+
if (!calc_ret) {
|
|
806
|
+
goto error;
|
|
807
|
+
}
|
|
816
808
|
|
|
817
|
-
|
|
809
|
+
ret = tree_calculate_user_set(tree, policy_oids, auth_nodes);
|
|
818
810
|
|
|
819
|
-
|
|
820
|
-
|
|
811
|
+
if (calc_ret == 2) {
|
|
812
|
+
sk_X509_POLICY_NODE_free(auth_nodes);
|
|
813
|
+
}
|
|
821
814
|
|
|
822
|
-
|
|
823
|
-
|
|
815
|
+
if (!ret) {
|
|
816
|
+
goto error;
|
|
817
|
+
}
|
|
824
818
|
|
|
825
819
|
|
|
826
|
-
|
|
827
|
-
|
|
820
|
+
if (tree) {
|
|
821
|
+
*ptree = tree;
|
|
822
|
+
}
|
|
828
823
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
824
|
+
if (*pexplicit_policy) {
|
|
825
|
+
nodes = X509_policy_tree_get0_user_policies(tree);
|
|
826
|
+
if (sk_X509_POLICY_NODE_num(nodes) <= 0) {
|
|
827
|
+
return -2;
|
|
833
828
|
}
|
|
829
|
+
}
|
|
834
830
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
error:
|
|
831
|
+
return 1;
|
|
838
832
|
|
|
839
|
-
|
|
833
|
+
error:
|
|
840
834
|
|
|
841
|
-
|
|
835
|
+
X509_policy_tree_free(tree);
|
|
842
836
|
|
|
837
|
+
return 0;
|
|
843
838
|
}
|