tttls1.3 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/Gemfile +3 -0
- data/example/helper.rb +0 -1
- data/interop/client_spec.rb +0 -2
- data/interop/helper.rb +0 -4
- data/lib/tttls1.3/client.rb +5 -2
- data/lib/tttls1.3/connection.rb +4 -0
- data/lib/tttls1.3/cryptograph/aead.rb +8 -5
- data/lib/tttls1.3/logging.rb +14 -0
- data/lib/tttls1.3/version.rb +1 -1
- data/lib/tttls1.3.rb +2 -0
- data/spec/spec_helper.rb +0 -3
- data/tttls1.3.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 990b3de64c01b392c33e66910d6419cce1ff276a9f957f3479c7aacac6909b00
|
4
|
+
data.tar.gz: 82702fe41052a5fbd80722f267d0ffe089f56b696d064a0f4b9a4baf59b64b97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d61ad9524126642b8ef1505369f2b08543a4f4ddf1a8a8d1ae15a364e29cf648b68b57840053118bc98104fe28d217519770c034bb3caed1d7401c85611f392
|
7
|
+
data.tar.gz: cd465dcfc8d671e10f1819ce7a49dc5b19b6310cf8855d2a09eec563947685bf2f8b860617399010a4b4c4cd34726410ed4a4b3c7a3c9332888e177feb0f0b9f
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/example/helper.rb
CHANGED
data/interop/client_spec.rb
CHANGED
data/interop/helper.rb
CHANGED
@@ -4,13 +4,9 @@
|
|
4
4
|
RSpec.configure(&:disable_monkey_patching!)
|
5
5
|
|
6
6
|
# rubocop: disable Style/MixinUsage
|
7
|
-
require 'openssl'
|
8
7
|
require 'tttls1.3'
|
9
8
|
include TTTLS13
|
10
|
-
include TTTLS13::Error
|
11
9
|
include TTTLS13::CipherSuite
|
12
10
|
include TTTLS13::SignatureScheme
|
13
|
-
include TTTLS13::Cryptograph
|
14
|
-
include TTTLS13::Message
|
15
11
|
include TTTLS13::Message::Extension
|
16
12
|
# rubocop: enable Style/MixinUsage
|
data/lib/tttls1.3/client.rb
CHANGED
@@ -55,7 +55,8 @@ module TTTLS13
|
|
55
55
|
psk_cipher_suite: nil,
|
56
56
|
ticket_nonce: nil,
|
57
57
|
ticket_age_add: nil,
|
58
|
-
ticket_timestamp: nil
|
58
|
+
ticket_timestamp: nil,
|
59
|
+
loglevel: Logger::WARN
|
59
60
|
}.freeze
|
60
61
|
|
61
62
|
# rubocop: disable Metrics/ClassLength
|
@@ -69,6 +70,8 @@ module TTTLS13
|
|
69
70
|
@endpoint = :client
|
70
71
|
@hostname = hostname
|
71
72
|
@settings = DEFAULT_CLIENT_SETTINGS.merge(settings)
|
73
|
+
logger.level = @settings[:loglevel]
|
74
|
+
|
72
75
|
@early_data = ''
|
73
76
|
@early_data_write_cipher = nil # Cryptograph::$Object
|
74
77
|
@accepted_early_data = false
|
@@ -118,7 +121,7 @@ module TTTLS13
|
|
118
121
|
# after here v
|
119
122
|
# CONNECTED
|
120
123
|
#
|
121
|
-
# https://tools.ietf.org/html/rfc8446#appendix-A
|
124
|
+
# https://tools.ietf.org/html/rfc8446#appendix-A.1
|
122
125
|
#
|
123
126
|
# rubocop: disable Metrics/AbcSize
|
124
127
|
# rubocop: disable Metrics/BlockLength
|
data/lib/tttls1.3/connection.rb
CHANGED
@@ -7,6 +7,8 @@ module TTTLS13
|
|
7
7
|
|
8
8
|
# rubocop: disable Metrics/ClassLength
|
9
9
|
class Connection
|
10
|
+
include Logging
|
11
|
+
|
10
12
|
# @param socket [Socket]
|
11
13
|
def initialize(socket)
|
12
14
|
@socket = socket
|
@@ -142,6 +144,7 @@ module TTTLS13
|
|
142
144
|
|
143
145
|
# @param record [TTTLS13::Message::Record]
|
144
146
|
def send_record(record)
|
147
|
+
logger.debug(record.inspect)
|
145
148
|
@socket.write(record.serialize(@send_record_size))
|
146
149
|
end
|
147
150
|
|
@@ -202,6 +205,7 @@ module TTTLS13
|
|
202
205
|
terminate(:unexpected_message)
|
203
206
|
end
|
204
207
|
|
208
|
+
logger.debug(record.inspect)
|
205
209
|
record
|
206
210
|
end
|
207
211
|
|
@@ -33,7 +33,8 @@ module TTTLS13
|
|
33
33
|
@length_of_padding = length_of_padding
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# NOTE:
|
37
|
+
# AEAD-Encrypt(write_key, nonce, additional_data, plaintext)
|
37
38
|
#
|
38
39
|
# @param content [String]
|
39
40
|
# @param type [TTTLS13::Message::ContentType]
|
@@ -50,8 +51,9 @@ module TTTLS13
|
|
50
51
|
encrypted_data + cipher.auth_tag
|
51
52
|
end
|
52
53
|
|
53
|
-
#
|
54
|
-
#
|
54
|
+
# NOTE:
|
55
|
+
# AEAD-Decrypt(peer_write_key, nonce,
|
56
|
+
# additional_data, AEADEncrypted)
|
55
57
|
#
|
56
58
|
# @param encrypted_record [String]
|
57
59
|
# @param auth_data [String]
|
@@ -78,7 +80,7 @@ module TTTLS13
|
|
78
80
|
# struct {
|
79
81
|
# opaque content[TLSPlaintext.length];
|
80
82
|
# ContentType type;
|
81
|
-
#
|
83
|
+
# uint8 zeros[length_of_padding];
|
82
84
|
# } TLSInnerPlaintext;
|
83
85
|
#
|
84
86
|
# @param record_size_limit [Integer]
|
@@ -93,6 +95,7 @@ module TTTLS13
|
|
93
95
|
# @return [String]
|
94
96
|
def additional_data(plaintext_len)
|
95
97
|
ciphertext_len = plaintext_len + 16 # length of auth_tag is 16
|
98
|
+
|
96
99
|
Message::ContentType::APPLICATION_DATA \
|
97
100
|
+ Message::ProtocolVersion::TLS_1_2 \
|
98
101
|
+ ciphertext_len.to_uint16
|
@@ -105,7 +108,7 @@ module TTTLS13
|
|
105
108
|
@cipher.iv = @sequence_number.xor(@write_iv, iv_len)
|
106
109
|
end
|
107
110
|
|
108
|
-
# @param [String]
|
111
|
+
# @param clear [String]
|
109
112
|
#
|
110
113
|
# @return [Integer]
|
111
114
|
def scan_zeros(clear)
|
data/lib/tttls1.3/version.rb
CHANGED
data/lib/tttls1.3.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'openssl'
|
4
|
+
require 'logger'
|
4
5
|
|
5
6
|
require 'tttls1.3/version'
|
6
7
|
require 'tttls1.3/utils'
|
8
|
+
require 'tttls1.3/logging'
|
7
9
|
require 'tttls1.3/error'
|
8
10
|
require 'tttls1.3/cipher_suites'
|
9
11
|
require 'tttls1.3/signature_scheme'
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
RSpec.configure(&:disable_monkey_patching!)
|
5
5
|
|
6
6
|
# rubocop: disable Style/MixinUsage
|
7
|
-
require 'openssl'
|
8
7
|
require 'tttls1.3'
|
9
8
|
include TTTLS13
|
10
9
|
include TTTLS13::Error
|
@@ -439,7 +438,6 @@ BIN
|
|
439
438
|
|
440
439
|
# https://tools.ietf.org/html/rfc8448#section-4
|
441
440
|
# 4. Resumed 0-RTT Handshake
|
442
|
-
|
443
441
|
TESTBINARY_0_RTT_CLIENT_HELLO = <<BIN.split.map(&:hex).map(&:chr).join
|
444
442
|
01 00 01 fc 03 03 1b c3 ce b6 bb e3 9c ff 93 83
|
445
443
|
55 b5 a5 0a db 6d b2 1b 7a 6a f6 49 d7 b4 bc 41
|
@@ -565,7 +563,6 @@ TESTBINARY_0_RTT_CLIENT_APPLICATION_WRITE_IV \
|
|
565
563
|
|
566
564
|
# https://tools.ietf.org/html/rfc8448#section-5
|
567
565
|
# 5. HelloRetryRequest
|
568
|
-
|
569
566
|
TESTBINARY_HRR_CLIENT_HELLO1 = <<BIN.split.map(&:hex).map(&:chr).join
|
570
567
|
01 00 00 b0 03 03 b0 b1 c5 a5 aa 37 c5 91 9f 2e
|
571
568
|
d1 d5 c6 ff f7 fc b7 84 97 16 94 5a 2b 8c ee 92
|
data/tttls1.3.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tttls1.3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekuwayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: logger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: openssl
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +84,7 @@ files:
|
|
70
84
|
- lib/tttls1.3/cryptograph/passer.rb
|
71
85
|
- lib/tttls1.3/error.rb
|
72
86
|
- lib/tttls1.3/key_schedule.rb
|
87
|
+
- lib/tttls1.3/logging.rb
|
73
88
|
- lib/tttls1.3/message.rb
|
74
89
|
- lib/tttls1.3/message/alert.rb
|
75
90
|
- lib/tttls1.3/message/application_data.rb
|