@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,380 +71,370 @@
71
71
  #include "internal.h"
72
72
 
73
73
 
74
- int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b)
75
- {
76
- int i;
77
- X509_CINF *ai, *bi;
78
-
79
- ai = a->cert_info;
80
- bi = b->cert_info;
81
- i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber);
82
- if (i)
83
- return (i);
84
- return (X509_NAME_cmp(ai->issuer, bi->issuer));
74
+ int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) {
75
+ int i;
76
+ X509_CINF *ai, *bi;
77
+
78
+ ai = a->cert_info;
79
+ bi = b->cert_info;
80
+ i = ASN1_INTEGER_cmp(ai->serialNumber, bi->serialNumber);
81
+ if (i) {
82
+ return i;
83
+ }
84
+ return (X509_NAME_cmp(ai->issuer, bi->issuer));
85
85
  }
86
86
 
87
- int X509_issuer_name_cmp(const X509 *a, const X509 *b)
88
- {
89
- return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer));
87
+ int X509_issuer_name_cmp(const X509 *a, const X509 *b) {
88
+ return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer));
90
89
  }
91
90
 
92
- int X509_subject_name_cmp(const X509 *a, const X509 *b)
93
- {
94
- return (X509_NAME_cmp(a->cert_info->subject, b->cert_info->subject));
91
+ int X509_subject_name_cmp(const X509 *a, const X509 *b) {
92
+ return (X509_NAME_cmp(a->cert_info->subject, b->cert_info->subject));
95
93
  }
96
94
 
97
- int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b)
98
- {
99
- return (X509_NAME_cmp(a->crl->issuer, b->crl->issuer));
95
+ int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b) {
96
+ return (X509_NAME_cmp(a->crl->issuer, b->crl->issuer));
100
97
  }
101
98
 
