@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
@@ -48,8 +48,7 @@ uint64_t SIPHASH_24(const uint64_t key[2], const uint8_t *input,
48
48
  v[3] = key[1] ^ UINT64_C(0x7465646279746573);
49
49
 
50
50
  while (input_len >= sizeof(uint64_t)) {
51
- uint64_t m;
52
- memcpy(&m, input, sizeof(m));
51
+ uint64_t m = CRYPTO_load_u64_le(input);
53
52
  v[3] ^= m;
54
53
  siphash_round(v);
55
54
  siphash_round(v);
@@ -59,18 +58,16 @@ uint64_t SIPHASH_24(const uint64_t key[2], const uint8_t *input,
59
58
  input_len -= sizeof(uint64_t);
60
59
  }
61
60
 
62
- union {
63
- uint8_t bytes[8];
64
- uint64_t word;
65
- } last_block;
66
- last_block.word = 0;
67
- OPENSSL_memcpy(last_block.bytes, input, input_len);
68
- last_block.bytes[7] = orig_input_len & 0xff;
61
+ uint8_t last_block[8];
62
+ OPENSSL_memset(last_block, 0, sizeof(last_block));
63
+ OPENSSL_memcpy(last_block, input, input_len);
64
+ last_block[7] = orig_input_len & 0xff;
69
65
 
70
- v[3] ^= last_block.word;
66
+ uint64_t last_block_word = CRYPTO_load_u64_le(last_block);
67
+ v[3] ^= last_block_word;
71
68
  siphash_round(v);
72
69
  siphash_round(v);
73
- v[0] ^= last_block.word;
70
+ v[0] ^= last_block_word;
74
71
 
75
72
  v[2] ^= 0xff;
76
73
  siphash_round(v);
@@ -23,14 +23,12 @@
23
23
 
24
24
  TEST(SipHash, Basic) {
25
25
  // This is the example from appendix A of the SipHash paper.
26
- union {
27
- uint8_t bytes[16];
28
- uint64_t words[2];
29
- } key;
30
-
26
+ uint8_t key_bytes[16];
31
27
  for (unsigned i = 0; i < 16; i++) {
32
- key.bytes[i] = i;
28
+ key_bytes[i] = i;
33
29
  }
30
+ uint64_t key[2];
31
+ memcpy(key, key_bytes, sizeof(key));
34
32
 
35
33
  uint8_t input[15];
36
34
  for (unsigned i = 0; i < sizeof(input); i++) {
@@ -38,7 +36,7 @@ TEST(SipHash, Basic) {
38
36
  }
39
37
 
40
38
  EXPECT_EQ(UINT64_C(0xa129ca6149be45e5),
41
- SIPHASH_24(key.words, input, sizeof(input)));
39
+ SIPHASH_24(key, input, sizeof(input)));
42
40
  }
43
41
 
44
42
  TEST(SipHash, Vectors) {
@@ -131,7 +131,7 @@ void sk_free(_STACK *sk) {
131
131
  OPENSSL_free(sk);
132
132
  }
133
133
 
134
- void sk_pop_free_ex(_STACK *sk, void (*call_free_func)(stack_free_func, void *),
134
+ void sk_pop_free_ex(_STACK *sk, stack_call_free_func call_free_func,
135
135
  stack_free_func free_func) {
136
136
  if (sk == NULL) {
137
137
  return;
@@ -234,8 +234,7 @@ void *sk_delete_ptr(_STACK *sk, const void *p) {
234
234
  }
235
235
 
236
236
  int sk_find(const _STACK *sk, size_t *out_index, const void *p,
237
- int (*call_cmp_func)(stack_cmp_func, const void **,
238
- const void **)) {
237
+ stack_call_cmp_func call_cmp_func) {
239
238
  if (sk == NULL) {
240
239
  return 0;
241
240
  }
@@ -355,24 +354,43 @@ err:
355
354
  return NULL;
356
355
  }
357
356
 
358
- void sk_sort(_STACK *sk) {
357
+ #if defined(_MSC_VER)
358
+ struct sort_compare_ctx {
359
+ stack_call_cmp_func call_cmp_func;
360
+ stack_cmp_func cmp_func;
361
+ };
362
+
363
+ static int sort_compare(void *ctx_v, const void *a, const void *b) {
364
+ struct sort_compare_ctx *ctx = ctx_v;
365
+ return ctx->call_cmp_func(ctx->cmp_func, a, b);
366
+ }
367
+ #endif
368
+
369
+ void sk_sort(_STACK *sk, stack_call_cmp_func call_cmp_func) {
359
370
  if (sk == NULL || sk->comp == NULL || sk->sorted) {
360
371
  return;
361
372
  }
362
373
 
363
- // sk->comp is a function that takes pointers to pointers to elements, but
364
- // qsort take a comparison function that just takes pointers to elements.
365
- // However, since we're passing an array of pointers to qsort, we can just
366
- // cast the comparison function and everything works.
367
- //
368
- // TODO(davidben): This is undefined behavior, but the call is in libc so,
369
- // e.g., CFI does not notice. Unfortunately, |qsort| is missing a void*
370
- // parameter in its callback and |qsort_s| / |qsort_r| are a mess of
371
- // incompatibility.
372
374
  if (sk->num >= 2) {
375
+ #if defined(_MSC_VER)
376
+ // MSVC's |qsort_s| is different from the C11 one.
377
+ // https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/qsort-s?view=msvc-170
378
+ struct sort_compare_ctx ctx = {call_cmp_func, sk->comp};
379
+ qsort_s(sk->data, sk->num, sizeof(void *), sort_compare, &ctx);
380
+ #else
381
+ // sk->comp is a function that takes pointers to pointers to elements, but
382
+ // qsort take a comparison function that just takes pointers to elements.
383
+ // However, since we're passing an array of pointers to qsort, we can just
384
+ // cast the comparison function and everything works.
385
+ //
386
+ // TODO(davidben): This is undefined behavior, but the call is in libc so,
387
+ // e.g., CFI does not notice. |qsort| is missing a void* parameter in its
388
+ // callback, while no one defines |qsort_r| or |qsort_s| consistently. See
389
+ // https://stackoverflow.com/a/39561369
373
390
  int (*comp_func)(const void *, const void *) =
374
391
  (int (*)(const void *, const void *))(sk->comp);
375
392
  qsort(sk->data, sk->num, sizeof(void *), comp_func);
393
+ #endif
376
394
  }
377
395
  sk->sorted = 1;
378
396
  }
@@ -395,10 +413,9 @@ stack_cmp_func sk_set_cmp_func(_STACK *sk, stack_cmp_func comp) {
395
413
  return old;
396
414
  }
397
415
 
398
- _STACK *sk_deep_copy(const _STACK *sk,
399
- void *(*call_copy_func)(stack_copy_func, void *),
416
+ _STACK *sk_deep_copy(const _STACK *sk, stack_call_copy_func call_copy_func,
400
417
  stack_copy_func copy_func,
401
- void (*call_free_func)(stack_free_func, void *),
418
+ stack_call_free_func call_free_func,
402
419
  stack_free_func free_func) {
403
420
  _STACK *ret = sk_dup(sk);
404
421
  if (ret == NULL) {
@@ -26,10 +26,8 @@
26
26
 
27
27
  OPENSSL_STATIC_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(pthread_rwlock_t),
28
28
  "CRYPTO_MUTEX is too small");
29
- #if defined(__GNUC__) || defined(__clang__)
30
29
  OPENSSL_STATIC_ASSERT(alignof(CRYPTO_MUTEX) >= alignof(pthread_rwlock_t),
31
30
  "CRYPTO_MUTEX has insufficient alignment");
32
- #endif
33
31
 
34
32
  void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) {
35
33
  if (pthread_rwlock_init((pthread_rwlock_t *) lock, NULL) != 0) {
@@ -29,10 +29,8 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
29
29
 
30
30
  OPENSSL_STATIC_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(SRWLOCK),
31
31
  "CRYPTO_MUTEX is too small");
32
- #if defined(__GNUC__) || defined(__clang__)
33
32
  OPENSSL_STATIC_ASSERT(alignof(CRYPTO_MUTEX) >= alignof(SRWLOCK),
34
33
  "CRYPTO_MUTEX has insufficient alignment");
35
- #endif
36
34
 
37
35
  static BOOL CALLBACK call_once_init(INIT_ONCE *once, void *arg, void **out) {
38
36
  void (**init)(void) = (void (**)(void))arg;
@@ -93,6 +93,9 @@ DEFINE_STACK_OF(TRUST_TOKEN_PRETOKEN)
93
93
  // functions for |TRUST_TOKENS_experiment_v1|'s PMBTokens construction which
94
94
  // uses P-384.
95
95
  int pmbtoken_exp1_generate_key(CBB *out_private, CBB *out_public);
96
+ int pmbtoken_exp1_derive_key_from_secret(CBB *out_private, CBB *out_public,
97
+ const uint8_t *secret,
98
+ size_t secret_len);
96
99
  int pmbtoken_exp1_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key,
97
100
  const uint8_t *in, size_t len);
98
101
  int pmbtoken_exp1_issuer_key_from_bytes(TRUST_TOKEN_ISSUER_KEY *key,
@@ -118,6 +121,9 @@ OPENSSL_EXPORT int pmbtoken_exp1_get_h_for_testing(uint8_t out[97]);
118
121
  // functions for |TRUST_TOKENS_experiment_v2|'s PMBTokens construction which
119
122
  // uses P-384.
120
123
  int pmbtoken_exp2_generate_key(CBB *out_private, CBB *out_public);
124
+ int pmbtoken_exp2_derive_key_from_secret(CBB *out_private, CBB *out_public,
125
+ const uint8_t *secret,
126
+ size_t secret_len);
121
127
  int pmbtoken_exp2_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key,
122
128
  const uint8_t *in, size_t len);
123
129
  int pmbtoken_exp2_issuer_key_from_bytes(TRUST_TOKEN_ISSUER_KEY *key,
@@ -153,6 +159,8 @@ OPENSSL_EXPORT int pmbtoken_exp2_get_h_for_testing(uint8_t out[97]);
153
159
  // functions for |TRUST_TOKENS_experiment_v2|'s VOPRF construction which uses
154
160
  // P-384.
155
161
  int voprf_exp2_generate_key(CBB *out_private, CBB *out_public);
162
+ int voprf_exp2_derive_key_from_secret(CBB *out_private, CBB *out_public,
163
+ const uint8_t *secret, size_t secret_len);
156
164
  int voprf_exp2_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key,
157
165
  const uint8_t *in, size_t len);
158
166
  int voprf_exp2_issuer_key_from_bytes(TRUST_TOKEN_ISSUER_KEY *key,
@@ -179,6 +187,12 @@ struct trust_token_method_st {
179
187
  // zero on failure.
180
188
  int (*generate_key)(CBB *out_private, CBB *out_public);
181
189
 
190
+ // derive_key_from_secret deterministically derives a keypair based on
191
+ // |secret| and writes their serialized forms into |out_private| and
192
+ // |out_public|. It returns one on success and zero on failure.
193
+ int (*derive_key_from_secret)(CBB *out_private, CBB *out_public,
194
+ const uint8_t *secret, size_t secret_len);
195
+
182
196
  // client_key_from_bytes decodes a client key from |in| and sets |key|
183
197
  // to the resulting key. It returns one on success and zero
184
198
  // on failure.
@@ -37,6 +37,8 @@ typedef int (*hash_s_func_t)(const EC_GROUP *group, EC_RAW_POINT *out,
37
37
  const uint8_t s[TRUST_TOKEN_NONCE_SIZE]);
38
38
  typedef int (*hash_c_func_t)(const EC_GROUP *group, EC_SCALAR *out,
39
39
  uint8_t *buf, size_t len);
40
+ typedef int (*hash_to_scalar_func_t)(const EC_GROUP *group, EC_SCALAR *out,
41
+ uint8_t *buf, size_t len);
40
42
 
41
43
  typedef struct {
42
44
  const EC_GROUP *group;
@@ -52,6 +54,9 @@ typedef struct {
52
54
  // hash_c implements the H_c operation in PMBTokens. It returns one on success
53
55
  // and zero on error.
54
56
  hash_c_func_t hash_c;
57
+ // hash_to_scalar implements the HashToScalar operation for PMBTokens. It
58
+ // returns one on success and zero on error.
59
+ hash_to_scalar_func_t hash_to_scalar;
55
60
  int prefix_point : 1;
56
61
  } PMBTOKEN_METHOD;
57
62
 
@@ -60,7 +65,9 @@ static const uint8_t kDefaultAdditionalData[32] = {0};
60
65
  static int pmbtoken_init_method(PMBTOKEN_METHOD *method, int curve_nid,
61
66
  const uint8_t *h_bytes, size_t h_len,
62
67
  hash_t_func_t hash_t, hash_s_func_t hash_s,
63
- hash_c_func_t hash_c, int prefix_point) {
68
+ hash_c_func_t hash_c,
69
+ hash_to_scalar_func_t hash_to_scalar,
70
+ int prefix_point) {
64
71
  method->group = EC_GROUP_new_by_curve_name(curve_nid);
65
72
  if (method->group == NULL) {
66
73
  return 0;
@@ -69,6 +76,7 @@ static int pmbtoken_init_method(PMBTOKEN_METHOD *method, int curve_nid,
69
76
  method->hash_t = hash_t;
70
77
  method->hash_s = hash_s;
71
78
  method->hash_c = hash_c;
79
+ method->hash_to_scalar = hash_to_scalar;
72
80
  method->prefix_point = prefix_point;
73
81
 
74
82
  EC_AFFINE h;
@@ -85,21 +93,32 @@ static int pmbtoken_init_method(PMBTOKEN_METHOD *method, int curve_nid,
85
93
  return 1;
86
94
  }
87
95
 
88
- // generate_keypair generates a keypair for the PMBTokens construction.
89
- // |out_x| and |out_y| are set to the secret half of the keypair, while
90
- // |*out_pub| is set to the public half of the keypair. It returns one on
91
- // success and zero on failure.
92
- static int generate_keypair(const PMBTOKEN_METHOD *method, EC_SCALAR *out_x,
93
- EC_SCALAR *out_y, EC_RAW_POINT *out_pub) {
94
- if (!ec_random_nonzero_scalar(method->group, out_x, kDefaultAdditionalData) ||
95
- !ec_random_nonzero_scalar(method->group, out_y, kDefaultAdditionalData) ||
96
- !ec_point_mul_scalar_precomp(method->group, out_pub, &method->g_precomp,
97
- out_x, &method->h_precomp, out_y, NULL,
98
- NULL)) {
99
- OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_MALLOC_FAILURE);
100
- return 0;
96
+ static int derive_scalar_from_secret(const PMBTOKEN_METHOD *method,
97
+ EC_SCALAR *out, const uint8_t *secret,
98
+ size_t secret_len, uint8_t scalar_id) {
99
+ static const uint8_t kKeygenLabel[] = "TrustTokenPMBTokenKeyGen";
100
+
101
+ int ok = 0;
102
+ CBB cbb;
103
+ CBB_zero(&cbb);
104
+ uint8_t *buf = NULL;
105
+ size_t len;
106
+ if (!CBB_init(&cbb, 0) ||
107
+ !CBB_add_bytes(&cbb, kKeygenLabel, sizeof(kKeygenLabel)) ||
108
+ !CBB_add_u8(&cbb, scalar_id) ||
109
+ !CBB_add_bytes(&cbb, secret, secret_len) ||
110
+ !CBB_finish(&cbb, &buf, &len) ||
111
+ !method->hash_to_scalar(method->group, out, buf, len)) {
112
+ OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE);
113
+ goto err;
101
114
  }
102
- return 1;
115
+
116
+ ok = 1;
117
+
118
+ err:
119
+ CBB_cleanup(&cbb);
120
+ OPENSSL_free(buf);
121
+ return ok;
103
122
  }
104
123
 
105
124
  static int point_to_cbb(CBB *out, const EC_GROUP *group,
@@ -165,19 +184,24 @@ static int mul_public_3(const EC_GROUP *group, EC_RAW_POINT *out,
165
184
  scalars, 3);
166
185
  }
167
186
 
168
- static int pmbtoken_generate_key(const PMBTOKEN_METHOD *method,
169
- CBB *out_private, CBB *out_public) {
187
+ static int pmbtoken_compute_keys(const PMBTOKEN_METHOD *method,
188
+ CBB *out_private, CBB *out_public,
189
+ const EC_SCALAR *x0, const EC_SCALAR *y0,
190
+ const EC_SCALAR *x1, const EC_SCALAR *y1,
191
+ const EC_SCALAR *xs, const EC_SCALAR *ys) {
170
192
  const EC_GROUP *group = method->group;
171
193
  EC_RAW_POINT pub[3];
172
- EC_SCALAR x0, y0, x1, y1, xs, ys;
173
- if (!generate_keypair(method, &x0, &y0, &pub[0]) ||
174
- !generate_keypair(method, &x1, &y1, &pub[1]) ||
175
- !generate_keypair(method, &xs, &ys, &pub[2])) {
194
+ if (!ec_point_mul_scalar_precomp(group, &pub[0], &method->g_precomp,
195
+ x0, &method->h_precomp, y0, NULL, NULL) ||
196
+ !ec_point_mul_scalar_precomp(group, &pub[1], &method->g_precomp,
197
+ x1, &method->h_precomp, y1, NULL, NULL) ||
198
+ !ec_point_mul_scalar_precomp(method->group, &pub[2], &method->g_precomp,
199
+ xs, &method->h_precomp, ys, NULL, NULL)) {
176
200
  OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE);
177
201
  return 0;
178
202
  }
179
203
 
180
- const EC_SCALAR *scalars[] = {&x0, &y0, &x1, &y1, &xs, &ys};
204
+ const EC_SCALAR *scalars[] = {x0, y0, x1, y1, xs, ys};
181
205
  size_t scalar_len = BN_num_bytes(&group->order);
182
206
  for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(scalars); i++) {
183
207
  uint8_t *buf;
@@ -206,6 +230,42 @@ static int pmbtoken_generate_key(const PMBTOKEN_METHOD *method,
206
230
  return 1;
207
231
  }
208
232
 
233
+ static int pmbtoken_generate_key(const PMBTOKEN_METHOD *method,
234
+ CBB *out_private, CBB *out_public) {
235
+ EC_SCALAR x0, y0, x1, y1, xs, ys;
236
+ if (!ec_random_nonzero_scalar(method->group, &x0, kDefaultAdditionalData) ||
237
+ !ec_random_nonzero_scalar(method->group, &y0, kDefaultAdditionalData) ||
238
+ !ec_random_nonzero_scalar(method->group, &x1, kDefaultAdditionalData) ||
239
+ !ec_random_nonzero_scalar(method->group, &y1, kDefaultAdditionalData) ||
240
+ !ec_random_nonzero_scalar(method->group, &xs, kDefaultAdditionalData) ||
241
+ !ec_random_nonzero_scalar(method->group, &ys, kDefaultAdditionalData)) {
242
+ OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE);
243
+ return 0;
244
+ }
245
+
246
+ return pmbtoken_compute_keys(method, out_private, out_public, &x0, &y0, &x1,
247
+ &y1, &xs, &ys);
248
+ }
249
+
250
+ static int pmbtoken_derive_key_from_secret(const PMBTOKEN_METHOD *method,
251
+ CBB *out_private, CBB *out_public,
252
+ const uint8_t *secret,
253
+ size_t secret_len) {
254
+ EC_SCALAR x0, y0, x1, y1, xs, ys;
255
+ if (!derive_scalar_from_secret(method, &x0, secret, secret_len, 0) ||
256
+ !derive_scalar_from_secret(method, &y0, secret, secret_len, 1) ||
257
+ !derive_scalar_from_secret(method, &x1, secret, secret_len, 2) ||
258
+ !derive_scalar_from_secret(method, &y1, secret, secret_len, 3) ||
259
+ !derive_scalar_from_secret(method, &xs, secret, secret_len, 4) ||
260
+ !derive_scalar_from_secret(method, &ys, secret, secret_len, 5)) {
261
+ OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE);
262
+ return 0;
263
+ }
264
+
265
+ return pmbtoken_compute_keys(method, out_private, out_public, &x0, &y0, &x1,
266
+ &y1, &xs, &ys);
267
+ }
268
+
209
269
  static int pmbtoken_client_key_from_bytes(const PMBTOKEN_METHOD *method,
210
270
  TRUST_TOKEN_CLIENT_KEY *key,
211
271
  const uint8_t *in, size_t len) {
@@ -1140,6 +1200,13 @@ static int pmbtoken_exp1_hash_c(const EC_GROUP *group, EC_SCALAR *out,
1140
1200
  group, out, kHashCLabel, sizeof(kHashCLabel), buf, len);
1141
1201
  }
1142
1202
 
1203
+ static int pmbtoken_exp1_hash_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
1204
+ uint8_t *buf, size_t len) {
1205
+ const uint8_t kHashLabel[] = "PMBTokens Experiment V1 HashToScalar";
1206
+ return ec_hash_to_scalar_p384_xmd_sha512_draft07(
1207
+ group, out, kHashLabel, sizeof(kHashLabel), buf, len);
1208
+ }
1209
+
1143
1210
  static int pmbtoken_exp1_ok = 0;
1144
1211
  static PMBTOKEN_METHOD pmbtoken_exp1_method;
1145
1212
  static CRYPTO_once_t pmbtoken_exp1_method_once = CRYPTO_ONCE_INIT;
@@ -1159,10 +1226,10 @@ static void pmbtoken_exp1_init_method_impl(void) {
1159
1226
  0x87, 0xc3, 0x95, 0xd0, 0x13, 0xb7, 0x0b, 0x5c, 0xc7,
1160
1227
  };
1161
1228
 
1162
- pmbtoken_exp1_ok =
1163
- pmbtoken_init_method(&pmbtoken_exp1_method, NID_secp384r1, kH, sizeof(kH),
1164
- pmbtoken_exp1_hash_t, pmbtoken_exp1_hash_s,
1165
- pmbtoken_exp1_hash_c, 1);
1229
+ pmbtoken_exp1_ok = pmbtoken_init_method(
1230
+ &pmbtoken_exp1_method, NID_secp384r1, kH, sizeof(kH),
1231
+ pmbtoken_exp1_hash_t, pmbtoken_exp1_hash_s, pmbtoken_exp1_hash_c,
1232
+ pmbtoken_exp1_hash_to_scalar, 1);
1166
1233
  }
1167
1234
 
1168
1235
  static int pmbtoken_exp1_init_method(void) {
@@ -1182,6 +1249,17 @@ int pmbtoken_exp1_generate_key(CBB *out_private, CBB *out_public) {
1182
1249
  return pmbtoken_generate_key(&pmbtoken_exp1_method, out_private, out_public);
1183
1250
  }
1184
1251
 
1252
+ int pmbtoken_exp1_derive_key_from_secret(CBB *out_private, CBB *out_public,
1253
+ const uint8_t *secret,
1254
+ size_t secret_len) {
1255
+ if (!pmbtoken_exp1_init_method()) {
1256
+ return 0;
1257
+ }
1258
+
1259
+ return pmbtoken_derive_key_from_secret(&pmbtoken_exp1_method, out_private,
1260
+ out_public, secret, secret_len);
1261
+ }
1262
+
1185
1263
  int pmbtoken_exp1_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key,
1186
1264
  const uint8_t *in, size_t len) {
1187
1265
  if (!pmbtoken_exp1_init_method()) {
@@ -1290,6 +1368,13 @@ static int pmbtoken_exp2_hash_c(const EC_GROUP *group, EC_SCALAR *out,
1290
1368
  group, out, kHashCLabel, sizeof(kHashCLabel), buf, len);
1291
1369
  }
1292
1370
 
1371
+ static int pmbtoken_exp2_hash_to_scalar(const EC_GROUP *group, EC_SCALAR *out,
1372
+ uint8_t *buf, size_t len) {
1373
+ const uint8_t kHashLabel[] = "PMBTokens Experiment V2 HashToScalar";
1374
+ return ec_hash_to_scalar_p384_xmd_sha512_draft07(
1375
+ group, out, kHashLabel, sizeof(kHashLabel), buf, len);
1376
+ }
1377
+
1293
1378
  static int pmbtoken_exp2_ok = 0;
1294
1379
  static PMBTOKEN_METHOD pmbtoken_exp2_method;
1295
1380
  static CRYPTO_once_t pmbtoken_exp2_method_once = CRYPTO_ONCE_INIT;
@@ -1309,10 +1394,10 @@ static void pmbtoken_exp2_init_method_impl(void) {
1309
1394
  0x25, 0x62, 0xbf, 0x59, 0xb2, 0xd2, 0x3d, 0x71, 0xff
1310
1395
  };
1311
1396
 
1312
- pmbtoken_exp2_ok =
1313
- pmbtoken_init_method(&pmbtoken_exp2_method, NID_secp384r1, kH, sizeof(kH),
1314
- pmbtoken_exp2_hash_t, pmbtoken_exp2_hash_s,
1315
- pmbtoken_exp2_hash_c, 0);
1397
+ pmbtoken_exp2_ok = pmbtoken_init_method(
1398
+ &pmbtoken_exp2_method, NID_secp384r1, kH, sizeof(kH),
1399
+ pmbtoken_exp2_hash_t, pmbtoken_exp2_hash_s, pmbtoken_exp2_hash_c,
1400
+ pmbtoken_exp2_hash_to_scalar, 0);
1316
1401
  }
1317
1402
 
1318
1403
  static int pmbtoken_exp2_init_method(void) {
@@ -1332,6 +1417,18 @@ int pmbtoken_exp2_generate_key(CBB *out_private, CBB *out_public) {
1332
1417
  return pmbtoken_generate_key(&pmbtoken_exp2_method, out_private, out_public);
1333
1418
  }
1334
1419
 
1420
+
1421
+ int pmbtoken_exp2_derive_key_from_secret(CBB *out_private, CBB *out_public,
1422
+ const uint8_t *secret,
1423
+ size_t secret_len) {
1424
+ if (!pmbtoken_exp2_init_method()) {
1425
+ return 0;
1426
+ }
1427
+
1428
+ return pmbtoken_derive_key_from_secret(&pmbtoken_exp2_method, out_private,
1429
+ out_public, secret, secret_len);
1430
+ }
1431
+
1335
1432
  int pmbtoken_exp2_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key,
1336
1433
  const uint8_t *in, size_t len) {
1337
1434
  if (!pmbtoken_exp2_init_method()) {
@@ -30,6 +30,7 @@
30
30
  const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v1(void) {
31
31
  static const TRUST_TOKEN_METHOD kMethod = {
32
32
  pmbtoken_exp1_generate_key,
33
+ pmbtoken_exp1_derive_key_from_secret,
33
34
  pmbtoken_exp1_client_key_from_bytes,
34
35
  pmbtoken_exp1_issuer_key_from_bytes,
35
36
  pmbtoken_exp1_blind,
@@ -46,6 +47,7 @@ const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v1(void) {
46
47
  const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v2_voprf(void) {
47
48
  static const TRUST_TOKEN_METHOD kMethod = {
48
49
  voprf_exp2_generate_key,
50
+ voprf_exp2_derive_key_from_secret,
49
51
  voprf_exp2_client_key_from_bytes,
50
52
  voprf_exp2_issuer_key_from_bytes,
51
53
  voprf_exp2_blind,
@@ -62,6 +64,7 @@ const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v2_voprf(void) {
62
64
  const TRUST_TOKEN_METHOD *TRUST_TOKEN_experiment_v2_pmb(void) {
63
65
  static const TRUST_TOKEN_METHOD kMethod = {
64
66
  pmbtoken_exp2_generate_key,
67
+ pmbtoken_exp2_derive_key_from_secret,
65
68
  pmbtoken_exp2_client_key_from_bytes,
66
69
  pmbtoken_exp2_issuer_key_from_bytes,
67
70
  pmbtoken_exp2_blind,
@@ -140,6 +143,43 @@ err:
140
143
  return ret;
141
144
  }
142
145
 
146
+ int TRUST_TOKEN_derive_key_from_secret(
147
+ const TRUST_TOKEN_METHOD *method, uint8_t *out_priv_key,
148
+ size_t *out_priv_key_len, size_t max_priv_key_len, uint8_t *out_pub_key,
149
+ size_t *out_pub_key_len, size_t max_pub_key_len, uint32_t id,
150
+ const uint8_t *secret, size_t secret_len) {
151
+ // Prepend the key ID in front of the PMBTokens format.
152
+ int ret = 0;
153
+ CBB priv_cbb, pub_cbb;
154
+ CBB_zero(&priv_cbb);
155
+ CBB_zero(&pub_cbb);
156
+ if (!CBB_init_fixed(&priv_cbb, out_priv_key, max_priv_key_len) ||
157
+ !CBB_init_fixed(&pub_cbb, out_pub_key, max_pub_key_len) ||
158
+ !CBB_add_u32(&priv_cbb, id) ||
159
+ !CBB_add_u32(&pub_cbb, id)) {
160
+ OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
161
+ goto err;
162
+ }
163
+
164
+ if (!method->derive_key_from_secret(&priv_cbb, &pub_cbb, secret,
165
+ secret_len)) {
166
+ goto err;
167
+ }
168
+
169
+ if (!CBB_finish(&priv_cbb, NULL, out_priv_key_len) ||
170
+ !CBB_finish(&pub_cbb, NULL, out_pub_key_len)) {
171
+ OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BUFFER_TOO_SMALL);
172
+ goto err;
173
+ }
174
+
175
+ ret = 1;
176
+
177
+ err:
178
+ CBB_cleanup(&priv_cbb);
179
+ CBB_cleanup(&pub_cbb);
180
+ return ret;
181
+ }
182
+
143
183
  TRUST_TOKEN_CLIENT *TRUST_TOKEN_CLIENT_new(const TRUST_TOKEN_METHOD *method,
144
184
  size_t max_batchsize) {
145
185
  if (max_batchsize > 0xffff) {