protocol-quic 0.0.0 → 0.0.1

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 (348) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/rakefile.rb +12 -0
  4. data/ext/ruby-protocol-quic-lock.yml +67 -0
  5. data/ext/teapot.rb +49 -0
  6. data/lib/protocol/quic/version.rb +4 -2
  7. data/lib/protocol/quic.rb +5 -5
  8. data/license.md +1 -1
  9. data/readme.md +55 -0
  10. data/releases.md +3 -0
  11. data.tar.gz.sig +0 -0
  12. metadata +32 -350
  13. metadata.gz.sig +0 -0
  14. data/ext/ngtcp2/AUTHORS +0 -44
  15. data/ext/ngtcp2/CMakeLists.txt +0 -431
  16. data/ext/ngtcp2/CMakeOptions.txt +0 -17
  17. data/ext/ngtcp2/COPYING +0 -22
  18. data/ext/ngtcp2/ChangeLog +0 -0
  19. data/ext/ngtcp2/Makefile.am +0 -60
  20. data/ext/ngtcp2/NEWS +0 -0
  21. data/ext/ngtcp2/README +0 -1
  22. data/ext/ngtcp2/README.rst +0 -258
  23. data/ext/ngtcp2/ci/build_boringssl.sh +0 -10
  24. data/ext/ngtcp2/ci/build_nghttp3.sh +0 -9
  25. data/ext/ngtcp2/ci/build_openssl1.sh +0 -8
  26. data/ext/ngtcp2/ci/build_openssl1_cross.sh +0 -9
  27. data/ext/ngtcp2/ci/build_openssl3.sh +0 -8
  28. data/ext/ngtcp2/ci/build_picotls.sh +0 -26
  29. data/ext/ngtcp2/ci/build_wolfssl.sh +0 -9
  30. data/ext/ngtcp2/ci/gen-certificate.sh +0 -8
  31. data/ext/ngtcp2/cmake/ExtractValidFlags.cmake +0 -31
  32. data/ext/ngtcp2/cmake/FindCUnit.cmake +0 -40
  33. data/ext/ngtcp2/cmake/FindJemalloc.cmake +0 -40
  34. data/ext/ngtcp2/cmake/FindLibev.cmake +0 -38
  35. data/ext/ngtcp2/cmake/FindLibnghttp3.cmake +0 -41
  36. data/ext/ngtcp2/cmake/Findwolfssl.cmake +0 -41
  37. data/ext/ngtcp2/cmake/Version.cmake +0 -11
  38. data/ext/ngtcp2/cmakeconfig.h.in +0 -36
  39. data/ext/ngtcp2/configure.ac +0 -755
  40. data/ext/ngtcp2/crypto/CMakeLists.txt +0 -56
  41. data/ext/ngtcp2/crypto/Makefile.am +0 -49
  42. data/ext/ngtcp2/crypto/boringssl/CMakeLists.txt +0 -64
  43. data/ext/ngtcp2/crypto/boringssl/Makefile.am +0 -39
  44. data/ext/ngtcp2/crypto/boringssl/boringssl.c +0 -630
  45. data/ext/ngtcp2/crypto/boringssl/libngtcp2_crypto_boringssl.pc.in +0 -33
  46. data/ext/ngtcp2/crypto/gnutls/CMakeLists.txt +0 -86
  47. data/ext/ngtcp2/crypto/gnutls/Makefile.am +0 -43
  48. data/ext/ngtcp2/crypto/gnutls/gnutls.c +0 -644
  49. data/ext/ngtcp2/crypto/gnutls/libngtcp2_crypto_gnutls.pc.in +0 -33
  50. data/ext/ngtcp2/crypto/includes/CMakeLists.txt +0 -56
  51. data/ext/ngtcp2/crypto/includes/Makefile.am +0 -45
  52. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto.h +0 -893
  53. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_boringssl.h +0 -104
  54. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_gnutls.h +0 -107
  55. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_openssl.h +0 -132
  56. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_picotls.h +0 -246
  57. data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_wolfssl.h +0 -106
  58. data/ext/ngtcp2/crypto/openssl/CMakeLists.txt +0 -86
  59. data/ext/ngtcp2/crypto/openssl/Makefile.am +0 -43
  60. data/ext/ngtcp2/crypto/openssl/libngtcp2_crypto_openssl.pc.in +0 -33
  61. data/ext/ngtcp2/crypto/openssl/openssl.c +0 -807
  62. data/ext/ngtcp2/crypto/picotls/CMakeLists.txt +0 -65
  63. data/ext/ngtcp2/crypto/picotls/Makefile.am +0 -39
  64. data/ext/ngtcp2/crypto/picotls/libngtcp2_crypto_picotls.pc.in +0 -33
  65. data/ext/ngtcp2/crypto/picotls/picotls.c +0 -707
  66. data/ext/ngtcp2/crypto/shared.c +0 -1431
  67. data/ext/ngtcp2/crypto/shared.h +0 -350
  68. data/ext/ngtcp2/crypto/wolfssl/CMakeLists.txt +0 -84
  69. data/ext/ngtcp2/crypto/wolfssl/Makefile.am +0 -43
  70. data/ext/ngtcp2/crypto/wolfssl/libngtcp2_crypto_wolfssl.pc.in +0 -33
  71. data/ext/ngtcp2/crypto/wolfssl/wolfssl.c +0 -534
  72. data/ext/ngtcp2/doc/Makefile.am +0 -65
  73. data/ext/ngtcp2/doc/make.bat +0 -35
  74. data/ext/ngtcp2/doc/mkapiref.py +0 -356
  75. data/ext/ngtcp2/doc/source/conf.py.in +0 -94
  76. data/ext/ngtcp2/doc/source/index.rst +0 -22
  77. data/ext/ngtcp2/doc/source/programmers-guide.rst +0 -476
  78. data/ext/ngtcp2/docker/Dockerfile +0 -39
  79. data/ext/ngtcp2/examples/CMakeLists.txt +0 -361
  80. data/ext/ngtcp2/examples/Makefile.am +0 -228
  81. data/ext/ngtcp2/examples/client.cc +0 -3049
  82. data/ext/ngtcp2/examples/client.h +0 -192
  83. data/ext/ngtcp2/examples/client_base.cc +0 -202
  84. data/ext/ngtcp2/examples/client_base.h +0 -213
  85. data/ext/ngtcp2/examples/debug.cc +0 -298
  86. data/ext/ngtcp2/examples/debug.h +0 -124
  87. data/ext/ngtcp2/examples/examplestest.cc +0 -84
  88. data/ext/ngtcp2/examples/gtlssimpleclient.c +0 -720
  89. data/ext/ngtcp2/examples/h09client.cc +0 -2601
  90. data/ext/ngtcp2/examples/h09client.h +0 -196
  91. data/ext/ngtcp2/examples/h09server.cc +0 -3024
  92. data/ext/ngtcp2/examples/h09server.h +0 -237
  93. data/ext/ngtcp2/examples/http.cc +0 -138
  94. data/ext/ngtcp2/examples/http.h +0 -44
  95. data/ext/ngtcp2/examples/network.h +0 -80
  96. data/ext/ngtcp2/examples/server.cc +0 -3731
  97. data/ext/ngtcp2/examples/server.h +0 -256
  98. data/ext/ngtcp2/examples/server_base.cc +0 -58
  99. data/ext/ngtcp2/examples/server_base.h +0 -195
  100. data/ext/ngtcp2/examples/shared.cc +0 -385
  101. data/ext/ngtcp2/examples/shared.h +0 -96
  102. data/ext/ngtcp2/examples/simpleclient.c +0 -683
  103. data/ext/ngtcp2/examples/template.h +0 -71
  104. data/ext/ngtcp2/examples/tests/README.rst +0 -60
  105. data/ext/ngtcp2/examples/tests/__init__.py +0 -0
  106. data/ext/ngtcp2/examples/tests/config.ini.in +0 -32
  107. data/ext/ngtcp2/examples/tests/conftest.py +0 -28
  108. data/ext/ngtcp2/examples/tests/ngtcp2test/__init__.py +0 -6
  109. data/ext/ngtcp2/examples/tests/ngtcp2test/certs.py +0 -476
  110. data/ext/ngtcp2/examples/tests/ngtcp2test/client.py +0 -187
  111. data/ext/ngtcp2/examples/tests/ngtcp2test/env.py +0 -191
  112. data/ext/ngtcp2/examples/tests/ngtcp2test/log.py +0 -101
  113. data/ext/ngtcp2/examples/tests/ngtcp2test/server.py +0 -137
  114. data/ext/ngtcp2/examples/tests/ngtcp2test/tls.py +0 -983
  115. data/ext/ngtcp2/examples/tests/test_01_handshake.py +0 -30
  116. data/ext/ngtcp2/examples/tests/test_02_resume.py +0 -46
  117. data/ext/ngtcp2/examples/tests/test_03_earlydata.py +0 -56
  118. data/ext/ngtcp2/examples/tests/test_04_clientcert.py +0 -57
  119. data/ext/ngtcp2/examples/tests/test_05_ciphers.py +0 -46
  120. data/ext/ngtcp2/examples/tls_client_context.h +0 -52
  121. data/ext/ngtcp2/examples/tls_client_context_boringssl.cc +0 -126
  122. data/ext/ngtcp2/examples/tls_client_context_boringssl.h +0 -49
  123. data/ext/ngtcp2/examples/tls_client_context_gnutls.cc +0 -74
  124. data/ext/ngtcp2/examples/tls_client_context_gnutls.h +0 -50
  125. data/ext/ngtcp2/examples/tls_client_context_openssl.cc +0 -137
  126. data/ext/ngtcp2/examples/tls_client_context_openssl.h +0 -49
  127. data/ext/ngtcp2/examples/tls_client_context_picotls.cc +0 -158
  128. data/ext/ngtcp2/examples/tls_client_context_picotls.h +0 -53
  129. data/ext/ngtcp2/examples/tls_client_context_wolfssl.cc +0 -177
  130. data/ext/ngtcp2/examples/tls_client_context_wolfssl.h +0 -51
  131. data/ext/ngtcp2/examples/tls_client_session.h +0 -52
  132. data/ext/ngtcp2/examples/tls_client_session_boringssl.cc +0 -110
  133. data/ext/ngtcp2/examples/tls_client_session_boringssl.h +0 -52
  134. data/ext/ngtcp2/examples/tls_client_session_gnutls.cc +0 -190
  135. data/ext/ngtcp2/examples/tls_client_session_gnutls.h +0 -52
  136. data/ext/ngtcp2/examples/tls_client_session_openssl.cc +0 -113
  137. data/ext/ngtcp2/examples/tls_client_session_openssl.h +0 -52
  138. data/ext/ngtcp2/examples/tls_client_session_picotls.cc +0 -147
  139. data/ext/ngtcp2/examples/tls_client_session_picotls.h +0 -52
  140. data/ext/ngtcp2/examples/tls_client_session_wolfssl.cc +0 -160
  141. data/ext/ngtcp2/examples/tls_client_session_wolfssl.h +0 -52
  142. data/ext/ngtcp2/examples/tls_server_context.h +0 -52
  143. data/ext/ngtcp2/examples/tls_server_context_boringssl.cc +0 -257
  144. data/ext/ngtcp2/examples/tls_server_context_boringssl.h +0 -54
  145. data/ext/ngtcp2/examples/tls_server_context_gnutls.cc +0 -99
  146. data/ext/ngtcp2/examples/tls_server_context_gnutls.h +0 -59
  147. data/ext/ngtcp2/examples/tls_server_context_openssl.cc +0 -338
  148. data/ext/ngtcp2/examples/tls_server_context_openssl.h +0 -54
  149. data/ext/ngtcp2/examples/tls_server_context_picotls.cc +0 -321
  150. data/ext/ngtcp2/examples/tls_server_context_picotls.h +0 -58
  151. data/ext/ngtcp2/examples/tls_server_context_wolfssl.cc +0 -284
  152. data/ext/ngtcp2/examples/tls_server_context_wolfssl.h +0 -55
  153. data/ext/ngtcp2/examples/tls_server_session.h +0 -52
  154. data/ext/ngtcp2/examples/tls_server_session_boringssl.cc +0 -84
  155. data/ext/ngtcp2/examples/tls_server_session_boringssl.h +0 -47
  156. data/ext/ngtcp2/examples/tls_server_session_gnutls.cc +0 -155
  157. data/ext/ngtcp2/examples/tls_server_session_gnutls.h +0 -46
  158. data/ext/ngtcp2/examples/tls_server_session_openssl.cc +0 -54
  159. data/ext/ngtcp2/examples/tls_server_session_openssl.h +0 -47
  160. data/ext/ngtcp2/examples/tls_server_session_picotls.cc +0 -70
  161. data/ext/ngtcp2/examples/tls_server_session_picotls.h +0 -47
  162. data/ext/ngtcp2/examples/tls_server_session_wolfssl.cc +0 -55
  163. data/ext/ngtcp2/examples/tls_server_session_wolfssl.h +0 -47
  164. data/ext/ngtcp2/examples/tls_session_base_gnutls.cc +0 -87
  165. data/ext/ngtcp2/examples/tls_session_base_gnutls.h +0 -51
  166. data/ext/ngtcp2/examples/tls_session_base_openssl.cc +0 -54
  167. data/ext/ngtcp2/examples/tls_session_base_openssl.h +0 -52
  168. data/ext/ngtcp2/examples/tls_session_base_picotls.cc +0 -56
  169. data/ext/ngtcp2/examples/tls_session_base_picotls.h +0 -54
  170. data/ext/ngtcp2/examples/tls_session_base_wolfssl.cc +0 -54
  171. data/ext/ngtcp2/examples/tls_session_base_wolfssl.h +0 -54
  172. data/ext/ngtcp2/examples/tls_shared_picotls.cc +0 -59
  173. data/ext/ngtcp2/examples/tls_shared_picotls.h +0 -36
  174. data/ext/ngtcp2/examples/util.cc +0 -646
  175. data/ext/ngtcp2/examples/util.h +0 -361
  176. data/ext/ngtcp2/examples/util_gnutls.cc +0 -136
  177. data/ext/ngtcp2/examples/util_openssl.cc +0 -131
  178. data/ext/ngtcp2/examples/util_test.cc +0 -237
  179. data/ext/ngtcp2/examples/util_test.h +0 -45
  180. data/ext/ngtcp2/examples/util_wolfssl.cc +0 -130
  181. data/ext/ngtcp2/fuzz/corpus/decode_frame/ack +0 -0
  182. data/ext/ngtcp2/fuzz/corpus/decode_frame/ack_ecn +0 -0
  183. data/ext/ngtcp2/fuzz/corpus/decode_frame/connection_close +0 -0
  184. data/ext/ngtcp2/fuzz/corpus/decode_frame/crypto +0 -1
  185. data/ext/ngtcp2/fuzz/corpus/decode_frame/data_blocked +0 -1
  186. data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram +0 -1
  187. data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram_len +0 -1
  188. data/ext/ngtcp2/fuzz/corpus/decode_frame/max_data +0 -1
  189. data/ext/ngtcp2/fuzz/corpus/decode_frame/max_stream_data +0 -0
  190. data/ext/ngtcp2/fuzz/corpus/decode_frame/max_streams +0 -0
  191. data/ext/ngtcp2/fuzz/corpus/decode_frame/new_connection_id +0 -1
  192. data/ext/ngtcp2/fuzz/corpus/decode_frame/new_token +0 -1
  193. data/ext/ngtcp2/fuzz/corpus/decode_frame/path_challenge +0 -1
  194. data/ext/ngtcp2/fuzz/corpus/decode_frame/path_response +0 -1
  195. data/ext/ngtcp2/fuzz/corpus/decode_frame/reset_stream +0 -0
  196. data/ext/ngtcp2/fuzz/corpus/decode_frame/retire_connection_id +0 -1
  197. data/ext/ngtcp2/fuzz/corpus/decode_frame/stop_sending +0 -0
  198. data/ext/ngtcp2/fuzz/corpus/decode_frame/stream +0 -0
  199. data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_data_blocked +0 -0
  200. data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_len +0 -0
  201. data/ext/ngtcp2/fuzz/corpus/decode_frame/streams_blocked +0 -0
  202. data/ext/ngtcp2/fuzz/corpus/ksl/random +0 -0
  203. data/ext/ngtcp2/fuzz/decode_frame.cc +0 -25
  204. data/ext/ngtcp2/fuzz/ksl.cc +0 -77
  205. data/ext/ngtcp2/interop/Dockerfile +0 -39
  206. data/ext/ngtcp2/interop/run_endpoint.sh +0 -93
  207. data/ext/ngtcp2/lib/CMakeLists.txt +0 -110
  208. data/ext/ngtcp2/lib/Makefile.am +0 -122
  209. data/ext/ngtcp2/lib/includes/CMakeLists.txt +0 -4
  210. data/ext/ngtcp2/lib/includes/Makefile.am +0 -25
  211. data/ext/ngtcp2/lib/includes/ngtcp2/ngtcp2.h +0 -5843
  212. data/ext/ngtcp2/lib/includes/ngtcp2/version.h.in +0 -51
  213. data/ext/ngtcp2/lib/libngtcp2.pc.in +0 -33
  214. data/ext/ngtcp2/lib/ngtcp2_acktr.c +0 -335
  215. data/ext/ngtcp2/lib/ngtcp2_acktr.h +0 -221
  216. data/ext/ngtcp2/lib/ngtcp2_addr.c +0 -117
  217. data/ext/ngtcp2/lib/ngtcp2_addr.h +0 -69
  218. data/ext/ngtcp2/lib/ngtcp2_balloc.c +0 -90
  219. data/ext/ngtcp2/lib/ngtcp2_balloc.h +0 -91
  220. data/ext/ngtcp2/lib/ngtcp2_bbr.c +0 -693
  221. data/ext/ngtcp2/lib/ngtcp2_bbr.h +0 -157
  222. data/ext/ngtcp2/lib/ngtcp2_bbr2.c +0 -1490
  223. data/ext/ngtcp2/lib/ngtcp2_bbr2.h +0 -149
  224. data/ext/ngtcp2/lib/ngtcp2_buf.c +0 -56
  225. data/ext/ngtcp2/lib/ngtcp2_buf.h +0 -108
  226. data/ext/ngtcp2/lib/ngtcp2_cc.c +0 -616
  227. data/ext/ngtcp2/lib/ngtcp2_cc.h +0 -422
  228. data/ext/ngtcp2/lib/ngtcp2_cid.c +0 -147
  229. data/ext/ngtcp2/lib/ngtcp2_cid.h +0 -175
  230. data/ext/ngtcp2/lib/ngtcp2_conn.c +0 -13731
  231. data/ext/ngtcp2/lib/ngtcp2_conn.h +0 -1119
  232. data/ext/ngtcp2/lib/ngtcp2_conn_stat.h +0 -131
  233. data/ext/ngtcp2/lib/ngtcp2_conv.c +0 -291
  234. data/ext/ngtcp2/lib/ngtcp2_conv.h +0 -208
  235. data/ext/ngtcp2/lib/ngtcp2_crypto.c +0 -895
  236. data/ext/ngtcp2/lib/ngtcp2_crypto.h +0 -148
  237. data/ext/ngtcp2/lib/ngtcp2_err.c +0 -154
  238. data/ext/ngtcp2/lib/ngtcp2_err.h +0 -34
  239. data/ext/ngtcp2/lib/ngtcp2_gaptr.c +0 -167
  240. data/ext/ngtcp2/lib/ngtcp2_gaptr.h +0 -98
  241. data/ext/ngtcp2/lib/ngtcp2_idtr.c +0 -79
  242. data/ext/ngtcp2/lib/ngtcp2_idtr.h +0 -89
  243. data/ext/ngtcp2/lib/ngtcp2_ksl.c +0 -819
  244. data/ext/ngtcp2/lib/ngtcp2_ksl.h +0 -345
  245. data/ext/ngtcp2/lib/ngtcp2_log.c +0 -822
  246. data/ext/ngtcp2/lib/ngtcp2_log.h +0 -123
  247. data/ext/ngtcp2/lib/ngtcp2_macro.h +0 -58
  248. data/ext/ngtcp2/lib/ngtcp2_map.c +0 -336
  249. data/ext/ngtcp2/lib/ngtcp2_map.h +0 -136
  250. data/ext/ngtcp2/lib/ngtcp2_mem.c +0 -113
  251. data/ext/ngtcp2/lib/ngtcp2_mem.h +0 -72
  252. data/ext/ngtcp2/lib/ngtcp2_net.h +0 -136
  253. data/ext/ngtcp2/lib/ngtcp2_objalloc.c +0 -40
  254. data/ext/ngtcp2/lib/ngtcp2_objalloc.h +0 -140
  255. data/ext/ngtcp2/lib/ngtcp2_opl.c +0 -46
  256. data/ext/ngtcp2/lib/ngtcp2_opl.h +0 -65
  257. data/ext/ngtcp2/lib/ngtcp2_path.c +0 -77
  258. data/ext/ngtcp2/lib/ngtcp2_path.h +0 -49
  259. data/ext/ngtcp2/lib/ngtcp2_pkt.c +0 -2527
  260. data/ext/ngtcp2/lib/ngtcp2_pkt.h +0 -1235
  261. data/ext/ngtcp2/lib/ngtcp2_pmtud.c +0 -160
  262. data/ext/ngtcp2/lib/ngtcp2_pmtud.h +0 -123
  263. data/ext/ngtcp2/lib/ngtcp2_ppe.c +0 -230
  264. data/ext/ngtcp2/lib/ngtcp2_ppe.h +0 -153
  265. data/ext/ngtcp2/lib/ngtcp2_pq.c +0 -164
  266. data/ext/ngtcp2/lib/ngtcp2_pq.h +0 -126
  267. data/ext/ngtcp2/lib/ngtcp2_pv.c +0 -172
  268. data/ext/ngtcp2/lib/ngtcp2_pv.h +0 -194
  269. data/ext/ngtcp2/lib/ngtcp2_qlog.c +0 -1219
  270. data/ext/ngtcp2/lib/ngtcp2_qlog.h +0 -161
  271. data/ext/ngtcp2/lib/ngtcp2_range.c +0 -61
  272. data/ext/ngtcp2/lib/ngtcp2_range.h +0 -80
  273. data/ext/ngtcp2/lib/ngtcp2_rcvry.h +0 -40
  274. data/ext/ngtcp2/lib/ngtcp2_ringbuf.c +0 -121
  275. data/ext/ngtcp2/lib/ngtcp2_ringbuf.h +0 -132
  276. data/ext/ngtcp2/lib/ngtcp2_rob.c +0 -319
  277. data/ext/ngtcp2/lib/ngtcp2_rob.h +0 -197
  278. data/ext/ngtcp2/lib/ngtcp2_rst.c +0 -138
  279. data/ext/ngtcp2/lib/ngtcp2_rst.h +0 -86
  280. data/ext/ngtcp2/lib/ngtcp2_rtb.c +0 -1676
  281. data/ext/ngtcp2/lib/ngtcp2_rtb.h +0 -468
  282. data/ext/ngtcp2/lib/ngtcp2_str.c +0 -233
  283. data/ext/ngtcp2/lib/ngtcp2_str.h +0 -94
  284. data/ext/ngtcp2/lib/ngtcp2_strm.c +0 -698
  285. data/ext/ngtcp2/lib/ngtcp2_strm.h +0 -310
  286. data/ext/ngtcp2/lib/ngtcp2_unreachable.c +0 -71
  287. data/ext/ngtcp2/lib/ngtcp2_unreachable.h +0 -46
  288. data/ext/ngtcp2/lib/ngtcp2_vec.c +0 -243
  289. data/ext/ngtcp2/lib/ngtcp2_vec.h +0 -120
  290. data/ext/ngtcp2/lib/ngtcp2_version.c +0 -39
  291. data/ext/ngtcp2/lib/ngtcp2_window_filter.c +0 -99
  292. data/ext/ngtcp2/lib/ngtcp2_window_filter.h +0 -65
  293. data/ext/ngtcp2/m4/ax_check_compile_flag.m4 +0 -74
  294. data/ext/ngtcp2/m4/ax_cxx_compile_stdcxx.m4 +0 -1009
  295. data/ext/ngtcp2/tests/CMakeLists.txt +0 -68
  296. data/ext/ngtcp2/tests/Makefile.am +0 -94
  297. data/ext/ngtcp2/tests/main.c +0 -358
  298. data/ext/ngtcp2/tests/ngtcp2_acktr_test.c +0 -367
  299. data/ext/ngtcp2/tests/ngtcp2_acktr_test.h +0 -37
  300. data/ext/ngtcp2/tests/ngtcp2_conn_test.c +0 -9821
  301. data/ext/ngtcp2/tests/ngtcp2_conn_test.h +0 -104
  302. data/ext/ngtcp2/tests/ngtcp2_conv_test.c +0 -430
  303. data/ext/ngtcp2/tests/ngtcp2_conv_test.h +0 -46
  304. data/ext/ngtcp2/tests/ngtcp2_crypto_test.c +0 -667
  305. data/ext/ngtcp2/tests/ngtcp2_crypto_test.h +0 -35
  306. data/ext/ngtcp2/tests/ngtcp2_gaptr_test.c +0 -127
  307. data/ext/ngtcp2/tests/ngtcp2_gaptr_test.h +0 -36
  308. data/ext/ngtcp2/tests/ngtcp2_idtr_test.c +0 -79
  309. data/ext/ngtcp2/tests/ngtcp2_idtr_test.h +0 -34
  310. data/ext/ngtcp2/tests/ngtcp2_ksl_test.c +0 -502
  311. data/ext/ngtcp2/tests/ngtcp2_ksl_test.h +0 -39
  312. data/ext/ngtcp2/tests/ngtcp2_map_test.c +0 -206
  313. data/ext/ngtcp2/tests/ngtcp2_map_test.h +0 -38
  314. data/ext/ngtcp2/tests/ngtcp2_pkt_test.c +0 -1645
  315. data/ext/ngtcp2/tests/ngtcp2_pkt_test.h +0 -68
  316. data/ext/ngtcp2/tests/ngtcp2_pmtud_test.c +0 -153
  317. data/ext/ngtcp2/tests/ngtcp2_pmtud_test.h +0 -34
  318. data/ext/ngtcp2/tests/ngtcp2_pv_test.c +0 -129
  319. data/ext/ngtcp2/tests/ngtcp2_pv_test.h +0 -35
  320. data/ext/ngtcp2/tests/ngtcp2_range_test.c +0 -105
  321. data/ext/ngtcp2/tests/ngtcp2_range_test.h +0 -36
  322. data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.c +0 -91
  323. data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.h +0 -35
  324. data/ext/ngtcp2/tests/ngtcp2_rob_test.c +0 -552
  325. data/ext/ngtcp2/tests/ngtcp2_rob_test.h +0 -37
  326. data/ext/ngtcp2/tests/ngtcp2_rtb_test.c +0 -470
  327. data/ext/ngtcp2/tests/ngtcp2_rtb_test.h +0 -38
  328. data/ext/ngtcp2/tests/ngtcp2_str_test.c +0 -96
  329. data/ext/ngtcp2/tests/ngtcp2_str_test.h +0 -36
  330. data/ext/ngtcp2/tests/ngtcp2_strm_test.c +0 -575
  331. data/ext/ngtcp2/tests/ngtcp2_strm_test.h +0 -36
  332. data/ext/ngtcp2/tests/ngtcp2_test_helper.c +0 -404
  333. data/ext/ngtcp2/tests/ngtcp2_test_helper.h +0 -191
  334. data/ext/ngtcp2/tests/ngtcp2_vec_test.c +0 -426
  335. data/ext/ngtcp2/tests/ngtcp2_vec_test.h +0 -36
  336. data/ext/ngtcp2/third-party/CMakeLists.txt +0 -34
  337. data/ext/ngtcp2/third-party/Makefile.am +0 -31
  338. data/ext/ngtcp2/third-party/http-parser/AUTHORS +0 -68
  339. data/ext/ngtcp2/third-party/http-parser/LICENSE-MIT +0 -23
  340. data/ext/ngtcp2/third-party/http-parser/Makefile +0 -157
  341. data/ext/ngtcp2/third-party/http-parser/README.md +0 -246
  342. data/ext/ngtcp2/third-party/http-parser/bench.c +0 -111
  343. data/ext/ngtcp2/third-party/http-parser/contrib/parsertrace.c +0 -160
  344. data/ext/ngtcp2/third-party/http-parser/contrib/url_parser.c +0 -47
  345. data/ext/ngtcp2/third-party/http-parser/http_parser.c +0 -2419
  346. data/ext/ngtcp2/third-party/http-parser/http_parser.gyp +0 -111
  347. data/ext/ngtcp2/third-party/http-parser/http_parser.h +0 -431
  348. data/ext/ngtcp2/third-party/http-parser/test.c +0 -4411
