simple_nts_client 0.0.2 → 0.0.3

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: 3452e99b47263c3c1c876411bf05e7518736acb03c9d28bb09f25eea3207235a
4
- data.tar.gz: 25ea815f69d92210381423b47695c2b435c964ee6d557ba099cbcdc11f532b03
3
+ metadata.gz: 652264467fb142946c50c1c01e3c5d44fdb68e8dee855246e52bed1dea34752f
4
+ data.tar.gz: cd08bca836f061cb2df2f6ed936af9f0b159cb9f1db9a69feddf552ca3883b2e
5
5
  SHA512:
6
- metadata.gz: 891fc8209f24ceda4ab400d4d4d45266f2dafe02b6b092fb9e4c98ee640d8f86620cbed92810f1aab58a783533b22bd6086717c557efca085f77298abd35df6a
7
- data.tar.gz: 70942fefc46c43ced0b0c883681359142cf62ef367670a10d8256b9a702c16e46c6908c0cf1c8fd843f398a71523755a98cb72f77cea73391b0486e875d6951e
6
+ metadata.gz: f34f766f6769a3a0f71ca679d045b0ed6d9ad953b82eeefa5b245c794b6bc8567f6e26facf67a4a7719a179b19ed6fac6648cb8bfe4d6e0cfda1828b025eb706
7
+ data.tar.gz: f1bf6f0e3c1b613fddbbf7e20eccb799e52451f9eae59305ad0874a2cf8785669fe24fc6c1538de82b7b967206e035101ba4d67bc3f9e77be4666738078a5d00
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ ci:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.6.x', '2.7.x']
17
+ steps:
18
+ - name: Set up Ruby
19
+ uses: actions/setup-ruby@v1
20
+ - uses: actions/checkout@v1
21
+ - name: Install dependencies
22
+ run: |
23
+ gem --version
24
+ gem install bundler
25
+ bundle --version
26
+ bundle install
27
+ - name: Run test
28
+ run: |
29
+ bundle exec rake
data/Gemfile CHANGED
@@ -7,8 +7,7 @@ gem 'rake'
7
7
  gem 'tttls1.3', '>= 0.2.7'
8
8
 
9
9
  group :test do
10
- gem 'pry'
11
- gem 'pry-byebug'
10
+ gem 'byebug'
12
11
  gem 'rspec', '3.9.0'
13
12
  gem 'rubocop', '0.79.0'
