@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
@@ -118,6 +118,8 @@ extern "C" {
118
118
  #define OPENSSL_32_BIT
119
119
  #elif defined(__myriad2__)
120
120
  #define OPENSSL_32_BIT
121
+ #elif defined(__riscv) && __riscv_xlen == 64
122
+ #define OPENSSL_64_BIT
121
123
  #else
122
124
  // Note BoringSSL only supports standard 32-bit and 64-bit two's-complement,
123
125
  // little-endian architectures. Functions will not produce the correct answer
@@ -195,7 +197,7 @@ extern "C" {
195
197
  // A consumer may use this symbol in the preprocessor to temporarily build
196
198
  // against multiple revisions of BoringSSL at the same time. It is not
197
199
  // recommended to do so for longer than is necessary.
198
- #define BORINGSSL_API_VERSION 17
200
+ #define BORINGSSL_API_VERSION 18
199
201
 
200
202
  #if defined(BORINGSSL_SHARED_LIBRARY)
201
203
 
@@ -681,6 +681,9 @@ OPENSSL_EXPORT void BN_GENCB_set(BN_GENCB *callback,
681
681
  // the callback, or 1 if |callback| is NULL.
682
682
  OPENSSL_EXPORT int BN_GENCB_call(BN_GENCB *callback, int event, int n);
683
683
 
684
+ // BN_GENCB_get_arg returns |callback->arg|.
685
+ OPENSSL_EXPORT void *BN_GENCB_get_arg(const BN_GENCB *callback);
686
+
684
687
  // BN_generate_prime_ex sets |ret| to a prime number of |bits| length. If safe
685
688
  // is non-zero then the prime will be such that (ret-1)/2 is also a prime.
686
689
  // (This is needed for Diffie-Hellman groups to ensure that the only subgroups
@@ -18,6 +18,7 @@
18
18
  #include <openssl/base.h>
19
19
 
20
20
  #include <openssl/span.h>
21
+ #include <time.h>
21
22
 
22
23
  #if defined(__cplusplus)
23
24
  extern "C" {
@@ -353,6 +354,25 @@ OPENSSL_EXPORT int CBS_is_unsigned_asn1_integer(const CBS *cbs);
353
354
  OPENSSL_EXPORT char *CBS_asn1_oid_to_text(const CBS *cbs);
354
355
 
355
356
 
357
+ // CBS_parse_generalized_time returns one if |cbs| is a valid DER-encoded, ASN.1
358
+ // GeneralizedTime body within the limitations imposed by RFC 5280, or zero
359
+ // otherwise. If |allow_timezone_offset| is non-zero, four-digit timezone
360
+ // offsets, which would not be allowed by DER, are permitted. On success, if
361
+ // |out_tm| is non-NULL, |*out_tm| will be zeroed, and then set to the
362
+ // corresponding time in UTC. This function does not compute |out_tm->tm_wday|
363
+ // or |out_tm->tm_yday|.
364
+ OPENSSL_EXPORT int CBS_parse_generalized_time(const CBS *cbs, struct tm *out_tm,
365
+ int allow_timezeone_offset);
366
+
367
+ // CBS_parse_utc_time returns one if |cbs| is a valid DER-encoded, ASN.1
368
+ // UTCTime body within the limitations imposed by RFC 5280, or zero otherwise.
369
+ // If |allow_timezone_offset| is non-zero, four-digit timezone offsets, which
370
+ // would not be allowed by DER, are permitted. On success, if |out_tm| is
371
+ // non-NULL, |*out_tm| will be zeroed, and then set to the corresponding time
372
+ // in UTC. This function does not compute |out_tm->tm_wday| or |out_tm->tm_yday|.
373
+ OPENSSL_EXPORT int CBS_parse_utc_time(const CBS *cbs, struct tm *out_tm,
374
+ int allow_timezeone_offset);
375
+
356
376
  // CRYPTO ByteBuilder.
357
377
  //
358
378
  // |CBB| objects allow one to build length-prefixed serialisations. A |CBB|
@@ -178,6 +178,7 @@ OPENSSL_EXPORT EC_KEY *EVP_PKEY_get1_EC_KEY(const EVP_PKEY *pkey);
178
178
  #define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
179
179
  #define EVP_PKEY_ED25519 NID_ED25519
180
180
  #define EVP_PKEY_X25519 NID_X25519
181
+ #define EVP_PKEY_HKDF NID_hkdf
181
182
 
182
183
  // EVP_PKEY_assign sets the underlying key of |pkey| to |key|, which must be of
183
184
  // the given type. It returns one if successful or zero if the |type| argument
@@ -665,11 +666,11 @@ OPENSSL_EXPORT int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
665
666
  // success and zero on error.
666
667
  OPENSSL_EXPORT int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
667
668
 
668
- // EVP_PKEY_derive derives a shared key between the two keys configured in
669
- // |ctx|. If |key| is non-NULL then, on entry, |out_key_len| must contain the
670
- // amount of space at |key|. If sufficient then the shared key will be written
671
- // to |key| and |*out_key_len| will be set to the length. If |key| is NULL then
672
- // |out_key_len| will be set to the maximum length.
669
+ // EVP_PKEY_derive derives a shared key from |ctx|. If |key| is non-NULL then,
670
+ // on entry, |out_key_len| must contain the amount of space at |key|. If
671
+ // sufficient then the shared key will be written to |key| and |*out_key_len|
672
+ // will be set to the length. If |key| is NULL then |out_key_len| will be set to
673
+ // the maximum length.
673
674
  //
674
675
  // WARNING: Setting |out| to NULL only gives the maximum size of the key. The
675
676
  // actual key may be smaller.
@@ -0,0 +1,91 @@
1
+ /* Copyright (c) 2022, Google Inc.
2
+ *
3
+ * Permission to use, copy, modify, and/or distribute this software for any
4
+ * purpose with or without fee is hereby granted, provided that the above
5
+ * copyright notice and this permission notice appear in all copies.
6
+ *
7
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
+
15
+ #ifndef OPENSSL_HEADER_KDF_H
16
+ #define OPENSSL_HEADER_KDF_H
17
+
18
+ #include <openssl/base.h>
19
+
20
+ #if defined(__cplusplus)
21
+ extern "C" {
22
+ #endif
23
+
24
+
25
+ // KDF support for EVP.
26
+
27
+
28
+ // HKDF-specific functions.
29
+ //
30
+ // The following functions are provided for OpenSSL compatibility. Prefer the
31
+ // HKDF functions in <openssl/hkdf.h>. In each, |ctx| must be created with
32
+ // |EVP_PKEY_CTX_new_id| with |EVP_PKEY_HKDF| and then initialized with
33
+ // |EVP_PKEY_derive_init|.
34
+
35
+ // EVP_PKEY_HKDEF_MODE_* define "modes" for use with |EVP_PKEY_CTX_hkdf_mode|.
36
+ // The mispelling of "HKDF" as "HKDEF" is intentional for OpenSSL compatibility.
37
+ #define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND 0
38
+ #define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY 1
39
+ #define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY 2
40
+
41
+ // EVP_PKEY_CTX_hkdf_mode configures which HKDF operation to run. It returns one
42
+ // on success and zero on error. |mode| must be one of |EVP_PKEY_HKDEF_MODE_*|.
43
+ // By default, the mode is |EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND|.
44
+ //
45
+ // If |mode| is |EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND| or
46
+ // |EVP_PKEY_HKDEF_MODE_EXPAND_ONLY|, the output is variable-length.
47
+ // |EVP_PKEY_derive| uses the size of the output buffer as the output length for
48
+ // HKDF-Expand.
49
+ //
50
+ // WARNING: Although this API calls it a "mode", HKDF-Extract and HKDF-Expand
51
+ // are distinct operations with distinct inputs and distinct kinds of keys.
52
+ // Callers should not pass input secrets for one operation into the other.
53
+ OPENSSL_EXPORT int EVP_PKEY_CTX_hkdf_mode(EVP_PKEY_CTX *ctx, int mode);
54
+
55
+ // EVP_PKEY_CTX_set_hkdf_md sets |md| as the digest to use with HKDF. It returns
56
+ // one on success and zero on error.
57
+ OPENSSL_EXPORT int EVP_PKEY_CTX_set_hkdf_md(EVP_PKEY_CTX *ctx,
58
+ const EVP_MD *md);
59
+
60
+ // EVP_PKEY_CTX_set1_hkdf_key configures HKDF to use |key_len| bytes from |key|
61
+ // as the "key", described below. It returns one on success and zero on error.
62
+ //
63
+ // Which input is the key depends on the "mode" (see |EVP_PKEY_CTX_hkdf_mode|).
64
+ // If |EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND| or
65
+ // |EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY|, this function specifies the input keying
66
+ // material (IKM) for HKDF-Extract. If |EVP_PKEY_HKDEF_MODE_EXPAND_ONLY|, it
67
+ // instead specifies the pseudorandom key (PRK) for HKDF-Expand.
68
+ OPENSSL_EXPORT int EVP_PKEY_CTX_set1_hkdf_key(EVP_PKEY_CTX *ctx,
69
+ const uint8_t *key,
70
+ size_t key_len);
71
+
72
+ // EVP_PKEY_CTX_set1_hkdf_salt configures HKDF to use |salt_len| bytes from
73
+ // |salt| as the salt parameter to HKDF-Extract. It returns one on success and
74
+ // zero on error. If performing HKDF-Expand only, this parameter is ignored.
75
+ OPENSSL_EXPORT int EVP_PKEY_CTX_set1_hkdf_salt(EVP_PKEY_CTX *ctx,
76
+ const uint8_t *salt,
77
+ size_t salt_len);
78
+
79
+ // EVP_PKEY_CTX_add1_hkdf_info appends |info_len| bytes from |info| to the info
80
+ // parameter used with HKDF-Expand. It returns one on success and zero on error.
81
+ // If performing HKDF-Extract only, this parameter is ignored.
82
+ OPENSSL_EXPORT int EVP_PKEY_CTX_add1_hkdf_info(EVP_PKEY_CTX *ctx,
83
+ const uint8_t *info,
84
+ size_t info_len);
85
+
86
+
87
+ #if defined(__cplusplus)
88
+ } // extern C
89
+ #endif
90
+
91
+ #endif // OPENSSL_HEADER_KDF_H
@@ -4251,6 +4251,10 @@ extern "C" {
4251
4251
  #define NID_sha512_256 962
4252
4252
  #define OBJ_sha512_256 2L, 16L, 840L, 1L, 101L, 3L, 4L, 2L, 6L
4253
4253
 
4254
+ #define SN_hkdf "HKDF"
4255
+ #define LN_hkdf "hkdf"
4256
+ #define NID_hkdf 963
4257
+
4254
4258
 
4255
4259
  #if defined(__cplusplus)
4256
4260
  } /* extern C */
@@ -2718,7 +2718,7 @@ OPENSSL_EXPORT int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x509);
2718
2718
 
2719
2719
  // SSL_load_client_CA_file opens |file| and reads PEM-encoded certificates from
2720
2720
  // it. It returns a newly-allocated stack of the certificate subjects or NULL
2721
- // on error.
2721
+ // on error. Duplicates in |file| are ignored.
2722
2722
  OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
2723
2723
 
2724
2724
  // SSL_dup_CA_list makes a deep copy of |list|. It returns the new list on
@@ -2731,6 +2731,11 @@ OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *list);
2731
2731
  OPENSSL_EXPORT int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *out,
2732
2732
  const char *file);
2733
2733
 
2734
+ // SSL_add_bio_cert_subjects_to_stack behaves like
2735
+ // |SSL_add_file_cert_subjects_to_stack| but reads from |bio|.
2736
+ OPENSSL_EXPORT int SSL_add_bio_cert_subjects_to_stack(STACK_OF(X509_NAME) *out,
2737
+ BIO *bio);
2738
+
2734
2739
 
2735
2740
  // Server name indication.
2736
2741
  //
@@ -101,10 +101,20 @@ typedef void *(*stack_copy_func)(void *ptr);
101
101
  // extra indirection - the function is given a pointer to a pointer to the
102
102
  // element. This differs from the usual qsort/bsearch comparison function.
103
103
  //
104
- // Note its actual type is int (*)(const T **, const T **). Low-level |sk_*|
104
+ // Note its actual type is |int (*)(const T **a, const T **b)|. Low-level |sk_*|
105
105
  // functions will be passed a type-specific wrapper to call it correctly.
106
+ //
107
+ // TODO(davidben): This type should be |const T *const *|. It is already fixed
108
+ // in OpenSSL 1.1.1, so hopefully we can fix this compatibly.
106
109
  typedef int (*stack_cmp_func)(const void **a, const void **b);
107
110
 
111
+ // The following function types call the above type-erased signatures with the
112
+ // true types.
113
+ typedef void (*stack_call_free_func)(stack_free_func, void *);
114
+ typedef void *(*stack_call_copy_func)(stack_copy_func, void *);
115
+ typedef int (*stack_call_cmp_func)(stack_cmp_func, const void *const *,
116
+ const void *const *);
117
+
108
118
  // stack_st contains an array of pointers. It is not designed to be used
109
119
  // directly, rather the wrapper macros should be used.
110
120
  typedef struct stack_st {
@@ -161,8 +171,7 @@ OPENSSL_EXPORT void sk_free(_STACK *sk);
161
171
  // |sk_pop_free_ex| as a workaround for existing code calling an older version
162
172
  // of |sk_pop_free|.
163
173
  OPENSSL_EXPORT void sk_pop_free_ex(_STACK *sk,
164
- void (*call_free_func)(stack_free_func,
165
- void *),
174
+ stack_call_free_func call_free_func,
166
175
  stack_free_func free_func);
167
176
 
168
177
  // sk_insert inserts |p| into the stack at index |where|, moving existing
@@ -192,8 +201,7 @@ OPENSSL_EXPORT void *sk_delete_ptr(_STACK *sk, const void *p);
192
201
  // OpenSSL's sk_find will implicitly sort |sk| if it has a comparison function
193
202
  // defined.
194
203
  OPENSSL_EXPORT int sk_find(const _STACK *sk, size_t *out_index, const void *p,
195
- int (*call_cmp_func)(stack_cmp_func, const void **,
196
- const void **));
204
+ stack_call_cmp_func call_cmp_func);
197
205
 
198
206
  // sk_shift removes and returns the first element in the stack, or returns NULL
199
207
  // if the stack is empty.
@@ -214,7 +222,7 @@ OPENSSL_EXPORT _STACK *sk_dup(const _STACK *sk);
214
222
  // sk_sort sorts the elements of |sk| into ascending order based on the
215
223
  // comparison function. The stack maintains a |sorted| flag and sorting an
216
224
  // already sorted stack is a no-op.
217
- OPENSSL_EXPORT void sk_sort(_STACK *sk);
225
+ OPENSSL_EXPORT void sk_sort(_STACK *sk, stack_call_cmp_func call_cmp_func);
218
226
 
219
227
  // sk_is_sorted returns one if |sk| is known to be sorted and zero
220
228
  // otherwise.
@@ -227,10 +235,11 @@ OPENSSL_EXPORT stack_cmp_func sk_set_cmp_func(_STACK *sk, stack_cmp_func comp);
227
235
  // sk_deep_copy performs a copy of |sk| and of each of the non-NULL elements in
228
236
  // |sk| by using |copy_func|. If an error occurs, |free_func| is used to free
229
237
  // any copies already made and NULL is returned.
230
- OPENSSL_EXPORT _STACK *sk_deep_copy(
231
- const _STACK *sk, void *(*call_copy_func)(stack_copy_func, void *),
232
- stack_copy_func copy_func, void (*call_free_func)(stack_free_func, void *),
233
- stack_free_func free_func);
238
+ OPENSSL_EXPORT _STACK *sk_deep_copy(const _STACK *sk,
239
+ stack_call_copy_func call_copy_func,
240
+ stack_copy_func copy_func,
241
+ stack_call_free_func call_free_func,
242
+ stack_free_func free_func);
234
243
 
235
244
 
236
245
  // Deprecated functions.
@@ -277,6 +286,16 @@ BSSL_NAMESPACE_END
277
286
  #endif
278
287
 
279
288
  #define BORINGSSL_DEFINE_STACK_OF_IMPL(name, ptrtype, constptrtype) \
289
+ /* We disable MSVC C4191 in this macro, which warns when pointers are cast \
290
+ * to the wrong type. While the cast itself is valid, it is often a bug \
291
+ * because calling it through the cast is UB. However, we never actually \
292
+ * call functions as |stack_cmp_func|. The type is just a type-erased \
293
+ * function pointer. (C does not guarantee function pointers fit in \
294
+ * |void*|, and GCC will warn on this.) Thus we just disable the false \
295
+ * positive warning. */ \
296
+ OPENSSL_MSVC_PRAGMA(warning(push)) \
297
+ OPENSSL_MSVC_PRAGMA(warning(disable : 4191)) \
298
+ \
280
299
  DECLARE_STACK_OF(name) \
281
300
  \
282
301
  typedef void (*stack_##name##_free_func)(ptrtype); \
@@ -294,14 +313,17 @@ BSSL_NAMESPACE_END
294
313
  } \
295
314
  \
296
315
  OPENSSL_INLINE int sk_##name##_call_cmp_func( \
297
- stack_cmp_func cmp_func, const void **a, const void **b) { \
316
+ stack_cmp_func cmp_func, const void *const *a, const void *const *b) { \
317
+ /* The data is actually stored as |void*| pointers, so read the pointer \
318
+ * as |void*| and then pass the corrected type into the caller-supplied \
319
+ * function, which expects |constptrtype*|. */ \
298
320
  constptrtype a_ptr = (constptrtype)*a; \
299
321
  constptrtype b_ptr = (constptrtype)*b; \
300
322
  return ((stack_##name##_cmp_func)cmp_func)(&a_ptr, &b_ptr); \
301
323
  } \
302
324
  \
303
- OPENSSL_INLINE STACK_OF(name) * \
304
- sk_##name##_new(stack_##name##_cmp_func comp) { \
325
+ OPENSSL_INLINE STACK_OF(name) *sk_##name##_new( \
326
+ stack_##name##_cmp_func comp) { \
305
327
  return (STACK_OF(name) *)sk_new((stack_cmp_func)comp); \
306
328
  } \
307
329
  \
@@ -327,12 +349,12 @@ BSSL_NAMESPACE_END
327
349
  return (ptrtype)sk_set((_STACK *)sk, i, (void *)p); \
328
350
  } \
