@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
@@ -80,603 +80,586 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
80
80
  static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
81
81
  const ASN1_TEMPLATE *tt, int tag, int aclass);
82
82
 
83
- /*
84
- * Top level i2d equivalents
85
- */
86
-
87
- int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
88
- {
89
- if (out && !*out) {
90
- unsigned char *p, *buf;
91
- int len = ASN1_item_ex_i2d(&val, NULL, it, /*tag=*/-1, /*aclass=*/0);
92
- if (len <= 0) {
93
- return len;
94
- }
95
- buf = OPENSSL_malloc(len);
96
- if (!buf) {
97
- OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
98
- return -1;
99
- }
100
- p = buf;
101
- int len2 = ASN1_item_ex_i2d(&val, &p, it, /*tag=*/-1, /*aclass=*/0);
102
- if (len2 <= 0) {
103
- return len2;
104
- }
105
- assert(len == len2);
106
- *out = buf;
107
- return len;
83
+ // Top level i2d equivalents
84
+
85
+ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it) {
86
+ if (out && !*out) {
87
+ unsigned char *p, *buf;
88
+ int len = ASN1_item_ex_i2d(&val, NULL, it, /*tag=*/-1, /*aclass=*/0);
89
+ if (len <= 0) {
90
+ return len;
91
+ }
92
+ buf = OPENSSL_malloc(len);
93
+ if (!buf) {
94
+ OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
95
+ return -1;
108
96
  }
97
+ p = buf;
98
+ int len2 = ASN1_item_ex_i2d(&val, &p, it, /*tag=*/-1, /*aclass=*/0);
99
+ if (len2 <= 0) {
100
+ return len2;
101
+ }
102
+ assert(len == len2);
103
+ *out = buf;
104
+ return len;
105
+ }
109
106
 
110
- return ASN1_item_ex_i2d(&val, out, it, /*tag=*/-1, /*aclass=*/0);
107
+ return ASN1_item_ex_i2d(&val, out, it, /*tag=*/-1, /*aclass=*/0);
111
108
  }
112
109
 
113
- /*
114
- * Encode an item, taking care of IMPLICIT tagging (if any). This function
115
- * performs the normal item handling: it can be used in external types.
116
- */
110
+ // Encode an item, taking care of IMPLICIT tagging (if any). This function
111
+ // performs the normal item handling: it can be used in external types.
117
112
 
118
113
  int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
119
- const ASN1_ITEM *it, int tag, int aclass)
120
- {
121
- int ret = asn1_item_ex_i2d_opt(pval, out, it, tag, aclass, /*optional=*/0);
122
- assert(ret != 0);
123
- return ret;
114
+ const ASN1_ITEM *it, int tag, int aclass) {
115
+ int ret = asn1_item_ex_i2d_opt(pval, out, it, tag, aclass, /*optional=*/0);
116
+ assert(ret != 0);
117
+ return ret;
124
118
  }
125
119
 
126
- /* asn1_item_ex_i2d_opt behaves like |ASN1_item_ex_i2d| but, if |optional| is
127
- * non-zero and |*pval| is omitted, it returns zero and writes no bytes. */
120
+ // asn1_item_ex_i2d_opt behaves like |ASN1_item_ex_i2d| but, if |optional| is
121
+ // non-zero and |*pval| is omitted, it returns zero and writes no bytes.
128
122
  int asn1_item_ex_i2d_opt(ASN1_VALUE **pval, unsigned char **out,
129
123
  const ASN1_ITEM *it, int tag, int aclass,
130
- int optional)
131
- {
132
- const ASN1_TEMPLATE *tt = NULL;
133
- int i, seqcontlen, seqlen;
134
-
135
- /* Historically, |aclass| was repurposed to pass additional flags into the
136
- * encoding process. */
137
- assert((aclass & ASN1_TFLG_TAG_CLASS) == aclass);
138
- /* If not overridding the tag, |aclass| is ignored and should be zero. */
139
- assert(tag != -1 || aclass == 0);
140
-
141
- /* All fields are pointers, except for boolean |ASN1_ITYPE_PRIMITIVE|s.
142
- * Optional primitives are handled later. */
143
- if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) {
144
- if (optional) {
145
- return 0;
146
- }
147
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
148
- return -1;
124
+ int optional) {
125
+ const ASN1_TEMPLATE *tt = NULL;
126
+ int i, seqcontlen, seqlen;
127
+
128
+ // Historically, |aclass| was repurposed to pass additional flags into the
129
+ // encoding process.
130
+ assert((aclass & ASN1_TFLG_TAG_CLASS) == aclass);
131
+ // If not overridding the tag, |aclass| is ignored and should be zero.
132
+ assert(tag != -1 || aclass == 0);
133
+
134
+ // All fields are pointers, except for boolean |ASN1_ITYPE_PRIMITIVE|s.
135
+ // Optional primitives are handled later.
136
+ if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) {
137
+ if (optional) {
138
+ return 0;
149
139
  }
140
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
141
+ return -1;
142
+ }
150
143
 