102
- int X509_CRL_match(const X509_CRL *a, const X509_CRL *b)
103
- {
104
- return OPENSSL_memcmp(a->crl_hash, b->crl_hash, SHA256_DIGEST_LENGTH);
99
+ int X509_CRL_match(const X509_CRL *a, const X509_CRL *b) {
100
+ return OPENSSL_memcmp(a->crl_hash, b->crl_hash, SHA256_DIGEST_LENGTH);
105
101
  }
106
102
 
107
- X509_NAME *X509_get_issuer_name(const X509 *a)
108
- {
109
- return (a->cert_info->issuer);
103
+ X509_NAME *X509_get_issuer_name(const X509 *a) {
104
+ return a->cert_info->issuer;
110
105
  }
111
106
 
112
- unsigned long X509_issuer_name_hash(X509 *x)
113
- {
114
- return (X509_NAME_hash(x->cert_info->issuer));
107
+ unsigned long X509_issuer_name_hash(X509 *x) {
108
+ return (X509_NAME_hash(x->cert_info->issuer));
115
109
  }
116
110
 
117
- unsigned long X509_issuer_name_hash_old(X509 *x)
118
- {
119
- return (X509_NAME_hash_old(x->cert_info->issuer));
111
+ unsigned long X509_issuer_name_hash_old(X509 *x) {
112
+ return (X509_NAME_hash_old(x->cert_info->issuer));
120
113
  }
121
114
 
122
- X509_NAME *X509_get_subject_name(const X509 *a)
123
- {
124
- return (a->cert_info->subject);
115
+ X509_NAME *X509_get_subject_name(const X509 *a) {
116
+ return a->cert_info->subject;
125
117
  }
126
118
 
127
- ASN1_INTEGER *X509_get_serialNumber(X509 *a)
128
- {
129
- return (a->cert_info->serialNumber);
119
+ ASN1_INTEGER *X509_get_serialNumber(X509 *a) {
120
+ return a->cert_info->serialNumber;
130
121
  }
131
122
 
132
- const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x509)
133
- {
134
- return x509->cert_info->serialNumber;
123
+ const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x509) {
124
+ return x509->cert_info->serialNumber;
135
125
  }
136
126
 
137
- unsigned long X509_subject_name_hash(X509 *x)
138
- {
139
- return (X509_NAME_hash(x->cert_info->subject));
127
+ unsigned long X509_subject_name_hash(X509 *x) {
128
+ return (X509_NAME_hash(x->cert_info->subject));
140
129
  }
141
130
 
142
- unsigned long X509_subject_name_hash_old(X509 *x)
143
- {
144
- return (X509_NAME_hash_old(x->cert_info->subject));
131
+ unsigned long X509_subject_name_hash_old(X509 *x) {
132
+ return (X509_NAME_hash_old(x->cert_info->subject));
145
133
  }
146
134
 
147
- /*
148
- * Compare two certificates: they must be identical for this to work. NB:
149
- * Although "cmp" operations are generally prototyped to take "const"
150
- * arguments (eg. for use in STACKs), the way X509 handling is - these
151
- * operations may involve ensuring the hashes are up-to-date and ensuring
152
- * certain cert information is cached. So this is the point where the
153
- * "depth-first" constification tree has to halt with an evil cast.
154
- */
155
- int X509_cmp(const X509 *a, const X509 *b)
156
- {
157
- /* Fill in the |cert_hash| fields.
158
- *
159
- * TODO(davidben): This may fail, in which case the the hash will be all
160
- * zeros. This produces a consistent comparison (failures are sticky), but
161
- * not a good one. OpenSSL now returns -2, but this is not a consistent
162
- * comparison and may cause misbehaving sorts by transitivity. For now, we
163
- * retain the old OpenSSL behavior, which was to ignore the error. See
164
- * https://crbug.com/boringssl/355. */
165
- x509v3_cache_extensions((X509 *)a);
166
- x509v3_cache_extensions((X509 *)b);
167
-
168
- return OPENSSL_memcmp(a->cert_hash, b->cert_hash, SHA256_DIGEST_LENGTH);
135
+ // Compare two certificates: they must be identical for this to work. NB:
136
+ // Although "cmp" operations are generally prototyped to take "const"
137
+ // arguments (eg. for use in STACKs), the way X509 handling is - these
138
+ // operations may involve ensuring the hashes are up-to-date and ensuring
139
+ // certain cert information is cached. So this is the point where the
140
+ // "depth-first" constification tree has to halt with an evil cast.
141
+ int X509_cmp(const X509 *a, const X509 *b) {
142
+ // Fill in the |cert_hash| fields.
143
+ //
144
+ // TODO(davidben): This may fail, in which case the the hash will be all
145
+ // zeros. This produces a consistent comparison (failures are sticky), but
146
+ // not a good one. OpenSSL now returns -2, but this is not a consistent
147
+ // comparison and may cause misbehaving sorts by transitivity. For now, we
148
+ // retain the old OpenSSL behavior, which was to ignore the error. See
149
+ // https://crbug.com/boringssl/355.
150
+ x509v3_cache_extensions((X509 *)a);
151
+ x509v3_cache_extensions((X509 *)b);
152
+
153
+ return OPENSSL_memcmp(a->cert_hash, b->cert_hash, SHA256_DIGEST_LENGTH);
169
154
  }
170
155
 
171
- int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
172
- {
173
- int ret;
156
+ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) {
157
+ int ret;
174
158
 
175
- /* Ensure canonical encoding is present and up to date */
159
+ // Ensure canonical encoding is present and up to date
176
160
 
177
- if (!a->canon_enc || a->modified) {
178
- ret = i2d_X509_NAME((X509_NAME *)a, NULL);
179
- if (ret < 0)
180
- return -2;
161
+ if (!a->canon_enc || a->modified) {
162
+ ret = i2d_X509_NAME((X509_NAME *)a, NULL);
163
+ if (ret < 0) {
164
+ return -2;
181
165
  }
166
+ }
182
167
 
183
- if (!b->canon_enc || b->modified) {
184
- ret = i2d_X509_NAME((X509_NAME *)b, NULL);
185
- if (ret < 0)
186
- return -2;
168
+ if (!b->canon_enc || b->modified) {
169
+ ret = i2d_X509_NAME((X509_NAME *)b, NULL);
170
+ if (ret < 0) {
171
+ return -2;
187
172
  }
173
+ }
188
174
 
189
- ret = a->canon_enclen - b->canon_enclen;
175
+ ret = a->canon_enclen - b->canon_enclen;
190
176
 
191
- if (ret)
192
- return ret;
193
-
194
- return OPENSSL_memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
177
+ if (ret) {
178
+ return ret;
179
+ }
195
180
 
181
+ return OPENSSL_memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
196
182
  }
197
183
 
198
- unsigned long X509_NAME_hash(X509_NAME *x)
199
- {
200
- unsigned long ret = 0;
201
- unsigned char md[SHA_DIGEST_LENGTH];
184
+ unsigned long X509_NAME_hash(X509_NAME *x) {
185
+ unsigned long ret = 0;
186
+ unsigned char md[SHA_DIGEST_LENGTH];
187
+
188
+ // Make sure X509_NAME structure contains valid cached encoding
189
+ i2d_X509_NAME(x, NULL);
190
+ if (!EVP_Digest(x->canon_enc, x->canon_enclen, md, NULL, EVP_sha1(), NULL)) {
191
+ return 0;
192
+ }
202
193
 
203
- /* Make sure X509_NAME structure contains valid cached encoding */
204
- i2d_X509_NAME(x, NULL);
205
- if (!EVP_Digest(x->canon_enc, x->canon_enclen, md, NULL, EVP_sha1(),
206
- NULL))
207
- return 0;
194
+ ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
195
+ ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)) &
196
+ 0xffffffffL;
197
+ return ret;
198
+ }
208
199
 
200
+ // I now DER encode the name and hash it. Since I cache the DER encoding,
201
+ // this is reasonably efficient.
202
+
203
+ unsigned long X509_NAME_hash_old(X509_NAME *x) {
204
+ EVP_MD_CTX md_ctx;
205
+ unsigned long ret = 0;
206
+ unsigned char md[16];
207
+
208
+ // Make sure X509_NAME structure contains valid cached encoding
209
+ i2d_X509_NAME(x, NULL);
210
+ EVP_MD_CTX_init(&md_ctx);
211
+ // EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
212
+ if (EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL) &&
213
+ EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length) &&
214
+ EVP_DigestFinal_ex(&md_ctx, md, NULL)) {
209
215
  ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
210
- ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
211
- ) & 0xffffffffL;
212
- return (ret);
213
- }
216
+ ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)) &
217
+ 0xffffffffL;
218
+ }
219
+ EVP_MD_CTX_cleanup(&md_ctx);
214
220
 
215
- /*
216
- * I now DER encode the name and hash it. Since I cache the DER encoding,
217
- * this is reasonably efficient.
218
- */
219
-
220
- unsigned long X509_NAME_hash_old(X509_NAME *x)
221
- {
222
- EVP_MD_CTX md_ctx;
223
- unsigned long ret = 0;
224
- unsigned char md[16];
225
-
226
- /* Make sure X509_NAME structure contains valid cached encoding */
227
- i2d_X509_NAME(x, NULL);
228
- EVP_MD_CTX_init(&md_ctx);
229
- /* EVP_MD_CTX_set_flags(&md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); */
230
- if (EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL)
231
- && EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length)
232
- && EVP_DigestFinal_ex(&md_ctx, md, NULL))
233
- ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
234
- ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
235
- ) & 0xffffffffL;
236
- EVP_MD_CTX_cleanup(&md_ctx);
237
-
238
- return (ret);
221
+ return ret;
239
222
  }
240
223
 
241
- /* Search a stack of X509 for a match */
224
+ // Search a stack of X509 for a match
242
225
  X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
243
- ASN1_INTEGER *serial)
244
- {
245
- size_t i;
246
- X509_CINF cinf;
247
- X509 x, *x509 = NULL;
248
-
249
- if (!sk)
250
- return NULL;
251
-
252
- x.cert_info = &cinf;
253
- cinf.serialNumber = serial;
254
- cinf.issuer = name;
255
-
256
- for (i = 0; i < sk_X509_num(sk); i++) {
257
- x509 = sk_X509_value(sk, i);
258
- if (X509_issuer_and_serial_cmp(x509, &x) == 0)
259
- return (x509);
226
+ ASN1_INTEGER *serial) {
227
+ size_t i;
228
+ X509_CINF cinf;
229
+ X509 x, *x509 = NULL;
230
+
231
+ if (!sk) {
232
+ return NULL;
233
+ }
234
+
235
+ x.cert_info = &cinf;
236
+ cinf.serialNumber = serial;
237
+ cinf.issuer = name;
238
+
239
+ for (i = 0; i < sk_X509_num(sk); i++) {
240
+ x509 = sk_X509_value(sk, i);
241
+ if (X509_issuer_and_serial_cmp(x509, &x) == 0) {
242
+ return x509;
260
243
  }
261
- return (NULL);
244
+ }
245
+ return NULL;
262
246
  }
263
247
 
264
- X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name)
265
- {
266
- X509 *x509;
267
- size_t i;
248
+ X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) {
249
+ X509 *x509;
250
+ size_t i;
268
251
 
269
- for (i = 0; i < sk_X509_num(sk); i++) {
270
- x509 = sk_X509_value(sk, i);
271
- if (X509_NAME_cmp(X509_get_subject_name(x509), name) == 0)
272
- return (x509);
252
+ for (i = 0; i < sk_X509_num(sk); i++) {
253
+ x509 = sk_X509_value(sk, i);
254
+ if (X509_NAME_cmp(X509_get_subject_name(x509), name) == 0) {
255
+ return x509;
273
256
  }
274
- return (NULL);
257
+ }
258
+ return NULL;
275
259
  }
276
260
 
277
- EVP_PKEY *X509_get_pubkey(X509 *x)
278
- {
279
- if ((x == NULL) || (x->cert_info == NULL))
280
- return (NULL);
281
- return (X509_PUBKEY_get(x->cert_info->key));
261
+ EVP_PKEY *X509_get_pubkey(X509 *x) {
262
+ if ((x == NULL) || (x->cert_info == NULL)) {
263
+ return NULL;
264
+ }
265
+ return (X509_PUBKEY_get(x->cert_info->key));
282
266
  }
283
267
 
284
- ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)
285
- {
286
- if (!x)
287
- return NULL;
288
- return x->cert_info->key->public_key;
268
+ ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x) {
269
+ if (!x) {
270
+ return NULL;
271
+ }
272
+ return x->cert_info->key->public_key;
289
273
  }
290
274
 
291
- int X509_check_private_key(X509 *x, const EVP_PKEY *k)
292
- {
293
- EVP_PKEY *xk;
294
- int ret;
275
+ int X509_check_private_key(X509 *x, const EVP_PKEY *k) {
276
+ EVP_PKEY *xk;
277
+ int ret;
295
278
 
296
- xk = X509_get_pubkey(x);
279
+ xk = X509_get_pubkey(x);
297
280
 
298
- if (xk)
299
- ret = EVP_PKEY_cmp(xk, k);
300
- else
301
- ret = -2;
281
+ if (xk) {
282
+ ret = EVP_PKEY_cmp(xk, k);
283
+ } else {
284
+ ret = -2;
285
+ }
302
286
 
303
- switch (ret) {
287
+ switch (ret) {
304
288
  case 1:
305
- break;
289
+ break;
306
290
  case 0:
307
- OPENSSL_PUT_ERROR(X509, X509_R_KEY_VALUES_MISMATCH);
308
- break;
291
+ OPENSSL_PUT_ERROR(X509, X509_R_KEY_VALUES_MISMATCH);
292
+ break;
309
293
  case -1:
310
- OPENSSL_PUT_ERROR(X509, X509_R_KEY_TYPE_MISMATCH);
311
- break;
294
+ OPENSSL_PUT_ERROR(X509, X509_R_KEY_TYPE_MISMATCH);
295
+ break;
312
296
  case -2:
313
- OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_KEY_TYPE);
314
- }
315
- if (xk)
316
- EVP_PKEY_free(xk);
317
- if (ret > 0)
318
- return 1;
319
- return 0;
297
+ OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_KEY_TYPE);
298
+ }
299
+ if (xk) {
300
+ EVP_PKEY_free(xk);
301
+ }
302
+ if (ret > 0) {
303
+ return 1;
304
+ }
305
+ return 0;
320
306
  }