329
351
  \
330
- OPENSSL_INLINE void sk_##name##_free(STACK_OF(name) * sk) { \
352
+ OPENSSL_INLINE void sk_##name##_free(STACK_OF(name) *sk) { \
331
353
  sk_free((_STACK *)sk); \
332
354
  } \
333
355
  \
334
356
  OPENSSL_INLINE void sk_##name##_pop_free( \
335
- STACK_OF(name) * sk, stack_##name##_free_func free_func) { \
357
+ STACK_OF(name) *sk, stack_##name##_free_func free_func) { \
336
358
  sk_pop_free_ex((_STACK *)sk, sk_##name##_call_free_func, \
337
359
  (stack_free_func)free_func); \
338
360
  } \
@@ -353,7 +375,7 @@ BSSL_NAMESPACE_END
353
375
  } \
354
376
  \
355
377
  OPENSSL_INLINE int sk_##name##_find(const STACK_OF(name) *sk, \
356
- size_t * out_index, constptrtype p) { \
378
+ size_t *out_index, constptrtype p) { \
357
379
  return sk_find((const _STACK *)sk, out_index, (const void *)p, \
358
380
  sk_##name##_call_cmp_func); \
359
381
  } \
@@ -370,12 +392,12 @@ BSSL_NAMESPACE_END
370
392
  return (ptrtype)sk_pop((_STACK *)sk); \
371
393
  } \
