raioquic 0.1.0

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/.containerignore +4 -0
  3. data/.rubocop.yml +93 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Containerfile +6 -0
  7. data/Gemfile +24 -0
  8. data/Gemfile.lock +113 -0
  9. data/LICENSE +28 -0
  10. data/README.md +48 -0
  11. data/Rakefile +16 -0
  12. data/Steepfile +8 -0
  13. data/example/curlcatcher.rb +18 -0
  14. data/example/interoperability/README.md +9 -0
  15. data/example/interoperability/aioquic/aioquic_client.py +47 -0
  16. data/example/interoperability/aioquic/aioquic_server.py +34 -0
  17. data/example/interoperability/key.pem +28 -0
  18. data/example/interoperability/localhost-unasuke-dev.crt +21 -0
  19. data/example/interoperability/quic-go/sample_server.go +61 -0
  20. data/example/interoperability/raioquic_client.rb +42 -0
  21. data/example/interoperability/raioquic_server.rb +43 -0
  22. data/example/parse_curl_example.rb +108 -0
  23. data/lib/raioquic/buffer.rb +202 -0
  24. data/lib/raioquic/core_ext.rb +54 -0
  25. data/lib/raioquic/crypto/README.md +5 -0
  26. data/lib/raioquic/crypto/aesgcm.rb +52 -0
  27. data/lib/raioquic/crypto/backend/aead.rb +52 -0
  28. data/lib/raioquic/crypto/backend.rb +12 -0
  29. data/lib/raioquic/crypto.rb +10 -0
  30. data/lib/raioquic/quic/configuration.rb +81 -0
  31. data/lib/raioquic/quic/connection.rb +2776 -0
  32. data/lib/raioquic/quic/crypto.rb +317 -0
  33. data/lib/raioquic/quic/event.rb +69 -0
  34. data/lib/raioquic/quic/logger.rb +272 -0
  35. data/lib/raioquic/quic/packet.rb +471 -0
  36. data/lib/raioquic/quic/packet_builder.rb +301 -0
  37. data/lib/raioquic/quic/rangeset.rb +113 -0
  38. data/lib/raioquic/quic/recovery.rb +528 -0
  39. data/lib/raioquic/quic/stream.rb +343 -0
  40. data/lib/raioquic/quic.rb +20 -0
  41. data/lib/raioquic/tls.rb +1659 -0
  42. data/lib/raioquic/version.rb +5 -0
  43. data/lib/raioquic.rb +12 -0
  44. data/misc/export_x25519.py +43 -0
  45. data/misc/gen_rfc8448_keypair.rb +90 -0
  46. data/raioquic.gemspec +37 -0
  47. data/sig/raioquic/buffer.rbs +37 -0
  48. data/sig/raioquic/core_ext.rbs +7 -0
  49. data/sig/raioquic/crypto/aesgcm.rbs +20 -0
  50. data/sig/raioquic/crypto/backend/aead.rbs +11 -0
  51. data/sig/raioquic/quic/configuration.rbs +34 -0
  52. data/sig/raioquic/quic/connection.rbs +277 -0
  53. data/sig/raioquic/quic/crypto.rbs +88 -0
  54. data/sig/raioquic/quic/event.rbs +51 -0
  55. data/sig/raioquic/quic/logger.rbs +57 -0
  56. data/sig/raioquic/quic/packet.rbs +157 -0
  57. data/sig/raioquic/quic/packet_builder.rbs +76 -0
  58. data/sig/raioquic/quic/rangeset.rbs +17 -0
  59. data/sig/raioquic/quic/recovery.rbs +142 -0
  60. data/sig/raioquic/quic/stream.rbs +87 -0
  61. data/sig/raioquic/tls.rbs +444 -0
  62. data/sig/raioquic.rbs +9 -0
  63. metadata +121 -0
