@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.
Files changed (300) hide show
  1. package/package.json +1 -1
  2. package/readme.md +1 -3
  3. package/src/http3eventloop.cc +83 -9
  4. package/src/http3eventloop.h +13 -3
  5. package/src/http3server.cc +22 -22
  6. package/src/http3server.h +7 -20
  7. package/src/http3wtstreamvisitor.cc +31 -10
  8. package/src/http3wtstreamvisitor.h +38 -11
  9. package/src/webtransport.js +91 -23
  10. package/test/echoserver.js +29 -5
  11. package/test/testsuite.js +242 -220
  12. package/third_party/boringssl/src/CMakeLists.txt +2 -0
  13. package/third_party/boringssl/src/crypto/CMakeLists.txt +1 -0
  14. package/third_party/boringssl/src/crypto/asn1/a_bitstr.c +174 -177
  15. package/third_party/boringssl/src/crypto/asn1/a_bool.c +46 -48
  16. package/third_party/boringssl/src/crypto/asn1/a_d2i_fp.c +21 -23
  17. package/third_party/boringssl/src/crypto/asn1/a_dup.c +21 -23
  18. package/third_party/boringssl/src/crypto/asn1/a_gentm.c +84 -187
  19. package/third_party/boringssl/src/crypto/asn1/a_i2d_fp.c +19 -21
  20. package/third_party/boringssl/src/crypto/asn1/a_int.c +305 -329
  21. package/third_party/boringssl/src/crypto/asn1/a_mbstr.c +190 -195
  22. package/third_party/boringssl/src/crypto/asn1/a_object.c +182 -189
  23. package/third_party/boringssl/src/crypto/asn1/a_octet.c +6 -9
  24. package/third_party/boringssl/src/crypto/asn1/a_print.c +15 -16
  25. package/third_party/boringssl/src/crypto/asn1/a_strex.c +386 -399
  26. package/third_party/boringssl/src/crypto/asn1/a_strnid.c +110 -131
  27. package/third_party/boringssl/src/crypto/asn1/a_time.c +118 -111
  28. package/third_party/boringssl/src/crypto/asn1/a_type.c +59 -60
  29. package/third_party/boringssl/src/crypto/asn1/a_utctm.c +114 -186
  30. package/third_party/boringssl/src/crypto/asn1/a_utf8.c +171 -159
  31. package/third_party/boringssl/src/crypto/asn1/asn1_lib.c +245 -260
  32. package/third_party/boringssl/src/crypto/asn1/asn1_par.c +41 -40
  33. package/third_party/boringssl/src/crypto/asn1/asn1_test.cc +31 -0
  34. package/third_party/boringssl/src/crypto/asn1/asn_pack.c +31 -33
  35. package/third_party/boringssl/src/crypto/asn1/f_int.c +36 -33
  36. package/third_party/boringssl/src/crypto/asn1/f_string.c +29 -26
  37. package/third_party/boringssl/src/crypto/asn1/internal.h +62 -61
  38. package/third_party/boringssl/src/crypto/asn1/tasn_dec.c +706 -702
  39. package/third_party/boringssl/src/crypto/asn1/tasn_enc.c +507 -524
  40. package/third_party/boringssl/src/crypto/asn1/tasn_fre.c +141 -133
  41. package/third_party/boringssl/src/crypto/asn1/tasn_new.c +207 -199
  42. package/third_party/boringssl/src/crypto/asn1/tasn_typ.c +19 -22
  43. package/third_party/boringssl/src/crypto/asn1/tasn_utl.c +24 -24
  44. package/third_party/boringssl/src/crypto/asn1/time_support.c +13 -13
  45. package/third_party/boringssl/src/crypto/bio/connect.c +9 -3
  46. package/third_party/boringssl/src/crypto/bytestring/bytestring_test.cc +125 -1
  47. package/third_party/boringssl/src/crypto/bytestring/cbb.c +4 -7
  48. package/third_party/boringssl/src/crypto/bytestring/cbs.c +167 -9
  49. package/third_party/boringssl/src/crypto/cipher_extra/e_aesctrhmac.c +0 -2
  50. package/third_party/boringssl/src/crypto/cipher_extra/e_aesgcmsiv.c +23 -54
  51. package/third_party/boringssl/src/crypto/cipher_extra/e_chacha20poly1305.c +0 -2
  52. package/third_party/boringssl/src/crypto/cipher_extra/e_tls.c +0 -2
  53. package/third_party/boringssl/src/crypto/curve25519/curve25519.c +6 -8
  54. package/third_party/boringssl/src/crypto/evp/evp_ctx.c +25 -22
  55. package/third_party/boringssl/src/crypto/evp/internal.h +15 -9
  56. package/third_party/boringssl/src/crypto/evp/p_dsa_asn1.c +2 -0
  57. package/third_party/boringssl/src/crypto/evp/p_ec_asn1.c +2 -0
  58. package/third_party/boringssl/src/crypto/evp/p_ed25519.c +3 -3
  59. package/third_party/boringssl/src/crypto/evp/p_ed25519_asn1.c +10 -7
  60. package/third_party/boringssl/src/crypto/evp/p_hkdf.c +241 -0
  61. package/third_party/boringssl/src/crypto/evp/p_rsa_asn1.c +2 -0
  62. package/third_party/boringssl/src/crypto/evp/p_x25519_asn1.c +1 -0
  63. package/third_party/boringssl/src/crypto/fipsmodule/aes/aes_nohw.c +9 -10
  64. package/third_party/boringssl/src/crypto/fipsmodule/aes/key_wrap.c +2 -6
  65. package/third_party/boringssl/src/crypto/fipsmodule/bn/exponentiation.c +5 -11
  66. package/third_party/boringssl/src/crypto/fipsmodule/bn/internal.h +1 -1
  67. package/third_party/boringssl/src/crypto/fipsmodule/bn/prime.c +2 -0
  68. package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aes.c +10 -26
  69. package/third_party/boringssl/src/crypto/fipsmodule/cipher/e_aesccm.c +2 -3
  70. package/third_party/boringssl/src/crypto/fipsmodule/digestsign/digestsign.c +1 -0
  71. package/third_party/boringssl/src/crypto/fipsmodule/ec/p256-nistz.c +44 -43
  72. package/third_party/boringssl/src/crypto/fipsmodule/modes/cbc.c +5 -9
  73. package/third_party/boringssl/src/crypto/fipsmodule/modes/gcm.c +14 -21
  74. package/third_party/boringssl/src/crypto/fipsmodule/rand/ctrdrbg.c +8 -8
  75. package/third_party/boringssl/src/crypto/fipsmodule/rand/internal.h +1 -4
  76. package/third_party/boringssl/src/crypto/hkdf/hkdf_test.cc +104 -0
  77. package/third_party/boringssl/src/crypto/internal.h +18 -4
  78. package/third_party/boringssl/src/crypto/lhash/internal.h +13 -1
  79. package/third_party/boringssl/src/crypto/obj/obj_dat.h +4 -1
  80. package/third_party/boringssl/src/crypto/obj/obj_mac.num +1 -0
  81. package/third_party/boringssl/src/crypto/obj/objects.txt +2 -0
  82. package/third_party/boringssl/src/crypto/pem/pem_all.c +77 -86
  83. package/third_party/boringssl/src/crypto/pem/pem_info.c +221 -233
  84. package/third_party/boringssl/src/crypto/pem/pem_lib.c +639 -608
  85. package/third_party/boringssl/src/crypto/pem/pem_oth.c +17 -16
  86. package/third_party/boringssl/src/crypto/pem/pem_pk8.c +133 -142
  87. package/third_party/boringssl/src/crypto/pem/pem_pkey.c +96 -92
  88. package/third_party/boringssl/src/crypto/poly1305/poly1305_vec.c +12 -28
  89. package/third_party/boringssl/src/crypto/siphash/siphash.c +8 -11
  90. package/third_party/boringssl/src/crypto/siphash/siphash_test.cc +5 -7
  91. package/third_party/boringssl/src/crypto/stack/stack.c +33 -16
  92. package/third_party/boringssl/src/crypto/thread_pthread.c +0 -2
  93. package/third_party/boringssl/src/crypto/thread_win.c +0 -2
  94. package/third_party/boringssl/src/crypto/trust_token/internal.h +14 -0
  95. package/third_party/boringssl/src/crypto/trust_token/pmbtoken.c +127 -30
  96. package/third_party/boringssl/src/crypto/trust_token/trust_token.c +40 -0
  97. package/third_party/boringssl/src/crypto/trust_token/trust_token_test.cc +165 -0
  98. package/third_party/boringssl/src/crypto/trust_token/voprf.c +55 -6
  99. package/third_party/boringssl/src/crypto/x509/a_digest.c +23 -24
  100. package/third_party/boringssl/src/crypto/x509/a_sign.c +52 -55
  101. package/third_party/boringssl/src/crypto/x509/a_verify.c +33 -34
  102. package/third_party/boringssl/src/crypto/x509/algorithm.c +17 -18
  103. package/third_party/boringssl/src/crypto/x509/asn1_gen.c +618 -612
  104. package/third_party/boringssl/src/crypto/x509/by_dir.c +320 -337
  105. package/third_party/boringssl/src/crypto/x509/by_file.c +186 -186
  106. package/third_party/boringssl/src/crypto/x509/i2d_pr.c +11 -14
  107. package/third_party/boringssl/src/crypto/x509/internal.h +22 -22
  108. package/third_party/boringssl/src/crypto/x509/name_print.c +155 -150
  109. package/third_party/boringssl/src/crypto/x509/rsa_pss.c +27 -29
  110. package/third_party/boringssl/src/crypto/x509/t_crl.c +67 -70
  111. package/third_party/boringssl/src/crypto/x509/t_req.c +3 -5
  112. package/third_party/boringssl/src/crypto/x509/t_x509.c +280 -251
  113. package/third_party/boringssl/src/crypto/x509/t_x509a.c +52 -47
  114. package/third_party/boringssl/src/crypto/x509/x509.c +3 -4
  115. package/third_party/boringssl/src/crypto/x509/x509_att.c +234 -223
  116. package/third_party/boringssl/src/crypto/x509/x509_cmp.c +286 -296
  117. package/third_party/boringssl/src/crypto/x509/x509_d2.c +37 -32
  118. package/third_party/boringssl/src/crypto/x509/x509_def.c +14 -30
  119. package/third_party/boringssl/src/crypto/x509/x509_ext.c +55 -84
  120. package/third_party/boringssl/src/crypto/x509/x509_lu.c +545 -581
  121. package/third_party/boringssl/src/crypto/x509/x509_obj.c +131 -121
  122. package/third_party/boringssl/src/crypto/x509/x509_req.c +120 -139
  123. package/third_party/boringssl/src/crypto/x509/x509_set.c +128 -142
  124. package/third_party/boringssl/src/crypto/x509/x509_trs.c +185 -193
  125. package/third_party/boringssl/src/crypto/x509/x509_txt.c +70 -72
  126. package/third_party/boringssl/src/crypto/x509/x509_v3.c +172 -161
  127. package/third_party/boringssl/src/crypto/x509/x509_vfy.c +2041 -2053
  128. package/third_party/boringssl/src/crypto/x509/x509_vpm.c +441 -461
  129. package/third_party/boringssl/src/crypto/x509/x509cset.c +152 -170
  130. package/third_party/boringssl/src/crypto/x509/x509name.c +274 -260
  131. package/third_party/boringssl/src/crypto/x509/x509rset.c +43 -20
  132. package/third_party/boringssl/src/crypto/x509/x509spki.c +62 -63
  133. package/third_party/boringssl/src/crypto/x509/x_algor.c +64 -62
  134. package/third_party/boringssl/src/crypto/x509/x_all.c +103 -133
  135. package/third_party/boringssl/src/crypto/x509/x_attrib.c +23 -24
  136. package/third_party/boringssl/src/crypto/x509/x_crl.c +310 -321
  137. package/third_party/boringssl/src/crypto/x509/x_exten.c +6 -5
  138. package/third_party/boringssl/src/crypto/x509/x_info.c +31 -28
  139. package/third_party/boringssl/src/crypto/x509/x_name.c +361 -365
  140. package/third_party/boringssl/src/crypto/x509/x_pkey.c +38 -32
  141. package/third_party/boringssl/src/crypto/x509/x_pubkey.c +114 -117
  142. package/third_party/boringssl/src/crypto/x509/x_req.c +27 -29
  143. package/third_party/boringssl/src/crypto/x509/x_sig.c +2 -2
  144. package/third_party/boringssl/src/crypto/x509/x_spki.c +8 -10
  145. package/third_party/boringssl/src/crypto/x509/x_val.c +2 -2
  146. package/third_party/boringssl/src/crypto/x509/x_x509.c +212 -226
  147. package/third_party/boringssl/src/crypto/x509/x_x509a.c +112 -109
  148. package/third_party/boringssl/src/crypto/x509v3/ext_dat.h +10 -13
  149. package/third_party/boringssl/src/crypto/x509v3/internal.h +72 -87
  150. package/third_party/boringssl/src/crypto/x509v3/pcy_cache.c +184 -176
  151. package/third_party/boringssl/src/crypto/x509v3/pcy_data.c +58 -56
  152. package/third_party/boringssl/src/crypto/x509v3/pcy_lib.c +71 -70
  153. package/third_party/boringssl/src/crypto/x509v3/pcy_map.c +56 -58
  154. package/third_party/boringssl/src/crypto/x509v3/pcy_node.c +89 -91
  155. package/third_party/boringssl/src/crypto/x509v3/pcy_tree.c +585 -590
  156. package/third_party/boringssl/src/crypto/x509v3/v3_akey.c +118 -112
  157. package/third_party/boringssl/src/crypto/x509v3/v3_akeya.c +3 -3
  158. package/third_party/boringssl/src/crypto/x509v3/v3_alt.c +447 -451
  159. package/third_party/boringssl/src/crypto/x509v3/v3_bcons.c +44 -38
  160. package/third_party/boringssl/src/crypto/x509v3/v3_bitst.c +39 -43
  161. package/third_party/boringssl/src/crypto/x509v3/v3_conf.c +321 -320
  162. package/third_party/boringssl/src/crypto/x509v3/v3_cpols.c +352 -327
  163. package/third_party/boringssl/src/crypto/x509v3/v3_crld.c +437 -383
  164. package/third_party/boringssl/src/crypto/x509v3/v3_enum.c +23 -16
  165. package/third_party/boringssl/src/crypto/x509v3/v3_extku.c +62 -53
  166. package/third_party/boringssl/src/crypto/x509v3/v3_genn.c +118 -115
  167. package/third_party/boringssl/src/crypto/x509v3/v3_ia5.c +30 -31
  168. package/third_party/boringssl/src/crypto/x509v3/v3_info.c +112 -98
  169. package/third_party/boringssl/src/crypto/x509v3/v3_int.c +40 -15
  170. package/third_party/boringssl/src/crypto/x509v3/v3_lib.c +248 -252
  171. package/third_party/boringssl/src/crypto/x509v3/v3_ncons.c +390 -386
  172. package/third_party/boringssl/src/crypto/x509v3/v3_ocsp.c +45 -32
  173. package/third_party/boringssl/src/crypto/x509v3/v3_pci.c +206 -209
  174. package/third_party/boringssl/src/crypto/x509v3/v3_pcia.c +6 -8
  175. package/third_party/boringssl/src/crypto/x509v3/v3_pcons.c +54 -50
  176. package/third_party/boringssl/src/crypto/x509v3/v3_pmaps.c +66 -65
  177. package/third_party/boringssl/src/crypto/x509v3/v3_prn.c +144 -133
  178. package/third_party/boringssl/src/crypto/x509v3/v3_purp.c +695 -709
  179. package/third_party/boringssl/src/crypto/x509v3/v3_skey.c +75 -69
  180. package/third_party/boringssl/src/crypto/x509v3/v3_utl.c +1102 -1082
  181. package/third_party/boringssl/src/include/openssl/base.h +3 -1
  182. package/third_party/boringssl/src/include/openssl/bn.h +3 -0
  183. package/third_party/boringssl/src/include/openssl/bytestring.h +20 -0
  184. package/third_party/boringssl/src/include/openssl/evp.h +6 -5
  185. package/third_party/boringssl/src/include/openssl/kdf.h +91 -0
  186. package/third_party/boringssl/src/include/openssl/nid.h +4 -0
  187. package/third_party/boringssl/src/include/openssl/ssl.h +6 -1
  188. package/third_party/boringssl/src/include/openssl/stack.h +47 -32
  189. package/third_party/boringssl/src/include/openssl/trust_token.h +18 -3
  190. package/third_party/boringssl/src/include/openssl/x509.h +18 -0
  191. package/third_party/boringssl/src/ssl/ssl_file.cc +61 -99
  192. package/third_party/boringssl/src/ssl/ssl_test.cc +101 -0
  193. package/third_party/boringssl/src/util/doc.config +2 -1
  194. package/third_party/boringssl/src/util/fipstools/acvp/acvptool/subprocess/subprocess.go +8 -0
  195. package/third_party/googleurl/AUTHORS +16 -2
  196. package/third_party/googleurl/base/BUILD +1 -0
  197. package/third_party/googleurl/base/compiler_specific.h +16 -17
  198. package/third_party/googleurl/base/containers/contiguous_iterator.h +13 -9
  199. package/third_party/googleurl/base/containers/span.h +23 -8
  200. package/third_party/googleurl/base/memory/raw_ptr.h +17 -25
  201. package/third_party/googleurl/base/memory/raw_ptr_exclusion.h +21 -0
  202. package/third_party/googleurl/base/strings/escape.cc +14 -2
  203. package/third_party/googleurl/base/strings/safe_sprintf.h +1 -1
  204. package/third_party/googleurl/base/strings/string_number_conversions.cc +5 -3
  205. package/third_party/googleurl/base/strings/string_number_conversions_internal.h +5 -5
  206. package/third_party/googleurl/base/strings/string_piece.h +3 -3
  207. package/third_party/googleurl/base/strings/string_util.cc +4 -27
  208. package/third_party/googleurl/base/strings/string_util.h +43 -8
  209. package/third_party/googleurl/base/strings/string_util_internal.h +11 -12
  210. package/third_party/googleurl/base/strings/string_util_unittest.cc +33 -0
  211. package/third_party/googleurl/base/strings/string_util_win.cc +0 -5
  212. package/third_party/googleurl/base/strings/string_util_win.h +9 -1
  213. package/third_party/googleurl/base/strings/utf_offset_string_conversions.cc +1 -1
  214. package/third_party/googleurl/base/strings/utf_string_conversion_utils.cc +5 -8
  215. package/third_party/googleurl/base/strings/utf_string_conversion_utils.h +13 -10
  216. package/third_party/googleurl/base/strings/utf_string_conversions.cc +32 -25
  217. package/third_party/googleurl/base/template_util.h +23 -35
  218. package/third_party/googleurl/build/build_config.h +14 -3
  219. package/third_party/googleurl/copy.bara.sky +1 -1
  220. package/third_party/googleurl/url/gurl.cc +8 -4
  221. package/third_party/googleurl/url/gurl.h +1 -0
  222. package/third_party/googleurl/url/gurl_unittest.cc +1 -0
  223. package/third_party/googleurl/url/origin.h +36 -26
  224. package/third_party/googleurl/url/scheme_host_port.h +4 -1
  225. package/third_party/googleurl/url/url_canon.h +2 -1
  226. package/third_party/googleurl/url/url_canon_internal.cc +9 -7
  227. package/third_party/googleurl/url/url_canon_internal.h +16 -16
  228. package/third_party/googleurl/url/url_canon_stdstring.h +2 -1
  229. package/third_party/googleurl/url/url_util.cc +9 -8
  230. package/third_party/quiche/build/source_list.bzl +7 -0
  231. package/third_party/quiche/build/source_list.gni +7 -0
  232. package/third_party/quiche/build/source_list.json +7 -0
  233. package/third_party/quiche/quiche/common/platform/api/quiche_mem_slice.h +7 -3
  234. package/third_party/quiche/quiche/http2/adapter/nghttp2_adapter_test.cc +86 -2
  235. package/third_party/quiche/quiche/http2/adapter/oghttp2_adapter_test.cc +104 -2
  236. package/third_party/quiche/quiche/http2/adapter/oghttp2_session.cc +23 -0
  237. package/third_party/quiche/quiche/http2/adapter/oghttp2_session.h +6 -1
  238. package/third_party/quiche/quiche/quic/core/congestion_control/send_algorithm_test.cc +0 -16
  239. package/third_party/quiche/quiche/quic/core/crypto/crypto_protocol.h +1 -1
  240. package/third_party/quiche/quiche/quic/core/http/end_to_end_test.cc +56 -2
  241. package/third_party/quiche/quiche/quic/core/http/http_constants.cc +1 -0
  242. package/third_party/quiche/quiche/quic/core/http/http_constants.h +1 -0
  243. package/third_party/quiche/quiche/quic/core/http/http_encoder.cc +28 -17
  244. package/third_party/quiche/quiche/quic/core/http/http_encoder.h +5 -0
  245. package/third_party/quiche/quiche/quic/core/http/http_encoder_test.cc +26 -30
  246. package/third_party/quiche/quiche/quic/core/http/http_frames.h +1 -0
  247. package/third_party/quiche/quiche/quic/core/http/quic_server_session_base.cc +4 -4
  248. package/third_party/quiche/quiche/quic/core/http/quic_server_session_base_test.cc +1 -1
  249. package/third_party/quiche/quiche/quic/core/http/quic_spdy_client_session.cc +5 -1
  250. package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.cc +6 -33
  251. package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream.h +0 -17
  252. package/third_party/quiche/quiche/quic/core/http/quic_spdy_stream_test.cc +5 -20
  253. package/third_party/quiche/quiche/quic/core/io/quic_event_loop.h +81 -0
  254. package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.cc +265 -0
  255. package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop.h +152 -0
  256. package/third_party/quiche/quiche/quic/core/io/quic_poll_event_loop_test.cc +341 -0
  257. package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.cc +3 -1
  258. package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store.h +7 -7
  259. package/third_party/quiche/quiche/quic/core/quic_buffered_packet_store_test.cc +4 -3
  260. package/third_party/quiche/quiche/quic/core/quic_connection.cc +69 -19
  261. package/third_party/quiche/quiche/quic/core/quic_connection.h +9 -3
  262. package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.cc +29 -10
  263. package/third_party/quiche/quiche/quic/core/quic_connection_id_manager.h +5 -3
  264. package/third_party/quiche/quiche/quic/core/quic_connection_id_manager_test.cc +85 -22
  265. package/third_party/quiche/quiche/quic/core/quic_connection_test.cc +186 -30
  266. package/third_party/quiche/quiche/quic/core/quic_crypto_stream.cc +2 -1
  267. package/third_party/quiche/quiche/quic/core/quic_default_clock.cc +31 -0
  268. package/third_party/quiche/quiche/quic/core/quic_default_clock.h +34 -0
  269. package/third_party/quiche/quiche/quic/core/quic_default_connection_helper.h +49 -0
  270. package/third_party/quiche/quiche/quic/core/quic_dispatcher.cc +53 -37
  271. package/third_party/quiche/quiche/quic/core/quic_dispatcher.h +19 -11
  272. package/third_party/quiche/quiche/quic/core/quic_dispatcher_test.cc +15 -2
  273. package/third_party/quiche/quiche/quic/core/quic_flags_list.h +10 -4
  274. package/third_party/quiche/quiche/quic/core/quic_idle_network_detector.cc +2 -2
  275. package/third_party/quiche/quiche/quic/core/quic_idle_network_detector_test.cc +4 -4
  276. package/third_party/quiche/quiche/quic/core/quic_packet_creator.cc +14 -3
  277. package/third_party/quiche/quiche/quic/core/quic_packet_creator_test.cc +145 -2
  278. package/third_party/quiche/quiche/quic/core/quic_packets.cc +3 -1
  279. package/third_party/quiche/quiche/quic/core/quic_packets.h +4 -0
  280. package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.cc +13 -11
  281. package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager.h +9 -0
  282. package/third_party/quiche/quiche/quic/core/quic_sent_packet_manager_test.cc +6 -0
  283. package/third_party/quiche/quiche/quic/core/quic_session.cc +3 -2
  284. package/third_party/quiche/quiche/quic/core/quic_session.h +8 -3
  285. package/third_party/quiche/quiche/quic/core/quic_types.cc +18 -0
  286. package/third_party/quiche/quiche/quic/core/quic_types.h +3 -0
  287. package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.cc +3 -0
  288. package/third_party/quiche/quiche/quic/core/tls_chlo_extractor.h +10 -0
  289. package/third_party/quiche/quiche/quic/test_tools/mock_quic_session_visitor.h +1 -1
  290. package/third_party/quiche/quiche/quic/test_tools/quic_test_utils.h +1 -1
  291. package/third_party/quiche/quiche/quic/test_tools/server_thread.cc +3 -2
  292. package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.cc +7 -1
  293. package/third_party/quiche/quiche/quic/test_tools/simple_session_notifier.h +3 -0
  294. package/third_party/quiche/quiche/quic/test_tools/simulator/quic_endpoint.h +4 -2
  295. package/certs/ca.cnf +0 -69
  296. package/certs/generate_certs.sh +0 -53
  297. package/certs/generate_certs_leaf.sh +0 -53
  298. package/certs/leaf.cnf +0 -24
  299. package/certs/readme.txt +0 -2
  300. 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