372
394
  \
373
- OPENSSL_INLINE STACK_OF(name) * sk_##name##_dup(const STACK_OF(name) *sk) { \
395
+ OPENSSL_INLINE STACK_OF(name) *sk_##name##_dup(const STACK_OF(name) *sk) { \
374
396
  return (STACK_OF(name) *)sk_dup((const _STACK *)sk); \
375
397
  } \
376
398
  \
377
399
  OPENSSL_INLINE void sk_##name##_sort(STACK_OF(name) *sk) { \
378
- sk_sort((_STACK *)sk); \
400
+ sk_sort((_STACK *)sk, sk_##name##_call_cmp_func); \
379
401
  } \
380
402
  \
381
403
  OPENSSL_INLINE int sk_##name##_is_sorted(const STACK_OF(name) *sk) { \
@@ -388,15 +410,16 @@ BSSL_NAMESPACE_END
388
410
  (stack_cmp_func)comp); \
389
411
  } \
390
412
  \
391
- OPENSSL_INLINE STACK_OF(name) * \
392
- sk_##name##_deep_copy(const STACK_OF(name) *sk, \
393
- ptrtype(*copy_func)(ptrtype), \
394
- void (*free_func)(ptrtype)) { \
413
+ OPENSSL_INLINE STACK_OF(name) *sk_##name##_deep_copy( \
414
+ const STACK_OF(name) *sk, ptrtype (*copy_func)(ptrtype), \
415
+ void (*free_func)(ptrtype)) { \
395
416
  return (STACK_OF(name) *)sk_deep_copy( \
396
417
  (const _STACK *)sk, sk_##name##_call_copy_func, \
397
418
  (stack_copy_func)copy_func, sk_##name##_call_free_func, \
398
419
  (stack_free_func)free_func); \
399
- }
420
+ } \
421
+ \
422
+ OPENSSL_MSVC_PRAGMA(warning(pop))
400
423
 
