@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
|
@@ -71,242 +71,225 @@
|
|
|
71
71
|
(ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_QUOTE | ASN1_STRFLGS_ESC_CTRL | \
|
|
72
72
|
ASN1_STRFLGS_ESC_MSB)
|
|
73
73
|
|
|
74
|
-
static int maybe_write(BIO *out, const void *buf, int len)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return out == NULL || BIO_write(out, buf, len) == len;
|
|
74
|
+
static int maybe_write(BIO *out, const void *buf, int len) {
|
|
75
|
+
// If |out| is NULL, ignore the output but report the length.
|
|
76
|
+
return out == NULL || BIO_write(out, buf, len) == len;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
static int is_control_character(unsigned char c)
|
|
81
|
-
{
|
|
82
|
-
return c < 32 || c == 127;
|
|
83
|
-
}
|
|
79
|
+
static int is_control_character(unsigned char c) { return c < 32 || c == 127; }
|
|
84
80
|
|
|
85
81
|
static int do_esc_char(uint32_t c, unsigned long flags, char *do_quotes,
|
|
86
|
-
BIO *out, int is_first, int is_last)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*do_quotes = 1;
|
|
112
|
-
}
|
|
113
|
-
return maybe_write(out, &u8, 1) ? 1 : -1;
|
|
114
|
-
}
|
|
115
|
-
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
|
|
116
|
-
} else {
|
|
117
|
-
return maybe_write(out, &u8, 1) ? 1 : -1;
|
|
82
|
+
BIO *out, int is_first, int is_last) {
|
|
83
|
+
// |c| is a |uint32_t| because, depending on |ASN1_STRFLGS_UTF8_CONVERT|,
|
|
84
|
+
// we may be escaping bytes or Unicode codepoints.
|
|
85
|
+
char buf[16]; // Large enough for "\\W01234567".
|
|
86
|
+
unsigned char u8 = (unsigned char)c;
|
|
87
|
+
if (c > 0xffff) {
|
|
88
|
+
BIO_snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c);
|
|
89
|
+
} else if (c > 0xff) {
|
|
90
|
+
BIO_snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c);
|
|
91
|
+
} else if ((flags & ASN1_STRFLGS_ESC_MSB) && c > 0x7f) {
|
|
92
|
+
BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
|
|
93
|
+
} else if ((flags & ASN1_STRFLGS_ESC_CTRL) && is_control_character(c)) {
|
|
94
|
+
BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
|
|
95
|
+
} else if (flags & ASN1_STRFLGS_ESC_2253) {
|
|
96
|
+
// See RFC 2253, sections 2.4 and 4.
|
|
97
|
+
if (c == '\\' || c == '"') {
|
|
98
|
+
// Quotes and backslashes are always escaped, quoted or not.
|
|
99
|
+
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
|
|
100
|
+
} else if (c == ',' || c == '+' || c == '<' || c == '>' || c == ';' ||
|
|
101
|
+
(is_first && (c == ' ' || c == '#')) ||
|
|
102
|
+
(is_last && (c == ' '))) {
|
|
103
|
+
if (flags & ASN1_STRFLGS_ESC_QUOTE) {
|
|
104
|
+
// No need to escape, just tell the caller to quote.
|
|
105
|
+
if (do_quotes != NULL) {
|
|
106
|
+
*do_quotes = 1;
|
|
118
107
|
}
|
|
119
|
-
} else if ((flags & ESC_FLAGS) && c == '\\') {
|
|
120
|
-
/* If any escape flags are set, also escape backslashes. */
|
|
121
|
-
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
|
|
122
|
-
} else {
|
|
123
108
|
return maybe_write(out, &u8, 1) ? 1 : -1;
|
|
109
|
+
}
|
|
110
|
+
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
|
|
111
|
+
} else {
|
|
112
|
+
return maybe_write(out, &u8, 1) ? 1 : -1;
|
|
124
113
|
}
|
|
114
|
+
} else if ((flags & ESC_FLAGS) && c == '\\') {
|
|
115
|
+
// If any escape flags are set, also escape backslashes.
|
|
116
|
+
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
|
|
117
|
+
} else {
|
|
118
|
+
return maybe_write(out, &u8, 1) ? 1 : -1;
|
|
119
|
+
}
|
|
125
120
|
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
int len = strlen(buf);
|
|
122
|
+
return maybe_write(out, buf, len) ? len : -1;
|
|
128
123
|
}
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* appropriate.
|
|
134
|
-
*/
|
|
125
|
+
// This function sends each character in a buffer to do_esc_char(). It
|
|
126
|
+
// interprets the content formats and converts to or from UTF8 as
|
|
127
|
+
// appropriate.
|
|
135
128
|
|
|
136
129
|
static int do_buf(const unsigned char *buf, int buflen, int encoding,
|
|
137
|
-
int utf8_convert, unsigned long flags, char *quotes,
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
int utf8_convert, unsigned long flags, char *quotes,
|
|
131
|
+
BIO *out) {
|
|
132
|
+
// Reject invalid UCS-4 and UCS-2 lengths without parsing.
|
|
133
|
+
switch (encoding) {
|
|
141
134
|
case MBSTRING_UNIV:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
if (buflen & 3) {
|
|
136
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UNIVERSALSTRING);
|
|
137
|
+
return -1;
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
147
140
|
case MBSTRING_BMP:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
if (buflen & 1) {
|
|
142
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BMPSTRING);
|
|
143
|
+
return -1;
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const unsigned char *p = buf;
|
|
149
|
+
const unsigned char *q = buf + buflen;
|
|
150
|
+
int outlen = 0;
|
|
151
|
+
while (p != q) {
|
|
152
|
+
const int is_first = p == buf;
|
|
153
|
+
// TODO(davidben): Replace this with |cbs_get_ucs2_be|, etc., to check
|
|
154
|
+
// for invalid codepoints. Before doing that, enforce it in the parser,
|
|
155
|
+
// https://crbug.com/boringssl/427, so these error cases are not
|
|
156
|
+
// reachable from parsed objects.
|
|
157
|
+
uint32_t c;
|
|
158
|
+
switch (encoding) {
|
|
159
|
+
case MBSTRING_UNIV:
|
|
160
|
+
c = ((uint32_t)*p++) << 24;
|
|
161
|
+
c |= ((uint32_t)*p++) << 16;
|
|
162
|
+
c |= ((uint32_t)*p++) << 8;
|
|
163
|
+
c |= *p++;
|
|
152
164
|
break;
|
|
153
|
-
}
|
|
154
165
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const int is_first = p == buf;
|
|
160
|
-
/* TODO(davidben): Replace this with |cbs_get_ucs2_be|, etc., to check
|
|
161
|
-
* for invalid codepoints. Before doing that, enforce it in the parser,
|
|
162
|
-
* https://crbug.com/boringssl/427, so these error cases are not
|
|
163
|
-
* reachable from parsed objects. */
|
|
164
|
-
uint32_t c;
|
|
165
|
-
switch (encoding) {
|
|
166
|
-
case MBSTRING_UNIV:
|
|
167
|
-
c = ((uint32_t)*p++) << 24;
|
|
168
|
-
c |= ((uint32_t)*p++) << 16;
|
|
169
|
-
c |= ((uint32_t)*p++) << 8;
|
|
170
|
-
c |= *p++;
|
|
171
|
-
break;
|
|
172
|
-
|
|
173
|
-
case MBSTRING_BMP:
|
|
174
|
-
c = ((uint32_t)*p++) << 8;
|
|
175
|
-
c |= *p++;
|
|
176
|
-
break;
|
|
177
|
-
|
|
178
|
-
case MBSTRING_ASC:
|
|
179
|
-
c = *p++;
|
|
180
|
-
break;
|
|
181
|
-
|
|
182
|
-
case MBSTRING_UTF8: {
|
|
183
|
-
int consumed = UTF8_getc(p, buflen, &c);
|
|
184
|
-
if (consumed < 0)
|
|
185
|
-
return -1; /* Invalid UTF8String */
|
|
186
|
-
buflen -= consumed;
|
|
187
|
-
p += consumed;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
166
|
+
case MBSTRING_BMP:
|
|
167
|
+
c = ((uint32_t)*p++) << 8;
|
|
168
|
+
c |= *p++;
|
|
169
|
+
break;
|
|
190
170
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
utflen = UTF8_putc(utfbuf, sizeof utfbuf, c);
|
|
200
|
-
for (int i = 0; i < utflen; i++) {
|
|
201
|
-
/*
|
|
202
|
-
* We don't need to worry about setting orflags correctly
|
|
203
|
-
* because if utflen==1 its value will be correct anyway
|
|
204
|
-
* otherwise each character will be > 0x7f and so the
|
|
205
|
-
* character will never be escaped on first and last.
|
|
206
|
-
*/
|
|
207
|
-
int len = do_esc_char(utfbuf[i], flags, quotes, out, is_first,
|
|
208
|
-
is_last);
|
|
209
|
-
if (len < 0) {
|
|
210
|
-
return -1;
|
|
211
|
-
}
|
|
212
|
-
outlen += len;
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
int len = do_esc_char(c, flags, quotes, out, is_first, is_last);
|
|
216
|
-
if (len < 0) {
|
|
217
|
-
return -1;
|
|
218
|
-
}
|
|
219
|
-
outlen += len;
|
|
171
|
+
case MBSTRING_ASC:
|
|
172
|
+
c = *p++;
|
|
173
|
+
break;
|
|
174
|
+
|
|
175
|
+
case MBSTRING_UTF8: {
|
|
176
|
+
int consumed = UTF8_getc(p, buflen, &c);
|
|
177
|
+
if (consumed < 0) {
|
|
178
|
+
return -1; // Invalid UTF8String
|
|
220
179
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
180
|
+
buflen -= consumed;
|
|
181
|
+
p += consumed;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
224
184
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return -1;
|
|
240
|
-
p++;
|
|
185
|
+
default:
|
|
186
|
+
assert(0);
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
const int is_last = p == q;
|
|
190
|
+
if (utf8_convert) {
|
|
191
|
+
unsigned char utfbuf[6];
|
|
192
|
+
int utflen;
|
|
193
|
+
utflen = UTF8_putc(utfbuf, sizeof utfbuf, c);
|
|
194
|
+
for (int i = 0; i < utflen; i++) {
|
|
195
|
+
int len = do_esc_char(utfbuf[i], flags, quotes, out, is_first && i == 0,
|
|
196
|
+
is_last && i == utflen - 1);
|
|
197
|
+
if (len < 0) {
|
|
198
|
+
return -1;
|
|
241
199
|
}
|
|
200
|
+
outlen += len;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
int len = do_esc_char(c, flags, quotes, out, is_first, is_last);
|
|
204
|
+
if (len < 0) {
|
|
205
|
+
return -1;
|
|
206
|
+
}
|
|
207
|
+
outlen += len;
|
|
242
208
|
}
|
|
243
|
-
|
|
209
|
+
}
|
|
210
|
+
return outlen;
|
|
244
211
|
}
|
|
245
212
|
|
|
246
|
-
|
|
247
|
-
* "dump" a string. This is done when the type is unknown, or the flags
|
|
248
|
-
* request it. We can either dump the content octets or the entire DER
|
|
249
|
-
* encoding. This uses the RFC 2253 #01234 format.
|
|
250
|
-
*/
|
|
213
|
+
// This function hex dumps a buffer of characters
|
|
251
214
|
|
|
252
|
-
static int
|
|
253
|
-
|
|
254
|
-
|
|
215
|
+
static int do_hex_dump(BIO *out, unsigned char *buf, int buflen) {
|
|
216
|
+
static const char hexdig[] = "0123456789ABCDEF";
|
|
217
|
+
unsigned char *p, *q;
|
|
218
|
+
char hextmp[2];
|
|
219
|
+
if (out) {
|
|
220
|
+
p = buf;
|
|
221
|
+
q = buf + buflen;
|
|
222
|
+
while (p != q) {
|
|
223
|
+
hextmp[0] = hexdig[*p >> 4];
|
|
224
|
+
hextmp[1] = hexdig[*p & 0xf];
|
|
225
|
+
if (!maybe_write(out, hextmp, 2)) {
|
|
255
226
|
return -1;
|
|
227
|
+
}
|
|
228
|
+
p++;
|
|
256
229
|
}
|
|
230
|
+
}
|
|
231
|
+
return buflen << 1;
|
|
232
|
+
}
|
|
257
233
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (outlen < 0) {
|
|
262
|
-
return -1;
|
|
263
|
-
}
|
|
264
|
-
return outlen + 1;
|
|
265
|
-
}
|
|
234
|
+
// "dump" a string. This is done when the type is unknown, or the flags
|
|
235
|
+
// request it. We can either dump the content octets or the entire DER
|
|
236
|
+
// encoding. This uses the RFC 2253 #01234 format.
|
|
266
237
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
*
|
|
276
|
-
* TODO(davidben): There are also some type fields which, in |ASN1_TYPE|, do
|
|
277
|
-
* not correspond to |ASN1_STRING|. It is unclear whether those are allowed
|
|
278
|
-
* in |ASN1_STRING| at all, or what the space of allowed types is.
|
|
279
|
-
* |ASN1_item_ex_d2i| will never produce such a value so, for now, we say
|
|
280
|
-
* this is an invalid input. But this corner of the library in general
|
|
281
|
-
* should be more robust. */
|
|
282
|
-
if (t.type == V_ASN1_NEG_INTEGER) {
|
|
283
|
-
t.type = V_ASN1_INTEGER;
|
|
284
|
-
} else if (t.type == V_ASN1_NEG_ENUMERATED) {
|
|
285
|
-
t.type = V_ASN1_ENUMERATED;
|
|
286
|
-
}
|
|
287
|
-
t.value.asn1_string = (ASN1_STRING *)str;
|
|
288
|
-
unsigned char *der_buf = NULL;
|
|
289
|
-
int der_len = i2d_ASN1_TYPE(&t, &der_buf);
|
|
290
|
-
if (der_len < 0) {
|
|
291
|
-
return -1;
|
|
292
|
-
}
|
|
293
|
-
int outlen = do_hex_dump(out, der_buf, der_len);
|
|
294
|
-
OPENSSL_free(der_buf);
|
|
238
|
+
static int do_dump(unsigned long flags, BIO *out, const ASN1_STRING *str) {
|
|
239
|
+
if (!maybe_write(out, "#", 1)) {
|
|
240
|
+
return -1;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// If we don't dump DER encoding just dump content octets
|
|
244
|
+
if (!(flags & ASN1_STRFLGS_DUMP_DER)) {
|
|
245
|
+
int outlen = do_hex_dump(out, str->data, str->length);
|
|
295
246
|
if (outlen < 0) {
|
|
296
|
-
|
|
247
|
+
return -1;
|
|
297
248
|
}
|
|
298
249
|
return outlen + 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Placing the ASN1_STRING in a temporary ASN1_TYPE allows the DER encoding
|
|
253
|
+
// to readily obtained.
|
|
254
|
+
ASN1_TYPE t;
|
|
255
|
+
t.type = str->type;
|
|
256
|
+
// Negative INTEGER and ENUMERATED values are the only case where
|
|
257
|
+
// |ASN1_STRING| and |ASN1_TYPE| types do not match.
|
|
258
|
+
//
|
|
259
|
+
// TODO(davidben): There are also some type fields which, in |ASN1_TYPE|, do
|
|
260
|
+
// not correspond to |ASN1_STRING|. It is unclear whether those are allowed
|
|
261
|
+
// in |ASN1_STRING| at all, or what the space of allowed types is.
|
|
262
|
+
// |ASN1_item_ex_d2i| will never produce such a value so, for now, we say
|
|
263
|
+
// this is an invalid input. But this corner of the library in general
|
|
264
|
+
// should be more robust.
|
|
265
|
+
if (t.type == V_ASN1_NEG_INTEGER) {
|
|
266
|
+
t.type = V_ASN1_INTEGER;
|
|
267
|
+
} else if (t.type == V_ASN1_NEG_ENUMERATED) {
|
|
268
|
+
t.type = V_ASN1_ENUMERATED;
|
|
269
|
+
}
|
|
270
|
+
t.value.asn1_string = (ASN1_STRING *)str;
|
|
271
|
+
unsigned char *der_buf = NULL;
|
|
272
|
+
int der_len = i2d_ASN1_TYPE(&t, &der_buf);
|
|
273
|
+
if (der_len < 0) {
|
|
274
|
+
return -1;
|
|
275
|
+
}
|
|
276
|
+
int outlen = do_hex_dump(out, der_buf, der_len);
|
|
277
|
+
OPENSSL_free(der_buf);
|
|
278
|
+
if (outlen < 0) {
|
|
279
|
+
return -1;
|
|
280
|
+
}
|
|
281
|
+
return outlen + 1;
|
|
299
282
|
}
|
|
300
283
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
284
|
+
// string_type_to_encoding returns the |MBSTRING_*| constant for the encoding
|
|
285
|
+
// used by the |ASN1_STRING| type |type|, or -1 if |tag| is not a string
|
|
286
|
+
// type.
|
|
304
287
|
static int string_type_to_encoding(int type) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
288
|
+
// This function is sometimes passed ASN.1 universal types and sometimes
|
|
289
|
+
// passed |ASN1_STRING| type values
|
|
290
|
+
switch (type) {
|
|
308
291
|
case V_ASN1_UTF8STRING:
|
|
309
|
-
|
|
292
|
+
return MBSTRING_UTF8;
|
|
310
293
|
case V_ASN1_NUMERICSTRING:
|
|
311
294
|
case V_ASN1_PRINTABLESTRING:
|
|
312
295
|
case V_ASN1_T61STRING:
|
|
@@ -314,235 +297,241 @@ static int string_type_to_encoding(int type) {
|
|
|
314
297
|
case V_ASN1_UTCTIME:
|
|
315
298
|
case V_ASN1_GENERALIZEDTIME:
|
|
316
299
|
case V_ASN1_ISO64STRING:
|
|
317
|
-
|
|
318
|
-
|
|
300
|
+
// |MBSTRING_ASC| refers to Latin-1, not ASCII.
|
|
301
|
+
return MBSTRING_ASC;
|
|
319
302
|
case V_ASN1_UNIVERSALSTRING:
|
|
320
|
-
|
|
303
|
+
return MBSTRING_UNIV;
|
|
321
304
|
case V_ASN1_BMPSTRING:
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
305
|
+
return MBSTRING_BMP;
|
|
306
|
+
}
|
|
307
|
+
return -1;
|
|
325
308
|
}
|
|
326
309
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
int
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (!maybe_write(out, tagname, outlen) || !maybe_write(out, ":", 1))
|
|
341
|
-
return -1;
|
|
342
|
-
outlen++;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/* Decide what to do with |str|, either dump the contents or display it. */
|
|
346
|
-
int encoding;
|
|
347
|
-
if (flags & ASN1_STRFLGS_DUMP_ALL) {
|
|
348
|
-
/* Dump everything. */
|
|
349
|
-
encoding = -1;
|
|
350
|
-
} else if (flags & ASN1_STRFLGS_IGNORE_TYPE) {
|
|
351
|
-
/* Ignore the string type and interpret the contents as Latin-1. */
|
|
352
|
-
encoding = MBSTRING_ASC;
|
|
353
|
-
} else {
|
|
354
|
-
encoding = string_type_to_encoding(type);
|
|
355
|
-
if (encoding == -1 && (flags & ASN1_STRFLGS_DUMP_UNKNOWN) == 0) {
|
|
356
|
-
encoding = MBSTRING_ASC;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (encoding == -1) {
|
|
361
|
-
int len = do_dump(flags, out, str);
|
|
362
|
-
if (len < 0)
|
|
363
|
-
return -1;
|
|
364
|
-
outlen += len;
|
|
365
|
-
return outlen;
|
|
310
|
+
// This is the main function, print out an ASN1_STRING taking note of various
|
|
311
|
+
// escape and display options. Returns number of characters written or -1 if
|
|
312
|
+
// an error occurred.
|
|
313
|
+
|
|
314
|
+
int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str,
|
|
315
|
+
unsigned long flags) {
|
|
316
|
+
int type = str->type;
|
|
317
|
+
int outlen = 0;
|
|
318
|
+
if (flags & ASN1_STRFLGS_SHOW_TYPE) {
|
|
319
|
+
const char *tagname = ASN1_tag2str(type);
|
|
320
|
+
outlen += strlen(tagname);
|
|
321
|
+
if (!maybe_write(out, tagname, outlen) || !maybe_write(out, ":", 1)) {
|
|
322
|
+
return -1;
|
|
366
323
|
}
|
|
324
|
+
outlen++;
|
|
325
|
+
}
|
|
367
326
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
327
|
+
// Decide what to do with |str|, either dump the contents or display it.
|
|
328
|
+
int encoding;
|
|
329
|
+
if (flags & ASN1_STRFLGS_DUMP_ALL) {
|
|
330
|
+
// Dump everything.
|
|
331
|
+
encoding = -1;
|
|
332
|
+
} else if (flags & ASN1_STRFLGS_IGNORE_TYPE) {
|
|
333
|
+
// Ignore the string type and interpret the contents as Latin-1.
|
|
334
|
+
encoding = MBSTRING_ASC;
|
|
335
|
+
} else {
|
|
336
|
+
encoding = string_type_to_encoding(type);
|
|
337
|
+
if (encoding == -1 && (flags & ASN1_STRFLGS_DUMP_UNKNOWN) == 0) {
|
|
338
|
+
encoding = MBSTRING_ASC;
|
|
380
339
|
}
|
|
340
|
+
}
|
|
381
341
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
int len = do_buf(str->data, str->length, encoding, utf8_convert, flags,
|
|
385
|
-
"es, NULL);
|
|
342
|
+
if (encoding == -1) {
|
|
343
|
+
int len = do_dump(flags, out, str);
|
|
386
344
|
if (len < 0) {
|
|
387
|
-
|
|
345
|
+
return -1;
|
|
388
346
|
}
|
|
389
347
|
outlen += len;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
if (!out) {
|
|
394
|
-
return outlen;
|
|
395
|
-
}
|
|
348
|
+
return outlen;
|
|
349
|
+
}
|
|
396
350
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
351
|
+
int utf8_convert = 0;
|
|
352
|
+
if (flags & ASN1_STRFLGS_UTF8_CONVERT) {
|
|
353
|
+
// If the string is UTF-8, skip decoding and just interpret it as 1 byte
|
|
354
|
+
// per character to avoid converting twice.
|
|
355
|
+
//
|
|
356
|
+
// TODO(davidben): This is not quite a valid optimization if the input
|
|
357
|
+
// was invalid UTF-8.
|
|
358
|
+
if (encoding == MBSTRING_UTF8) {
|
|
359
|
+
encoding = MBSTRING_ASC;
|
|
360
|
+
} else {
|
|
361
|
+
utf8_convert = 1;
|
|
403
362
|
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Measure the length.
|
|
366
|
+
char quotes = 0;
|
|
367
|
+
int len = do_buf(str->data, str->length, encoding, utf8_convert, flags,
|
|
368
|
+
"es, NULL);
|
|
369
|
+
if (len < 0) {
|
|
370
|
+
return -1;
|
|
371
|
+
}
|
|
372
|
+
outlen += len;
|
|
373
|
+
if (quotes) {
|
|
374
|
+
outlen += 2;
|
|
375
|
+
}
|
|
376
|
+
if (!out) {
|
|
404
377
|
return outlen;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Encode the value.
|
|
381
|
+
if ((quotes && !maybe_write(out, "\"", 1)) ||
|
|
382
|
+
do_buf(str->data, str->length, encoding, utf8_convert, flags, NULL, out) <
|
|
383
|
+
0 ||
|
|
384
|
+
(quotes && !maybe_write(out, "\"", 1))) {
|
|
385
|
+
return -1;
|
|
386
|
+
}
|
|
387
|
+
return outlen;
|
|
405
388
|
}
|
|
406
389
|
|
|
407
390
|
int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str,
|
|
408
|
-
unsigned long flags)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
return -1;
|
|
417
|
-
}
|
|
391
|
+
unsigned long flags) {
|
|
392
|
+
BIO *bio = NULL;
|
|
393
|
+
if (fp != NULL) {
|
|
394
|
+
// If |fp| is NULL, this function returns the number of bytes without
|
|
395
|
+
// writing.
|
|
396
|
+
bio = BIO_new_fp(fp, BIO_NOCLOSE);
|
|
397
|
+
if (bio == NULL) {
|
|
398
|
+
return -1;
|
|
418
399
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
400
|
+
}
|
|
401
|
+
int ret = ASN1_STRING_print_ex(bio, str, flags);
|
|
402
|
+
BIO_free(bio);
|
|
403
|
+
return ret;
|
|
422
404
|
}
|
|
423
405
|
|
|
424
|
-
int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in)
|
|
425
|
-
{
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
406
|
+
int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in) {
|
|
407
|
+
if (!in) {
|
|
408
|
+
return -1;
|
|
409
|
+
}
|
|
410
|
+
int mbflag = string_type_to_encoding(in->type);
|
|
411
|
+
if (mbflag == -1) {
|
|
412
|
+
OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_TAG);
|
|
413
|
+
return -1;
|
|
414
|
+
}
|
|
415
|
+
ASN1_STRING stmp, *str = &stmp;
|
|
416
|
+
stmp.data = NULL;
|
|
417
|
+
stmp.length = 0;
|
|
418
|
+
stmp.flags = 0;
|
|
419
|
+
int ret =
|
|
420
|
+
ASN1_mbstring_copy(&str, in->data, in->length, mbflag, B_ASN1_UTF8STRING);
|
|
421
|
+
if (ret < 0) {
|
|
422
|
+
return ret;
|
|
423
|
+
}
|
|
424
|
+
*out = stmp.data;
|
|
425
|
+
return stmp.length;
|
|
443
426
|
}
|
|
444
427
|
|
|
445
|
-
int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
buf[n] = p[i];
|
|
461
|
-
n++;
|
|
462
|
-
if (n >= 80) {
|
|
463
|
-
if (BIO_write(bp, buf, n) <= 0)
|
|
464
|
-
return (0);
|
|
465
|
-
n = 0;
|
|
466
|
-
}
|
|
428
|
+
int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v) {
|
|
429
|
+
int i, n;
|
|
430
|
+
char buf[80];
|
|
431
|
+
const char *p;
|
|
432
|
+
|
|
433
|
+
if (v == NULL) {
|
|
434
|
+
return 0;
|
|
435
|
+
}
|
|
436
|
+
n = 0;
|
|
437
|
+
p = (const char *)v->data;
|
|
438
|
+
for (i = 0; i < v->length; i++) {
|
|
439
|
+
if ((p[i] > '~') || ((p[i] < ' ') && (p[i] != '\n') && (p[i] != '\r'))) {
|
|
440
|
+
buf[n] = '.';
|
|
441
|
+
} else {
|
|
442
|
+
buf[n] = p[i];
|
|
467
443
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
444
|
+
n++;
|
|
445
|
+
if (n >= 80) {
|
|
446
|
+
if (BIO_write(bp, buf, n) <= 0) {
|
|
447
|
+
return 0;
|
|
448
|
+
}
|
|
449
|
+
n = 0;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (n > 0) {
|
|
453
|
+
if (BIO_write(bp, buf, n) <= 0) {
|
|
454
|
+
return 0;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return 1;
|
|
472
458
|
}
|
|
473
459
|
|
|
474
|
-
int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
|
475
|
-
{
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
460
|
+
int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm) {
|
|
461
|
+
if (tm->type == V_ASN1_UTCTIME) {
|
|
462
|
+
return ASN1_UTCTIME_print(bp, tm);
|
|
463
|
+
}
|
|
464
|
+
if (tm->type == V_ASN1_GENERALIZEDTIME) {
|
|
465
|
+
return ASN1_GENERALIZEDTIME_print(bp, tm);
|
|
466
|
+
}
|
|
467
|
+
BIO_write(bp, "Bad time value", 14);
|
|
468
|
+
return 0;
|
|
482
469
|
}
|
|
483
470
|
|
|
484
|
-
static const char *const mon[12] = {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
int
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
471
|
+
static const char *const mon[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
472
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
|
473
|
+
|
|
474
|
+
int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) {
|
|
475
|
+
char *v;
|
|
476
|
+
int gmt = 0;
|
|
477
|
+
int i;
|
|
478
|
+
int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
|
|
479
|
+
char *f = NULL;
|
|
480
|
+
int f_len = 0;
|
|
481
|
+
|
|
482
|
+
i = tm->length;
|
|
483
|
+
v = (char *)tm->data;
|
|
484
|
+
|
|
485
|
+
if (i < 12) {
|
|
486
|
+
goto err;
|
|
487
|
+
}
|
|
488
|
+
if (v[i - 1] == 'Z') {
|
|
489
|
+
gmt = 1;
|
|
490
|
+
}
|
|
491
|
+
for (i = 0; i < 12; i++) {
|
|
492
|
+
if ((v[i] > '9') || (v[i] < '0')) {
|
|
493
|
+
goto err;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + (v[2] - '0') * 10 +
|
|
497
|
+
(v[3] - '0');
|
|
498
|
+
M = (v[4] - '0') * 10 + (v[5] - '0');
|
|
499
|
+
if ((M > 12) || (M < 1)) {
|
|
500
|
+
goto err;
|
|
501
|
+
}
|
|
502
|
+
d = (v[6] - '0') * 10 + (v[7] - '0');
|
|
503
|
+
h = (v[8] - '0') * 10 + (v[9] - '0');
|
|
504
|
+
m = (v[10] - '0') * 10 + (v[11] - '0');
|
|
505
|
+
if (tm->length >= 14 && (v[12] >= '0') && (v[12] <= '9') && (v[13] >= '0') &&
|
|
506
|
+
(v[13] <= '9')) {
|
|
507
|
+
s = (v[12] - '0') * 10 + (v[13] - '0');
|
|
508
|
+
// Check for fractions of seconds.
|
|
509
|
+
if (tm->length >= 15 && v[14] == '.') {
|
|
510
|
+
int l = tm->length;
|
|
511
|
+
f = &v[14]; // The decimal point.
|
|
512
|
+
f_len = 1;
|
|
513
|
+
while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9') {
|
|
514
|
+
++f_len;
|
|
515
|
+
}
|
|
528
516
|
}
|
|
517
|
+
}
|
|
529
518
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
519
|
+
if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s", mon[M - 1], d, h, m, s,
|
|
520
|
+
f_len, f, y, (gmt) ? " GMT" : "") <= 0) {
|
|
521
|
+
return 0;
|
|
522
|
+
} else {
|
|
523
|
+
return 1;
|
|
524
|
+
}
|
|
525
|
+
err:
|
|
526
|
+
BIO_write(bp, "Bad time value", 14);
|
|
527
|
+
return 0;
|
|
539
528
|
}
|
|
540
529
|
|
|
541
530
|
// consume_two_digits is a helper function for ASN1_UTCTIME_print. If |*v|,
|
|
542
531
|
// assumed to be |*len| bytes long, has two leading digits, updates |*out| with
|
|
543
532
|
// their value, updates |v| and |len|, and returns one. Otherwise, returns
|
|
544
533
|
// zero.
|
|
545
|
-
static int consume_two_digits(int*
|
|
534
|
+
static int consume_two_digits(int *out, const char **v, int *len) {
|
|
546
535
|
if (*len < 2 || !isdigit((unsigned char)((*v)[0])) ||
|
|
547
536
|
!isdigit((unsigned char)((*v)[1]))) {
|
|
548
537
|
return 0;
|
|
@@ -572,10 +561,8 @@ int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm) {
|
|
|
572
561
|
int Y = 0, M = 0, D = 0, h = 0, m = 0, s = 0;
|
|
573
562
|
|
|
574
563
|
// YYMMDDhhmm are required to be present.
|
|
575
|
-
if (!consume_two_digits(&Y, &v, &len) ||
|
|
576
|
-
!consume_two_digits(&
|
|
577
|
-
!consume_two_digits(&D, &v, &len) ||
|
|
578
|
-
!consume_two_digits(&h, &v, &len) ||
|
|
564
|
+
if (!consume_two_digits(&Y, &v, &len) || !consume_two_digits(&M, &v, &len) ||
|
|
565
|
+
!consume_two_digits(&D, &v, &len) || !consume_two_digits(&h, &v, &len) ||
|
|
579
566
|
!consume_two_digits(&m, &v, &len)) {
|
|
580
567
|
goto err;
|
|
581
568
|
}
|