@@ -0,0 +1,444 @@
1
+ module Raioquic
2
+ module TLS
3
+ TLS_VERSION_1_2: ::Integer # 0x0303
4
+ TLS_VERSION_1_3: ::Integer # 0x0304
5
+ TLS_VERSION_1_3_DRAFT_28: ::Integer # 0x7f1c
6
+ TLS_VERSION_1_3_DRAFT_27: ::Integer # 0x7f1b
7
+ TLS_VERSION_1_3_DRAFT_26: ::Integer # 0x7f1a
8
+
9
+ class AlertDescription
10
+ CLOSE_NOTIFY: 0
11
+ UNEXPECTED_MESSAGE: 10
12
+ BAD_RECORD_MAC: 20
13
+ RECORD_OVERFLOW: 22
14
+ HANDSHAKE_FAILURE: 40
15
+ BAD_CERTIFICATE: 42
16
+ UNSUPPORTED_CERTIFICATE: 43
17
+ CERTIFICATE_REVOKED: 44
18
+ CERTIFICATE_EXPIRED: 45
19
+ CERTIFICATE_UNKNOWN: 46
20
+ ILLEGAL_PARAMETER: 47
21
+ UNKNOWN_CA: 48
22
+ ACCESS_DENIED: 49
23
+ DECODE_ERROR: 50
24
+ DECRYPT_ERROR: 51
25
+ PROTOCOL_VERSION: 70
26
+ INSUFFICIENT_SECURITY: 71
27
+ INTERNAL_ERROR: 80
28
+ INAPPROPRIATE_FALLBACK: 86
29
+ USER_CANCELED: 90
30
+ MISSING_EXTENSION: 109
31
+ UNSUPPORTED_EXTENSION: 110
32
+ UNRECOGNIZED_NAME: 112
33
+ BAD_CERTIFICATE_STATUS_RESPONSE: 113
34
+ UNKNOWN_PSK_IDENTITY: 115
35
+ CERTIFICATE_REQUIRED: 116
36
+ NO_APPLICATION_PROTOCOL: 120
37
+ end
38
+
39
+ class Alert < StandardError
40
+ end
41
+
42
+ class AlertBadCertificate < Alert
43
+ def description: () -> ::Integer
44
+ end
45
+
46
+ class AlertCertificateExpired < Alert
47
+ def description: () -> ::Integer
48
+ end
49
+
50
+ class AlertDecryptError < Alert
51
+ def description: () -> ::Integer
52
+ end
53
+
54
+ class AlertHandshakeFailure < Alert
55
+ def description: () -> ::Integer
56
+ end
57
+
58
+ class AlertIllegalParameter < Alert
59
+ def description: () -> ::Integer
60
+ end
61
+
62
+ class AlertInternalError < Alert
63
+ def description: () -> ::Integer
64
+ end
65
+
66
+ class AlertProtocolVersion < Alert
67
+ def description: () -> ::Integer
68
+ end
69
+
70
+ class AlertUnexpectedMessage < Alert
71
+ def description: () -> ::Integer
72
+ end
73
+
74
+ class Direction
75
+ DECRYPT: 0
76
+ ENCRYPT: 1
77
+ end
78
+
79
+ class Epoch
80
+ INITIAL: 0
81
+ ZERO_RTT: 1
82
+ HANDSHAKE: 2
83
+ ONE_RTT: 3
84
+ end
85
+
86
+ class State
87
+ CLIENT_HANDSHAKE_START: 0
88
+ CLIENT_EXPECT_SERVER_HELLO: 1
89
+ CLIENT_EXPECT_ENCRYPTED_EXTENSIONS: 2
90
+ CLIENT_EXPECT_CERTIFICATE_REQUEST_OR_CERTIFICATE: 3
91
+ CLIENT_EXPECT_CERTIFICATE_CERTIFICATE: 4
92
+ CLIENT_EXPECT_CERTIFICATE_VERIFY: 5
93
+ CLIENT_EXPECT_FINISHED: 6
94
+ CLIENT_POST_HANDSHAKE: 7
95
+ SERVER_EXPECT_CLIENT_HELLO: 8
96
+ SERVER_EXPECT_FINISHED: 9
97
+ SERVER_POST_HANDSHAKE: 10
98
+ end
99
+
100
+ def self.load_pem_private_key: (::String) -> OpenSSL::PKey::PKey
101
+ | (::String, ::String) -> OpenSSL::PKey::PKey
102
+ def self.load_pem_x509_certificates: (::String) -> ::Array[OpenSSL::X509::Certificate]
103
+ def self.verify_certificate: (certificate: OpenSSL::X509::Certificate, ?chain: ::Array[untyped], ?server_name: ::String|nil, ?cadata: untyped, ?cafile: untyped, ?capath: untyped) -> void
104
+
105
+ class CipherSuite
106
+ AES_128_GCM_SHA256: ::Integer # 0x1301
107
+ AES_256_GCM_SHA384: ::Integer # 0x1302
108
+ CHACHA20_POLY1305_SHA256: ::Integer # 0x1303
109
+ EMPTY_RENEGOTIATION_INFO_SCSV: ::Integer # 0x00ff
110
+ end
111
+
112
+ class CompressionMethod
113
+ NULL: 0
114
+ end
115
+
116
+ class ExtensionType
117
+ SERVER_NAME: 0
118
+ STATUS_REQUEST: 5
119
+ SUPPORTED_GROUPS: 10
120
+ SIGNATURE_ALGORITHMS: 13
121
+ ALPN: 16
122
+ COMPRESS_CERTIFICATE: 27
123
+ PRE_SHARED_KEY: 41
124
+ EARLY_DATA: 42
125
+ SUPPORTED_VERSIONS: 43
126
+ COOKIE: 44
127
+ PSK_KEY_EXCHANGE_MODES: 45
128
+ KEY_SHARE: 51
129
+ QUIC_TRANSPORT_PARAMETERS: ::Integer # 0x0039
130
+ QUIC_TRANSPORT_PARAMETERS_DRAFT: ::Integer # 0xffa5
131
+ ENCRYPTED_SERVER_NAME: 65486
132
+ end
133
+
134
+ class Group
135
+ SECP256R1: ::Integer # 0x0017
136
+ SECP384R1: ::Integer # 0x0018
137
+ SECP521R1: ::Integer # 0x0019
138
+ X25519: ::Integer # 0x001d
139
+ X448: ::Integer # 0x001e
140
+ GREASE: ::Integer # 0xaaaa
141
+ end
142
+
143
+ class HandshakeType
144
+ CLIENT_HELLO: 1
145
+ SERVER_HELLO: 2
146
+ NEW_SESSION_TICKET: 4
147
+ END_OF_EARLY_DATA: 5
148
+ ENCRYPTED_EXTENSIONS: 8
149
+ CERTIFICATE: 11
150
+ CERTIFICATE_REQUEST: 13
151
+ CERTIFICATE_VERIFY: 15
152
+ FINISHED: 20
153
+ KEY_UPDATE: 24
154
+ COMPRESSED_CERTIFICATE: 25
155
+ MESSAGE_HASH: 254
156
+ end
157
+
158
+ class PskKeyExchangeMode
159
+ PSK_KE: 0
160
+ PSK_DHE_KE: 1
161
+ end
162
+
163
+ class SignatureAlgorithm
164
+ ECDSA_SECP256R1_SHA256: ::Integer # 0x0403
165
+ ECDSA_SECP384R1_SHA384: ::Integer # 0x0503
166
+ ECDSA_SECP521R1_SHA512: ::Integer # 0x0603
167
+ ED25519: ::Integer # 0x0807
168
+ ED448: ::Integer # 0x0808
169
+ RSA_PKCS1_SHA256: ::Integer # 0x0401
170
+ RSA_PKCS1_SHA384: ::Integer # 0x0501
171
+ RSA_PKCS1_SHA512: ::Integer # 0x0601
172
+ RSA_PSS_PSS_SHA256: ::Integer # 0x0809
173
+ RSA_PSS_PSS_SHA384: ::Integer # 0x080a
174
+ RSA_PSS_PSS_SHA512: ::Integer # 0x080b
175
+ RSA_PSS_RSAE_SHA256: ::Integer # 0x0804
176
+ RSA_PSS_RSAE_SHA384: ::Integer # 0x0805
177
+ RSA_PSS_RSAE_SHA512: ::Integer # 0x0806
178
+
179
+ # legacy
180
+ RSA_PKCS1_SHA1: ::Integer # 0x0201
181
+ SHA1_DSA: ::Integer # 0x0202
182
+ ECDSA_SHA1: ::Integer # 0x0203
183
+ end
184
+
185
+ def self.pull_block: (buf: ::Raioquic::Buffer, capacity: ::Integer) { (::Integer) -> untyped } -> untyped
186
+ def self.push_block: (buf: ::Raioquic::Buffer, capacity: ::Integer) { (untyped) -> untyped } -> untyped
187
+ def self.pull_list: (buf: ::Raioquic::Buffer, capacity: ::Integer, func: ::Proc) -> ::Array[untyped]
188
+ def self.push_list: (buf: ::Raioquic::Buffer, capacity: ::Integer, func: ::Proc, values: ::Array[untyped]) -> void
189
+ def self.pull_opaque: (buf: ::Raioquic::Buffer, capacity: ::Integer) -> ::String
190
+ def self.push_opaque: (buf: ::Raioquic::Buffer, capacity: ::Integer, value: untyped) -> void
191
+ def self.push_extension: (buf: ::Raioquic::Buffer, extension_type: ::Integer) { (untyped) -> untyped } -> void
192
+ type key_share_entry = [::Integer, ::String]
193
+ def self.pull_key_share: (buf: ::Raioquic::Buffer) -> key_share_entry
194
+ def self.push_key_share: (buf: ::Raioquic::Buffer, value: key_share_entry) -> void
195
+ def self.pull_alpn_protocol: (buf: ::Raioquic::Buffer) -> ::String
196
+ def self.push_alpn_protocol: (buf: ::Raioquic::Buffer, protocol: ::Integer) -> void
197
+ type psk_identity = [::String, ::Integer]
198
+ def self.pull_psk_identity: (buf: ::Raioquic::Buffer) -> psk_identity
199
+ def self.push_psk_identity: (buf: ::Raioquic::Buffer, entry: psk_identity) -> void
200
+ def self.pull_psk_binder: (buf: ::Raioquic::Buffer) -> ::String
201
+ def self.push_psk_binder: (buf: ::Raioquic::Buffer, binder: ::String) -> void
202
+
203
+ class OfferedPsks
204
+ attr_accessor identities: ::Array[psk_identity]
205
+ attr_accessor binders: ::Array[::String]
206
+ end
207
+
208
+ type tls_extension = [::Integer, ::String]
209
+ class ClientHello
210
+ attr_accessor random: ::String
211
+ attr_accessor legacy_session_id: ::String
212
+ attr_accessor cipher_suites: ::Array[::Integer]
213
+ attr_accessor legacy_compression_methods: ::Array[::Integer]
214
+ attr_accessor alpn_protocols: ::Array[::String] | nil
215
+ attr_accessor early_data: bool
216
+ attr_accessor key_share: ::Array[key_share_entry] | nil
217
+ attr_accessor pre_shared_key: OfferedPsks | nil
218
+ attr_accessor psk_key_exchange_modes: ::Array[::Integer] | nil
219
+ attr_accessor server_name: ::String | nil
220
+ attr_accessor signature_algorithms: ::Array[::Integer] | nil
221
+ attr_accessor supported_groups: ::Array[::Integer] | nil
222
+ attr_accessor supported_versions: ::Array[::Integer] | nil
223
+ attr_accessor other_extensions: ::Array[tls_extension]
224
+ end
225
+
226
+ def self.pull_client_hello: (::Raioquic::Buffer) -> ClientHello
227
+ def self.push_client_hello: (buf: ::Raioquic::Buffer, hello: ClientHello) -> void
228
+
229
+ class ServerHello
230
+ attr_accessor random: ::String
231
+ attr_accessor legacy_session_id: ::String
232
+ attr_accessor cipher_suite: ::Integer
233
+ attr_accessor compression_method: ::Integer
234
+ attr_accessor key_share: key_share_entry | nil
235
+ attr_accessor pre_shared_key: ::Integer | nil
236
+ attr_accessor supported_version: ::Integer | nil
237
+ attr_accessor other_extensions: ::Array[tls_extension]
238
+ end
239
+
240
+ def self.pull_server_hello: (::Raioquic::Buffer) -> ServerHello
241
+ def self.push_server_hello: (buf: ::Raioquic::Buffer, hello: ServerHello) -> void
242
+
243
+ class NewSessionTicket
244
+ attr_accessor ticket_lifetime: ::Integer
245
+ attr_accessor ticket_age_add: ::Integer
246
+ attr_accessor ticket_nonce: ::String
247
+ attr_accessor ticket: ::String
248
+ attr_accessor max_early_data_size: ::Integer | nil
249
+ attr_accessor other_extensions: ::Array[tls_extension]
250
+ end
251
+
252
+ def self.pull_new_session_ticket: (::Raioquic::Buffer) -> NewSessionTicket
253
+ def self.push_new_session_ticket: (buf: ::Raioquic::Buffer, new_session_ticket: NewSessionTicket) -> void
254
+
255
+ class EncryptedExtensions
256
+ attr_accessor alpn_protocol: ::String | nil
257
+ attr_accessor early_data: bool
258
+ attr_accessor other_extensions: ::Array[tls_extension]
259
+ end
260
+
261
+ def self.pull_encrypted_extensions: (::Raioquic::Buffer) -> EncryptedExtensions
262
+ def self.push_encrypted_extensions: (buf: ::Raioquic::Buffer, extensions: EncryptedExtensions) -> void
263
+
264
+ type certificate_entry = [::String, ::String]
265
+ class Certificate
266
+ attr_accessor request_context: ::String
267
+ attr_accessor certificates: ::Array[certificate_entry]
268
+ end
269
+
270
+ def self.pull_certificate: (::Raioquic::Buffer) -> Certificate
271
+ def self.push_certificate: (buf: ::Raioquic::Buffer, certificate: Certificate) -> void
272
+
273
+ class CertificateVerify
274
+ attr_accessor algorithm: ::Integer
275
+ attr_accessor signature: ::String
276
+ end
277
+
278
+ def self.pull_certificate_verify: (::Raioquic::Buffer) -> CertificateVerify
279
+ def self.push_certificate_verify: (buf: ::Raioquic::Buffer, verify: CertificateVerify) -> void
280
+
281
+ class Finished
282
+ attr_accessor verify_data: ::String
283
+ end
284
+
285
+ def self.pull_finished: (::Raioquic::Buffer) -> Finished
286
+ def self.push_finished: (buf: ::Raioquic::Buffer, finished: Finished) -> void
287
+
288
+ class KeySchedule
289
+ @algorithm: singleton(::OpenSSL::Digest)
290
+ @cipher_suite: CipherSuite
291
+ @generation: ::Integer
292
+ @hash: untyped # TODO: ::OpenSSL::Digest::SHA256 | ::OpenSSL::Digest::SHA384 | ::OpenSSL::Digest::SHA512
293
+ @hash_empty_value: untyped
294
+ @secret: ::String
295
+
296
+ def initialize: (::Integer) -> void
297
+ def certificate_verify_data: (::String) -> ::String
298
+ def finished_verify_data: (::String) -> ::String
299
+ def derive_secret: (::String) -> ::String
300
+ def extract: (::String) -> void
301
+ | () -> void
302
+ def update_hash: (::String) -> void
303
+ end
304
+
305
+ class KeyScheduleProxy
306
+ @schedules: ::Hash[::Integer, KeySchedule]
307
+
308
+ def initialize: (::Array[::Integer]) -> void
309
+ def extract: (::String) -> void
310
+ | () -> void
311
+ def select: (::Integer) -> KeySchedule
312
+ def update_hash: (::String) -> void
313
+ end
314
+
315
+ CIPHER_SUITES: ::Hash[::Integer, singleton(::OpenSSL::Digest)]
316
+ SIGNATURE_ALGORITHMS: ::Hash[::Integer, ::Array[untyped]] # TODO: [(::Symbol|nil), singleton(::OpenSSL::Digest)]
317
+ GROUP_TO_CURVE: ::Hash[::Integer, ::String]
318
+ CURVE_TO_GROUP: ::Hash[::String, ::Integer]
319
+
320
+ def self.cipher_suite_hash: (::Integer) -> singleton(OpenSSL::Digest)
321
+ def self.decode_public_key: ([::Integer, ::String]) -> (::OpenSSL::PKey::EC::Point | ::OpenSSL::PKey::PKey | nil)
322
+ def self.encode_public_key: (::OpenSSL::PKey::EC::Point) -> key_share_entry
323
+ def self.negotiate: [T] (supported: ::Array[T], offered: ::Array[T], ?exc: singleton(Alert)) -> (T | nil)
324
+ def self.push_message: (key_schedule: KeySchedule|KeyScheduleProxy, buf: ::Raioquic::Buffer) { (untyped) -> untyped } -> void
325
+
326
+ class SessionTicket
327
+ attr_accessor age_add: ::Integer
328
+ attr_accessor cipher_suite: CipherSuite
329
+ attr_accessor not_valid_after: ::Time
330
+ attr_accessor not_valid_before: ::Time
331
+ attr_accessor resumption_secret: ::String
332
+ attr_accessor server_name: ::String
333
+ attr_accessor ticket: ::String
334
+ attr_accessor max_early_data_size: (::Integer | nil)
335
+ attr_accessor other_extensions: ::Array[tls_extension]
336
+
337
+ def is_valid: () -> bool
338
+ def obfuscated_age: () -> ::Integer
339
+ end
340
+
341
+ class Context
342
+ type alpn_handler = ^(::Integer) -> void
343
+ type session_ticket_fetcher = ^(::String) -> (SessionTicket | nil)
344
+ type session_ticket_handler = ^(SessionTicket) -> void
345
+
346
+ attr_reader session_resumed: bool
347
+ attr_reader enc_key: ::String | nil
348
+ attr_reader dec_key: ::String | nil
349
+ attr_reader key_schedule: KeySchedule | nil
350
+ attr_reader alpn_negotiated: ::String | nil
351
+ attr_reader received_context: ::Array[tls_extension] | nil
352
+ attr_reader early_data_accepted: bool
353
+
354
+ attr_accessor state: ::Integer
355
+ attr_accessor handshake_extensions: ::Array[tls_extension]
356
+ attr_accessor certificate: ::OpenSSL::X509::Certificate | nil
357
+ attr_accessor certificate_chain: ::Array[::OpenSSL::X509::Certificate]
358
+ attr_accessor certificate_private_key: ::OpenSSL::PKey | nil
359
+ attr_accessor supported_groups: ::Array[::Integer]
360
+ attr_accessor supported_versions: ::Array[::Integer]
361
+ attr_accessor signature_algorithms: ::Array[::Integer]
362
+ attr_accessor new_session_ticket_cb: session_ticket_handler | nil
363
+ attr_accessor get_session_ticket_cb: session_ticket_fetcher | nil
364
+ attr_accessor session_ticket: SessionTicket | nil
365
+ attr_accessor alpn_cb: alpn_handler | nil
366
+ attr_accessor update_traffic_key_cb: ::Proc
367
+
368
+ @alpn_protocols: ::Array[::String]
369
+ @cadata: ::String | nil
370
+ @cafile: ::String | nil
371
+ @capath: ::String | nil
372
+ @certificate: ::OpenSSL::X509::Certificate | nil
373
+ @certificate_chain: ::Array[::OpenSSL::X509::Certificate]
374
+ @certificate_private_key: ::OpenSSL::PKey | nil
375
+ @handshake_extensions: ::Array[tls_extension]
376
+ @max_early_data: ::Integer | nil
377
+ @session_ticket: SessionTicket | nil
378
+ @server_name: ::String | nil
379
+ @verify_mode: ::Integer # OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER
380
+ @alpn_cb: alpn_handler | nil
381
+ @get_session_ticket_cb: session_ticket_fetcher | nil
382
+ @new_session_ticket_cb: session_ticket_handler | nil
383
+ @update_traffic_key_cb: ::Proc # TODO: How to define lambda that has four arguments?
384
+ @cipher_suites: ::Array[::Integer]
385
+ @legacy_compression_methods: [::Integer]
386
+ @psk_key_exchange_modes: [::Integer]
387
+ @signature_algorithms: ::Array[::Integer]
388
+ @supported_groups: ::Array[::Integer]
389
+ @supported_versions: ::Array[::Integer]
390
+
391
+ # state
392
+ @alpn_negotiated: ::String | nil
393
+ @early_data_accepted: bool
394
+ @key_schedule: KeySchedule | nil
395
+ @key_schedule_psk: ::Array[tls_extension] | nil
396
+ @received_extensions: ::Array[tls_extension] | nil
397
+ @key_schedule_proxy: KeyScheduleProxy | nil
398
+ @new_session_ticket: NewSessionTicket | nil
399
+ @peer_certificate: ::OpenSSL::X509::Certificate | nil
400
+ @peer_certificate_chain: ::Array[::OpenSSL::X509::Certificate]
401
+ @receive_buffer: ::String
402
+ @session_resumed: bool
403
+ @enc_key: ::String | nil
404
+ @dec_key: ::String | nil
405
+ @logger: untyped | nil # TODO: logger
406
+ @ec_key: ::OpenSSL::PKey::EC | nil
407
+ @ec_private_key: ::OpenSSL::BN
408
+ @x25519_private_key: untyped
409
+ @x448_private_key: untyped
410
+ @client_random: ::String | nil
411
+ @legacy_session_id: ::String | nil
412
+ @state: ::Integer
413
+
414
+ def initialize: (
415
+ is_client: bool,
416
+ ?alpn_protocols: ::Array[::String],
417
+ ?cadata: (::String | nil),
418
+ ?cafile: (::String | nil),
419
+ ?capath: (::String | nil),
420
+ ?cipher_suites: (::Array[::Integer] | nil),
421
+ ?logger: (untyped | nil), # TODO: logger
422
+ ?max_early_data: (::Integer | nil),
423
+ ?server_name: (::String | nil),
424
+ ?verify_mode: (::Integer | nil),
425
+ ) -> void
426
+
427
+ def handle_message: (input_data: ::String, output_buf: ::Hash[::Integer, Buffer]) -> void
428
+ def build_session_ticket: (new_session_ticket: NewSessionTicket, other_extensions: ::Array[tls_extension]) -> SessionTicket
429
+ def client_send_hello: (Buffer) -> void
430
+ def client_handle_hello: (input_buf: Buffer, output_buf: Buffer) -> void
431
+ def client_handle_encrypted_extensions: (Buffer) -> void
432
+ def client_handle_certificate: (Buffer) -> void
433
+ def client_handle_certificate_verify: (Buffer) -> void
434
+ def client_handle_finished: (input_buf: Buffer, output_buf: Buffer) -> void
435
+ def client_handle_new_session_ticket: (Buffer) -> void
436
+ def server_handle_hello: (input_buf: Buffer, initial_buf: Buffer, handshake_buf: Buffer, onertt_buf: Buffer) -> void
437
+ def server_handle_finished: (input_buf: Buffer, output_buf: Buffer) -> void
438
+ def setup_traffic_protection: (::Integer, ::Integer, ::String) -> void
439
+ def set_state: (::Integer) -> void
440
+ private def sign_with_params: (priv_key: ::OpenSSL::PKey::PKey|OpenSSL::PKey::RSA, signature_algorithm: ::Integer, verify_data: ::String) -> ::String
441
+ private def verify_with_params: (cert: ::OpenSSL::X509::Certificate, signature_algorithm: ::Integer, signature: ::String, verify_data: ::String) -> ::String
442
+ end
443
+ end
444
+ end
data/sig/raioquic.rbs ADDED
@@ -0,0 +1,9 @@
1
+ module Raioquic
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+
5
+ class Error < StandardError
6
+ end
7
+ class ValueError < Error
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: raioquic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yusuke Nakamura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tttls1.3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Write a longer description or delete this line.
28
+ email:
29
+ - yusuke1994525@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".containerignore"
35
+ - ".rubocop.yml"
36
+ - CHANGELOG.md
37
+ - CODE_OF_CONDUCT.md
38
+ - Containerfile
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - Steepfile
45
+ - example/curlcatcher.rb
46
+ - example/interoperability/README.md
47
+ - example/interoperability/aioquic/aioquic_client.py
48
+ - example/interoperability/aioquic/aioquic_server.py
49
+ - example/interoperability/key.pem
50
+ - example/interoperability/localhost-unasuke-dev.crt
51
+ - example/interoperability/quic-go/sample_server.go
52
+ - example/interoperability/raioquic_client.rb
53
+ - example/interoperability/raioquic_server.rb
54
+ - example/parse_curl_example.rb
55
+ - lib/raioquic.rb
56
+ - lib/raioquic/buffer.rb
57
+ - lib/raioquic/core_ext.rb
58
+ - lib/raioquic/crypto.rb
59
+ - lib/raioquic/crypto/README.md
60
+ - lib/raioquic/crypto/aesgcm.rb
61
+ - lib/raioquic/crypto/backend.rb
62
+ - lib/raioquic/crypto/backend/aead.rb
63
+ - lib/raioquic/quic.rb
64
+ - lib/raioquic/quic/configuration.rb
65
+ - lib/raioquic/quic/connection.rb
66
+ - lib/raioquic/quic/crypto.rb
67
+ - lib/raioquic/quic/event.rb
68
+ - lib/raioquic/quic/logger.rb
69
+ - lib/raioquic/quic/packet.rb
70
+ - lib/raioquic/quic/packet_builder.rb
71
+ - lib/raioquic/quic/rangeset.rb
72
+ - lib/raioquic/quic/recovery.rb
73
+ - lib/raioquic/quic/stream.rb
74
+ - lib/raioquic/tls.rb
75
+ - lib/raioquic/version.rb
76
+ - misc/export_x25519.py
77
+ - misc/gen_rfc8448_keypair.rb
78
+ - raioquic.gemspec
79
+ - sig/raioquic.rbs
80
+ - sig/raioquic/buffer.rbs
81
+ - sig/raioquic/core_ext.rbs
82
+ - sig/raioquic/crypto/aesgcm.rbs
83
+ - sig/raioquic/crypto/backend/aead.rbs
84
+ - sig/raioquic/quic/configuration.rbs
85
+ - sig/raioquic/quic/connection.rbs
86
+ - sig/raioquic/quic/crypto.rbs
87
+ - sig/raioquic/quic/event.rbs
88
+ - sig/raioquic/quic/logger.rbs
89
+ - sig/raioquic/quic/packet.rbs
90
+ - sig/raioquic/quic/packet_builder.rbs
91
+ - sig/raioquic/quic/rangeset.rbs
92
+ - sig/raioquic/quic/recovery.rbs
93
+ - sig/raioquic/quic/stream.rbs
94
+ - sig/raioquic/tls.rbs
95
+ homepage: https://example.com
96
+ licenses: []
97
+ metadata:
98
+ homepage_uri: https://example.com
99
+ source_code_uri: https://example.com
100
+ changelog_uri: https://example.com
101
+ rubygems_mfa_required: 'true'
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.4.6
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Write a short summary, because RubyGems requires one.
121
+ test_files: []