401
424
  // DEFINE_NAMED_STACK_OF defines |STACK_OF(name)| to be a stack whose elements
402
425
  // are |type| *.
@@ -414,18 +437,10 @@ BSSL_NAMESPACE_END
414
437
  BORINGSSL_DEFINE_STACK_OF_IMPL(type, const type *, const type *) \
415
438
  BORINGSSL_DEFINE_STACK_TRAITS(type, const type, true)
416
439
 
417
- // DEFINE_SPECIAL_STACK_OF defines |STACK_OF(type)| to be a stack whose elements
418
- // are |type|, where |type| must be a typedef for a pointer.
419
- #define DEFINE_SPECIAL_STACK_OF(type) \
420
- OPENSSL_STATIC_ASSERT(sizeof(type) == sizeof(void *), \
421
- #type " is not a pointer"); \
422
- BORINGSSL_DEFINE_STACK_OF_IMPL(type, type, const type)
423
-
424
-
425
440
  typedef char *OPENSSL_STRING;
426
441
 
427
442
  DEFINE_STACK_OF(void)
428
- DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING)
443
+ DEFINE_NAMED_STACK_OF(OPENSSL_STRING, char)
429
444
 
430
445
 
431
446
  #if defined(__cplusplus)
@@ -78,15 +78,30 @@ OPENSSL_EXPORT void TRUST_TOKEN_free(TRUST_TOKEN *token);
78
78
  // to ensure success, these should be at least