151
- switch (it->itype) {
152
-
144
+ switch (it->itype) {
153
145
  case ASN1_ITYPE_PRIMITIVE:
154
- if (it->templates) {
155
- if (it->templates->flags & ASN1_TFLG_OPTIONAL) {
156
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
157
- return -1;
158
- }
159
- return asn1_template_ex_i2d(pval, out, it->templates, tag, aclass);
146
+ if (it->templates) {
147
+ if (it->templates->flags & ASN1_TFLG_OPTIONAL) {
148
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
149
+ return -1;
160
150
  }
161
- return asn1_i2d_ex_primitive(pval, out, it, tag, aclass, optional);
151
+ return asn1_template_ex_i2d(pval, out, it->templates, tag, aclass);
152
+ }
153
+ return asn1_i2d_ex_primitive(pval, out, it, tag, aclass, optional);
162
154
 
163
155
  case ASN1_ITYPE_MSTRING:
164
- /*
165
- * It never makes sense for multi-strings to have implicit tagging, so
166
- * if tag != -1, then this looks like an error in the template.
167
- */
168
- if (tag != -1) {
169
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
170
- return -1;
171
- }
172
- return asn1_i2d_ex_primitive(pval, out, it, -1, 0, optional);
156
+ // It never makes sense for multi-strings to have implicit tagging, so
157
+ // if tag != -1, then this looks like an error in the template.
158
+ if (tag != -1) {
159
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
160
+ return -1;
161
+ }
162
+ return asn1_i2d_ex_primitive(pval, out, it, -1, 0, optional);
173
163
 
174
164
  case ASN1_ITYPE_CHOICE: {
175
- /*
176
- * It never makes sense for CHOICE types to have implicit tagging, so if
177
- * tag != -1, then this looks like an error in the template.
178
- */
179
- if (tag != -1) {
180
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
181
- return -1;
182
- }
183
- i = asn1_get_choice_selector(pval, it);
184
- if (i < 0 || i >= it->tcount) {
185
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_NO_MATCHING_CHOICE_TYPE);
186
- return -1;
187
- }
188
- const ASN1_TEMPLATE *chtt = it->templates + i;
189
- if (chtt->flags & ASN1_TFLG_OPTIONAL) {
190
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
191
- return -1;
192
- }
193
- ASN1_VALUE **pchval = asn1_get_field_ptr(pval, chtt);
194
- return asn1_template_ex_i2d(pchval, out, chtt, -1, 0);
165
+ // It never makes sense for CHOICE types to have implicit tagging, so if
166
+ // tag != -1, then this looks like an error in the template.
167
+ if (tag != -1) {
168
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
169
+ return -1;
170
+ }
171
+ i = asn1_get_choice_selector(pval, it);
172
+ if (i < 0 || i >= it->tcount) {
173
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_NO_MATCHING_CHOICE_TYPE);
174
+ return -1;
175
+ }
176
+ const ASN1_TEMPLATE *chtt = it->templates + i;
177
+ if (chtt->flags & ASN1_TFLG_OPTIONAL) {
178
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
179
+ return -1;
180
+ }
181
+ ASN1_VALUE **pchval = asn1_get_field_ptr(pval, chtt);
182
+ return asn1_template_ex_i2d(pchval, out, chtt, -1, 0);
195
183
  }
196
184
 
197
185
  case ASN1_ITYPE_EXTERN: {
198
- /* If new style i2d it does all the work */
199
- const ASN1_EXTERN_FUNCS *ef = it->funcs;
200
- int ret = ef->asn1_ex_i2d(pval, out, it, tag, aclass);
201
- if (ret == 0) {
202
- /* |asn1_ex_i2d| should never return zero. We have already checked
203
- * for optional values generically, and |ASN1_ITYPE_EXTERN| fields
204
- * must be pointers. */
205
- OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
206
- return -1;
207
- }
208
- return ret;
186
+ // If new style i2d it does all the work
187
+ const ASN1_EXTERN_FUNCS *ef = it->funcs;
188
+ int ret = ef->asn1_ex_i2d(pval, out, it, tag, aclass);
189
+ if (ret == 0) {
190
+ // |asn1_ex_i2d| should never return zero. We have already checked
191
+ // for optional values generically, and |ASN1_ITYPE_EXTERN| fields
192
+ // must be pointers.
193
+ OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
194
+ return -1;
195
+ }
196
+ return ret;
209
197
  }
210
198
 
211
199
  case ASN1_ITYPE_SEQUENCE: {
212
- i = asn1_enc_restore(&seqcontlen, out, pval, it);
213
- /* An error occurred */
214
- if (i < 0)
215
- return -1;
216
- /* We have a valid cached encoding... */
217
- if (i > 0)
218
- return seqcontlen;
219
- /* Otherwise carry on */
220
- seqcontlen = 0;
221
- /* If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL */
222
- if (tag == -1) {
223
- tag = V_ASN1_SEQUENCE;
224
- aclass = V_ASN1_UNIVERSAL;
200
+ i = asn1_enc_restore(&seqcontlen, out, pval, it);
201
+ // An error occurred
202
+ if (i < 0) {
203
+ return -1;
204
+ }
205
+ // We have a valid cached encoding...
206
+ if (i > 0) {
207
+ return seqcontlen;
208
+ }
209
+ // Otherwise carry on
210
+ seqcontlen = 0;
211
+ // If no IMPLICIT tagging set to SEQUENCE, UNIVERSAL
212
+ if (tag == -1) {
213
+ tag = V_ASN1_SEQUENCE;
214
+ aclass = V_ASN1_UNIVERSAL;
215
+ }
216
+ // First work out sequence content length
217
+ for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
218
+ const ASN1_TEMPLATE *seqtt;
219
+ ASN1_VALUE **pseqval;
220
+ int tmplen;
221
+ seqtt = asn1_do_adb(pval, tt, 1);
222
+ if (!seqtt) {
223
+ return -1;
225
224
  }
226
- /* First work out sequence content length */
227
- for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
228
- const ASN1_TEMPLATE *seqtt;
229
- ASN1_VALUE **pseqval;
230
- int tmplen;
231
- seqtt = asn1_do_adb(pval, tt, 1);
232
- if (!seqtt)
233
- return -1;
234
- pseqval = asn1_get_field_ptr(pval, seqtt);
235
- tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, 0);
236
- if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen))
237
- return -1;
238
- seqcontlen += tmplen;
225
+ pseqval = asn1_get_field_ptr(pval, seqtt);
226
+ tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, 0);
227
+ if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen)) {
228
+ return -1;
239
229
  }
230
+ seqcontlen += tmplen;
231
+ }
240
232
 
