simple_nts_client 0.0.2 → 0.0.3
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/.github/workflows/ci.yml +29 -0
- data/Gemfile +1 -2
- data/README.md +2 -2
- data/lib/nts/ntske/client.rb +2 -2
- data/lib/nts/ntske/message.rb +2 -2
- data/lib/nts/ntske/message/aead_algorithm_negotiation.rb +1 -1
- data/lib/nts/ntske/message/cookie.rb +1 -1
- data/lib/nts/ntske/message/end_of_message.rb +1 -1
- data/lib/nts/ntske/message/error_record.rb +1 -1
- data/lib/nts/ntske/message/nts_next_protocol_negotiation.rb +1 -1
- data/lib/nts/ntske/message/ntsv4_port_negotiation.rb +1 -1
- data/lib/nts/ntske/message/ntsv4_server_negotiation.rb +1 -1
- data/lib/nts/ntske/message/warning_record.rb +1 -1
- data/lib/nts/sntp/client.rb +9 -7
- data/lib/nts/sntp/extension.rb +1 -1
- data/lib/nts/sntp/extension/nts_authenticator.rb +1 -1
- data/lib/nts/sntp/extension/nts_cookie.rb +1 -1
- data/lib/nts/sntp/extension/unique_identifier.rb +1 -1
- data/lib/nts/version.rb +1 -1
- metadata +6 -6
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 652264467fb142946c50c1c01e3c5d44fdb68e8dee855246e52bed1dea34752f
|
4
|
+
data.tar.gz: cd08bca836f061cb2df2f6ed936af9f0b159cb9f1db9a69feddf552ca3883b2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# simple_nts_client
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/simple_nts_client)
|
4
|
-
[](https://github.com/thekuwayama/simple_nts_client/actions?workflow=CI)
|
5
5
|
[](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-
|
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
|
data/lib/nts/ntske/client.rb
CHANGED
@@ -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
|
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-
|
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?
|
data/lib/nts/ntske/message.rb
CHANGED
@@ -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-
|
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-
|
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-
|
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-
|
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-
|
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-
|
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
|
|
data/lib/nts/sntp/client.rb
CHANGED
@@ -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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
ex
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
data/lib/nts/sntp/extension.rb
CHANGED
@@ -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-
|
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-
|
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
|
data/lib/nts/version.rb
CHANGED
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.
|
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-
|
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:
|