79
79
  // |TRUST_TOKEN_MAX_PRIVATE_KEY_SIZE| and |TRUST_TOKEN_MAX_PUBLIC_KEY_SIZE|.
80
80
  //
81
- // WARNING: This API is unstable and the serializations of these keys are
82
- // subject to change. Keys generated with this function may not be persisted.
83
- //
84
81
  // This function returns one on success or zero on error.
85
82
  OPENSSL_EXPORT int TRUST_TOKEN_generate_key(
86
83
  const TRUST_TOKEN_METHOD *method, uint8_t *out_priv_key,
87
84
  size_t *out_priv_key_len, size_t max_priv_key_len, uint8_t *out_pub_key,
88
85
  size_t *out_pub_key_len, size_t max_pub_key_len, uint32_t id);
89
86
 
87
+ // TRUST_TOKEN_derive_key_from_secret deterministically derives a new Trust
88
+ // Token keypair labeled with |id| from an input |secret| and serializes the
89
+ // private and public keys, writing the private key to |out_priv_key| and
90
+ // setting |*out_priv_key_len| to the number of bytes written, and writing the
91
+ // public key to |out_pub_key| and setting |*out_pub_key_len| to the number of
92
+ // bytes written.
93
+ //
94
+ // At most |max_priv_key_len| and |max_pub_key_len| bytes are written. In order
95
+ // to ensure success, these should be at least
96
+ // |TRUST_TOKEN_MAX_PRIVATE_KEY_SIZE| and |TRUST_TOKEN_MAX_PUBLIC_KEY_SIZE|.
97
+ //
98
+ // This function returns one on success or zero on error.
99
+ OPENSSL_EXPORT int TRUST_TOKEN_derive_key_from_secret(
100
+ const TRUST_TOKEN_METHOD *method, uint8_t *out_priv_key,
101
+ size_t *out_priv_key_len, size_t max_priv_key_len, uint8_t *out_pub_key,
102
+ size_t *out_pub_key_len, size_t max_pub_key_len, uint32_t id,
103
+ const uint8_t *secret, size_t secret_len);
104
+
90
105
 