241
- seqlen = ASN1_object_size(/*constructed=*/1, seqcontlen, tag);
242
- if (!out || seqlen == -1)
243
- return seqlen;
244
- /* Output SEQUENCE header */
245
- ASN1_put_object(out, /*constructed=*/1, seqcontlen, tag, aclass);
246
- for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
247
- const ASN1_TEMPLATE *seqtt;
248
- ASN1_VALUE **pseqval;
249
- seqtt = asn1_do_adb(pval, tt, 1);
250
- if (!seqtt)
251
- return -1;
252
- pseqval = asn1_get_field_ptr(pval, seqtt);
253
- if (asn1_template_ex_i2d(pseqval, out, seqtt, -1, 0) < 0) {
254
- return -1;
255
- }
256
- }
233
+ seqlen = ASN1_object_size(/*constructed=*/1, seqcontlen, tag);
234
+ if (!out || seqlen == -1) {
257
235
  return seqlen;
236
+ }
237
+ // Output SEQUENCE header
238
+ ASN1_put_object(out, /*constructed=*/1, seqcontlen, tag, aclass);
239
+ for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
240
+ const ASN1_TEMPLATE *seqtt;
241
+ ASN1_VALUE **pseqval;
242
+ seqtt = asn1_do_adb(pval, tt, 1);
243
+ if (!seqtt) {
244
+ return -1;
245
+ }
246
+ pseqval = asn1_get_field_ptr(pval, seqtt);
247
+ if (asn1_template_ex_i2d(pseqval, out, seqtt, -1, 0) < 0) {
248
+ return -1;
249
+ }
250
+ }
251
+ return seqlen;
258
252
  }
259
253
 
260
254
  default:
261
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
262
- return -1;
263
- }
255
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
256
+ return -1;
257
+ }
264
258
  }
265
259
 
266
- /* asn1_template_ex_i2d behaves like |asn1_item_ex_i2d_opt| but uses an
267
- * |ASN1_TEMPLATE| instead of an |ASN1_ITEM|. An |ASN1_TEMPLATE| wraps an
268
- * |ASN1_ITEM| with modifiers such as tagging, SEQUENCE or SET, etc. Instead of
269
- * taking an |optional| parameter, it uses the |ASN1_TFLG_OPTIONAL| flag. */
260
+ // asn1_template_ex_i2d behaves like |asn1_item_ex_i2d_opt| but uses an
261
+ // |ASN1_TEMPLATE| instead of an |ASN1_ITEM|. An |ASN1_TEMPLATE| wraps an
262
+ // |ASN1_ITEM| with modifiers such as tagging, SEQUENCE or SET, etc. Instead of
263
+ // taking an |optional| parameter, it uses the |ASN1_TFLG_OPTIONAL| flag.
270
264
  static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
