@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
|
@@ -68,60 +68,59 @@
|
|
|
68
68
|
#include "../x509v3/internal.h"
|
|
69
69
|
#include "internal.h"
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
#define ASN1_GEN_FLAG
|
|
77
|
-
#define
|
|
78
|
-
#define
|
|
79
|
-
#define
|
|
80
|
-
#define
|
|
81
|
-
#define
|
|
82
|
-
#define
|
|
83
|
-
|
|
84
|
-
#define
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/* List of bits */
|
|
71
|
+
// Although this file is in crypto/x509 for layering purposes, it emits
|
|
72
|
+
// errors from the ASN.1 module for OpenSSL compatibility.
|
|
73
|
+
|
|
74
|
+
#define ASN1_GEN_FLAG 0x10000
|
|
75
|
+
#define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG | 1)
|
|
76
|
+
#define ASN1_GEN_FLAG_EXP (ASN1_GEN_FLAG | 2)
|
|
77
|
+
#define ASN1_GEN_FLAG_TAG (ASN1_GEN_FLAG | 3)
|
|
78
|
+
#define ASN1_GEN_FLAG_BITWRAP (ASN1_GEN_FLAG | 4)
|
|
79
|
+
#define ASN1_GEN_FLAG_OCTWRAP (ASN1_GEN_FLAG | 5)
|
|
80
|
+
#define ASN1_GEN_FLAG_SEQWRAP (ASN1_GEN_FLAG | 6)
|
|
81
|
+
#define ASN1_GEN_FLAG_SETWRAP (ASN1_GEN_FLAG | 7)
|
|
82
|
+
#define ASN1_GEN_FLAG_FORMAT (ASN1_GEN_FLAG | 8)
|
|
83
|
+
|
|
84
|
+
#define ASN1_GEN_STR(str, val) \
|
|
85
|
+
{ str, sizeof(str) - 1, val }
|
|
86
|
+
|
|
87
|
+
#define ASN1_FLAG_EXP_MAX 20
|
|
88
|
+
// Maximum number of nested sequences
|
|
89
|
+
#define ASN1_GEN_SEQ_MAX_DEPTH 50
|
|
90
|
+
|
|
91
|
+
// Input formats
|
|
92
|
+
|
|
93
|
+
// ASCII: default
|
|
94
|
+
#define ASN1_GEN_FORMAT_ASCII 1
|
|
95
|
+
// UTF8
|
|
96
|
+
#define ASN1_GEN_FORMAT_UTF8 2
|
|
97
|
+
// Hex
|
|
98
|
+
#define ASN1_GEN_FORMAT_HEX 3
|
|
99
|
+
// List of bits
|
|
101
100
|
#define ASN1_GEN_FORMAT_BITLIST 4
|
|
102
101
|
|
|
103
102
|
struct tag_name_st {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
const char *strnam;
|
|
104
|
+
int len;
|
|
105
|
+
int tag;
|
|
107
106
|
};
|
|
108
107
|
|
|
109
108
|
typedef struct {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
int exp_tag;
|
|
110
|
+
int exp_class;
|
|
111
|
+
int exp_constructed;
|
|
112
|
+
int exp_pad;
|
|
113
|
+
long exp_len;
|
|
115
114
|
} tag_exp_type;
|
|
116
115
|
|
|
117
116
|
typedef struct {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
int imp_tag;
|
|
118
|
+
int imp_class;
|
|
119
|
+
int utype;
|
|
120
|
+
int format;
|
|
121
|
+
const char *str;
|
|
122
|
+
tag_exp_type exp_list[ASN1_FLAG_EXP_MAX];
|
|
123
|
+
int exp_count;
|
|
125
124
|
} tag_exp_arg;
|
|
126
125
|
|
|
127
126
|
static ASN1_TYPE *generate_v3(const char *str, X509V3_CTX *cnf, int depth,
|
|
@@ -130,591 +129,601 @@ static int bitstr_cb(const char *elem, int len, void *bitstr);
|
|
|
130
129
|
static int asn1_cb(const char *elem, int len, void *bitstr);
|
|
131
130
|
static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class,
|
|
132
131
|
int exp_constructed, int exp_pad, int imp_ok);
|
|
133
|
-
static int parse_tagging(const char *vstart, int vlen, int *ptag,
|
|
134
|
-
int *pclass);
|
|
132
|
+
static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass);
|
|
135
133
|
static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
|
|
136
134
|
int depth, int *perr);
|
|
137
135
|
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype);
|
|
138
136
|
static int asn1_str2tag(const char *tagstr, int len);
|
|
139
137
|
|
|
140
|
-
ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf) {
|
|
139
|
+
int err = 0;
|
|
140
|
+
ASN1_TYPE *ret = generate_v3(str, cnf, 0, &err);
|
|
141
|
+
if (err) {
|
|
142
|
+
OPENSSL_PUT_ERROR(ASN1, err);
|
|
143
|
+
}
|
|
144
|
+
return ret;
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
static ASN1_TYPE *generate_v3(const char *str, X509V3_CTX *cnf, int depth,
|
|
150
|
-
int *perr)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
148
|
+
int *perr) {
|
|
149
|
+
ASN1_TYPE *ret;
|
|
150
|
+
tag_exp_arg asn1_tags;
|
|
151
|
+
tag_exp_type *etmp;
|
|
152
|
+
|
|
153
|
+
int i, len;
|
|
154
|
+
|
|
155
|
+
unsigned char *orig_der = NULL, *new_der = NULL;
|
|
156
|
+
const unsigned char *cpy_start;
|
|
157
|
+
unsigned char *p;
|
|
158
|
+
const unsigned char *cp;
|
|
159
|
+
int cpy_len;
|
|
160
|
+
long hdr_len = 0;
|
|
161
|
+
int hdr_constructed = 0, hdr_tag, hdr_class;
|
|
162
|
+
int r;
|
|
163
|
+
|
|
164
|
+
asn1_tags.imp_tag = -1;
|
|
165
|
+
asn1_tags.imp_class = -1;
|
|
166
|
+
asn1_tags.format = ASN1_GEN_FORMAT_ASCII;
|
|
167
|
+
asn1_tags.exp_count = 0;
|
|
168
|
+
if (CONF_parse_list(str, ',', 1, asn1_cb, &asn1_tags) != 0) {
|
|
169
|
+
*perr = ASN1_R_UNKNOWN_TAG;
|
|
170
|
+
return NULL;
|
|
171
|
+
}
|
|
175
172
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return NULL;
|
|
181
|
-
}
|
|
182
|
-
if (depth >= ASN1_GEN_SEQ_MAX_DEPTH) {
|
|
183
|
-
*perr = ASN1_R_ILLEGAL_NESTED_TAGGING;
|
|
184
|
-
return NULL;
|
|
185
|
-
}
|
|
186
|
-
ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf, depth, perr);
|
|
187
|
-
} else
|
|
188
|
-
ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype);
|
|
189
|
-
|
|
190
|
-
if (!ret)
|
|
191
|
-
return NULL;
|
|
192
|
-
|
|
193
|
-
/* If no tagging return base type */
|
|
194
|
-
if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0))
|
|
195
|
-
return ret;
|
|
196
|
-
|
|
197
|
-
/* Generate the encoding */
|
|
198
|
-
cpy_len = i2d_ASN1_TYPE(ret, &orig_der);
|
|
199
|
-
ASN1_TYPE_free(ret);
|
|
200
|
-
ret = NULL;
|
|
201
|
-
/* Set point to start copying for modified encoding */
|
|
202
|
-
cpy_start = orig_der;
|
|
203
|
-
|
|
204
|
-
/* Do we need IMPLICIT tagging? */
|
|
205
|
-
if (asn1_tags.imp_tag != -1) {
|
|
206
|
-
/* If IMPLICIT we will replace the underlying tag */
|
|
207
|
-
/* Skip existing tag+len */
|
|
208
|
-
r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class,
|
|
209
|
-
cpy_len);
|
|
210
|
-
if (r & 0x80)
|
|
211
|
-
goto err;
|
|
212
|
-
/* Update copy length */
|
|
213
|
-
cpy_len -= cpy_start - orig_der;
|
|
214
|
-
/*
|
|
215
|
-
* For IMPLICIT tagging the length should match the original length
|
|
216
|
-
* and constructed flag should be consistent.
|
|
217
|
-
*/
|
|
218
|
-
hdr_constructed = r & V_ASN1_CONSTRUCTED;
|
|
219
|
-
/*
|
|
220
|
-
* Work out new length with IMPLICIT tag: ignore constructed because
|
|
221
|
-
* it will mess up if indefinite length
|
|
222
|
-
*/
|
|
223
|
-
len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag);
|
|
224
|
-
} else
|
|
225
|
-
len = cpy_len;
|
|
226
|
-
|
|
227
|
-
/* Work out length in any EXPLICIT, starting from end */
|
|
228
|
-
|
|
229
|
-
for (i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1;
|
|
230
|
-
i < asn1_tags.exp_count; i++, etmp--) {
|
|
231
|
-
/* Content length: number of content octets + any padding */
|
|
232
|
-
len += etmp->exp_pad;
|
|
233
|
-
etmp->exp_len = len;
|
|
234
|
-
/* Total object length: length including new header */
|
|
235
|
-
len = ASN1_object_size(0, len, etmp->exp_tag);
|
|
173
|
+
if ((asn1_tags.utype == V_ASN1_SEQUENCE) || (asn1_tags.utype == V_ASN1_SET)) {
|
|
174
|
+
if (!cnf) {
|
|
175
|
+
*perr = ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG;
|
|
176
|
+
return NULL;
|
|
236
177
|
}
|
|
178
|
+
if (depth >= ASN1_GEN_SEQ_MAX_DEPTH) {
|
|
179
|
+
*perr = ASN1_R_ILLEGAL_NESTED_TAGGING;
|
|
180
|
+
return NULL;
|
|
181
|
+
}
|
|
182
|
+
ret = asn1_multi(asn1_tags.utype, asn1_tags.str, cnf, depth, perr);
|
|
183
|
+
} else {
|
|
184
|
+
ret = asn1_str2type(asn1_tags.str, asn1_tags.format, asn1_tags.utype);
|
|
185
|
+
}
|
|
237
186
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (!new_der)
|
|
242
|
-
goto err;
|
|
243
|
-
|
|
244
|
-
/* Generate tagged encoding */
|
|
245
|
-
|
|
246
|
-
p = new_der;
|
|
247
|
-
|
|
248
|
-
/* Output explicit tags first */
|
|
187
|
+
if (!ret) {
|
|
188
|
+
return NULL;
|
|
189
|
+
}
|
|
249
190
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
191
|
+
// If no tagging return base type
|
|
192
|
+
if ((asn1_tags.imp_tag == -1) && (asn1_tags.exp_count == 0)) {
|
|
193
|
+
return ret;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Generate the encoding
|
|
197
|
+
cpy_len = i2d_ASN1_TYPE(ret, &orig_der);
|
|
198
|
+
ASN1_TYPE_free(ret);
|
|
199
|
+
ret = NULL;
|
|
200
|
+
// Set point to start copying for modified encoding
|
|
201
|
+
cpy_start = orig_der;
|
|
202
|
+
|
|
203
|
+
// Do we need IMPLICIT tagging?
|
|
204
|
+
if (asn1_tags.imp_tag != -1) {
|
|
205
|
+
// If IMPLICIT we will replace the underlying tag
|
|
206
|
+
// Skip existing tag+len
|
|
207
|
+
r = ASN1_get_object(&cpy_start, &hdr_len, &hdr_tag, &hdr_class, cpy_len);
|
|
208
|
+
if (r & 0x80) {
|
|
209
|
+
goto err;
|
|
210
|
+
}
|
|
211
|
+
// Update copy length
|
|
212
|
+
cpy_len -= cpy_start - orig_der;
|
|
213
|
+
// For IMPLICIT tagging the length should match the original length
|
|
214
|
+
// and constructed flag should be consistent.
|
|
215
|
+
hdr_constructed = r & V_ASN1_CONSTRUCTED;
|
|
216
|
+
// Work out new length with IMPLICIT tag: ignore constructed because
|
|
217
|
+
// it will mess up if indefinite length
|
|
218
|
+
len = ASN1_object_size(0, hdr_len, asn1_tags.imp_tag);
|
|
219
|
+
} else {
|
|
220
|
+
len = cpy_len;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Work out length in any EXPLICIT, starting from end
|
|
224
|
+
|
|
225
|
+
for (i = 0, etmp = asn1_tags.exp_list + asn1_tags.exp_count - 1;
|
|
226
|
+
i < asn1_tags.exp_count; i++, etmp--) {
|
|
227
|
+
// Content length: number of content octets + any padding
|
|
228
|
+
len += etmp->exp_pad;
|
|
229
|
+
etmp->exp_len = len;
|
|
230
|
+
// Total object length: length including new header
|
|
231
|
+
len = ASN1_object_size(0, len, etmp->exp_tag);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Allocate buffer for new encoding
|
|
235
|
+
|
|
236
|
+
new_der = OPENSSL_malloc(len);
|
|
237
|
+
if (!new_der) {
|
|
238
|
+
goto err;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Generate tagged encoding
|
|
242
|
+
|
|
243
|
+
p = new_der;
|
|
244
|
+
|
|
245
|
+
// Output explicit tags first
|
|
246
|
+
|
|
247
|
+
for (i = 0, etmp = asn1_tags.exp_list; i < asn1_tags.exp_count; i++, etmp++) {
|
|
248
|
+
ASN1_put_object(&p, etmp->exp_constructed, etmp->exp_len, etmp->exp_tag,
|
|
249
|
+
etmp->exp_class);
|
|
250
|
+
if (etmp->exp_pad) {
|
|
251
|
+
*p++ = 0;
|
|
256
252
|
}
|
|
253
|
+
}
|
|
257
254
|
|
|
258
|
-
|
|
255
|
+
// If IMPLICIT, output tag
|
|
259
256
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
ASN1_put_object(&p, hdr_constructed, hdr_len,
|
|
266
|
-
asn1_tags.imp_tag, asn1_tags.imp_class);
|
|
257
|
+
if (asn1_tags.imp_tag != -1) {
|
|
258
|
+
if (asn1_tags.imp_class == V_ASN1_UNIVERSAL &&
|
|
259
|
+
(asn1_tags.imp_tag == V_ASN1_SEQUENCE ||
|
|
260
|
+
asn1_tags.imp_tag == V_ASN1_SET)) {
|
|
261
|
+
hdr_constructed = V_ASN1_CONSTRUCTED;
|
|
267
262
|
}
|
|
263
|
+
ASN1_put_object(&p, hdr_constructed, hdr_len, asn1_tags.imp_tag,
|
|
264
|
+
asn1_tags.imp_class);
|
|
265
|
+
}
|
|
268
266
|
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
// Copy across original encoding
|
|
268
|
+
OPENSSL_memcpy(p, cpy_start, cpy_len);
|
|
271
269
|
|
|
272
|
-
|
|
270
|
+
cp = new_der;
|
|
273
271
|
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
// Obtain new ASN1_TYPE structure
|
|
273
|
+
ret = d2i_ASN1_TYPE(NULL, &cp, len);
|
|
276
274
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
275
|
+
err:
|
|
276
|
+
if (orig_der) {
|
|
277
|
+
OPENSSL_free(orig_der);
|
|
278
|
+
}
|
|
279
|
+
if (new_der) {
|
|
280
|
+
OPENSSL_free(new_der);
|
|
281
|
+
}
|
|
284
282
|
|
|
283
|
+
return ret;
|
|
285
284
|
}
|
|
286
285
|
|
|
287
|
-
static int asn1_cb(const char *elem, int len, void *bitstr)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const char *p, *vstart = NULL;
|
|
286
|
+
static int asn1_cb(const char *elem, int len, void *bitstr) {
|
|
287
|
+
tag_exp_arg *arg = bitstr;
|
|
288
|
+
int i;
|
|
289
|
+
int utype;
|
|
290
|
+
int vlen = 0;
|
|
291
|
+
const char *p, *vstart = NULL;
|
|
294
292
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (elem == NULL)
|
|
298
|
-
return -1;
|
|
293
|
+
int tmp_tag, tmp_class;
|
|
299
294
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
295
|
+
if (elem == NULL) {
|
|
296
|
+
return -1;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
for (i = 0, p = elem; i < len; p++, i++) {
|
|
300
|
+
// Look for the ':' in name value pairs
|
|
301
|
+
if (*p == ':') {
|
|
302
|
+
vstart = p + 1;
|
|
303
|
+
vlen = len - (vstart - elem);
|
|
304
|
+
len = p - elem;
|
|
305
|
+
break;
|
|
308
306
|
}
|
|
307
|
+
}
|
|
309
308
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (utype == -1) {
|
|
313
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_TAG);
|
|
314
|
-
ERR_add_error_data(2, "tag=", elem);
|
|
315
|
-
return -1;
|
|
316
|
-
}
|
|
309
|
+
utype = asn1_str2tag(elem, len);
|
|
317
310
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
311
|
+
if (utype == -1) {
|
|
312
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_TAG);
|
|
313
|
+
ERR_add_error_data(2, "tag=", elem);
|
|
314
|
+
return -1;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// If this is not a modifier mark end of string and exit
|
|
318
|
+
if (!(utype & ASN1_GEN_FLAG)) {
|
|
319
|
+
arg->utype = utype;
|
|
320
|
+
arg->str = vstart;
|
|
321
|
+
// If no value and not end of string, error
|
|
322
|
+
if (!vstart && elem[len]) {
|
|
323
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
|
|
324
|
+
return -1;
|
|
328
325
|
}
|
|
326
|
+
return 0;
|
|
327
|
+
}
|
|
329
328
|
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
switch (utype) {
|
|
332
330
|
case ASN1_GEN_FLAG_IMP:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
331
|
+
// Check for illegal multiple IMPLICIT tagging
|
|
332
|
+
if (arg->imp_tag != -1) {
|
|
333
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_NESTED_TAGGING);
|
|
334
|
+
return -1;
|
|
335
|
+
}
|
|
336
|
+
if (!parse_tagging(vstart, vlen, &arg->imp_tag, &arg->imp_class)) {
|
|
337
|
+
return -1;
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
341
340
|
|
|
342
341
|
case ASN1_GEN_FLAG_EXP:
|
|
343
342
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
if (!parse_tagging(vstart, vlen, &tmp_tag, &tmp_class)) {
|
|
344
|
+
return -1;
|
|
345
|
+
}
|
|
346
|
+
if (!append_exp(arg, tmp_tag, tmp_class, 1, 0, 0)) {
|
|
347
|
+
return -1;
|
|
348
|
+
}
|
|
349
|
+
break;
|
|
349
350
|
|
|
350
351
|
case ASN1_GEN_FLAG_SEQWRAP:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
if (!append_exp(arg, V_ASN1_SEQUENCE, V_ASN1_UNIVERSAL, 1, 0, 1)) {
|
|
353
|
+
return -1;
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
354
356
|
|
|
355
357
|
case ASN1_GEN_FLAG_SETWRAP:
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
358
|
+
if (!append_exp(arg, V_ASN1_SET, V_ASN1_UNIVERSAL, 1, 0, 1)) {
|
|
359
|
+
return -1;
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
359
362
|
|
|
360
363
|
case ASN1_GEN_FLAG_BITWRAP:
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
+
if (!append_exp(arg, V_ASN1_BIT_STRING, V_ASN1_UNIVERSAL, 0, 1, 1)) {
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
break;
|
|
364
368
|
|
|
365
369
|
case ASN1_GEN_FLAG_OCTWRAP:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
370
|
+
if (!append_exp(arg, V_ASN1_OCTET_STRING, V_ASN1_UNIVERSAL, 0, 0, 1)) {
|
|
371
|
+
return -1;
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
369
374
|
|
|
370
375
|
case ASN1_GEN_FLAG_FORMAT:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
376
|
+
if (!vstart) {
|
|
377
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_FORMAT);
|
|
378
|
+
return -1;
|
|
379
|
+
}
|
|
380
|
+
if (!strncmp(vstart, "ASCII", 5)) {
|
|
381
|
+
arg->format = ASN1_GEN_FORMAT_ASCII;
|
|
382
|
+
} else if (!strncmp(vstart, "UTF8", 4)) {
|
|
383
|
+
arg->format = ASN1_GEN_FORMAT_UTF8;
|
|
384
|
+
} else if (!strncmp(vstart, "HEX", 3)) {
|
|
385
|
+
arg->format = ASN1_GEN_FORMAT_HEX;
|
|
386
|
+
} else if (!strncmp(vstart, "BITLIST", 7)) {
|
|
387
|
+
arg->format = ASN1_GEN_FORMAT_BITLIST;
|
|
388
|
+
} else {
|
|
389
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_FORMAT);
|
|
390
|
+
return -1;
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
388
394
|
|
|
389
|
-
|
|
395
|
+
return 1;
|
|
396
|
+
}
|
|
390
397
|
|
|
391
|
-
|
|
398
|
+
static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) {
|
|
399
|
+
char erch[2];
|
|
400
|
+
long tag_num;
|
|
401
|
+
char *eptr;
|
|
402
|
+
if (!vstart) {
|
|
403
|
+
return 0;
|
|
404
|
+
}
|
|
405
|
+
tag_num = strtoul(vstart, &eptr, 10);
|
|
406
|
+
// Check we haven't gone past max length: should be impossible
|
|
407
|
+
if (eptr && *eptr && (eptr > vstart + vlen)) {
|
|
408
|
+
return 0;
|
|
409
|
+
}
|
|
410
|
+
if (tag_num < 0) {
|
|
411
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_NUMBER);
|
|
412
|
+
return 0;
|
|
413
|
+
}
|
|
414
|
+
*ptag = tag_num;
|
|
415
|
+
// If we have non numeric characters, parse them
|
|
416
|
+
if (eptr) {
|
|
417
|
+
vlen -= eptr - vstart;
|
|
418
|
+
} else {
|
|
419
|
+
vlen = 0;
|
|
420
|
+
}
|
|
421
|
+
if (vlen) {
|
|
422
|
+
switch (*eptr) {
|
|
423
|
+
case 'U':
|
|
424
|
+
*pclass = V_ASN1_UNIVERSAL;
|
|
425
|
+
break;
|
|
392
426
|
|
|
393
|
-
|
|
427
|
+
case 'A':
|
|
428
|
+
*pclass = V_ASN1_APPLICATION;
|
|
429
|
+
break;
|
|
394
430
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
long tag_num;
|
|
399
|
-
char *eptr;
|
|
400
|
-
if (!vstart)
|
|
401
|
-
return 0;
|
|
402
|
-
tag_num = strtoul(vstart, &eptr, 10);
|
|
403
|
-
/* Check we haven't gone past max length: should be impossible */
|
|
404
|
-
if (eptr && *eptr && (eptr > vstart + vlen))
|
|
405
|
-
return 0;
|
|
406
|
-
if (tag_num < 0) {
|
|
407
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_NUMBER);
|
|
408
|
-
return 0;
|
|
409
|
-
}
|
|
410
|
-
*ptag = tag_num;
|
|
411
|
-
/* If we have non numeric characters, parse them */
|
|
412
|
-
if (eptr)
|
|
413
|
-
vlen -= eptr - vstart;
|
|
414
|
-
else
|
|
415
|
-
vlen = 0;
|
|
416
|
-
if (vlen) {
|
|
417
|
-
switch (*eptr) {
|
|
418
|
-
|
|
419
|
-
case 'U':
|
|
420
|
-
*pclass = V_ASN1_UNIVERSAL;
|
|
421
|
-
break;
|
|
422
|
-
|
|
423
|
-
case 'A':
|
|
424
|
-
*pclass = V_ASN1_APPLICATION;
|
|
425
|
-
break;
|
|
426
|
-
|
|
427
|
-
case 'P':
|
|
428
|
-
*pclass = V_ASN1_PRIVATE;
|
|
429
|
-
break;
|
|
430
|
-
|
|
431
|
-
case 'C':
|
|
432
|
-
*pclass = V_ASN1_CONTEXT_SPECIFIC;
|
|
433
|
-
break;
|
|
434
|
-
|
|
435
|
-
default:
|
|
436
|
-
erch[0] = *eptr;
|
|
437
|
-
erch[1] = 0;
|
|
438
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_MODIFIER);
|
|
439
|
-
ERR_add_error_data(2, "Char=", erch);
|
|
440
|
-
return 0;
|
|
441
|
-
break;
|
|
431
|
+
case 'P':
|
|
432
|
+
*pclass = V_ASN1_PRIVATE;
|
|
433
|
+
break;
|
|
442
434
|
|
|
443
|
-
|
|
444
|
-
} else
|
|
435
|
+
case 'C':
|
|
445
436
|
*pclass = V_ASN1_CONTEXT_SPECIFIC;
|
|
437
|
+
break;
|
|
446
438
|
|
|
447
|
-
|
|
439
|
+
default:
|
|
440
|
+
erch[0] = *eptr;
|
|
441
|
+
erch[1] = 0;
|
|
442
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_MODIFIER);
|
|
443
|
+
ERR_add_error_data(2, "Char=", erch);
|
|
444
|
+
return 0;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
} else {
|
|
448
|
+
*pclass = V_ASN1_CONTEXT_SPECIFIC;
|
|
449
|
+
}
|
|
448
450
|
|
|
451
|
+
return 1;
|
|
449
452
|
}
|
|
450
453
|
|
|
451
|
-
|
|
454
|
+
// Handle multiple types: SET and SEQUENCE
|
|
452
455
|
|
|
453
456
|
static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
|
|
454
|
-
int depth, int *perr)
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
457
|
+
int depth, int *perr) {
|
|
458
|
+
ASN1_TYPE *ret = NULL;
|
|
459
|
+
STACK_OF(ASN1_TYPE) *sk = NULL;
|
|
460
|
+
STACK_OF(CONF_VALUE) *sect = NULL;
|
|
461
|
+
unsigned char *der = NULL;
|
|
462
|
+
int derlen;
|
|
463
|
+
size_t i;
|
|
464
|
+
sk = sk_ASN1_TYPE_new_null();
|
|
465
|
+
if (!sk) {
|
|
466
|
+
goto bad;
|
|
467
|
+
}
|
|
468
|
+
if (section) {
|
|
469
|
+
if (!cnf) {
|
|
470
|
+
goto bad;
|
|
471
|
+
}
|
|
472
|
+
sect = X509V3_get_section(cnf, (char *)section);
|
|
473
|
+
if (!sect) {
|
|
474
|
+
goto bad;
|
|
475
|
+
}
|
|
476
|
+
for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
|
|
477
|
+
ASN1_TYPE *typ = generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf,
|
|
478
|
+
depth + 1, perr);
|
|
479
|
+
if (!typ) {
|
|
464
480
|
goto bad;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!sect)
|
|
470
|
-
goto bad;
|
|
471
|
-
for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
|
|
472
|
-
ASN1_TYPE *typ =
|
|
473
|
-
generate_v3(sk_CONF_VALUE_value(sect, i)->value, cnf,
|
|
474
|
-
depth + 1, perr);
|
|
475
|
-
if (!typ)
|
|
476
|
-
goto bad;
|
|
477
|
-
if (!sk_ASN1_TYPE_push(sk, typ))
|
|
478
|
-
goto bad;
|
|
479
|
-
}
|
|
481
|
+
}
|
|
482
|
+
if (!sk_ASN1_TYPE_push(sk, typ)) {
|
|
483
|
+
goto bad;
|
|
484
|
+
}
|
|
480
485
|
}
|
|
486
|
+
}
|
|
481
487
|
|
|
482
|
-
|
|
483
|
-
* Now we has a STACK of the components, convert to the correct form
|
|
484
|
-
*/
|
|
488
|
+
// Now we has a STACK of the components, convert to the correct form
|
|
485
489
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
+
if (utype == V_ASN1_SET) {
|
|
491
|
+
derlen = i2d_ASN1_SET_ANY(sk, &der);
|
|
492
|
+
} else {
|
|
493
|
+
derlen = i2d_ASN1_SEQUENCE_ANY(sk, &der);
|
|
494
|
+
}
|
|
490
495
|
|
|
491
|
-
|
|
492
|
-
|
|
496
|
+
if (derlen < 0) {
|
|
497
|
+
goto bad;
|
|
498
|
+
}
|
|
493
499
|
|
|
494
|
-
|
|
495
|
-
|
|
500
|
+
if (!(ret = ASN1_TYPE_new())) {
|
|
501
|
+
goto bad;
|
|
502
|
+
}
|
|
496
503
|
|
|
497
|
-
|
|
498
|
-
|
|
504
|
+
if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype))) {
|
|
505
|
+
goto bad;
|
|
506
|
+
}
|
|
499
507
|
|
|
500
|
-
|
|
508
|
+
ret->type = utype;
|
|
501
509
|
|
|
502
|
-
|
|
503
|
-
|
|
510
|
+
ret->value.asn1_string->data = der;
|
|
511
|
+
ret->value.asn1_string->length = derlen;
|
|
504
512
|
|
|
505
|
-
|
|
513
|
+
der = NULL;
|
|
506
514
|
|
|
507
|
-
|
|
515
|
+
bad:
|
|
508
516
|
|
|
509
|
-
|
|
510
|
-
|
|
517
|
+
if (der) {
|
|
518
|
+
OPENSSL_free(der);
|
|
519
|
+
}
|
|
511
520
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
521
|
+
if (sk) {
|
|
522
|
+
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
|
|
523
|
+
}
|
|
524
|
+
if (sect) {
|
|
525
|
+
X509V3_section_free(cnf, sect);
|
|
526
|
+
}
|
|
516
527
|
|
|
517
|
-
|
|
528
|
+
return ret;
|
|
518
529
|
}
|
|
519
530
|
|
|
520
531
|
static int append_exp(tag_exp_arg *arg, int exp_tag, int exp_class,
|
|
521
|
-
int exp_constructed, int exp_pad, int imp_ok)
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
exp_tmp->exp_pad = exp_pad;
|
|
552
|
-
|
|
553
|
-
return 1;
|
|
532
|
+
int exp_constructed, int exp_pad, int imp_ok) {
|
|
533
|
+
tag_exp_type *exp_tmp;
|
|
534
|
+
// Can only have IMPLICIT if permitted
|
|
535
|
+
if ((arg->imp_tag != -1) && !imp_ok) {
|
|
536
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_IMPLICIT_TAG);
|
|
537
|
+
return 0;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (arg->exp_count == ASN1_FLAG_EXP_MAX) {
|
|
541
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DEPTH_EXCEEDED);
|
|
542
|
+
return 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
exp_tmp = &arg->exp_list[arg->exp_count++];
|
|
546
|
+
|
|
547
|
+
// If IMPLICIT set tag to implicit value then reset implicit tag since it
|
|
548
|
+
// has been used.
|
|
549
|
+
if (arg->imp_tag != -1) {
|
|
550
|
+
exp_tmp->exp_tag = arg->imp_tag;
|
|
551
|
+
exp_tmp->exp_class = arg->imp_class;
|
|
552
|
+
arg->imp_tag = -1;
|
|
553
|
+
arg->imp_class = -1;
|
|
554
|
+
} else {
|
|
555
|
+
exp_tmp->exp_tag = exp_tag;
|
|
556
|
+
exp_tmp->exp_class = exp_class;
|
|
557
|
+
}
|
|
558
|
+
exp_tmp->exp_constructed = exp_constructed;
|
|
559
|
+
exp_tmp->exp_pad = exp_pad;
|
|
560
|
+
|
|
561
|
+
return 1;
|
|
554
562
|
}
|
|
555
563
|
|
|
556
|
-
static int asn1_str2tag(const char *tagstr, int len)
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
564
|
+
static int asn1_str2tag(const char *tagstr, int len) {
|
|
565
|
+
unsigned int i;
|
|
566
|
+
static const struct tag_name_st *tntmp,
|
|
567
|
+
tnst[] = {
|
|
568
|
+
ASN1_GEN_STR("BOOL", V_ASN1_BOOLEAN),
|
|
569
|
+
ASN1_GEN_STR("BOOLEAN", V_ASN1_BOOLEAN),
|
|
570
|
+
ASN1_GEN_STR("NULL", V_ASN1_NULL),
|
|
571
|
+
ASN1_GEN_STR("INT", V_ASN1_INTEGER),
|
|
572
|
+
ASN1_GEN_STR("INTEGER", V_ASN1_INTEGER),
|
|
573
|
+
ASN1_GEN_STR("ENUM", V_ASN1_ENUMERATED),
|
|
574
|
+
ASN1_GEN_STR("ENUMERATED", V_ASN1_ENUMERATED),
|
|
575
|
+
ASN1_GEN_STR("OID", V_ASN1_OBJECT),
|
|
576
|
+
ASN1_GEN_STR("OBJECT", V_ASN1_OBJECT),
|
|
577
|
+
ASN1_GEN_STR("UTCTIME", V_ASN1_UTCTIME),
|
|
578
|
+
ASN1_GEN_STR("UTC", V_ASN1_UTCTIME),
|
|
579
|
+
ASN1_GEN_STR("GENERALIZEDTIME", V_ASN1_GENERALIZEDTIME),
|
|
580
|
+
ASN1_GEN_STR("GENTIME", V_ASN1_GENERALIZEDTIME),
|
|
581
|
+
ASN1_GEN_STR("OCT", V_ASN1_OCTET_STRING),
|
|
582
|
+
ASN1_GEN_STR("OCTETSTRING", V_ASN1_OCTET_STRING),
|
|
583
|
+
ASN1_GEN_STR("BITSTR", V_ASN1_BIT_STRING),
|
|
584
|
+
ASN1_GEN_STR("BITSTRING", V_ASN1_BIT_STRING),
|
|
585
|
+
ASN1_GEN_STR("UNIVERSALSTRING", V_ASN1_UNIVERSALSTRING),
|
|
586
|
+
ASN1_GEN_STR("UNIV", V_ASN1_UNIVERSALSTRING),
|
|
587
|
+
ASN1_GEN_STR("IA5", V_ASN1_IA5STRING),
|
|
588
|
+
ASN1_GEN_STR("IA5STRING", V_ASN1_IA5STRING),
|
|
589
|
+
ASN1_GEN_STR("UTF8", V_ASN1_UTF8STRING),
|
|
590
|
+
ASN1_GEN_STR("UTF8String", V_ASN1_UTF8STRING),
|
|
591
|
+
ASN1_GEN_STR("BMP", V_ASN1_BMPSTRING),
|
|
592
|
+
ASN1_GEN_STR("BMPSTRING", V_ASN1_BMPSTRING),
|
|
593
|
+
ASN1_GEN_STR("VISIBLESTRING", V_ASN1_VISIBLESTRING),
|
|
594
|
+
ASN1_GEN_STR("VISIBLE", V_ASN1_VISIBLESTRING),
|
|
595
|
+
ASN1_GEN_STR("PRINTABLESTRING", V_ASN1_PRINTABLESTRING),
|
|
596
|
+
ASN1_GEN_STR("PRINTABLE", V_ASN1_PRINTABLESTRING),
|
|
597
|
+
ASN1_GEN_STR("T61", V_ASN1_T61STRING),
|
|
598
|
+
ASN1_GEN_STR("T61STRING", V_ASN1_T61STRING),
|
|
599
|
+
ASN1_GEN_STR("TELETEXSTRING", V_ASN1_T61STRING),
|
|
600
|
+
ASN1_GEN_STR("GeneralString", V_ASN1_GENERALSTRING),
|
|
601
|
+
ASN1_GEN_STR("GENSTR", V_ASN1_GENERALSTRING),
|
|
602
|
+
ASN1_GEN_STR("NUMERIC", V_ASN1_NUMERICSTRING),
|
|
603
|
+
ASN1_GEN_STR("NUMERICSTRING", V_ASN1_NUMERICSTRING),
|
|
604
|
+
|
|
605
|
+
// Special cases
|
|
606
|
+
ASN1_GEN_STR("SEQUENCE", V_ASN1_SEQUENCE),
|
|
607
|
+
ASN1_GEN_STR("SEQ", V_ASN1_SEQUENCE),
|
|
608
|
+
ASN1_GEN_STR("SET", V_ASN1_SET),
|
|
609
|
+
// type modifiers
|
|
610
|
+
// Explicit tag
|
|
611
|
+
ASN1_GEN_STR("EXP", ASN1_GEN_FLAG_EXP),
|
|
612
|
+
ASN1_GEN_STR("EXPLICIT", ASN1_GEN_FLAG_EXP),
|
|
613
|
+
// Implicit tag
|
|
614
|
+
ASN1_GEN_STR("IMP", ASN1_GEN_FLAG_IMP),
|
|
615
|
+
ASN1_GEN_STR("IMPLICIT", ASN1_GEN_FLAG_IMP),
|
|
616
|
+
// OCTET STRING wrapper
|
|
617
|
+
ASN1_GEN_STR("OCTWRAP", ASN1_GEN_FLAG_OCTWRAP),
|
|
618
|
+
// SEQUENCE wrapper
|
|
619
|
+
ASN1_GEN_STR("SEQWRAP", ASN1_GEN_FLAG_SEQWRAP),
|
|
620
|
+
// SET wrapper
|
|
621
|
+
ASN1_GEN_STR("SETWRAP", ASN1_GEN_FLAG_SETWRAP),
|
|
622
|
+
// BIT STRING wrapper
|
|
623
|
+
ASN1_GEN_STR("BITWRAP", ASN1_GEN_FLAG_BITWRAP),
|
|
624
|
+
ASN1_GEN_STR("FORM", ASN1_GEN_FLAG_FORMAT),
|
|
625
|
+
ASN1_GEN_STR("FORMAT", ASN1_GEN_FLAG_FORMAT),
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
if (len == -1) {
|
|
629
|
+
len = strlen(tagstr);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
tntmp = tnst;
|
|
633
|
+
for (i = 0; i < sizeof(tnst) / sizeof(struct tag_name_st); i++, tntmp++) {
|
|
634
|
+
if ((len == tntmp->len) && !strncmp(tntmp->strnam, tagstr, len)) {
|
|
635
|
+
return tntmp->tag;
|
|
627
636
|
}
|
|
637
|
+
}
|
|
628
638
|
|
|
629
|
-
|
|
639
|
+
return -1;
|
|
630
640
|
}
|
|
631
641
|
|
|
632
|
-
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
|
|
633
|
-
|
|
634
|
-
ASN1_TYPE *atmp = NULL;
|
|
635
|
-
|
|
636
|
-
CONF_VALUE vtmp;
|
|
642
|
+
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) {
|
|
643
|
+
ASN1_TYPE *atmp = NULL;
|
|
637
644
|
|
|
638
|
-
|
|
639
|
-
long rdlen;
|
|
645
|
+
CONF_VALUE vtmp;
|
|
640
646
|
|
|
641
|
-
|
|
647
|
+
unsigned char *rdata;
|
|
648
|
+
long rdlen;
|
|
642
649
|
|
|
643
|
-
|
|
644
|
-
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
645
|
-
return NULL;
|
|
646
|
-
}
|
|
650
|
+
int no_unused = 1;
|
|
647
651
|
|
|
648
|
-
|
|
649
|
-
|
|
652
|
+
if (!(atmp = ASN1_TYPE_new())) {
|
|
653
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
654
|
+
return NULL;
|
|
655
|
+
}
|
|
650
656
|
|
|
651
|
-
|
|
657
|
+
if (!str) {
|
|
658
|
+
str = "";
|
|
659
|
+
}
|
|
652
660
|
|
|
661
|
+
switch (utype) {
|
|
653
662
|
case V_ASN1_NULL:
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
663
|
+
if (str && *str) {
|
|
664
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_NULL_VALUE);
|
|
665
|
+
goto bad_form;
|
|
666
|
+
}
|
|
667
|
+
break;
|
|
659
668
|
|
|
660
669
|
case V_ASN1_BOOLEAN:
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
if (format != ASN1_GEN_FORMAT_ASCII) {
|
|
671
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ASCII_FORMAT);
|
|
672
|
+
goto bad_form;
|
|
673
|
+
}
|
|
674
|
+
vtmp.name = NULL;
|
|
675
|
+
vtmp.section = NULL;
|
|
676
|
+
vtmp.value = (char *)str;
|
|
677
|
+
if (!X509V3_get_value_bool(&vtmp, &atmp->value.boolean)) {
|
|
678
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_BOOLEAN);
|
|
679
|
+
goto bad_str;
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
673
682
|
|
|
674
683
|
case V_ASN1_INTEGER:
|
|
675
684
|
case V_ASN1_ENUMERATED:
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
+
if (format != ASN1_GEN_FORMAT_ASCII) {
|
|
686
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INTEGER_NOT_ASCII_FORMAT);
|
|
687
|
+
goto bad_form;
|
|
688
|
+
}
|
|
689
|
+
if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) {
|
|
690
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_INTEGER);
|
|
691
|
+
goto bad_str;
|
|
692
|
+
}
|
|
693
|
+
break;
|
|
685
694
|
|
|
686
695
|
case V_ASN1_OBJECT:
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
+
if (format != ASN1_GEN_FORMAT_ASCII) {
|
|
697
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_OBJECT_NOT_ASCII_FORMAT);
|
|
698
|
+
goto bad_form;
|
|
699
|
+
}
|
|
700
|
+
if (!(atmp->value.object = OBJ_txt2obj(str, 0))) {
|
|
701
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_OBJECT);
|
|
702
|
+
goto bad_str;
|
|
703
|
+
}
|
|
704
|
+
break;
|
|
696
705
|
|
|
697
706
|
case V_ASN1_UTCTIME:
|
|
698
707
|
case V_ASN1_GENERALIZEDTIME:
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
708
|
+
if (format != ASN1_GEN_FORMAT_ASCII) {
|
|
709
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TIME_NOT_ASCII_FORMAT);
|
|
710
|
+
goto bad_form;
|
|
711
|
+
}
|
|
712
|
+
if (!(atmp->value.asn1_string = ASN1_STRING_new())) {
|
|
713
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
714
|
+
goto bad_str;
|
|
715
|
+
}
|
|
716
|
+
if (!ASN1_STRING_set(atmp->value.asn1_string, str, -1)) {
|
|
717
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
718
|
+
goto bad_str;
|
|
719
|
+
}
|
|
720
|
+
atmp->value.asn1_string->type = utype;
|
|
721
|
+
if (!ASN1_TIME_check(atmp->value.asn1_string)) {
|
|
722
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_TIME_VALUE);
|
|
723
|
+
goto bad_str;
|
|
724
|
+
}
|
|
716
725
|
|
|
717
|
-
|
|
726
|
+
break;
|
|
718
727
|
|
|
719
728
|
case V_ASN1_BMPSTRING:
|
|
720
729
|
case V_ASN1_PRINTABLESTRING:
|
|
@@ -726,101 +735,98 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
|
|
|
726
735
|
case V_ASN1_GENERALSTRING:
|
|
727
736
|
case V_ASN1_NUMERICSTRING:
|
|
728
737
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
738
|
+
if (format == ASN1_GEN_FORMAT_ASCII) {
|
|
739
|
+
format = MBSTRING_ASC;
|
|
740
|
+
} else if (format == ASN1_GEN_FORMAT_UTF8) {
|
|
741
|
+
format = MBSTRING_UTF8;
|
|
742
|
+
} else {
|
|
743
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_FORMAT);
|
|
744
|
+
goto bad_form;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
if (ASN1_mbstring_copy(&atmp->value.asn1_string, (unsigned char *)str, -1,
|
|
748
|
+
format, ASN1_tag2bit(utype)) <= 0) {
|
|
749
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
750
|
+
goto bad_str;
|
|
751
|
+
}
|
|
743
752
|
|
|
744
|
-
|
|
753
|
+
break;
|
|
745
754
|
|
|
746
755
|
case V_ASN1_BIT_STRING:
|
|
747
756
|
|
|
748
757
|
case V_ASN1_OCTET_STRING:
|
|
749
758
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
759
|
+
if (!(atmp->value.asn1_string = ASN1_STRING_new())) {
|
|
760
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
761
|
+
goto bad_form;
|
|
762
|
+
}
|
|
754
763
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
goto bad_str;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
atmp->value.asn1_string->data = rdata;
|
|
763
|
-
atmp->value.asn1_string->length = rdlen;
|
|
764
|
-
atmp->value.asn1_string->type = utype;
|
|
765
|
-
|
|
766
|
-
} else if (format == ASN1_GEN_FORMAT_ASCII)
|
|
767
|
-
ASN1_STRING_set(atmp->value.asn1_string, str, -1);
|
|
768
|
-
else if ((format == ASN1_GEN_FORMAT_BITLIST)
|
|
769
|
-
&& (utype == V_ASN1_BIT_STRING)) {
|
|
770
|
-
if (!CONF_parse_list
|
|
771
|
-
(str, ',', 1, bitstr_cb, atmp->value.bit_string)) {
|
|
772
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_LIST_ERROR);
|
|
773
|
-
goto bad_str;
|
|
774
|
-
}
|
|
775
|
-
no_unused = 0;
|
|
776
|
-
|
|
777
|
-
} else {
|
|
778
|
-
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
|
|
779
|
-
goto bad_form;
|
|
764
|
+
if (format == ASN1_GEN_FORMAT_HEX) {
|
|
765
|
+
if (!(rdata = x509v3_hex_to_bytes((char *)str, &rdlen))) {
|
|
766
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_HEX);
|
|
767
|
+
goto bad_str;
|
|
780
768
|
}
|
|
781
769
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
770
|
+
atmp->value.asn1_string->data = rdata;
|
|
771
|
+
atmp->value.asn1_string->length = rdlen;
|
|
772
|
+
atmp->value.asn1_string->type = utype;
|
|
773
|
+
|
|
774
|
+
} else if (format == ASN1_GEN_FORMAT_ASCII) {
|
|
775
|
+
ASN1_STRING_set(atmp->value.asn1_string, str, -1);
|
|
776
|
+
} else if ((format == ASN1_GEN_FORMAT_BITLIST) &&
|
|
777
|
+
(utype == V_ASN1_BIT_STRING)) {
|
|
778
|
+
if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string)) {
|
|
779
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_LIST_ERROR);
|
|
780
|
+
goto bad_str;
|
|
786
781
|
}
|
|
782
|
+
no_unused = 0;
|
|
787
783
|
|
|
788
|
-
|
|
784
|
+
} else {
|
|
785
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_BITSTRING_FORMAT);
|
|
786
|
+
goto bad_form;
|
|
787
|
+
}
|
|
789
788
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}
|
|
789
|
+
if ((utype == V_ASN1_BIT_STRING) && no_unused) {
|
|
790
|
+
atmp->value.asn1_string->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
|
|
791
|
+
atmp->value.asn1_string->flags |= ASN1_STRING_FLAG_BITS_LEFT;
|
|
792
|
+
}
|
|
795
793
|
|
|
796
|
-
|
|
797
|
-
return atmp;
|
|
794
|
+
break;
|
|
798
795
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
796
|
+
default:
|
|
797
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNSUPPORTED_TYPE);
|
|
798
|
+
goto bad_str;
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
802
801
|
|
|
803
|
-
|
|
804
|
-
|
|
802
|
+
atmp->type = utype;
|
|
803
|
+
return atmp;
|
|
805
804
|
|
|
805
|
+
bad_str:
|
|
806
|
+
ERR_add_error_data(2, "string=", str);
|
|
807
|
+
bad_form:
|
|
808
|
+
|
|
809
|
+
ASN1_TYPE_free(atmp);
|
|
810
|
+
return NULL;
|
|
806
811
|
}
|
|
807
812
|
|
|
808
|
-
static int bitstr_cb(const char *elem, int len, void *bitstr)
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
813
|
+
static int bitstr_cb(const char *elem, int len, void *bitstr) {
|
|
814
|
+
long bitnum;
|
|
815
|
+
char *eptr;
|
|
816
|
+
if (!elem) {
|
|
817
|
+
return 0;
|
|
818
|
+
}
|
|
819
|
+
bitnum = strtoul(elem, &eptr, 10);
|
|
820
|
+
if (eptr && *eptr && (eptr != elem + len)) {
|
|
821
|
+
return 0;
|
|
822
|
+
}
|
|
823
|
+
if (bitnum < 0) {
|
|
824
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_NUMBER);
|
|
825
|
+
return 0;
|
|
826
|
+
}
|
|
827
|
+
if (!ASN1_BIT_STRING_set_bit(bitstr, bitnum, 1)) {
|
|
828
|
+
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
|
|
829
|
+
return 0;
|
|
830
|
+
}
|
|
831
|
+
return 1;
|
|
826
832
|
}
|