91
106
  // Trust Token client implementation.
92
107
  //
@@ -1191,6 +1191,24 @@ OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req,
1191
1191
  const unsigned char *data,
1192
1192
  int len);
1193
1193
 
1194
+ // X509_REQ_set1_signature_algo sets |req|'s signature algorithm to |algo| and
1195
+ // returns one on success or zero on error.
1196
+ OPENSSL_EXPORT int X509_REQ_set1_signature_algo(X509_REQ *req,
1197
+ const X509_ALGOR *algo);
1198
+
1199
+ // X509_REQ_set1_signature_value sets |req|'s signature to a copy of the
1200
+ // |sig_len| bytes pointed by |sig|. It returns one on success and zero on
1201
+ // error.
1202
+ //
1203
+ // Due to a specification error, PKCS#10 certificate requests store signatures
1204
+ // in ASN.1 BIT STRINGs, but signature algorithms return byte strings rather
1205
+ // than bit strings. This function creates a BIT STRING containing a whole
1206
+ // number of bytes, with the bit order matching the DER encoding. This matches
1207
+ // the encoding used by all X.509 signature algorithms.
1208
+ OPENSSL_EXPORT int X509_REQ_set1_signature_value(X509_REQ *req,
1209
+ const uint8_t *sig,
1210
+ size_t sig_len);
1211
+
1194
1212
  // X509_CRL_set_version sets |crl|'s version to |version|, which should be one