271
- const ASN1_TEMPLATE *tt, int tag, int iclass)
272
- {
273
- int i, ret, flags, ttag, tclass;
274
- size_t j;
275
- flags = tt->flags;
276
-
277
- /* Historically, |iclass| was repurposed to pass additional flags into the
278
- * encoding process. */
279
- assert((iclass & ASN1_TFLG_TAG_CLASS) == iclass);
280
- /* If not overridding the tag, |iclass| is ignored and should be zero. */
281
- assert(tag != -1 || iclass == 0);
282
-
283
- /*
284
- * Work out tag and class to use: tagging may come either from the
285
- * template or the arguments, not both because this would create
286
- * ambiguity.
287
- */
288
- if (flags & ASN1_TFLG_TAG_MASK) {
289
- /* Error if argument and template tagging */
290
- if (tag != -1) {
291
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
292
- return -1;
293
- }
294
- /* Get tagging from template */
295
- ttag = tt->tag;
296
- tclass = flags & ASN1_TFLG_TAG_CLASS;
297
- } else if (tag != -1) {
298
- /* No template tagging, get from arguments */
299
- ttag = tag;
300
- tclass = iclass & ASN1_TFLG_TAG_CLASS;
301
- } else {
302
- ttag = -1;
303
- tclass = 0;
265
+ const ASN1_TEMPLATE *tt, int tag, int iclass) {
266
+ int i, ret, flags, ttag, tclass;
267
+ size_t j;
268
+ flags = tt->flags;
269
+
270
+ // Historically, |iclass| was repurposed to pass additional flags into the
271
+ // encoding process.
272
+ assert((iclass & ASN1_TFLG_TAG_CLASS) == iclass);
273
+ // If not overridding the tag, |iclass| is ignored and should be zero.
274
+ assert(tag != -1 || iclass == 0);
275
+
276
+ // Work out tag and class to use: tagging may come either from the
277
+ // template or the arguments, not both because this would create
278
+ // ambiguity.
279
+ if (flags & ASN1_TFLG_TAG_MASK) {
280
+ // Error if argument and template tagging
281
+ if (tag != -1) {
282
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
283
+ return -1;
284
+ }
285
+ // Get tagging from template
286
+ ttag = tt->tag;
287
+ tclass = flags & ASN1_TFLG_TAG_CLASS;
288
+ } else if (tag != -1) {
289
+ // No template tagging, get from arguments
290
+ ttag = tag;
291
+ tclass = iclass & ASN1_TFLG_TAG_CLASS;
292
+ } else {
293
+ ttag = -1;
294
+ tclass = 0;
295
+ }
296
+
297
+ const int optional = (flags & ASN1_TFLG_OPTIONAL) != 0;
298
+
299
+ // At this point 'ttag' contains the outer tag to use, and 'tclass' is the
300
+ // class.
301
+
302
+ if (flags & ASN1_TFLG_SK_MASK) {
303
+ // SET OF, SEQUENCE OF
304
+ STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
305
+ int isset, sktag, skaclass;
306
+ int skcontlen, sklen;
307
+ ASN1_VALUE *skitem;
308
+
309
+ if (!*pval) {
310
+ if (optional) {
311
+ return 0;
312
+ }
313
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
314
+ return -1;
304
315
  }
305
316
 
306
- const int optional = (flags & ASN1_TFLG_OPTIONAL) != 0;
307
-
308
- /*
309
- * At this point 'ttag' contains the outer tag to use, and 'tclass' is the
310
- * class.
311
- */
312
-
313
- if (flags & ASN1_TFLG_SK_MASK) {
314
- /* SET OF, SEQUENCE OF */
315
- STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
316
- int isset, sktag, skaclass;
317
- int skcontlen, sklen;
318
- ASN1_VALUE *skitem;
319
-
320
- if (!*pval) {
321
- if (optional) {
322
- return 0;
323
- }
324
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
325
- return -1;
326
- }
317
+ if (flags & ASN1_TFLG_SET_OF) {
318
+ isset = 1;
319
+ // Historically, types with both bits set were mutated when
320
+ // serialized to apply the sort. We no longer support this.
321
+ assert((flags & ASN1_TFLG_SEQUENCE_OF) == 0);
322
+ } else {
323
+ isset = 0;
324
+ }
327
325
 
328
- if (flags & ASN1_TFLG_SET_OF) {
329
- isset = 1;
330
- /* Historically, types with both bits set were mutated when
331
- * serialized to apply the sort. We no longer support this. */
332
- assert((flags & ASN1_TFLG_SEQUENCE_OF) == 0);
333
- } else {
334
- isset = 0;
335
- }
326
+ // Work out inner tag value: if EXPLICIT or no tagging use underlying
327
+ // type.
328
+ if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) {
329
+ sktag = ttag;
330
+ skaclass = tclass;
331
+ } else {
332
+ skaclass = V_ASN1_UNIVERSAL;
333
+ if (isset) {
334
+ sktag = V_ASN1_SET;
335
+ } else {
336
+ sktag = V_ASN1_SEQUENCE;
337
+ }
338
+ }
336
339
 
337
- /*
338
- * Work out inner tag value: if EXPLICIT or no tagging use underlying
339
- * type.
340
- */
341
- if ((ttag != -1) && !(flags & ASN1_TFLG_EXPTAG)) {
342
- sktag = ttag;
343
- skaclass = tclass;
344
- } else {
345
- skaclass = V_ASN1_UNIVERSAL;
346
- if (isset)
347
- sktag = V_ASN1_SET;
348
- else
349
- sktag = V_ASN1_SEQUENCE;
350
- }
340
+ // Determine total length of items
341
+ skcontlen = 0;
342
+ for (j = 0; j < sk_ASN1_VALUE_num(sk); j++) {
343
+ int tmplen;
344
+ skitem = sk_ASN1_VALUE_value(sk, j);
345
+ tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item), -1, 0);
346
+ if (tmplen == -1 || (skcontlen > INT_MAX - tmplen)) {
347
+ return -1;
348
+ }
349
+ skcontlen += tmplen;
350
+ }
351
+ sklen = ASN1_object_size(/*constructed=*/1, skcontlen, sktag);
352
+ if (sklen == -1) {
353
+ return -1;
354
+ }
355
+ // If EXPLICIT need length of surrounding tag
356
+ if (flags & ASN1_TFLG_EXPTAG) {
357
+ ret = ASN1_object_size(/*constructed=*/1, sklen, ttag);
358
+ } else {
359
+ ret = sklen;
360
+ }
351
361
 
352
- /* Determine total length of items */
353
- skcontlen = 0;
354
- for (j = 0; j < sk_ASN1_VALUE_num(sk); j++) {
355
- int tmplen;
356
- skitem = sk_ASN1_VALUE_value(sk, j);
357
- tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item),
358
- -1, 0);
359
- if (tmplen == -1 || (skcontlen > INT_MAX - tmplen))
360
- return -1;
361
- skcontlen += tmplen;
362
- }
363
- sklen = ASN1_object_size(/*constructed=*/1, skcontlen, sktag);
364
- if (sklen == -1)
365
- return -1;
366
- /* If EXPLICIT need length of surrounding tag */
367
- if (flags & ASN1_TFLG_EXPTAG)
368
- ret = ASN1_object_size(/*constructed=*/1, sklen, ttag);
369
- else
370
- ret = sklen;
371
-
372
- if (!out || ret == -1)
373
- return ret;
374
-
375
- /* Now encode this lot... */
376
- /* EXPLICIT tag */
377
- if (flags & ASN1_TFLG_EXPTAG)
378
- ASN1_put_object(out, /*constructed=*/1, sklen, ttag, tclass);
379
- /* SET or SEQUENCE and IMPLICIT tag */
380
- ASN1_put_object(out, /*constructed=*/1, skcontlen, sktag, skaclass);
381
- /* And the stuff itself */
382
- if (!asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item),
383
- isset)) {
384
- return -1;
385
- }
386
- return ret;
362
+ if (!out || ret == -1) {
363
+ return ret;
387
364
  }
388
365
 
366
+ // Now encode this lot...
367
+ // EXPLICIT tag
389
368
  if (flags & ASN1_TFLG_EXPTAG) {
390
- /* EXPLICIT tagging */
391
- /* Find length of tagged item */
392
- i = asn1_item_ex_i2d_opt(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, 0,
393
- optional);
394
- if (i <= 0)
395
- return i;
396
- /* Find length of EXPLICIT tag */
397
- ret = ASN1_object_size(/*constructed=*/1, i, ttag);
398
- if (out && ret != -1) {
399
- /* Output tag and item */
400
- ASN1_put_object(out, /*constructed=*/1, i, ttag, tclass);
401
- if (ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1,
402
- 0) < 0) {
403
- return -1;
404
- }
405
- }
406
- return ret;
369
+ ASN1_put_object(out, /*constructed=*/1, sklen, ttag, tclass);
407
370
  }