@@ -1,983 +0,0 @@
1
- import binascii
2
- import logging
3
- import sys
4
- from collections.abc import Iterator
5
- from typing import Dict, Any, Iterable
6
-
7
-
8
- log = logging.getLogger(__name__)
9
-
10
-
11
- class ParseError(Exception):
12
- pass
13
-
14
- def _get_int(d, n):
15
- if len(d) < n:
16
- raise ParseError(f'get_int: {n} bytes needed, but data is {d}')
17
- if n == 1:
18
- dlen = d[0]
19
- else:
20
- dlen = int.from_bytes(d[0:n], byteorder='big')
21
- return d[n:], dlen
22
-
23
-
24
- def _get_field(d, dlen):
25
- if dlen > 0:
26
- if len(d) < dlen:
27
- raise ParseError(f'field len={dlen}, but data len={len(d)}')
28
- field = d[0:dlen]
29
- return d[dlen:], field
30
- return d, b''
31
-
32
-
33
- def _get_len_field(d, n):
34
- d, dlen = _get_int(d, n)
35
- return _get_field(d, dlen)
36
-
37
-
38
- # d are bytes that start with a quic variable length integer
39
- def _get_qint(d):
40
- i = d[0] & 0xc0
41
- if i == 0:
42
- return d[1:], int(d[0])
43
- elif i == 0x40:
44
- ndata = bytearray(d[0:2])
45
- d = d[2:]
46
- ndata[0] = ndata[0] & ~0xc0
47
- return d, int.from_bytes(ndata, byteorder='big')
48
- elif i == 0x80:
49
- ndata = bytearray(d[0:4])
50
- d = d[4:]
51
- ndata[0] = ndata[0] & ~0xc0
52
- return d, int.from_bytes(ndata, byteorder='big')
53
- else:
54
- ndata = bytearray(d[0:8])
55
- d = d[8:]
56
- ndata[0] = ndata[0] & ~0xc0
57
- return d, int.from_bytes(ndata, byteorder='big')
58
-
59
-
60
- class TlsSupportedGroups:
61
- NAME_BY_ID = {
62
- 0: 'Reserved',
63
- 1: 'sect163k1',
64
- 2: 'sect163r1',
65
- 3: 'sect163r2',
66
- 4: 'sect193r1',
67
- 5: 'sect193r2',
68
- 6: 'sect233k1',
69
- 7: 'sect233r1',
70
- 8: 'sect239k1',
71
- 9: 'sect283k1',
72
- 10: 'sect283r1',
73
- 11: 'sect409k1',
74
- 12: 'sect409r1',
75
- 13: 'sect571k1',
76
- 14: 'sect571r1',
77
- 15: 'secp160k1',
78
- 16: 'secp160r1',
79
- 17: 'secp160r2',
80
- 18: 'secp192k1',
81
- 19: 'secp192r1',
82
- 20: 'secp224k1',
83
- 21: 'secp224r1',
84
- 22: 'secp256k1',
85
- 23: 'secp256r1',
86
- 24: 'secp384r1',
87
- 25: 'secp521r1',
88
- 26: 'brainpoolP256r1',
89
- 27: 'brainpoolP384r1',
90
- 28: 'brainpoolP512r1',
91
- 29: 'x25519',
92
- 30: 'x448',
93
- 31: 'brainpoolP256r1tls13',
94
- 32: 'brainpoolP384r1tls13',
95
- 33: 'brainpoolP512r1tls13',
96
- 34: 'GC256A',
97
- 35: 'GC256B',
98
- 36: 'GC256C',
99
- 37: 'GC256D',
100
- 38: 'GC512A',
101
- 39: 'GC512B',
102
- 40: 'GC512C',
103
- 41: 'curveSM2',
104
- }
105
-
106
- @classmethod
107
- def name(cls, gid):
108
- if gid in cls.NAME_BY_ID:
109
- return f'{cls.NAME_BY_ID[gid]}(0x{gid:0x})'
110
- return f'0x{gid:0x}'
111
-
112
-
113
- class TlsSignatureScheme:
114
- NAME_BY_ID = {
115
- 0x0201: 'rsa_pkcs1_sha1',
116
- 0x0202: 'Reserved',
117
- 0x0203: 'ecdsa_sha1',
118
- 0x0401: 'rsa_pkcs1_sha256',
119
- 0x0403: 'ecdsa_secp256r1_sha256',
120
- 0x0420: 'rsa_pkcs1_sha256_legacy',
121
- 0x0501: 'rsa_pkcs1_sha384',
122
- 0x0503: 'ecdsa_secp384r1_sha384',
123
- 0x0520: 'rsa_pkcs1_sha384_legacy',
124
- 0x0601: 'rsa_pkcs1_sha512',
125
- 0x0603: 'ecdsa_secp521r1_sha512',
126
- 0x0620: 'rsa_pkcs1_sha512_legacy',
127
- 0x0704: 'eccsi_sha256',
128
- 0x0705: 'iso_ibs1',
129
- 0x0706: 'iso_ibs2',
130
- 0x0707: 'iso_chinese_ibs',
131
- 0x0708: 'sm2sig_sm3',
132
- 0x0709: 'gostr34102012_256a',
133
- 0x070A: 'gostr34102012_256b',
134
- 0x070B: 'gostr34102012_256c',
135
- 0x070C: 'gostr34102012_256d',
136
- 0x070D: 'gostr34102012_512a',
137
- 0x070E: 'gostr34102012_512b',
138
- 0x070F: 'gostr34102012_512c',
139
- 0x0804: 'rsa_pss_rsae_sha256',
140
- 0x0805: 'rsa_pss_rsae_sha384',
141
- 0x0806: 'rsa_pss_rsae_sha512',
142
- 0x0807: 'ed25519',
143
- 0x0808: 'ed448',
144
- 0x0809: 'rsa_pss_pss_sha256',
145
- 0x080A: 'rsa_pss_pss_sha384',
146
- 0x080B: 'rsa_pss_pss_sha512',
147
- 0x081A: 'ecdsa_brainpoolP256r1tls13_sha256',
148
- 0x081B: 'ecdsa_brainpoolP384r1tls13_sha384',
149
- 0x081C: 'ecdsa_brainpoolP512r1tls13_sha512',
150
- }
151
-
152
- @classmethod
153
- def name(cls, gid):
154
- if gid in cls.NAME_BY_ID:
155
- return f'{cls.NAME_BY_ID[gid]}(0x{gid:0x})'
156
- return f'0x{gid:0x}'
157
-
158
-
159
- class TlsCipherSuites:
160
- NAME_BY_ID = {
161
- 0x1301: 'TLS_AES_128_GCM_SHA256',
162
- 0x1302: 'TLS_AES_256_GCM_SHA384',
163
- 0x1303: 'TLS_CHACHA20_POLY1305_SHA256',
164
- 0x1304: 'TLS_AES_128_CCM_SHA256',
165
- 0x1305: 'TLS_AES_128_CCM_8_SHA256',
166
- 0x00ff: 'TLS_EMPTY_RENEGOTIATION_INFO_SCSV',
167
- }
168
-
169
- @classmethod
170
- def name(cls, cid):
171
- if cid in cls.NAME_BY_ID:
172
- return f'{cls.NAME_BY_ID[cid]}(0x{cid:0x})'
173
- return f'Cipher(0x{cid:0x})'
174
-
175
-
176
- class PskKeyExchangeMode:
177
- NAME_BY_ID = {
178
- 0x00: 'psk_ke',
179
- 0x01: 'psk_dhe_ke',
180
- }
181
-
182
- @classmethod
183
- def name(cls, gid):
184
- if gid in cls.NAME_BY_ID:
185
- return f'{cls.NAME_BY_ID[gid]}(0x{gid:0x})'
186
- return f'0x{gid:0x}'
187
-
188
-
189
- class QuicTransportParam:
190
- NAME_BY_ID = {
191
- 0x00: 'original_destination_connection_id',
192
- 0x01: 'max_idle_timeout',
193
- 0x02: 'stateless_reset_token',
194
- 0x03: 'max_udp_payload_size',
195
- 0x04: 'initial_max_data',
196
- 0x05: 'initial_max_stream_data_bidi_local',
197
- 0x06: 'initial_max_stream_data_bidi_remote',
198
- 0x07: 'initial_max_stream_data_uni',
199
- 0x08: 'initial_max_streams_bidi',
200
- 0x09: 'initial_max_streams_uni',
201
- 0x0a: 'ack_delay_exponent',
202
- 0x0b: 'max_ack_delay',
203
- 0x0c: 'disable_active_migration',
204
- 0x0d: 'preferred_address',
205
- 0x0e: 'active_connection_id_limit',
206
- 0x0f: 'initial_source_connection_id',
207
- 0x10: 'retry_source_connection_id',
208
- }
209
- TYPE_BY_ID = {
210
- 0x00: bytes,
211
- 0x01: int,
212
- 0x02: bytes,
213
- 0x03: int,
214
- 0x04: int,
215
- 0x05: int,
216
- 0x06: int,
217
- 0x07: int,
218
- 0x08: int,
219
- 0x09: int,
220
- 0x0a: int,
221
- 0x0b: int,
222
- 0x0c: int,
223
- 0x0d: bytes,
224
- 0x0e: int,
225
- 0x0f: bytes,
226
- 0x10: bytes,
227
- }
228
-
229
- @classmethod
230
- def name(cls, cid):
231
- if cid in cls.NAME_BY_ID:
232
- return f'{cls.NAME_BY_ID[cid]}(0x{cid:0x})'
233
- return f'QuicTP(0x{cid:0x})'
234
-
235
- @classmethod
236
- def is_qint(cls, cid):
237
- if cid in cls.TYPE_BY_ID:
238
- return cls.TYPE_BY_ID[cid] == int
239
- return False
240
-
241
-
242
- class Extension:
243
-
244
- def __init__(self, eid, name, edata, hsid):
245
- self._eid = eid
246
- self._name = name
247
- self._edata = edata
248
- self._hsid = hsid
249
-
250
- @property
251
- def data(self):
252
- return self._edata
253
-
254
- @property
255
- def hsid(self):
256
- return self._hsid
257
-
258
- def to_json(self):
259
- jdata = {
260
- 'id': self._eid,
261
- 'name': self._name,
262
- }
263
- if len(self.data) > 0:
264
- jdata['data'] = binascii.hexlify(self.data).decode()
265
- return jdata
266
-
267
- def to_text(self, indent: int = 0):
268
- ind = ' ' * (indent + 2)
269
- s = f'{ind}{self._name}(0x{self._eid:0x})'
270
- if len(self._edata):
271
- s += f'\n{ind} data({len(self._edata)}): ' \
272
- f'{binascii.hexlify(self._edata).decode()}'
273
- return s
274
-
275
-
276
- class ExtSupportedGroups(Extension):
277
-
278
- def __init__(self, eid, name, edata, hsid):
279
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
280
- d = edata
281
- self._groups = []
282
- while len(d) > 0:
283
- d, gid = _get_int(d, 2)
284
- self._groups.append(gid)
285
-
286
- def to_json(self):
287
- jdata = {
288
- 'id': self._eid,
289
- 'name': self._name,
290
- }
291
- if len(self._groups):
292
- jdata['groups'] = [TlsSupportedGroups.name(gid)
293
- for gid in self._groups]
294
- return jdata
295
-
296
- def to_text(self, indent: int = 0):
297
- ind = ' ' * (indent + 2)
298
- gnames = [TlsSupportedGroups.name(gid) for gid in self._groups]
299
- s = f'{ind}{self._name}(0x{self._eid:0x}): {", ".join(gnames)}'
300
- return s
301
-
302
-
303
- class ExtKeyShare(Extension):
304
-
305
- def __init__(self, eid, name, edata, hsid):
306
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
307
- d = self.data
308
- self._keys = []
309
- self._group = None
310
- self._pubkey = None
311
- if self.hsid == 2: # ServerHello
312
- # single key share (group, pubkey)
313
- d, self._group = _get_int(d, 2)
314
- d, self._pubkey = _get_len_field(d, 2)
315
- elif self.hsid == 6: # HelloRetryRequest
316
- assert len(d) == 2
317
- d, self._group = _get_int(d, 2)
318
- else:
319
- # list if key shares (group, pubkey)
320
- d, shares = _get_len_field(d, 2)
321
- while len(shares) > 0:
322
- shares, group = _get_int(shares, 2)
323
- shares, pubkey = _get_len_field(shares, 2)
324
- self._keys.append({
325
- 'group': TlsSupportedGroups.name(group),
326
- 'pubkey': binascii.hexlify(pubkey).decode()
327
- })
328
-
329
- def to_json(self):
330
- jdata = super().to_json()
331
- if self._group is not None:
332
- jdata['group'] = TlsSupportedGroups.name(self._group)
333
- if self._pubkey is not None:
334
- jdata['pubkey'] = binascii.hexlify(self._pubkey).decode()
335
- if len(self._keys) > 0:
336
- jdata['keys'] = self._keys
337
- return jdata
338
-
339
- def to_text(self, indent: int = 0):
340
- ind = ' ' * (indent + 2)
341
- s = f'{ind}{self._name}(0x{self._eid:0x})'
342
- if self._group is not None:
343
- s += f'\n{ind} group: {TlsSupportedGroups.name(self._group)}'
344
- if self._pubkey is not None:
345
- s += f'\n{ind} pubkey: {binascii.hexlify(self._pubkey).decode()}'
346
- if len(self._keys) > 0:
347
- for idx, key in enumerate(self._keys):
348
- s += f'\n{ind} {idx}: {key["group"]}, {key["pubkey"]}'
349
- return s
350
-
351
-
352
- class ExtSNI(Extension):
353
-
354
- def __init__(self, eid, name, edata, hsid):
355
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
356
- d = self.data
357
- self._indicators = []
358
- while len(d) > 0:
359
- d, entry = _get_len_field(d, 2)
360
- entry, stype = _get_int(entry, 1)
361
- entry, sname = _get_len_field(entry, 2)
362
- self._indicators.append({
363
- 'type': stype,
364
- 'name': sname.decode()
365
- })
366
-
367
- def to_json(self):
368
- jdata = super().to_json()
369
- for i in self._indicators:
370
- if i['type'] == 0:
371
- jdata['host_name'] = i['name']
372
- else:
373
- jdata[f'0x{i["type"]}'] = i['name']
374
- return jdata
375
-
376
- def to_text(self, indent: int = 0):
377
- ind = ' ' * (indent + 2)
378
- s = f'{ind}{self._name}(0x{self._eid:0x})'
379
- if len(self._indicators) == 1 and self._indicators[0]['type'] == 0:
380
- s += f': {self._indicators[0]["name"]}'
381
- else:
382
- for i in self._indicators:
383
- ikey = 'host_name' if i["type"] == 0 else f'type(0x{i["type"]:0x}'
384
- s += f'\n{ind} {ikey}: {i["name"]}'
385
- return s
386
-
387
-
388
- class ExtALPN(Extension):
389
-
390
- def __init__(self, eid, name, edata, hsid):
391
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
392
- d = self.data
393
- d, list_len = _get_int(d, 2)
394
- self._protocols = []
395
- while len(d) > 0:
396
- d, proto = _get_len_field(d, 1)
397
- self._protocols.append(proto.decode())
398
-
399
- def to_json(self):
400
- jdata = super().to_json()
401
- if len(self._protocols) == 1:
402
- jdata['alpn'] = self._protocols[0]
403
- else:
404
- jdata['alpn'] = self._protocols
405
- return jdata
406
-
407
- def to_text(self, indent: int = 0):
408
- ind = ' ' * (indent + 2)
409
- return f'{ind}{self._name}(0x{self._eid:0x}): {", ".join(self._protocols)}'
410
-
411
-
412
- class ExtEarlyData(Extension):
413
-
414
- def __init__(self, eid, name, edata, hsid):
415
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
416
- self._max_size = None
417
- d = self.data
418
- if hsid == 4: # SessionTicket
419
- assert len(d) == 4, f'expected 4, len is {len(d)} data={d}'
420
- d, self._max_size = _get_int(d, 4)
421
- else:
422
- assert len(d) == 0
423
-
424
- def to_json(self):
425
- jdata = super().to_json()
426
- if self._max_size is not None:
427
- jdata['max_size'] = self._max_size
428
- return jdata
429
-
430
-
431
- class ExtSignatureAlgorithms(Extension):
432
-
433
- def __init__(self, eid, name, edata, hsid):
434
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
435
- d = self.data
436
- d, list_len = _get_int(d, 2)
437
- self._algos = []
438
- while len(d) > 0:
439
- d, algo = _get_int(d, 2)
440
- self._algos.append(TlsSignatureScheme.name(algo))
441
-
442
- def to_json(self):
443
- jdata = super().to_json()
444
- if len(self._algos) > 0:
445
- jdata['algorithms'] = self._algos
446
- return jdata
447
-
448
- def to_text(self, indent: int = 0):
449
- ind = ' ' * (indent + 2)
450
- return f'{ind}{self._name}(0x{self._eid:0x}): {", ".join(self._algos)}'
451
-
452
-
453
- class ExtPSKExchangeModes(Extension):
454
-
455
- def __init__(self, eid, name, edata, hsid):
456
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
457
- d = self.data
458
- d, list_len = _get_int(d, 1)
459
- self._modes = []
460
- while len(d) > 0:
461
- d, mode = _get_int(d, 1)
462
- self._modes.append(PskKeyExchangeMode.name(mode))
463
-
464
- def to_json(self):
465
- jdata = super().to_json()
466
- jdata['modes'] = self._modes
467
- return jdata
468
-
469
- def to_text(self, indent: int = 0):
470
- ind = ' ' * (indent + 2)
471
- return f'{ind}{self._name}(0x{self._eid:0x}): {", ".join(self._modes)}'
472
-
473
-
474
- class ExtPreSharedKey(Extension):
475
-
476
- def __init__(self, eid, name, edata, hsid):
477
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
478
- self._kid = None
479
- self._identities = None
480
- self._binders = None
481
- d = self.data
482
- if hsid == 1: # client hello
483
- d, idata = _get_len_field(d, 2)
484
- self._identities = []
485
- while len(idata):
486
- idata, identity = _get_len_field(idata, 2)
487
- idata, obfs_age = _get_int(idata, 4)
488
- self._identities.append({
489
- 'id': binascii.hexlify(identity).decode(),
490
- 'age': obfs_age,
491
- })
492
- d, binders = _get_len_field(d, 2)
493
- self._binders = []
494
- while len(binders) > 0:
495
- binders, hmac = _get_len_field(binders, 1)
496
- self._binders.append(binascii.hexlify(hmac).decode())
497
- assert len(d) == 0
498
- else:
499
- d, self._kid = _get_int(d, 2)
500
-
501
- def to_json(self):
502
- jdata = super().to_json()
503
- if self.hsid == 1:
504
- jdata['identities'] = self._identities
505
- jdata['binders'] = self._binders
506
- else:
507
- jdata['identity'] = self._kid
508
- return jdata
509
-
510
- def to_text(self, indent: int = 0):
511
- ind = ' ' * (indent + 2)
512
- s = f'{ind}{self._name}(0x{self._hsid:0x})'
513
- if self.hsid == 1:
514
- for idx, i in enumerate(self._identities):
515
- s += f'\n{ind} {idx}: {i["id"]} ({i["age"]})'
516
- s += f'\n{ind} binders: {self._binders}'
517
- else:
518
- s += f'\n{ind} identity: {self._kid}'
519
- return s
520
-
521
-
522
- class ExtSupportedVersions(Extension):
523
-
524
- def __init__(self, eid, name, edata, hsid):
525
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
526
- d = self.data
527
- self._versions = []
528
- if hsid == 1: # client hello
529
- d, list_len = _get_int(d, 1)
530
- while len(d) > 0:
531
- d, version = _get_int(d, 2)
532
- self._versions.append(f'0x{version:0x}')
533
- else:
534
- d, version = _get_int(d, 2)
535
- self._versions.append(f'0x{version:0x}')
536
-
537
- def to_json(self):
538
- jdata = super().to_json()
539
- if len(self._versions) == 1:
540
- jdata['version'] = self._versions[0]
541
- else:
542
- jdata['versions'] = self._versions
543
- return jdata
544
-
545
- def to_text(self, indent: int = 0):
546
- ind = ' ' * (indent + 2)
547
- return f'{ind}{self._name}(0x{self._eid:0x}): {", ".join(self._versions)}'
548
-
549
-
550
- class ExtQuicTP(Extension):
551
-
552
- def __init__(self, eid, name, edata, hsid):
553
- super().__init__(eid=eid, name=name, edata=edata, hsid=hsid)
554
- d = self.data
555
- self._params = []
556
- while len(d) > 0:
557
- d, ptype = _get_qint(d)
558
- d, plen = _get_qint(d)
559
- d, pvalue = _get_field(d, plen)
560
- if QuicTransportParam.is_qint(ptype):
561
- _, pvalue = _get_qint(pvalue)
562
- else:
563
- pvalue = binascii.hexlify(pvalue).decode()
564
- self._params.append({
565
- 'key': QuicTransportParam.name(ptype),
566
- 'value': pvalue,
567
- })
568
-
569
- def to_json(self):
570
- jdata = super().to_json()
571
- jdata['params'] = self._params
572
- return jdata
573
-
574
- def to_text(self, indent: int = 0):
575
- ind = ' ' * (indent + 2)
576
- s = f'{ind}{self._name}(0x{self._eid:0x})'
577
- for p in self._params:
578
- s += f'\n{ind} {p["key"]}: {p["value"]}'
579
- return s
580
-
581
-
582
- class TlsExtensions:
583
-
584
- EXT_TYPES = [
585
- (0x00, 'SNI', ExtSNI),
586
- (0x01, 'MAX_FRAGMENT_LENGTH', Extension),
587
- (0x03, 'TRUSTED_CA_KEYS', Extension),
588
- (0x04, 'TRUNCATED_HMAC', Extension),
589
- (0x05, 'OSCP_STATUS_REQUEST', Extension),
590
- (0x0a, 'SUPPORTED_GROUPS', ExtSupportedGroups),
591
- (0x0b, 'EC_POINT_FORMATS', Extension),
592
- (0x0d, 'SIGNATURE_ALGORITHMS', ExtSignatureAlgorithms),
593
- (0x0e, 'USE_SRTP', Extension),
594
- (0x10, 'ALPN', ExtALPN),
595
- (0x11, 'STATUS_REQUEST_V2', Extension),
596
- (0x16, 'ENCRYPT_THEN_MAC', Extension),
597
- (0x17, 'EXTENDED_MASTER_SECRET', Extension),
598
- (0x23, 'SESSION_TICKET', Extension),
599
- (0x29, 'PRE_SHARED_KEY', ExtPreSharedKey),
600
- (0x2a, 'EARLY_DATA', ExtEarlyData),
601
- (0x2b, 'SUPPORTED_VERSIONS', ExtSupportedVersions),
602
- (0x2c, 'COOKIE', Extension),
603
- (0x2d, 'PSK_KEY_EXCHANGE_MODES', ExtPSKExchangeModes),
604
- (0x31, 'POST_HANDSHAKE_AUTH', Extension),
605
- (0x32, 'SIGNATURE_ALGORITHMS_CERT', Extension),
606
- (0x33, 'KEY_SHARE', ExtKeyShare),
607
- (0x39, 'QUIC_TP_PARAMS', ExtQuicTP),
608
- (0xff01, 'RENEGOTIATION_INFO', Extension),
609
- (0xffa5, 'QUIC_TP_PARAMS_DRAFT', ExtQuicTP),
610
- ]
611
- NAME_BY_ID = {}
612
- CLASS_BY_ID = {}
613
-
614
- @classmethod
615
- def init(cls):
616
- for (eid, name, ecls) in cls.EXT_TYPES:
617
- cls.NAME_BY_ID[eid] = name
618
- cls.CLASS_BY_ID[eid] = ecls
619
-
620
- @classmethod
621
- def from_data(cls, hsid, data):
622
- exts = []
623
- d = data
624
- while len(d):
625
- d, eid = _get_int(d, 2)
626
- d, elen = _get_int(d, 2)
627
- d, edata = _get_field(d, elen)
628
- if eid in cls.NAME_BY_ID:
629
- ename = cls.NAME_BY_ID[eid]
630
- ecls = cls.CLASS_BY_ID[eid]
631
- exts.append(ecls(eid=eid, name=ename, edata=edata, hsid=hsid))
632
- else:
633
- exts.append(Extension(eid=eid, name=f'(0x{eid:0x})',
634
- edata=edata, hsid=hsid))
635
- return exts
636
-
637
-
638
- TlsExtensions.init()
639
-
640
-
641
- class HSRecord:
642
-
643
- def __init__(self, hsid: int, name: str, data):
644
- self._hsid = hsid
645
- self._name = name
646
- self._data = data
647
-
648
- @property
649
- def hsid(self):
650
- return self._hsid
651
-
652
- @property
653
- def name(self):
654
- return self._name
655
-
656
- @name.setter
657
- def name(self, value):
658
- self._name = value
659
-
660
- @property
661
- def data(self):
662
- return self._data
663
-
664
- def __repr__(self):
665
- return f'{self.name}[{binascii.hexlify(self._data).decode()}]'
666
-
667
- def to_json(self) -> Dict[str, Any]:
668
- return {
669
- 'name': self.name,
670
- 'data': binascii.hexlify(self._data).decode(),
671
- }
672
-
673
- def to_text(self, indent: int = 0):
674
- ind = ' ' * (indent + 2)
675
- return f'{ind}{self._name}\n'\
676
- f'{ind} id: 0x{self._hsid:0x}\n'\
677
- f'{ind} data({len(self._data)}): '\
678
- f'{binascii.hexlify(self._data).decode()}'
679
-
680
-
681
- class ClientHello(HSRecord):
682
-
683
- def __init__(self, hsid: int, name: str, data):
684
- super().__init__(hsid=hsid, name=name, data=data)
685
- d = data
686
- d, self._version = _get_int(d, 2)
687
- d, self._random = _get_field(d, 32)
688
- d, self._session_id = _get_len_field(d, 1)
689
- self._ciphers = []
690
- d, ciphers = _get_len_field(d, 2)
691
- while len(ciphers):
692
- ciphers, cipher = _get_int(ciphers, 2)
693
- self._ciphers.append(TlsCipherSuites.name(cipher))
694
- d, comps = _get_len_field(d, 1)
695
- self._compressions = [int(c) for c in comps]
696
- d, edata = _get_len_field(d, 2)
697
- self._extensions = TlsExtensions.from_data(hsid, edata)
698
-
699
- def to_json(self):
700
- jdata = super().to_json()
701
- jdata['version'] = f'0x{self._version:0x}'
702
- jdata['random'] = f'{binascii.hexlify(self._random).decode()}'
703
- jdata['session_id'] = binascii.hexlify(self._session_id).decode()
704
- jdata['ciphers'] = self._ciphers
705
- jdata['compressions'] = self._compressions
706
- jdata['extensions'] = [ext.to_json() for ext in self._extensions]
707
- return jdata
708
-
709
- def to_text(self, indent: int = 0):
710
- ind = ' ' * (indent + 2)
711
- return super().to_text(indent=indent) + '\n'\
712
- f'{ind} version: 0x{self._version:0x}\n'\
713
- f'{ind} random: {binascii.hexlify(self._random).decode()}\n' \
714
- f'{ind} session_id: {binascii.hexlify(self._session_id).decode()}\n' \
715
- f'{ind} ciphers: {", ".join(self._ciphers)}\n'\
716
- f'{ind} compressions: {self._compressions}\n'\
717
- f'{ind} extensions: \n' + '\n'.join(
718
- [ext.to_text(indent=indent+4) for ext in self._extensions])
719
-
720
-
721
- class ServerHello(HSRecord):
722
-
723
- HELLO_RETRY_RANDOM = binascii.unhexlify(
724
- 'CF21AD74E59A6111BE1D8C021E65B891C2A211167ABB8C5E079E09E2C8A8339C'
725
- )
726
-
727
- def __init__(self, hsid: int, name: str, data):
728
- super().__init__(hsid=hsid, name=name, data=data)
729
- d = data
730
- d, self._version = _get_int(d, 2)
731
- d, self._random = _get_field(d, 32)
732
- if self._random == self.HELLO_RETRY_RANDOM:
733
- self.name = 'HelloRetryRequest'
734
- hsid = 6
735
- d, self._session_id = _get_len_field(d, 1)
736
- d, cipher = _get_int(d, 2)
737
- self._cipher = TlsCipherSuites.name(cipher)
738
- d, self._compression = _get_int(d, 1)
739
- d, edata = _get_len_field(d, 2)
740
- self._extensions = TlsExtensions.from_data(hsid, edata)
741
-
742
- def to_json(self):
743
- jdata = super().to_json()
744
- jdata['version'] = f'0x{self._version:0x}'
745
- jdata['random'] = f'{binascii.hexlify(self._random).decode()}'
746
- jdata['session_id'] = binascii.hexlify(self._session_id).decode()
747
- jdata['cipher'] = self._cipher
748
- jdata['compression'] = int(self._compression)
749
- jdata['extensions'] = [ext.to_json() for ext in self._extensions]
750
- return jdata
751
-
752
- def to_text(self, indent: int = 0):
753
- ind = ' ' * (indent + 2)
754
- return super().to_text(indent=indent) + '\n'\
755
- f'{ind} version: 0x{self._version:0x}\n'\
756
- f'{ind} random: {binascii.hexlify(self._random).decode()}\n' \
757
- f'{ind} session_id: {binascii.hexlify(self._session_id).decode()}\n' \
758
- f'{ind} cipher: {self._cipher}\n'\
759
- f'{ind} compression: {int(self._compression)}\n'\
760
- f'{ind} extensions: \n' + '\n'.join(
761
- [ext.to_text(indent=indent+4) for ext in self._extensions])
762
-
763
-
764
- class EncryptedExtensions(HSRecord):
765
-
766
- def __init__(self, hsid: int, name: str, data):
767
- super().__init__(hsid=hsid, name=name, data=data)
768
- d = data
769
- d, edata = _get_len_field(d, 2)
770
- self._extensions = TlsExtensions.from_data(hsid, edata)
771
-
772
- def to_json(self):
773
- jdata = super().to_json()
774
- jdata['extensions'] = [ext.to_json() for ext in self._extensions]
775
- return jdata
776
-
777
- def to_text(self, indent: int = 0):
778
- ind = ' ' * (indent + 2)
779
- return super().to_text(indent=indent) + '\n'\
780
- f'{ind} extensions: \n' + '\n'.join(
781
- [ext.to_text(indent=indent+4) for ext in self._extensions])
782
-
783
-
784
- class CertificateRequest(HSRecord):
785
-
786
- def __init__(self, hsid: int, name: str, data):
787
- super().__init__(hsid=hsid, name=name, data=data)
788
- d = data
789
- d, self._context = _get_int(d, 1)
790
- d, edata = _get_len_field(d, 2)
791
- self._extensions = TlsExtensions.from_data(hsid, edata)
792
-
793
- def to_json(self):
794
- jdata = super().to_json()
795
- jdata['context'] = self._context
796
- jdata['extensions'] = [ext.to_json() for ext in self._extensions]
797
- return jdata
798
-
799
- def to_text(self, indent: int = 0):
800
- ind = ' ' * (indent + 2)
801
- return super().to_text(indent=indent) + '\n'\
802
- f'{ind} context: {self._context}\n'\
803
- f'{ind} extensions: \n' + '\n'.join(
804
- [ext.to_text(indent=indent+4) for ext in self._extensions])
805
-
806
-
807
- class Certificate(HSRecord):
808
-
809
- def __init__(self, hsid: int, name: str, data):
810
- super().__init__(hsid=hsid, name=name, data=data)
811
- d = data
812
- d, self._context = _get_int(d, 1)
813
- d, clist = _get_len_field(d, 3)
814
- self._cert_entries = []
815
- while len(clist) > 0:
816
- clist, cert_data = _get_len_field(clist, 3)
817
- clist, cert_exts = _get_len_field(clist, 2)
818
- exts = TlsExtensions.from_data(hsid, cert_exts)
819
- self._cert_entries.append({
820
- 'cert': binascii.hexlify(cert_data).decode(),
821
- 'extensions': exts,
822
- })
823
-
824
- def to_json(self):
825
- jdata = super().to_json()
826
- jdata['context'] = self._context
827
- jdata['certificate_list'] = [{
828
- 'cert': e['cert'],
829
- 'extensions': [x.to_json() for x in e['extensions']],
830
- } for e in self._cert_entries]
831
- return jdata
832
-
833
- def _enxtry_text(self, e, indent: int = 0):
834
- ind = ' ' * (indent + 2)
835
- return f'{ind} cert: {e["cert"]}\n'\
836
- f'{ind} extensions: \n' + '\n'.join(
837
- [x.to_text(indent=indent + 4) for x in e['extensions']])
838
-
839
- def to_text(self, indent: int = 0):
840
- ind = ' ' * (indent + 2)
841
- return super().to_text(indent=indent) + '\n'\
842
- f'{ind} context: {self._context}\n'\
843
- f'{ind} certificate_list: \n' + '\n'.join(
844
- [self._enxtry_text(e, indent+4) for e in self._cert_entries])
845
-
846
-
847
- class SessionTicket(HSRecord):
848
-
849
- def __init__(self, hsid: int, name: str, data):
850
- super().__init__(hsid=hsid, name=name, data=data)
851
- d = data
852
- d, self._lifetime = _get_int(d, 4)
853
- d, self._age = _get_int(d, 4)
854
- d, self._nonce = _get_len_field(d, 1)
855
- d, self._ticket = _get_len_field(d, 2)
856
- d, edata = _get_len_field(d, 2)
857
- self._extensions = TlsExtensions.from_data(hsid, edata)
858
-
859
- def to_json(self):
860
- jdata = super().to_json()
861
- jdata['lifetime'] = self._lifetime
862
- jdata['age'] = self._age
863
- jdata['nonce'] = binascii.hexlify(self._nonce).decode()
864
- jdata['ticket'] = binascii.hexlify(self._ticket).decode()
865
- jdata['extensions'] = [ext.to_json() for ext in self._extensions]
866
- return jdata
867
-
868
-
869
- class HSIterator(Iterator):
870
-
871
- def __init__(self, recs):
872
- self._recs = recs
873
- self._index = 0
874
-
875
- def __iter__(self):
876
- return self
877
-
878
- def __next__(self):
879
- try:
880
- result = self._recs[self._index]
881
- except IndexError:
882
- raise StopIteration
883
- self._index += 1
884
- return result
885
-
886
-
887
- class HandShake:
888
- REC_TYPES = [
889
- (1, 'ClientHello', ClientHello),
890
- (2, 'ServerHello', ServerHello),
891
- (3, 'HelloVerifyRequest', HSRecord),
892
- (4, 'SessionTicket', SessionTicket),
893
- (5, 'EndOfEarlyData', HSRecord),
894
- (6, 'HelloRetryRequest', ServerHello),
895
- (8, 'EncryptedExtensions', EncryptedExtensions),
896
- (11, 'Certificate', Certificate),
897
- (12, 'ServerKeyExchange ', HSRecord),
898
- (13, 'CertificateRequest', CertificateRequest),
899
- (14, 'ServerHelloDone', HSRecord),
900
- (15, 'CertificateVerify', HSRecord),
901
- (16, 'ClientKeyExchange', HSRecord),
902
- (20, 'Finished', HSRecord),
903
- (22, 'CertificateStatus', HSRecord),
904
- (24, 'KeyUpdate', HSRecord),
905
- ]
906
- RT_NAME_BY_ID = {}
907
- RT_CLS_BY_ID = {}
908
-
909
- @classmethod
910
- def _parse_rec(cls, data):
911
- d, hsid = _get_int(data, 1)
912
- if hsid not in cls.RT_CLS_BY_ID:
913
- raise ParseError(f'unknown type {hsid}')
914
- d, rec_len = _get_int(d, 3)
915
- if rec_len > len(d):
916
- # incomplete, need more data
917
- return data, None
918
- d, rec_data = _get_field(d, rec_len)
919
- if hsid in cls.RT_CLS_BY_ID:
920
- name = cls.RT_NAME_BY_ID[hsid]
921
- rcls = cls.RT_CLS_BY_ID[hsid]
922
- else:
923
- name = f'CryptoRecord(0x{hsid:0x})'
924
- rcls = HSRecord
925
- return d, rcls(hsid=hsid, name=name, data=rec_data)
926
-
927
- @classmethod
928
- def _parse(cls, source, strict=False, verbose: int = 0):
929
- d = b''
930
- hsid = 0
931
- hsrecs = []
932
- if verbose > 0:
933
- log.debug(f'scanning for handshake records')
934
- blocks = [d for d in source]
935
- while len(blocks) > 0:
936
- try:
937
- total_data = b''.join(blocks)
938
- remain, r = cls._parse_rec(total_data)
939
- if r is None:
940
- # if we could not recognize a record, skip the first
941
- # data block and try again
942
- blocks = blocks[1:]
943
- continue
944
- hsrecs.append(r)
945
- cons_len = len(total_data) - len(remain)
946
- while cons_len > 0 and len(blocks) > 0:
947
- if cons_len >= len(blocks[0]):
948
- cons_len -= len(blocks[0])
949
- blocks = blocks[1:]
950
- else:
951
- blocks[0] = blocks[0][cons_len:]
952
- cons_len = 0
953
- if verbose > 2:
954
- log.debug(f'added record: {r.to_text()}')
955
- except ParseError as err:
956
- # if we could not recognize a record, skip the first
957
- # data block and try again
958
- blocks = blocks[1:]
959
- if len(blocks) > 0 and strict:
960
- raise Exception(f'possibly incomplete handshake record '
961
- f'id={hsid}, from raw={blocks}\n')
962
- return hsrecs
963
-
964
-
965
-
966
- @classmethod
967
- def init(cls):
968
- for (hsid, name, rcls) in cls.REC_TYPES:
969
- cls.RT_NAME_BY_ID[hsid] = name
970
- cls.RT_CLS_BY_ID[hsid] = rcls
971
-
972
- def __init__(self, source: Iterable[bytes], strict: bool = False,
973
- verbose: int = 0):
974
- self._source = source
975
- self._strict = strict
976
- self._verbose = verbose
977
-
978
- def __iter__(self):
979
- return HSIterator(recs=self._parse(self._source, strict=self._strict,
980
- verbose=self._verbose))
981
-
982
-
983
- HandShake.init()