1195
1213
  // of the |X509_CRL_VERSION_*| constants. It returns one on success and zero on
1196
1214
  // error.
@@ -128,125 +128,87 @@ static int xname_cmp(const X509_NAME **a, const X509_NAME **b) {
128
128
  return X509_NAME_cmp(*a, *b);
129
129
  }
130
130
 
131
- // TODO(davidben): Is there any reason this doesn't call
132
- // |SSL_add_file_cert_subjects_to_stack|?
133
131
  STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file) {
134
- BIO *in;
135
- X509 *x = NULL;
136
- X509_NAME *xn = NULL;
137
- STACK_OF(X509_NAME) *ret = NULL, *sk;
138
-
139
- sk = sk_X509_NAME_new(xname_cmp);
140
- in = BIO_new(BIO_s_file());
141
-
142
- if (sk == NULL || in == NULL) {
143
- OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
144
- goto err;
132
+ bssl::UniquePtr<STACK_OF(X509_NAME)> ret(sk_X509_NAME_new_null());
133
+ if (ret == nullptr ||
134
+ !SSL_add_file_cert_subjects_to_stack(ret.get(), file)) {
135
+ return nullptr;
145
136
  }
137
+ return ret.release();
138
+ }
146
139
 
147
- if (!BIO_read_filename(in, file)) {
148
- goto err;
140
+ int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *out,
141
+ const char *file) {
142
+ bssl::UniquePtr<BIO> in(BIO_new_file(file, "r"));
143
+ if (in == nullptr) {
144
+ return 0;
149
145
  }
146
+ return SSL_add_bio_cert_subjects_to_stack(out, in.get());
147
+ }
150
148
 
149
+ int SSL_add_bio_cert_subjects_to_stack(STACK_OF(X509_NAME) *out, BIO *bio) {
150
+ // This function historically sorted |out| after every addition and skipped
151
+ // duplicates. This implementation preserves that behavior, but only sorts at
152
+ // the end, to avoid a quadratic running time. Existing duplicates in |out|
153
+ // are preserved, but do not introduce new duplicates.
154
+ bssl::UniquePtr<STACK_OF(X509_NAME)> to_append(sk_X509_NAME_new(xname_cmp));
155
+ if (to_append == nullptr) {
156
+ return 0;
157
+ }
158
+
159
+ // Temporarily switch the comparison function for |out|.
160
+ struct RestoreCmpFunc {
161
+ ~RestoreCmpFunc() { sk_X509_NAME_set_cmp_func(stack, old_cmp); }
162
+ STACK_OF(X509_NAME) *stack;
163
+ int (*old_cmp)(const X509_NAME **, const X509_NAME **);
164
+ };
165
+ RestoreCmpFunc restore = {out, sk_X509_NAME_set_cmp_func(out, xname_cmp)};
166
+
167
+ sk_X509_NAME_sort(out);
151
168
  for (;;) {
152
- if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) {
169
+ bssl::UniquePtr<X509> x509(
170
+ PEM_read_bio_X509(bio, nullptr, nullptr, nullptr));
171
+ if (x509 == nullptr) {
172
+ // TODO(davidben): This ignores PEM syntax errors. It should only succeed
173
+ // on |PEM_R_NO_START_LINE|.
174
+ ERR_clear_error();
153
175
  break;
154
176
  }
155
- if (ret == NULL) {
156
- ret = sk_X509_NAME_new_null();
157
- if (ret == NULL) {
158
- OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
159
- goto err;
160
- }
161
- }
162
- xn = X509_get_subject_name(x);
163
- if (xn == NULL) {
164
- goto err;
165
- }
166
177
 
167
- // Check for duplicates.
168
- sk_X509_NAME_sort(sk);
169
- if (sk_X509_NAME_find(sk, NULL, xn)) {
178
+ X509_NAME *subject = X509_get_subject_name(x509.get());
179
+ // Skip if already present in |out|. Duplicates in |to_append| will be
180
+ // handled separately.
181
+ if (sk_X509_NAME_find(out, /*out_index=*/NULL, subject)) {
170
182
  continue;
171
183
  }
172
184
 
173
- xn = X509_NAME_dup(xn);
174
- if (xn == NULL ||
175
- !sk_X509_NAME_push(sk /* non-owning */, xn) ||
176
- !sk_X509_NAME_push(ret /* owning */, xn)) {
177
- X509_NAME_free(xn);
178
- goto err;
185
+ bssl::UniquePtr<X509_NAME> copy(X509_NAME_dup(subject));
186
+ if (copy == nullptr ||
187
+ !bssl::PushToStack(to_append.get(), std::move(copy))) {
188
+ return 0;
179
189
  }
180
190
  }
181
191
 
182
- if (false) {
183
- err:
184
- sk_X509_NAME_pop_free(ret, X509_NAME_free);
185
- ret = NULL;
186
- }
187
-
188
- sk_X509_NAME_free(sk);
189
- BIO_free(in);
190
- X509_free(x);
191
- if (ret != NULL) {
192
- ERR_clear_error();
193
- }
194
- return ret;
195
- }
196
-
197
- int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
198
- const char *file) {
199
- BIO *in;
200
- X509 *x = NULL;
201
- X509_NAME *xn = NULL;
202
- int ret = 0;
203
- int (*oldcmp)(const X509_NAME **a, const X509_NAME **b);
204
-
205
- oldcmp = sk_X509_NAME_set_cmp_func(stack, xname_cmp);
206
- in = BIO_new(BIO_s_file());
207
-
208
- if (in == NULL) {
209
- OPENSSL_PUT_ERROR(SSL, ERR_R_MALLOC_FAILURE);
210
- goto err;
211
- }
212
-
213
- if (!BIO_read_filename(in, file)) {
214
- goto err;
215
- }
216
-
217
- for (;;) {
218
- if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL) {
219
- break;
220
- }
221
- xn = X509_get_subject_name(x);
222
- if (xn == NULL) {
223
- goto err;
224
- }
225
-
226
- // Check for duplicates.
227
- sk_X509_NAME_sort(stack);
228
- if (sk_X509_NAME_find(stack, NULL, xn)) {
192
+ // Append |to_append| to |stack|, skipping any duplicates.
193
+ sk_X509_NAME_sort(to_append.get());
194
+ size_t num = sk_X509_NAME_num(to_append.get());
195
+ for (size_t i = 0; i < num; i++) {
196
+ bssl::UniquePtr<X509_NAME> name(sk_X509_NAME_value(to_append.get(), i));
197
+ sk_X509_NAME_set(to_append.get(), i, nullptr);
198
+ if (i + 1 < num &&
199
+ X509_NAME_cmp(name.get(), sk_X509_NAME_value(to_append.get(), i + 1)) ==
200
+ 0) {
229
201
  continue;
230
202
  }
231
-
232
- xn = X509_NAME_dup(xn);
233
- if (xn == NULL ||
234
- !sk_X509_NAME_push(stack, xn)) {
235
- X509_NAME_free(xn);
236
- goto err;
203
+ if (!bssl::PushToStack(out, std::move(name))) {
204
+ return 0;
237
205
  }
238
206
  }
239
207
 
240
- ERR_clear_error();
241
- ret = 1;
242
-
243
- err:
244
- BIO_free(in);
245
- X509_free(x);
246
-
247
- (void) sk_X509_NAME_set_cmp_func(stack, oldcmp);
248
-
249
- return ret;
208
+ // Sort |out| one last time, to preserve the historical behavior of
209
+ // maintaining the sorted list.
210
+ sk_X509_NAME_sort(out);
211
+ return 1;
250
212
  }
251
213
 
252
214
  int SSL_use_certificate_file(SSL *ssl, const char *file, int type) {