371
+ // SET or SEQUENCE and IMPLICIT tag
372
+ ASN1_put_object(out, /*constructed=*/1, skcontlen, sktag, skaclass);
373
+ // And the stuff itself
374
+ if (!asn1_set_seq_out(sk, out, skcontlen, ASN1_ITEM_ptr(tt->item), isset)) {
375
+ return -1;
376
+ }
377
+ return ret;
378
+ }
379
+
380
+ if (flags & ASN1_TFLG_EXPTAG) {
381
+ // EXPLICIT tagging
382
+ // Find length of tagged item
383
+ i = asn1_item_ex_i2d_opt(pval, NULL, ASN1_ITEM_ptr(tt->item), -1, 0,
384
+ optional);
385
+ if (i <= 0) {
386
+ return i;
387
+ }
388
+ // Find length of EXPLICIT tag
389
+ ret = ASN1_object_size(/*constructed=*/1, i, ttag);
390
+ if (out && ret != -1) {
391
+ // Output tag and item
392
+ ASN1_put_object(out, /*constructed=*/1, i, ttag, tclass);
393
+ if (ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, 0) < 0) {
394
+ return -1;
395
+ }
396
+ }
397
+ return ret;
398
+ }
408
399
 
409
- /* Either normal or IMPLICIT tagging */
410
- return asn1_item_ex_i2d_opt(pval, out, ASN1_ITEM_ptr(tt->item),
411
- ttag, tclass, optional);
412
-
400
+ // Either normal or IMPLICIT tagging
401
+ return asn1_item_ex_i2d_opt(pval, out, ASN1_ITEM_ptr(tt->item), ttag, tclass,
402
+ optional);
413
403
  }
414
404
 
415
- /* Temporary structure used to hold DER encoding of items for SET OF */
405
+ // Temporary structure used to hold DER encoding of items for SET OF
416
406
 
417
407
  typedef struct {
418
- unsigned char *data;
419
- int length;
408
+ unsigned char *data;
409
+ int length;
420
410
  } DER_ENC;
421
411
 
422
- static int der_cmp(const void *a, const void *b)
423
- {
424
- const DER_ENC *d1 = a, *d2 = b;
425
- int cmplen, i;
426
- cmplen = (d1->length < d2->length) ? d1->length : d2->length;
427
- i = OPENSSL_memcmp(d1->data, d2->data, cmplen);
428
- if (i)
429
- return i;
430
- return d1->length - d2->length;
412
+ static int der_cmp(const void *a, const void *b) {
413
+ const DER_ENC *d1 = a, *d2 = b;
414
+ int cmplen, i;
415
+ cmplen = (d1->length < d2->length) ? d1->length : d2->length;
416
+ i = OPENSSL_memcmp(d1->data, d2->data, cmplen);
417
+ if (i) {
418
+ return i;
419
+ }
420
+ return d1->length - d2->length;
431
421
  }
432
422
 
433
- /* asn1_set_seq_out writes |sk| to |out| under the i2d output convention,
434
- * excluding the tag and length. It returns one on success and zero on error.
435
- * |skcontlen| must be the total encoded size. If |do_sort| is non-zero, the
436
- * elements are sorted for a SET OF type. Each element of |sk| has type
437
- * |item|. */
423
+ // asn1_set_seq_out writes |sk| to |out| under the i2d output convention,
424
+ // excluding the tag and length. It returns one on success and zero on error.
425
+ // |skcontlen| must be the total encoded size. If |do_sort| is non-zero, the
426
+ // elements are sorted for a SET OF type. Each element of |sk| has type
427
+ // |item|.
438
428
  static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
439
- int skcontlen, const ASN1_ITEM *item, int do_sort)
440
- {
441
- /* No need to sort if there are fewer than two items. */
442
- if (!do_sort || sk_ASN1_VALUE_num(sk) < 2) {
443
- for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
444
- ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
445
- if (ASN1_item_ex_i2d(&skitem, out, item, -1, 0) < 0) {
446
- return 0;
447
- }
448
- }
449
- return 1;
450
- }
451
-
452
- if (sk_ASN1_VALUE_num(sk) > ((size_t)-1) / sizeof(DER_ENC)) {
453
- OPENSSL_PUT_ERROR(ASN1, ERR_R_OVERFLOW);
429
+ int skcontlen, const ASN1_ITEM *item, int do_sort) {
430
+ // No need to sort if there are fewer than two items.
431
+ if (!do_sort || sk_ASN1_VALUE_num(sk) < 2) {
432
+ for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
433
+ ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
434
+ if (ASN1_item_ex_i2d(&skitem, out, item, -1, 0) < 0) {
454
435
  return 0;
436
+ }
455
437
  }
456
-
457
- int ret = 0;
458
- unsigned char *const buf = OPENSSL_malloc(skcontlen);
459
- DER_ENC *encoded = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) * sizeof(*encoded));
460
- if (encoded == NULL || buf == NULL) {
461
- OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
462
- goto err;
438
+ return 1;
439
+ }
440
+
441
+ if (sk_ASN1_VALUE_num(sk) > ((size_t)-1) / sizeof(DER_ENC)) {
442
+ OPENSSL_PUT_ERROR(ASN1, ERR_R_OVERFLOW);
443
+ return 0;
444
+ }
445
+
446
+ int ret = 0;
447
+ unsigned char *const buf = OPENSSL_malloc(skcontlen);
448
+ DER_ENC *encoded = OPENSSL_malloc(sk_ASN1_VALUE_num(sk) * sizeof(*encoded));
449
+ if (encoded == NULL || buf == NULL) {
450
+ OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
451
+ goto err;
452
+ }
453
+
454
+ // Encode all the elements into |buf| and populate |encoded|.
455
+ unsigned char *p = buf;
456
+ for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
457
+ ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
458
+ encoded[i].data = p;
459
+ encoded[i].length = ASN1_item_ex_i2d(&skitem, &p, item, -1, 0);
460
+ if (encoded[i].length < 0) {
461
+ goto err;
463
462
  }