14
13
  end
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # simple_nts_client
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/simple_nts_client.svg)](https://badge.fury.io/rb/simple_nts_client)
4
- [![Build Status](https://travis-ci.org/thekuwayama/simple_nts_client.svg?branch=master)](https://travis-ci.org/thekuwayama/simple_nts_client)
4
+ [![CI](https://github.com/thekuwayama/simple_nts_client/workflows/CI/badge.svg)](https://github.com/thekuwayama/simple_nts_client/actions?workflow=CI)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/7b34a4868f1e297af084/maintainability)](https://codeclimate.com/github/thekuwayama/simple_nts_client/maintainability)
6
6
 
7
7
  simple\_nts\_client is CLI that is simple NTS(Network Time Security) Client implementation.
8
8
  This CLI prints the now timestamp got with NTS.
9
9
  Current implementation is based on:
10
10
 
11
- * [draft-ietf-ntp-using-nts-for-ntp-22](https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22)
11
+ * [draft-ietf-ntp-using-nts-for-ntp-28](https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28)
12
12
 
13
13
 
14
14
  ## Installation
@@ -7,7 +7,7 @@ module Nts
7
7
  ALPN = 'ntske/1'
8
8
  private_constant :ALPN
9
9
 
10
- KE_LABEL = 'EXPORTER-network-time-security/1'
10
+ KE_LABEL = 'EXPORTER-network-time-security'
11
11
  private_constant :KE_LABEL
12
12
 
13
13
  # @param hostname [String]
@@ -78,7 +78,7 @@ module Nts
78
78
  raise Exception if cookies.empty?
79
79
 
80
80
  # AEAD algorithm => C2S, S2C key
81
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-5.1
81
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-5.1
82
82
  alg = res.find { |m| m.is_a?(AeadAlgorithmNegotiation) }&.algorithms
83
83
  &.first
84
84
  raise Exception if alg.nil?
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-7.6
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-7.6
6
6
  module RecordType
7
7
  END_OF_MESSAGE = 0
8
8
  NTS_NEXT_PROTOCOL_NEGOTIATION = 1
@@ -14,7 +14,7 @@ module Nts
14
14
  NTPV4_PORT_NEGOTIATION = 7
15
15
  end
16
16
 
17
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4
17
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4
18
18
  class Record
19
19
  # @param c [Boolean]
20
20
  # @param type [Integer] less than 32768(15 bits)
@@ -8,7 +8,7 @@ module Nts
8
8
  AEAD_AES_SIV_CMAC_256 = "\x00\x0F"
9
9
  end
10
10
 
11
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.5
11
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.5
12
12
  class AeadAlgorithmNegotiation < Record
13
13
  attr_reader :algorithms
14
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.6
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.6
6
6
  class Cookie < Record
7
7
  attr_reader :cookie
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.1
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.1
6
6
  class EndOfMessage < Record
7
7
  def initialize
8
8
  super(true, RecordType::END_OF_MESSAGE)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.3
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.3
6
6
  module ErrorCode
7
7
  UNRECOGNIZED_CRITICAL_RECORD = "\x00\x00"
8
8
  BAD_REQUEST = "\x00\x01"
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Nts
5
5
  module Ntske
6
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.2
6
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.2
7
7
  class NtsNextProtocolNegotiation < Record
8
8
  attr_reader :next_protocol
9
9
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.8
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.8
6
6
  class Ntsv4PortNegotiation < Record
7
7
  attr_reader :port
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.7
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.7
6
6
  class Ntsv4ServerNegotiation < Record
7
7
  attr_reader :server
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Ntske
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-4.1.4
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-4.1.4
6
6
  class WarningRecord < Record
7
7
  attr_reader :warning_code
8
8
 
@@ -70,13 +70,15 @@ module Nts
70
70
 
71
71
  # validate NTS Authenticator and Encrypted Extension Fields
72
72
  decipher = Miscreant::AEAD.new('AES-CMAC-SIV', @s2c_key)
73
- ciphertext = res.nts_authenticator.ciphertext
74
- nonce = res.nts_authenticator.nonce
75
- ad = res.ntp_header + res.extensions.reject { |ex|
76
- ex.is_a?(Extension::NtsAuthenticator)
77
- }.map(&:serialize).join
78
- plaintext = decipher.open(ciphertext, nonce: nonce, ad: ad)
79
- Message.extensions_deserialize(plaintext)
73
+ if !res.nts_authenticator.nil? && !res.nts_authenticator.ciphertext.nil?
74
+ ciphertext = res.nts_authenticator.ciphertext
75
+ nonce = res.nts_authenticator.nonce
76
+ ad = res.ntp_header + res.extensions.reject { |ex|
77
+ ex.is_a?(Extension::NtsAuthenticator)
78
+ }.map(&:serialize).join
79
+ plaintext = decipher.open(ciphertext, nonce: nonce, ad: ad)
80
+ Message.extensions_deserialize(plaintext)
81
+ end
80
82
  # not handle decrypt any NTP Extensions
81
83
 
82
84
  # calculate system clock offset
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nts
4
4
  module Sntp
5
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-7.5
5
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-7.5
6
6
  module ExtensionFieldType
7
7
  UNIQUE_IDENTIFIER = 260
8
8
  NTS_COOKIE = 516
@@ -3,7 +3,7 @@
3
3
  module Nts
4
4
  module Sntp
5
5
  module Extension
6
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-5.6
6
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-5.6
7
7
  class NtsAuthenticator
8
8
  include Extension
9
9
  attr_reader :nonce, :ciphertext, :padding_length
@@ -3,7 +3,7 @@
3
3
  module Nts
4
4
  module Sntp
5
5
  module Extension
6
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-5.4
6
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-5.4
7
7
  class NtsCookie
8
8
  include Extension
9
9
  attr_reader :cookie
@@ -3,7 +3,7 @@
3
3
  module Nts
4
4
  module Sntp
5
5
  module Extension
6
- # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-22#section-5.3
6
+ # https://tools.ietf.org/html/draft-ietf-ntp-using-nts-for-ntp-28#section-5.3
7
7
  class UniqueIdentifier
8
8
  include Extension
9
9
  attr_reader :id
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nts
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_nts_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekuwayama
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-03 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,9 +60,9 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".github/workflows/ci.yml"
63
64
  - ".gitignore"
64
65
  - ".rubocop.yml"
65
- - ".travis.yml"
66
66
  - Gemfile
67
67
  - LICENSE.txt
68
68
  - README.md
@@ -109,7 +109,7 @@ homepage: https://github.com/thekuwayama/simple_nts_client
109
109
  licenses:
110
110
  - MIT
111
111
  metadata: {}
112
- post_install_message:
112
+ post_install_message:
113
113
  rdoc_options: []
114
114
  require_paths:
115
115
  - lib
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubygems_version: 3.1.2
128
- signing_key:
128
+ signing_key:
129
129
  specification_version: 4
130
130
  summary: Simple NTS(Network Time Security) Client
131
131
  test_files:
@@ -1,17 +0,0 @@
1
- sudo: false
2
-
3
- language: ruby
4
-
5
- rvm:
6
- - 2.6.3
7
- - ruby-head
8
-
9
- matrix:
10
- allow_failures:
11
- - rvm: ruby-head
12
-
13
- before_install:
14
- - gem install bundler
15
- - bundle install
16
-
17
- script: bundle exec rake