321
307
 
322
- /*
323
- * Check a suite B algorithm is permitted: pass in a public key and the NID
324
- * of its signature (or 0 if no signature). The pflags is a pointer to a
325
- * flags field which must contain the suite B verification flags.
326
- */
327
-
328
- static int check_suite_b(EVP_PKEY *pkey, int sign_nid, unsigned long *pflags)
329
- {
330
- const EC_GROUP *grp = NULL;
331
- int curve_nid;
332
- if (pkey && pkey->type == EVP_PKEY_EC)
333
- grp = EC_KEY_get0_group(pkey->pkey.ec);
334
- if (!grp)
335
- return X509_V_ERR_SUITE_B_INVALID_ALGORITHM;
336
- curve_nid = EC_GROUP_get_curve_name(grp);
337
- /* Check curve is consistent with LOS */
338
- if (curve_nid == NID_secp384r1) { /* P-384 */
339
- /*
340
- * Check signature algorithm is consistent with curve.
341
- */
342
- if (sign_nid != -1 && sign_nid != NID_ecdsa_with_SHA384)
343
- return X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM;
344
- if (!(*pflags & X509_V_FLAG_SUITEB_192_LOS))
345
- return X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED;
346
- /* If we encounter P-384 we cannot use P-256 later */
347
- *pflags &= ~X509_V_FLAG_SUITEB_128_LOS_ONLY;
348
- } else if (curve_nid == NID_X9_62_prime256v1) { /* P-256 */
349
- if (sign_nid != -1 && sign_nid != NID_ecdsa_with_SHA256)
350
- return X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM;
351
- if (!(*pflags & X509_V_FLAG_SUITEB_128_LOS_ONLY))
352
- return X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED;
353
- } else
354
- return X509_V_ERR_SUITE_B_INVALID_CURVE;
308
+ // Check a suite B algorithm is permitted: pass in a public key and the NID
309
+ // of its signature (or 0 if no signature). The pflags is a pointer to a
310
+ // flags field which must contain the suite B verification flags.
311
+
312
+ static int check_suite_b(EVP_PKEY *pkey, int sign_nid, unsigned long *pflags) {
313
+ const EC_GROUP *grp = NULL;
314
+ int curve_nid;
315
+ if (pkey && pkey->type == EVP_PKEY_EC) {
316
+ grp = EC_KEY_get0_group(pkey->pkey.ec);
317
+ }
318
+ if (!grp) {
319
+ return X509_V_ERR_SUITE_B_INVALID_ALGORITHM;
320
+ }
321
+ curve_nid = EC_GROUP_get_curve_name(grp);
322
+ // Check curve is consistent with LOS
323
+ if (curve_nid == NID_secp384r1) { // P-384
324
+ // Check signature algorithm is consistent with curve.
325
+ if (sign_nid != -1 && sign_nid != NID_ecdsa_with_SHA384) {
326
+ return X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM;
327
+ }
328
+ if (!(*pflags & X509_V_FLAG_SUITEB_192_LOS)) {
329
+ return X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED;
330
+ }
331
+ // If we encounter P-384 we cannot use P-256 later
332
+ *pflags &= ~X509_V_FLAG_SUITEB_128_LOS_ONLY;
333
+ } else if (curve_nid == NID_X9_62_prime256v1) { // P-256
334
+ if (sign_nid != -1 && sign_nid != NID_ecdsa_with_SHA256) {
335
+ return X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM;
336
+ }
337
+ if (!(*pflags & X509_V_FLAG_SUITEB_128_LOS_ONLY)) {
338
+ return X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED;
339
+ }
340
+ } else {
341
+ return X509_V_ERR_SUITE_B_INVALID_CURVE;
342
+ }
355
343
 
356
- return X509_V_OK;
344
+ return X509_V_OK;
357
345
  }
358
346
 
359
347
  int X509_chain_check_suiteb(int *perror_depth, X509 *x, STACK_OF(X509) *chain,
360
- unsigned long flags)
361
- {
362
- int rv, sign_nid;
363
- size_t i;
364
- EVP_PKEY *pk = NULL;
365
- unsigned long tflags;
366
- if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
367
- return X509_V_OK;
368
- tflags = flags;
369
- /* If no EE certificate passed in must be first in chain */
370
- if (x == NULL) {
371
- x = sk_X509_value(chain, 0);
372
- i = 1;
373
- } else
374
- i = 0;
375
-
348
+ unsigned long flags) {
349
+ int rv, sign_nid;
350
+ size_t i;
351
+ EVP_PKEY *pk = NULL;
352
+ unsigned long tflags;
353
+ if (!(flags & X509_V_FLAG_SUITEB_128_LOS)) {
354
+ return X509_V_OK;
355
+ }
356
+ tflags = flags;
357
+ // If no EE certificate passed in must be first in chain
358
+ if (x == NULL) {
359
+ x = sk_X509_value(chain, 0);
360
+ i = 1;
361
+ } else {
362
+ i = 0;
363
+ }
364
+
365
+ if (X509_get_version(x) != X509_VERSION_3) {
366
+ rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
367
+ // Correct error depth
368
+ i = 0;
369
+ goto end;
370
+ }
371
+
372
+ pk = X509_get_pubkey(x);
373
+ // Check EE key only
374
+ rv = check_suite_b(pk, -1, &tflags);
375
+ if (rv != X509_V_OK) {
376
+ // Correct error depth
377
+ i = 0;
378
+ goto end;
379
+ }
380
+ for (; i < sk_X509_num(chain); i++) {
381
+ sign_nid = X509_get_signature_nid(x);
382
+ x = sk_X509_value(chain, i);
376
383
  if (X509_get_version(x) != X509_VERSION_3) {
377
- rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
378
- /* Correct error depth */
379
- i = 0;
380
- goto end;
384
+ rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
385
+ goto end;
381
386
  }
382
-
387
+ EVP_PKEY_free(pk);
383
388
  pk = X509_get_pubkey(x);
384
- /* Check EE key only */
385
- rv = check_suite_b(pk, -1, &tflags);
389
+ rv = check_suite_b(pk, sign_nid, &tflags);
386
390
  if (rv != X509_V_OK) {
387
- /* Correct error depth */
388
- i = 0;
389
- goto end;
391
+ goto end;
390
392
  }
391
- for (; i < sk_X509_num(chain); i++) {
392
- sign_nid = X509_get_signature_nid(x);
393
- x = sk_X509_value(chain, i);
394
- if (X509_get_version(x) != X509_VERSION_3) {
395
- rv = X509_V_ERR_SUITE_B_INVALID_VERSION;
396
- goto end;
397
- }
398
- EVP_PKEY_free(pk);
399
- pk = X509_get_pubkey(x);
400
- rv = check_suite_b(pk, sign_nid, &tflags);
401
- if (rv != X509_V_OK)
402
- goto end;
393
+ }
394
+
395
+ // Final check: root CA signature
396
+ rv = check_suite_b(pk, X509_get_signature_nid(x), &tflags);
397
+ end:
398
+ if (pk) {
399
+ EVP_PKEY_free(pk);
400
+ }
401
+ if (rv != X509_V_OK) {
402
+ // Invalid signature or LOS errors are for previous cert
403
+ if ((rv == X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM ||
404
+ rv == X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED) &&
405
+ i) {
406
+ i--;
403
407
  }
404
-
405
- /* Final check: root CA signature */
406
- rv = check_suite_b(pk, X509_get_signature_nid(x), &tflags);
407
- end:
408
- if (pk)
409
- EVP_PKEY_free(pk);
410
- if (rv != X509_V_OK) {
411
- /* Invalid signature or LOS errors are for previous cert */
412
- if ((rv == X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM
413
- || rv == X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED) && i)
414
- i--;
415
- /*
416
- * If we have LOS error and flags changed then we are signing P-384
417
- * with P-256. Use more meaninggul error.
418
- */
419
- if (rv == X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED && flags != tflags)
420
- rv = X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256;
421
- if (perror_depth)
422
- *perror_depth = i;
408
+ // If we have LOS error and flags changed then we are signing P-384
409
+ // with P-256. Use more meaninggul error.
410
+ if (rv == X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED && flags != tflags) {
411
+ rv = X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256;
412
+ }
413
+ if (perror_depth) {
414
+ *perror_depth = i;
423
415
  }
424
- return rv;
416
+ }
417
+ return rv;
425
418
  }
426
419
 
427
- int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags)
428
- {
429
- int sign_nid;
430
- if (!(flags & X509_V_FLAG_SUITEB_128_LOS))
431
- return X509_V_OK;
432
- sign_nid = OBJ_obj2nid(crl->crl->sig_alg->algorithm);
433
- return check_suite_b(pk, sign_nid, &flags);
420
+ int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags) {
421
+ int sign_nid;
422
+ if (!(flags & X509_V_FLAG_SUITEB_128_LOS)) {
423
+ return X509_V_OK;
424
+ }
425
+ sign_nid = OBJ_obj2nid(crl->crl->sig_alg->algorithm);
426
+ return check_suite_b(pk, sign_nid, &flags);
434
427
  }
435
428
 
436
- /*
437
- * Not strictly speaking an "up_ref" as a STACK doesn't have a reference
438
- * count but it has the same effect by duping the STACK and upping the ref of
439
- * each X509 structure.
440
- */
441
- STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain)
442
- {
443
- STACK_OF(X509) *ret;
444
- size_t i;
445
- ret = sk_X509_dup(chain);
446
- for (i = 0; i < sk_X509_num(ret); i++) {
447
- X509_up_ref(sk_X509_value(ret, i));
448
- }
449
- return ret;
429
+ // Not strictly speaking an "up_ref" as a STACK doesn't have a reference
430
+ // count but it has the same effect by duping the STACK and upping the ref of
431
+ // each X509 structure.
432
+ STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain) {
433
+ STACK_OF(X509) *ret;
434
+ size_t i;
435
+ ret = sk_X509_dup(chain);
436
+ for (i = 0; i < sk_X509_num(ret); i++) {
437
+ X509_up_ref(sk_X509_value(ret, i));
438
+ }
439
+ return ret;
450
440
  }