463
+ assert(p - buf <= skcontlen);
464
+ }
464
465
 
465
- /* Encode all the elements into |buf| and populate |encoded|. */
466
- unsigned char *p = buf;
467
- for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
468
- ASN1_VALUE *skitem = sk_ASN1_VALUE_value(sk, i);
469
- encoded[i].data = p;
470
- encoded[i].length = ASN1_item_ex_i2d(&skitem, &p, item, -1, 0);
471
- if (encoded[i].length < 0) {
472
- goto err;
473
- }
474
- assert(p - buf <= skcontlen);
475
- }
466
+ qsort(encoded, sk_ASN1_VALUE_num(sk), sizeof(*encoded), der_cmp);
476
467
 
477
- qsort(encoded, sk_ASN1_VALUE_num(sk), sizeof(*encoded), der_cmp);
468
+ // Output the elements in sorted order.
469
+ p = *out;
470
+ for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
471
+ OPENSSL_memcpy(p, encoded[i].data, encoded[i].length);
472
+ p += encoded[i].length;
473
+ }
474
+ *out = p;
478
475
 
479
- /* Output the elements in sorted order. */
480
- p = *out;
481
- for (size_t i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
482
- OPENSSL_memcpy(p, encoded[i].data, encoded[i].length);
483
- p += encoded[i].length;
484
- }
485
- *out = p;
486
-
487
- ret = 1;
476
+ ret = 1;
488
477
 
489
478
  err:
490
- OPENSSL_free(encoded);
491
- OPENSSL_free(buf);
492
- return ret;
479
+ OPENSSL_free(encoded);
480
+ OPENSSL_free(buf);
481
+ return ret;
493
482
  }
494
483
 
495
- /* asn1_i2d_ex_primitive behaves like |ASN1_item_ex_i2d| but |item| must be a
496
- * a PRIMITIVE or MSTRING type that is not an |ASN1_ITEM_TEMPLATE|. */
484
+ // asn1_i2d_ex_primitive behaves like |ASN1_item_ex_i2d| but |item| must be a
485
+ // a PRIMITIVE or MSTRING type that is not an |ASN1_ITEM_TEMPLATE|.
497
486
  static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
498
487
  const ASN1_ITEM *it, int tag, int aclass,
499
- int optional)
500
- {
501
- /* Get length of content octets and maybe find out the underlying type. */
502
- int omit;
503
- int utype = it->utype;
504
- int len = asn1_ex_i2c(pval, NULL, &omit, &utype, it);
505
- if (len < 0) {
506
- return -1;
507
- }
508
- if (omit) {
509
- if (optional) {
510
- return 0;
511
- }
512
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
513
- return -1;
488
+ int optional) {
489
+ // Get length of content octets and maybe find out the underlying type.
490
+ int omit;
491
+ int utype = it->utype;
492
+ int len = asn1_ex_i2c(pval, NULL, &omit, &utype, it);
493
+ if (len < 0) {
494
+ return -1;
495
+ }
496
+ if (omit) {
497
+ if (optional) {
498
+ return 0;
514
499
  }
515
-
516
- /*
517
- * If SEQUENCE, SET or OTHER then header is included in pseudo content
518
- * octets so don't include tag+length. We need to check here because the
519
- * call to asn1_ex_i2c() could change utype.
520
- */
521
- int usetag = utype != V_ASN1_SEQUENCE && utype != V_ASN1_SET &&
522
- utype != V_ASN1_OTHER;
523
-
524
- /* If not implicitly tagged get tag from underlying type */
525
- if (tag == -1)
526
- tag = utype;
527
-
528
- /* Output tag+length followed by content octets */
529
- if (out) {
530
- if (usetag) {
531
- ASN1_put_object(out, /*constructed=*/0, len, tag, aclass);
532
- }
533
- int len2 = asn1_ex_i2c(pval, *out, &omit, &utype, it);
534
- if (len2 < 0) {
535
- return -1;
536
- }
537
- assert(len == len2);
538
- assert(!omit);
539
- *out += len;
540
- }
541
-
500
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_VALUE);
501
+ return -1;
502
+ }
503
+
504
+ // If SEQUENCE, SET or OTHER then header is included in pseudo content
505
+ // octets so don't include tag+length. We need to check here because the
506
+ // call to asn1_ex_i2c() could change utype.
507
+ int usetag =
508
+ utype != V_ASN1_SEQUENCE && utype != V_ASN1_SET && utype != V_ASN1_OTHER;
509
+
510
+ // If not implicitly tagged get tag from underlying type
511
+ if (tag == -1) {
512
+ tag = utype;
513
+ }
514
+
515
+ // Output tag+length followed by content octets
516
+ if (out) {
542
517
  if (usetag) {
543
- return ASN1_object_size(/*constructed=*/0, len, tag);
518
+ ASN1_put_object(out, /*constructed=*/0, len, tag, aclass);
544
519
  }
545
- return len;
520
+ int len2 = asn1_ex_i2c(pval, *out, &omit, &utype, it);
521
+ if (len2 < 0) {
522
+ return -1;
523
+ }
524
+ assert(len == len2);
525
+ assert(!omit);
526
+ *out += len;
527
+ }
528
+
529
+ if (usetag) {
530
+ return ASN1_object_size(/*constructed=*/0, len, tag);
531
+ }
532
+ return len;
546
533
  }
547
534
 