- /* If |out| is NULL, ignore the output but report the length. */
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
- /* |c| is a |uint32_t| because, depending on |ASN1_STRFLGS_UTF8_CONVERT|,
89
- * we may be escaping bytes or Unicode codepoints. */
90
- char buf[16]; /* Large enough for "\\W01234567". */
91
- unsigned char u8 = (unsigned char)c;
92
- if (c > 0xffff) {
93
- BIO_snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c);
94
- } else if (c > 0xff) {
95
- BIO_snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c);
96
- } else if ((flags & ASN1_STRFLGS_ESC_MSB) && c > 0x7f) {
97
- BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
98
- } else if ((flags & ASN1_STRFLGS_ESC_CTRL) && is_control_character(c)) {
99
- BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
100
- } else if (flags & ASN1_STRFLGS_ESC_2253) {
101
- /* See RFC 2253, sections 2.4 and 4. */
102
- if (c == '\\' || c == '"') {
103
- /* Quotes and backslashes are always escaped, quoted or not. */
104
- BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
105
- } else if (c == ',' || c == '+' || c == '<' || c == '>' || c == ';' ||
106
- (is_first && (c == ' ' || c == '#')) ||
107
- (is_last && (c == ' '))) {
108
- if (flags & ASN1_STRFLGS_ESC_QUOTE) {
109
- /* No need to escape, just tell the caller to quote. */
110
- if (do_quotes != NULL) {
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
- int len = strlen(buf);
127
- return maybe_write(out, buf, len) ? len : -1;
121
+ int len = strlen(buf);
122
+ return maybe_write(out, buf, len) ? len : -1;
128
123
  }
129
124
 
130
- /*
131
- * This function sends each character in a buffer to do_esc_char(). It
132
- * interprets the content formats and converts to or from UTF8 as
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, BIO *out)
138
- {
139
- /* Reject invalid UCS-4 and UCS-2 lengths without parsing. */
140
- switch (encoding) {
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
- if (buflen & 3) {
143
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UNIVERSALSTRING);
144
- return -1;
145
- }
146
- break;
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
- if (buflen & 1) {
149
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BMPSTRING);
150
- return -1;
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
- const unsigned char *p = buf;
156
- const unsigned char *q = buf + buflen;
157
- int outlen = 0;
158
- while (p != q) {
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
- default:
192
- assert(0);
193
- return -1;
194
- }
195
- const int is_last = p == q;
196
- if (utf8_convert) {
197
- unsigned char utfbuf[6];
198
- int utflen;
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
- return outlen;
223
- }
180
+ buflen -= consumed;
181
+ p += consumed;
182
+ break;
183
+ }
224
184
 
225
- /* This function hex dumps a buffer of characters */
226
-
227
- static int do_hex_dump(BIO *out, unsigned char *buf, int buflen)
228
- {
229
- static const char hexdig[] = "0123456789ABCDEF";
230
- unsigned char *p, *q;
231
- char hextmp[2];
232
- if (out) {
233
- p = buf;
234
- q = buf + buflen;
235
- while (p != q) {
236
- hextmp[0] = hexdig[*p >> 4];
237
- hextmp[1] = hexdig[*p & 0xf];
238
- if (!maybe_write(out, hextmp, 2))
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
- return buflen << 1;
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 do_dump(unsigned long flags, BIO *out, const ASN1_STRING *str)
253
- {
254
- if (!maybe_write(out, "#", 1)) {
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
- /* If we don't dump DER encoding just dump content octets */
259
- if (!(flags & ASN1_STRFLGS_DUMP_DER)) {
260
- int outlen = do_hex_dump(out, str->data, str->length);
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
- * Placing the ASN1_STRING in a temporary ASN1_TYPE allows the DER encoding
269
- * to readily obtained.
270
- */
271
- ASN1_TYPE t;
272
- t.type = str->type;
273
- /* Negative INTEGER and ENUMERATED values are the only case where
274
- * |ASN1_STRING| and |ASN1_TYPE| types do not match.
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
- return -1;
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
- /* string_type_to_encoding returns the |MBSTRING_*| constant for the encoding
302
- * used by the |ASN1_STRING| type |type|, or -1 if |tag| is not a string
303
- * type. */
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
- /* This function is sometimes passed ASN.1 universal types and sometimes
306
- * passed |ASN1_STRING| type values */
307
- switch (type) {
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
- return MBSTRING_UTF8;
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
- /* |MBSTRING_ASC| refers to Latin-1, not ASCII. */
318
- return MBSTRING_ASC;
300
+ // |MBSTRING_ASC| refers to Latin-1, not ASCII.
301
+ return MBSTRING_ASC;
319
302
  case V_ASN1_UNIVERSALSTRING:
320
- return MBSTRING_UNIV;
303
+ return MBSTRING_UNIV;
321
304
  case V_ASN1_BMPSTRING:
322
- return MBSTRING_BMP;
323
- }
324
- return -1;
305
+ return MBSTRING_BMP;
306
+ }
307
+ return -1;
325
308
  }
326
309
 
327
- /*
328
- * This is the main function, print out an ASN1_STRING taking note of various
329
- * escape and display options. Returns number of characters written or -1 if
330
- * an error occurred.
331
- */
332
-
333
- int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags)
334
- {
335
- int type = str->type;
336
- int outlen = 0;
337
- if (flags & ASN1_STRFLGS_SHOW_TYPE) {
338
- const char *tagname = ASN1_tag2str(type);
339
- outlen += strlen(tagname);
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
- int utf8_convert = 0;
369
- if (flags & ASN1_STRFLGS_UTF8_CONVERT) {
370
- /* If the string is UTF-8, skip decoding and just interpret it as 1 byte
371
- * per character to avoid converting twice.
372
- *
373
- * TODO(davidben): This is not quite a valid optimization if the input
374
- * was invalid UTF-8. */
375
- if (encoding == MBSTRING_UTF8) {
376
- encoding = MBSTRING_ASC;
377
- } else {
378
- utf8_convert = 1;
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
- /* Measure the length. */
383
- char quotes = 0;
384
- int len = do_buf(str->data, str->length, encoding, utf8_convert, flags,
385
- &quotes, NULL);
342
+ if (encoding == -1) {
343
+ int len = do_dump(flags, out, str);
386
344
  if (len < 0) {
387
- return -1;
345
+ return -1;
388
346
  }
389
347
  outlen += len;
390
- if (quotes) {
391
- outlen += 2;
392
- }
393
- if (!out) {
394
- return outlen;
395
- }
348
+ return outlen;
349
+ }
396
350
 
397
- /* Encode the value. */
398
- if ((quotes && !maybe_write(out, "\"", 1)) ||
399
- do_buf(str->data, str->length, encoding, utf8_convert, flags, NULL,
400
- out) < 0 ||
401
- (quotes && !maybe_write(out, "\"", 1))) {
402
- return -1;
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
+ &quotes, 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
- BIO *bio = NULL;
411
- if (fp != NULL) {
412
- /* If |fp| is NULL, this function returns the number of bytes without
413
- * writing. */
414
- bio = BIO_new_fp(fp, BIO_NOCLOSE);
415
- if (bio == NULL) {
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
- int ret = ASN1_STRING_print_ex(bio, str, flags);
420
- BIO_free(bio);
421
- return ret;
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
- if (!in)
427
- return -1;
428
- int mbflag = string_type_to_encoding(in->type);
429
- if (mbflag == -1) {
430
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_UNKNOWN_TAG);
431
- return -1;
432
- }
433
- ASN1_STRING stmp, *str = &stmp;
434
- stmp.data = NULL;
435
- stmp.length = 0;
436
- stmp.flags = 0;
437
- int ret = ASN1_mbstring_copy(&str, in->data, in->length, mbflag,
438
- B_ASN1_UTF8STRING);
439
- if (ret < 0)
440
- return ret;
441
- *out = stmp.data;
442
- return stmp.length;
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
- int i, n;
448
- char buf[80];
449
- const char *p;
450
-
451
- if (v == NULL)
452
- return (0);
453
- n = 0;
454
- p = (const char *)v->data;
455
- for (i = 0; i < v->length; i++) {
456
- if ((p[i] > '~') || ((p[i] < ' ') &&
457
- (p[i] != '\n') && (p[i] != '\r')))
458
- buf[n] = '.';
459
- else
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
- if (n > 0)
469
- if (BIO_write(bp, buf, n) <= 0)
470
- return (0);
471
- return (1);
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
- if (tm->type == V_ASN1_UTCTIME)
477
- return ASN1_UTCTIME_print(bp, tm);
478
- if (tm->type == V_ASN1_GENERALIZEDTIME)
479
- return ASN1_GENERALIZEDTIME_print(bp, tm);
480
- BIO_write(bp, "Bad time value", 14);
481
- return (0);
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
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
486
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
487
- };
488
-
489
- int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
490
- {
491
- char *v;
492
- int gmt = 0;
493
- int i;
494
- int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
495
- char *f = NULL;
496
- int f_len = 0;
497
-
498
- i = tm->length;
499
- v = (char *)tm->data;
500
-
501
- if (i < 12)
502
- goto err;
503
- if (v[i - 1] == 'Z')
504
- gmt = 1;
505
- for (i = 0; i < 12; i++)
506
- if ((v[i] > '9') || (v[i] < '0'))
507
- goto err;
508
- y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 + (v[2] - '0') * 10 + (v[3] -
509
- '0');
510
- M = (v[4] - '0') * 10 + (v[5] - '0');
511
- if ((M > 12) || (M < 1))
512
- goto err;
513
- d = (v[6] - '0') * 10 + (v[7] - '0');
514
- h = (v[8] - '0') * 10 + (v[9] - '0');
515
- m = (v[10] - '0') * 10 + (v[11] - '0');
516
- if (tm->length >= 14 &&
517
- (v[12] >= '0') && (v[12] <= '9') &&
518
- (v[13] >= '0') && (v[13] <= '9')) {
519
- s = (v[12] - '0') * 10 + (v[13] - '0');
520
- /* Check for fractions of seconds. */
521
- if (tm->length >= 15 && v[14] == '.') {
522
- int l = tm->length;
523
- f = &v[14]; /* The decimal point. */
524
- f_len = 1;
525
- while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
526
- ++f_len;
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
- if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
531
- mon[M - 1], d, h, m, s, f_len, f, y,
532
- (gmt) ? " GMT" : "") <= 0)
533
- return (0);
534
- else
535
- return (1);
536
- err:
537
- BIO_write(bp, "Bad time value", 14);
538
- return (0);
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* out, const char **v, int *len) {
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(&M, &v, &len) ||
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
  }