tttls1.3 0.3.6 → 0.3.7
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/.ruby-version +1 -1
- data/lib/tttls1.3/version.rb +1 -1
- data/lib/tttls1.3.rb +1 -0
- data/tttls1.3.gemspec +5 -2
- metadata +3 -113
- data/.github/workflows/ci.yml +0 -39
- data/.gitignore +0 -17
- data/spec/aead_spec.rb +0 -95
- data/spec/alert_spec.rb +0 -54
- data/spec/alpn_spec.rb +0 -55
- data/spec/application_data_spec.rb +0 -26
- data/spec/certificate_spec.rb +0 -82
- data/spec/certificate_verify_spec.rb +0 -51
- data/spec/change_cipher_spec_spec.rb +0 -26
- data/spec/cipher_suites_spec.rb +0 -39
- data/spec/client_hello_spec.rb +0 -105
- data/spec/client_spec.rb +0 -274
- data/spec/compress_certificate_spec.rb +0 -54
- data/spec/cookie_spec.rb +0 -98
- data/spec/early_data_indication_spec.rb +0 -64
- data/spec/ech_outer_extensions_spec.rb +0 -42
- data/spec/ech_spec.rb +0 -122
- data/spec/encrypted_extensions_spec.rb +0 -94
- data/spec/end_of_early_data_spec.rb +0 -28
- data/spec/endpoint_spec.rb +0 -167
- data/spec/error_spec.rb +0 -18
- data/spec/extensions_spec.rb +0 -250
- data/spec/finished_spec.rb +0 -55
- data/spec/fixtures/rsa_ca.crt +0 -18
- data/spec/fixtures/rsa_ca.key +0 -27
- data/spec/fixtures/rsa_rsa.crt +0 -18
- data/spec/fixtures/rsa_rsa.key +0 -27
- data/spec/fixtures/rsa_rsa_ocsp.crt +0 -18
- data/spec/fixtures/rsa_rsa_ocsp.key +0 -27
- data/spec/fixtures/rsa_rsassaPss.crt +0 -20
- data/spec/fixtures/rsa_rsassaPss.key +0 -27
- data/spec/fixtures/rsa_secp256r1.crt +0 -14
- data/spec/fixtures/rsa_secp256r1.key +0 -5
- data/spec/fixtures/rsa_secp384r1.crt +0 -14
- data/spec/fixtures/rsa_secp384r1.key +0 -6
- data/spec/fixtures/rsa_secp521r1.crt +0 -15
- data/spec/fixtures/rsa_secp521r1.key +0 -7
- data/spec/key_schedule_spec.rb +0 -221
- data/spec/key_share_spec.rb +0 -199
- data/spec/new_session_ticket_spec.rb +0 -80
- data/spec/pre_shared_key_spec.rb +0 -167
- data/spec/psk_key_exchange_modes_spec.rb +0 -45
- data/spec/record_size_limit_spec.rb +0 -61
- data/spec/record_spec.rb +0 -105
- data/spec/server_hello_spec.rb +0 -200
- data/spec/server_name_spec.rb +0 -110
- data/spec/server_spec.rb +0 -232
- data/spec/signature_algorithms_cert_spec.rb +0 -77
- data/spec/signature_algorithms_spec.rb +0 -104
- data/spec/spec_helper.rb +0 -990
- data/spec/status_request_spec.rb +0 -140
- data/spec/supported_groups_spec.rb +0 -79
- data/spec/supported_versions_spec.rb +0 -136
- data/spec/transcript_spec.rb +0 -83
- data/spec/unknown_extension_spec.rb +0 -90
- data/spec/utils_spec.rb +0 -235
data/spec/status_request_spec.rb
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# encoding: ascii-8bit
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative 'spec_helper'
|
|
5
|
-
using Refinements
|
|
6
|
-
|
|
7
|
-
RSpec.describe OCSPStatusRequest do
|
|
8
|
-
context 'default OCSPStatusRequest' do
|
|
9
|
-
let(:extension) do
|
|
10
|
-
OCSPStatusRequest.new
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'should be generated' do
|
|
14
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
15
|
-
expect(extension.responder_id_list).to be_empty
|
|
16
|
-
expect(extension.request_extensions).to be_empty
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'should be serialized' do
|
|
20
|
-
expect(extension.serialize).to eq "\x00\x05\x00\x05\x01\x00\x00\x00\x00"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'valid OCSPStatusRequest' do
|
|
25
|
-
let(:extension) do
|
|
26
|
-
OCSPStatusRequest.new(responder_id_list: [], request_extensions: [])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'should be generated' do
|
|
30
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
31
|
-
expect(extension.responder_id_list).to be_empty
|
|
32
|
-
expect(extension.request_extensions).to be_empty
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'should be serialized' do
|
|
36
|
-
expect(extension.serialize).to eq "\x00\x05\x00\x05\x01\x00\x00\x00\x00"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context 'valid OCSPStatusRequest, 0 length request ' do
|
|
41
|
-
let(:extension) do
|
|
42
|
-
OCSPStatusRequest.new(responder_id_list: nil, request_extensions: nil)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'should be generated' do
|
|
46
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
47
|
-
expect(extension.responder_id_list).to be_empty
|
|
48
|
-
expect(extension.request_extensions).to be_empty
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'should be serialized' do
|
|
52
|
-
expect(extension.serialize).to eq "\x00\x05\x00\x05\x01\x00\x00\x00\x00"
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context 'valid OCSPStatusRequest binary' do
|
|
57
|
-
let(:extension) do
|
|
58
|
-
OCSPStatusRequest.deserialize(TESTBINARY_OCSP_STATUS_REQUEST)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'should generate valid object' do
|
|
62
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
63
|
-
expect(extension.responder_id_list).to be_empty
|
|
64
|
-
expect(extension.request_extensions).to be_empty
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'should generate serializable object' do
|
|
68
|
-
expect(extension.serialize)
|
|
69
|
-
.to eq ExtensionType::STATUS_REQUEST \
|
|
70
|
-
+ TESTBINARY_OCSP_STATUS_REQUEST.prefix_uint16_length
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
RSpec.describe OCSPResponse do
|
|
76
|
-
context 'valid OCSPResponse whose status is good' do
|
|
77
|
-
let(:basic_resp) do
|
|
78
|
-
server_crt = OpenSSL::X509::Certificate.new(
|
|
79
|
-
File.read(__dir__ + '/fixtures/rsa_rsa.crt')
|
|
80
|
-
)
|
|
81
|
-
ca_crt = OpenSSL::X509::Certificate.new(
|
|
82
|
-
File.read(__dir__ + '/fixtures/rsa_ca.crt')
|
|
83
|
-
)
|
|
84
|
-
ocsp_crt = OpenSSL::X509::Certificate.new(
|
|
85
|
-
File.read(__dir__ + '/fixtures/rsa_rsa_ocsp.crt')
|
|
86
|
-
)
|
|
87
|
-
ocsp_key = OpenSSL::PKey.read(
|
|
88
|
-
File.read(__dir__ + '/fixtures/rsa_rsa_ocsp.key')
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
br = OpenSSL::OCSP::BasicResponse.new
|
|
92
|
-
cid = OpenSSL::OCSP::CertificateId.new(server_crt, ca_crt)
|
|
93
|
-
br.add_status(
|
|
94
|
-
cid,
|
|
95
|
-
OpenSSL::OCSP::V_CERTSTATUS_GOOD,
|
|
96
|
-
0,
|
|
97
|
-
nil,
|
|
98
|
-
Time.now,
|
|
99
|
-
DateTime.now.next_day(1).to_time,
|
|
100
|
-
[]
|
|
101
|
-
)
|
|
102
|
-
br.sign(ocsp_crt, ocsp_key)
|
|
103
|
-
br
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
let(:ocsp_response) do
|
|
107
|
-
OpenSSL::OCSP::Response.create(
|
|
108
|
-
OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL,
|
|
109
|
-
basic_resp
|
|
110
|
-
)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
let(:extension) do
|
|
114
|
-
OCSPResponse.new(ocsp_response)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'should be generated' do
|
|
118
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
119
|
-
expect(extension.ocsp_response).to eq ocsp_response
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it 'should be serialized' do
|
|
123
|
-
binary = CertificateStatusType::OCSP \
|
|
124
|
-
+ ocsp_response.to_der.prefix_uint24_length
|
|
125
|
-
|
|
126
|
-
expect(extension.serialize).to eq ExtensionType::STATUS_REQUEST \
|
|
127
|
-
+ binary.prefix_uint16_length
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
context 'valid OCSPResponse binary' do
|
|
132
|
-
let(:extension) do
|
|
133
|
-
OCSPResponse.deserialize(TESTBINARY_OCSP_RESPONSE)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it 'should generate valid object' do
|
|
137
|
-
expect(extension.extension_type).to eq ExtensionType::STATUS_REQUEST
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# encoding: ascii-8bit
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative 'spec_helper'
|
|
5
|
-
using Refinements
|
|
6
|
-
|
|
7
|
-
RSpec.describe SupportedGroups do
|
|
8
|
-
context 'valid supported_groups' do
|
|
9
|
-
let(:named_group_list) do
|
|
10
|
-
[NamedGroup::SECP256R1,
|
|
11
|
-
NamedGroup::SECP384R1]
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:extension) do
|
|
15
|
-
SupportedGroups.new(named_group_list)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'should be generated' do
|
|
19
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_GROUPS
|
|
20
|
-
expect(extension.named_group_list).to eq named_group_list
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'should be serialized' do
|
|
24
|
-
expect(extension.serialize).to eq ExtensionType::SUPPORTED_GROUPS \
|
|
25
|
-
+ 6.to_uint16 \
|
|
26
|
-
+ 4.to_uint16 \
|
|
27
|
-
+ named_group_list.join
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'invalid supported_groups, empty,' do
|
|
32
|
-
let(:extension) do
|
|
33
|
-
SupportedGroups.new([])
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'should not be generated' do
|
|
37
|
-
expect { extension }.to raise_error(ErrorAlerts)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context 'invalid supported_groups, too long,' do
|
|
42
|
-
let(:extension) do
|
|
43
|
-
SupportedGroups.new((0..2**15 - 1).to_a.map(&:to_uint16))
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'should not be generated' do
|
|
47
|
-
expect { extension }.to raise_error(ErrorAlerts)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'valid supported_groups binary' do
|
|
52
|
-
let(:extension) do
|
|
53
|
-
SupportedGroups.deserialize(TESTBINARY_SUPPORTED_GROUPS)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it 'should generate valid object' do
|
|
57
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_GROUPS
|
|
58
|
-
expect(extension.named_group_list).to eq [NamedGroup::SECP256R1,
|
|
59
|
-
NamedGroup::SECP384R1,
|
|
60
|
-
NamedGroup::SECP521R1]
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'should generate serializable object' do
|
|
64
|
-
expect(extension.serialize)
|
|
65
|
-
.to eq ExtensionType::SUPPORTED_GROUPS \
|
|
66
|
-
+ TESTBINARY_SUPPORTED_GROUPS.prefix_uint16_length
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context 'invalid supported_groups binary, malformed binary,' do
|
|
71
|
-
let(:extension) do
|
|
72
|
-
SupportedGroups.deserialize(TESTBINARY_SUPPORTED_GROUPS[0...-1])
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'should return nil' do
|
|
76
|
-
expect(extension).to be nil
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# encoding: ascii-8bit
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative 'spec_helper'
|
|
5
|
-
using Refinements
|
|
6
|
-
|
|
7
|
-
RSpec.describe SupportedVersions do
|
|
8
|
-
context 'valid supported_versions of ClientHello' do
|
|
9
|
-
let(:extension) do
|
|
10
|
-
SupportedVersions.new(
|
|
11
|
-
msg_type: HandshakeType::CLIENT_HELLO,
|
|
12
|
-
versions: [ProtocolVersion::TLS_1_3, ProtocolVersion::TLS_1_2]
|
|
13
|
-
)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it 'should be generated' do
|
|
17
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_VERSIONS
|
|
18
|
-
expect(extension.versions).to eq [ProtocolVersion::TLS_1_3,
|
|
19
|
-
ProtocolVersion::TLS_1_2]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it 'should be serialized' do
|
|
23
|
-
expect(extension.serialize).to eq ExtensionType::SUPPORTED_VERSIONS \
|
|
24
|
-
+ 5.to_uint16 \
|
|
25
|
-
+ 4.to_uint8 \
|
|
26
|
-
+ ProtocolVersion::TLS_1_3 \
|
|
27
|
-
+ ProtocolVersion::TLS_1_2
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'default supported_versions of ClientHello' do
|
|
32
|
-
let(:extension) do
|
|
33
|
-
SupportedVersions.new(msg_type: HandshakeType::CLIENT_HELLO)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'should be generated' do
|
|
37
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_VERSIONS
|
|
38
|
-
expect(extension.versions).to eq [ProtocolVersion::TLS_1_3]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should be serialized' do
|
|
42
|
-
expect(extension.serialize).to eq ExtensionType::SUPPORTED_VERSIONS \
|
|
43
|
-
+ 3.to_uint16 \
|
|
44
|
-
+ 2.to_uint8 \
|
|
45
|
-
+ ProtocolVersion::TLS_1_3
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'invalid supported_versions of ClientHello, empty,' do
|
|
50
|
-
let(:extension) do
|
|
51
|
-
SupportedVersions.new(msg_type: HandshakeType::CLIENT_HELLO,
|
|
52
|
-
versions: [])
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'should not be generated' do
|
|
56
|
-
expect { extension }.to raise_error(ErrorAlerts)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'invalid supported_versions of ClientHello, too large,' do
|
|
61
|
-
let(:extension) do
|
|
62
|
-
SupportedVersions.new(msg_type: HandshakeType::CLIENT_HELLO,
|
|
63
|
-
versions: (0..127).to_a.map(&:to_uint16))
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'should not be generated' do
|
|
67
|
-
expect { extension }.to raise_error(ErrorAlerts)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context 'valid supported_versions of ServerHello' do
|
|
72
|
-
let(:extension) do
|
|
73
|
-
SupportedVersions.new(msg_type: HandshakeType::SERVER_HELLO,
|
|
74
|
-
versions: [ProtocolVersion::TLS_1_3])
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'should be generated' do
|
|
78
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_VERSIONS
|
|
79
|
-
expect(extension.versions).to eq [ProtocolVersion::TLS_1_3]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it 'should be serialized' do
|
|
83
|
-
expect(extension.serialize).to eq ExtensionType::SUPPORTED_VERSIONS \
|
|
84
|
-
+ 2.to_uint16 \
|
|
85
|
-
+ ProtocolVersion::TLS_1_3
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context 'invalid supported_versions of ServerHello, empty,' do
|
|
90
|
-
let(:extension) do
|
|
91
|
-
SupportedVersions.new(msg_type: HandshakeType::SERVER_HELLO,
|
|
92
|
-
versions: [])
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'should not be generated' do
|
|
96
|
-
expect { extension }.to raise_error(ErrorAlerts)
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context 'valid supported_versions binary, ClientHello' do
|
|
101
|
-
let(:extension) do
|
|
102
|
-
SupportedVersions.deserialize(TESTBINARY_SUPPORTED_VERSIONS_CH,
|
|
103
|
-
HandshakeType::CLIENT_HELLO)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it 'should generate valid object' do
|
|
107
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_VERSIONS
|
|
108
|
-
expect(extension.versions).to eq [ProtocolVersion::TLS_1_3,
|
|
109
|
-
ProtocolVersion::TLS_1_2]
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it 'should generate serializable object' do
|
|
113
|
-
expect(extension.serialize)
|
|
114
|
-
.to eq ExtensionType::SUPPORTED_VERSIONS \
|
|
115
|
-
+ TESTBINARY_SUPPORTED_VERSIONS_CH.prefix_uint16_length
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
context 'valid supported_versions binary, ServerHello' do
|
|
120
|
-
let(:extension) do
|
|
121
|
-
SupportedVersions.deserialize(TESTBINARY_SUPPORTED_VERSIONS_SH,
|
|
122
|
-
HandshakeType::SERVER_HELLO)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it 'should generate valid object' do
|
|
126
|
-
expect(extension.extension_type).to eq ExtensionType::SUPPORTED_VERSIONS
|
|
127
|
-
expect(extension.versions).to eq [ProtocolVersion::TLS_1_3]
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it 'should generate serializable object' do
|
|
131
|
-
expect(extension.serialize)
|
|
132
|
-
.to eq ExtensionType::SUPPORTED_VERSIONS \
|
|
133
|
-
+ TESTBINARY_SUPPORTED_VERSIONS_SH.prefix_uint16_length
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
data/spec/transcript_spec.rb
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# encoding: ascii-8bit
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative 'spec_helper'
|
|
5
|
-
|
|
6
|
-
RSpec.describe Transcript do
|
|
7
|
-
context 'transcript, not including HRR,' do
|
|
8
|
-
let(:transcript) do
|
|
9
|
-
ch = ClientHello.deserialize(TESTBINARY_CLIENT_HELLO)
|
|
10
|
-
sh = ServerHello.deserialize(TESTBINARY_SERVER_HELLO)
|
|
11
|
-
ee = EncryptedExtensions.deserialize(TESTBINARY_ENCRYPTED_EXTENSIONS)
|
|
12
|
-
ct = Certificate.deserialize(TESTBINARY_CERTIFICATE)
|
|
13
|
-
cv = CertificateVerify.deserialize(TESTBINARY_CERTIFICATE_VERIFY)
|
|
14
|
-
sf = Finished.deserialize(TESTBINARY_SERVER_FINISHED)
|
|
15
|
-
cf = Finished.deserialize(TESTBINARY_CLIENT_FINISHED)
|
|
16
|
-
t = Transcript.new
|
|
17
|
-
t.merge!(
|
|
18
|
-
CH => [ch, TESTBINARY_CLIENT_HELLO],
|
|
19
|
-
SH => [sh, TESTBINARY_SERVER_HELLO],
|
|
20
|
-
EE => [ee, TESTBINARY_ENCRYPTED_EXTENSIONS],
|
|
21
|
-
CT => [ct, TESTBINARY_CERTIFICATE],
|
|
22
|
-
CV => [cv, TESTBINARY_CERTIFICATE_VERIFY],
|
|
23
|
-
SF => [sf, TESTBINARY_SERVER_FINISHED],
|
|
24
|
-
CF => [cf, TESTBINARY_CLIENT_FINISHED]
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'should return valid transcript-hash' do
|
|
29
|
-
expect(transcript.hash('SHA256', CF))
|
|
30
|
-
.to eq TESTBINARY_CH_CF_TRANSCRIPT_HASH
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context 'transcript, including HRR,' do
|
|
35
|
-
let(:transcript) do
|
|
36
|
-
ch1 = ClientHello.deserialize(TESTBINARY_HRR_CLIENT_HELLO1)
|
|
37
|
-
hrr = ServerHello.deserialize(TESTBINARY_HRR_HELLO_RETRY_REQUEST)
|
|
38
|
-
ch = ClientHello.deserialize(TESTBINARY_HRR_CLIENT_HELLO)
|
|
39
|
-
sh = ServerHello.deserialize(TESTBINARY_HRR_SERVER_HELLO)
|
|
40
|
-
ee = EncryptedExtensions.deserialize(TESTBINARY_HRR_ENCRYPTED_EXTENSIONS)
|
|
41
|
-
ct = Certificate.deserialize(TESTBINARY_HRR_CERTIFICATE)
|
|
42
|
-
cv = CertificateVerify.deserialize(TESTBINARY_HRR_CERTIFICATE_VERIFY)
|
|
43
|
-
sf = Finished.deserialize(TESTBINARY_HRR_SERVER_FINISHED)
|
|
44
|
-
cf = Finished.deserialize(TESTBINARY_HRR_CLIENT_FINISHED)
|
|
45
|
-
t = Transcript.new
|
|
46
|
-
t.merge!(
|
|
47
|
-
CH1 => [ch1, TESTBINARY_HRR_CLIENT_HELLO1],
|
|
48
|
-
HRR => [hrr, TESTBINARY_HRR_HELLO_RETRY_REQUEST],
|
|
49
|
-
CH => [ch, TESTBINARY_HRR_CLIENT_HELLO],
|
|
50
|
-
SH => [sh, TESTBINARY_HRR_SERVER_HELLO],
|
|
51
|
-
EE => [ee, TESTBINARY_HRR_ENCRYPTED_EXTENSIONS],
|
|
52
|
-
CT => [ct, TESTBINARY_HRR_CERTIFICATE],
|
|
53
|
-
CV => [cv, TESTBINARY_HRR_CERTIFICATE_VERIFY],
|
|
54
|
-
SF => [sf, TESTBINARY_HRR_SERVER_FINISHED],
|
|
55
|
-
CF => [cf, TESTBINARY_HRR_CLIENT_FINISHED]
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'should return valid transcript-hash' do
|
|
60
|
-
expect(transcript.hash('SHA256', SH))
|
|
61
|
-
.to eq TESTBINARY_HRR_CH1_SH_TRANSCRIPT_HASH
|
|
62
|
-
expect(transcript.hash('SHA256', CF))
|
|
63
|
-
.to eq TESTBINARY_HRR_CH1_CF_TRANSCRIPT_HASH
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
context 'transcript, Resumed 0-RTT Handshake,' do
|
|
68
|
-
let(:transcript) do
|
|
69
|
-
ch = ClientHello.deserialize(TESTBINARY_0_RTT_CLIENT_HELLO)
|
|
70
|
-
t = Transcript.new
|
|
71
|
-
t.merge!(CH => [ch, TESTBINARY_0_RTT_CLIENT_HELLO])
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
let(:hash_len) do
|
|
75
|
-
OpenSSL::Digest.new('SHA256').digest_length
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'should return valid transcript-hash' do
|
|
79
|
-
expect(transcript.truncate_hash('SHA256', CH, hash_len + 3))
|
|
80
|
-
.to eq TESTBINARY_0_RTT_BINDER_HASH
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# encoding: ascii-8bit
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative 'spec_helper'
|
|
5
|
-
using Refinements
|
|
6
|
-
|
|
7
|
-
RSpec.describe UnknownExtension do
|
|
8
|
-
context 'valid uknown extension, no extension_data' do
|
|
9
|
-
let(:extension) do
|
|
10
|
-
UnknownExtension.new(extension_type: "\x8a\x8a")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'should be generated' do
|
|
14
|
-
expect(extension.extension_type).to eq "\x8a\x8a"
|
|
15
|
-
expect(extension.extension_data).to be_empty
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'should be serialized' do
|
|
19
|
-
expect(extension.serialize).to eq "\x8a\x8a" + ''.prefix_uint16_length
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context 'valid uknown extension' do
|
|
24
|
-
let(:random_bytes) do
|
|
25
|
-
OpenSSL::Random.random_bytes(20)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
let(:extension) do
|
|
29
|
-
UnknownExtension.new(extension_type: "\x8a\x8a",
|
|
30
|
-
extension_data: random_bytes)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it 'should be generated' do
|
|
34
|
-
expect(extension.extension_type).to eq "\x8a\x8a"
|
|
35
|
-
expect(extension.extension_data).to eq random_bytes
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'should be serialized' do
|
|
39
|
-
expect(extension.serialize).to eq "\x8a\x8a" \
|
|
40
|
-
+ random_bytes.prefix_uint16_length
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context 'invalid uknown extension, no extension_type,' do
|
|
45
|
-
let(:extension) do
|
|
46
|
-
UnknownExtension.new
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'should not be generated' do
|
|
50
|
-
expect { extension }.to raise_error(ArgumentError)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context 'valid uknown extension binary, binary is nil,' do
|
|
55
|
-
let(:extension) do
|
|
56
|
-
UnknownExtension.deserialize(nil, "\x8a\x8a")
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'should generate valid object' do
|
|
60
|
-
expect(extension.extension_type).to eq "\x8a\x8a"
|
|
61
|
-
expect(extension.extension_data).to be_empty
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context 'valid uknown extension binary, binary is empty,' do
|
|
66
|
-
let(:extension) do
|
|
67
|
-
UnknownExtension.deserialize([], "\x8a\x8a")
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'should generate valid object' do
|
|
71
|
-
expect(extension.extension_type).to eq "\x8a\x8a"
|
|
72
|
-
expect(extension.extension_data).to be_empty
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context 'valid uknown extension binary' do
|
|
77
|
-
let(:random_bytes) do
|
|
78
|
-
OpenSSL::Random.random_bytes(20)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
let(:extension) do
|
|
82
|
-
UnknownExtension.deserialize(random_bytes, "\x8a\x8a")
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it 'should generate valid object' do
|
|
86
|
-
expect(extension.extension_type).to eq "\x8a\x8a"
|
|
87
|
-
expect(extension.extension_data).to eq random_bytes
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|