548
- /* asn1_ex_i2c writes the |*pval| to |cout| under the i2d output convention,
549
- * excluding the tag and length. It returns the number of bytes written,
550
- * possibly zero, on success or -1 on error. If |*pval| should be omitted, it
551
- * returns zero and sets |*out_omit| to true.
552
- *
553
- * If |it| is an MSTRING or ANY type, it gets the underlying type from |*pval|,
554
- * which must be an |ASN1_STRING| or |ASN1_TYPE|, respectively. It then updates
555
- * |*putype| with the tag number of type used, or |V_ASN1_OTHER| if it was not a
556
- * universal type. If |*putype| is set to |V_ASN1_SEQUENCE|, |V_ASN1_SET|, or
557
- * |V_ASN1_OTHER|, it additionally outputs the tag and length, so the caller
558
- * must not do so.
559
- *
560
- * Otherwise, |*putype| must contain |it->utype|.
561
- *
562
- * WARNING: Unlike most functions in this file, |asn1_ex_i2c| can return zero
563
- * without omitting the element. ASN.1 values may have empty contents. */
535
+ // asn1_ex_i2c writes the |*pval| to |cout| under the i2d output convention,
536
+ // excluding the tag and length. It returns the number of bytes written,
537
+ // possibly zero, on success or -1 on error. If |*pval| should be omitted, it
538
+ // returns zero and sets |*out_omit| to true.
539
+ //
540
+ // If |it| is an MSTRING or ANY type, it gets the underlying type from |*pval|,
541
+ // which must be an |ASN1_STRING| or |ASN1_TYPE|, respectively. It then updates
542
+ // |*putype| with the tag number of type used, or |V_ASN1_OTHER| if it was not a
543
+ // universal type. If |*putype| is set to |V_ASN1_SEQUENCE|, |V_ASN1_SET|, or
544
+ // |V_ASN1_OTHER|, it additionally outputs the tag and length, so the caller
545
+ // must not do so.
546
+ //
547
+ // Otherwise, |*putype| must contain |it->utype|.
548
+ //
549
+ // WARNING: Unlike most functions in this file, |asn1_ex_i2c| can return zero
550
+ // without omitting the element. ASN.1 values may have empty contents.
564
551
  static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
565
- int *putype, const ASN1_ITEM *it)
566
- {
567
- ASN1_BOOLEAN *tbool = NULL;
568
- ASN1_STRING *strtmp;
569
- ASN1_OBJECT *otmp;
570
- int utype;
571
- const unsigned char *cont;
572
- unsigned char c;
573
- int len;
574
-
575
- /* Historically, |it->funcs| for primitive types contained an
576
- * |ASN1_PRIMITIVE_FUNCS| table of callbacks. */
577
- assert(it->funcs == NULL);
578
-
579
- *out_omit = 0;
580
-
581
- /* Should type be omitted? */
582
- if ((it->itype != ASN1_ITYPE_PRIMITIVE)
583
- || (it->utype != V_ASN1_BOOLEAN)) {
584
- if (!*pval) {
585
- *out_omit = 1;
586
- return 0;
587
- }
552
+ int *putype, const ASN1_ITEM *it) {
553
+ ASN1_BOOLEAN *tbool = NULL;
554
+ ASN1_STRING *strtmp;
555
+ ASN1_OBJECT *otmp;
556
+ int utype;
557
+ const unsigned char *cont;
558
+ unsigned char c;
559
+ int len;
560
+
561
+ // Historically, |it->funcs| for primitive types contained an
562
+ // |ASN1_PRIMITIVE_FUNCS| table of callbacks.
563
+ assert(it->funcs == NULL);
564
+
565
+ *out_omit = 0;
566
+
567
+ // Should type be omitted?
568
+ if ((it->itype != ASN1_ITYPE_PRIMITIVE) || (it->utype != V_ASN1_BOOLEAN)) {
569
+ if (!*pval) {
570
+ *out_omit = 1;
571
+ return 0;
588
572
  }
573
+ }
574
+
575
+ if (it->itype == ASN1_ITYPE_MSTRING) {
576
+ // If MSTRING type set the underlying type
577
+ strtmp = (ASN1_STRING *)*pval;
578
+ utype = strtmp->type;
579
+ if (utype < 0 && utype != V_ASN1_OTHER) {
580
+ // MSTRINGs can have type -1 when default-constructed.
581
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TYPE);
582
+ return -1;
583
+ }
584
+ // Negative INTEGER and ENUMERATED values use |ASN1_STRING| type values
585
+ // that do not match their corresponding utype values. INTEGERs cannot
586
+ // participate in MSTRING types, but ENUMERATEDs can.
587
+ //
588
+ // TODO(davidben): Is this a bug? Although arguably one of the MSTRING
589
+ // types should contain more values, rather than less. See
590
+ // https://crbug.com/boringssl/412. But it is not possible to fit all
591
+ // possible ANY values into an |ASN1_STRING|, so matching the spec here
592
+ // is somewhat hopeless.
593
+ if (utype == V_ASN1_NEG_INTEGER) {
594
+ utype = V_ASN1_INTEGER;
595
+ } else if (utype == V_ASN1_NEG_ENUMERATED) {
596
+ utype = V_ASN1_ENUMERATED;
597
+ }
598
+ *putype = utype;
599
+ } else if (it->utype == V_ASN1_ANY) {
600
+ // If ANY set type and pointer to value
601
+ ASN1_TYPE *typ;
602
+ typ = (ASN1_TYPE *)*pval;
603
+ utype = typ->type;
604
+ if (utype < 0 && utype != V_ASN1_OTHER) {
605
+ // |ASN1_TYPE|s can have type -1 when default-constructed.
606
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TYPE);
607
+ return -1;
608
+ }
609
+ *putype = utype;
610
+ pval = &typ->value.asn1_value;
611
+ } else {
612
+ utype = *putype;
613
+ }
589
614
 
