tttls1.3 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 600d070cd1e13d0480c362a9e1a38eee26890a55e744f87ba9f3204455aecfe1
4
- data.tar.gz: 9f5cc406f36d3e746f430fbf6e0fcc6ce2b84f9eb30952cbd672b42475852b43
3
+ metadata.gz: 990b3de64c01b392c33e66910d6419cce1ff276a9f957f3479c7aacac6909b00
4
+ data.tar.gz: 82702fe41052a5fbd80722f267d0ffe089f56b696d064a0f4b9a4baf59b64b97
5
5
  SHA512:
6
- metadata.gz: '091354c4bdd832b8c705ad3c4349fd0de5a59b68e28bac1f8f82ca70a09b970bf7da0641bad24897aea683698da65bf2a5503b82d3faf7087037123ea33d5d6d'
7
- data.tar.gz: e98c2774e0cc277a5cee70819aad60d25325de6c29d2328f400873dc8370b534452d9f07582afd0df015ae9be81e2529d9147358098bab75e9b521db7663840b
6
+ metadata.gz: 3d61ad9524126642b8ef1505369f2b08543a4f4ddf1a8a8d1ae15a364e29cf648b68b57840053118bc98104fe28d217519770c034bb3caed1d7401c85611f392
7
+ data.tar.gz: cd465dcfc8d671e10f1819ce7a49dc5b19b6310cf8855d2a09eec563947685bf2f8b860617399010a4b4c4cd34726410ed4a4b3c7a3c9332888e177feb0f0b9f
data/.rubocop.yml CHANGED
@@ -14,3 +14,4 @@ Metrics/BlockLength:
14
14
  Exclude:
15
15
  - 'Rakefile'
16
16
  - 'spec/*.rb'
17
+ - 'interop/*.rb'
data/Gemfile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ gem 'logger'
5
6
  gem 'openssl'
6
7
  gem 'rake'
7
8
 
@@ -11,3 +12,5 @@ group :test do
11
12
  gem 'rspec', '3.8.0'
12
13
  gem 'rubocop', '0.67.2'
13
14
  end
15
+
16
+ gemspec
data/example/helper.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  $LOAD_PATH << __dir__ + '/../lib'
4
4
 
5
5
  require 'socket'
6
- require 'openssl'
7
6
  require 'tttls1.3'
8
7
 
9
8
  def http_get(hostname)
@@ -5,7 +5,6 @@ require_relative 'helper'
5
5
 
6
6
  TMP_DIR = __dir__ + '/../tmp'
7
7
 
8
- # rubocop: disable Metrics/BlockLength
9
8
  RSpec.describe Client do
10
9
  # testcases
11
10
  [
@@ -85,4 +84,3 @@ RSpec.describe Client do
85
84
  end
86
85
  end
87
86
  end
88
- # rubocop: enable Metrics/BlockLength
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
@@ -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
@@ -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
- # AEAD-Encrypt(write_key, nonce, additional_data, plaintext)
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
- # AEAD-Decrypt(peer_write_key, nonce,
54
- # additional_data, AEADEncrypted)
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
- # uint8 zeros[length_of_padding];
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)
@@ -0,0 +1,14 @@
1
+ # encoding: ascii-8bit
2
+ # frozen_string_literal: true
3
+
4
+ module TTTLS13
5
+ module Logging
6
+ def logger
7
+ Logging.logger
8
+ end
9
+
10
+ def self.logger
11
+ @logger ||= Logger.new(STDERR, Logger::WARN)
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTTLS13
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
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
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ['lib']
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 2.0'
24
+ spec.add_dependency 'logger'
24
25
  spec.add_dependency 'openssl'
25
26
  end
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.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-04-29 00:00:00.000000000 Z
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