590
- if (it->itype == ASN1_ITYPE_MSTRING) {
591
- /* If MSTRING type set the underlying type */
592
- strtmp = (ASN1_STRING *)*pval;
593
- utype = strtmp->type;
594
- if (utype < 0 && utype != V_ASN1_OTHER) {
595
- /* MSTRINGs can have type -1 when default-constructed. */
596
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TYPE);
597
- return -1;
598
- }
599
- /* Negative INTEGER and ENUMERATED values use |ASN1_STRING| type values
600
- * that do not match their corresponding utype values. INTEGERs cannot
601
- * participate in MSTRING types, but ENUMERATEDs can.
602
- *
603
- * TODO(davidben): Is this a bug? Although arguably one of the MSTRING
604
- * types should contain more values, rather than less. See
605
- * https://crbug.com/boringssl/412. But it is not possible to fit all
606
- * possible ANY values into an |ASN1_STRING|, so matching the spec here
607
- * is somewhat hopeless. */
608
- if (utype == V_ASN1_NEG_INTEGER) {
609
- utype = V_ASN1_INTEGER;
610
- } else if (utype == V_ASN1_NEG_ENUMERATED) {
611
- utype = V_ASN1_ENUMERATED;
612
- }
613
- *putype = utype;
614
- } else if (it->utype == V_ASN1_ANY) {
615
- /* If ANY set type and pointer to value */
616
- ASN1_TYPE *typ;
617
- typ = (ASN1_TYPE *)*pval;
618
- utype = typ->type;
619
- if (utype < 0 && utype != V_ASN1_OTHER) {
620
- /* |ASN1_TYPE|s can have type -1 when default-constructed. */
621
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_WRONG_TYPE);
622
- return -1;
623
- }
624
- *putype = utype;
625
- pval = &typ->value.asn1_value;
626
- } else
627
- utype = *putype;
628
-
629
- switch (utype) {
615
+ switch (utype) {
630
616
  case V_ASN1_OBJECT:
631
- otmp = (ASN1_OBJECT *)*pval;
632
- cont = otmp->data;
633
- len = otmp->length;
634
- if (len == 0) {
635
- /* Some |ASN1_OBJECT|s do not have OIDs and cannot be serialized. */
636
- OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_OBJECT);
637
- return -1;
638
- }
639
- break;
617
+ otmp = (ASN1_OBJECT *)*pval;
618
+ cont = otmp->data;
619
+ len = otmp->length;
620
+ if (len == 0) {
621
+ // Some |ASN1_OBJECT|s do not have OIDs and cannot be serialized.
622
+ OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_OBJECT);
623
+ return -1;
624
+ }
625
+ break;
640
626
 
641
627
  case V_ASN1_NULL:
642
- cont = NULL;
643
- len = 0;
644
- break;
628
+ cont = NULL;
629
+ len = 0;
630
+ break;
645
631
 
646
632
  case V_ASN1_BOOLEAN:
647
- tbool = (ASN1_BOOLEAN *)pval;
648
- if (*tbool == -1) {
649
- *out_omit = 1;
650
- return 0;
651
- }
652
- if (it->utype != V_ASN1_ANY) {
653
- /*
654
- * Default handling if value == size field then omit
655
- */
656
- if ((*tbool && (it->size > 0)) ||
657
- (!*tbool && !it->size)) {
658
- *out_omit = 1;
659
- return 0;
660
- }
661
- }
662
- c = *tbool ? 0xff : 0x00;
663
- cont = &c;
664
- len = 1;
665
- break;
633
+ tbool = (ASN1_BOOLEAN *)pval;
634
+ if (*tbool == -1) {
635
+ *out_omit = 1;
636
+ return 0;
637
+ }
638
+ if (it->utype != V_ASN1_ANY) {
639
+ // Default handling if value == size field then omit
640
+ if ((*tbool && (it->size > 0)) || (!*tbool && !it->size)) {
641
+ *out_omit = 1;
642
+ return 0;
643
+ }
644
+ }
645
+ c = *tbool ? 0xff : 0x00;
646
+ cont = &c;
647
+ len = 1;
648
+ break;
666
649
 
667
650
  case V_ASN1_BIT_STRING: {
668
- int ret = i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval,
669
- cout ? &cout : NULL);
670
- /* |i2c_ASN1_BIT_STRING| returns zero on error instead of -1. */
671
- return ret <= 0 ? -1 : ret;
651
+ int ret =
652
+ i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval, cout ? &cout : NULL);
653
+ // |i2c_ASN1_BIT_STRING| returns zero on error instead of -1.
654
+ return ret <= 0 ? -1 : ret;
672
655
  }
673
656
 
674
657
  case V_ASN1_INTEGER:
675
658
  case V_ASN1_ENUMERATED: {
676
- /* |i2c_ASN1_INTEGER| also handles ENUMERATED. */
677
- int ret = i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL);
678
- /* |i2c_ASN1_INTEGER| returns zero on error instead of -1. */
679
- return ret <= 0 ? -1 : ret;
659
+ // |i2c_ASN1_INTEGER| also handles ENUMERATED.
660
+ int ret = i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval, cout ? &cout : NULL);
661
+ // |i2c_ASN1_INTEGER| returns zero on error instead of -1.
662
+ return ret <= 0 ? -1 : ret;
680
663
  }
681
664
 
682
665
  case V_ASN1_OCTET_STRING:
@@ -696,15 +679,15 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *out_omit,
696
679
  case V_ASN1_SEQUENCE:
697
680
  case V_ASN1_SET:
698
681
  default:
699
- /* All based on ASN1_STRING and handled the same */
700
- strtmp = (ASN1_STRING *)*pval;
701
- cont = strtmp->data;
702
- len = strtmp->length;
703
-
704
- break;
705
-
706
- }
707
- if (cout && len)
708
- OPENSSL_memcpy(cout, cont, len);
709
- return len;
682
+ // All based on ASN1_STRING and handled the same
683
+ strtmp = (ASN1_STRING *)*pval;
684
+ cont = strtmp->data;
685
+ len = strtmp->length;
686
+
687
+ break;
688
+ }
689
+ if (cout && len) {
690
+ OPENSSL_memcpy(cout, cont, len);
691
+ }
692
+ return len;
710
693
  }