noise-ruby 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/Gemfile +0 -2
- data/README.md +5 -0
- data/lib/noise/functions/cipher/aes_gcm.rb +12 -9
- data/lib/noise/functions/cipher/cha_cha_poly.rb +1 -1
- data/lib/noise/state/handshake_state.rb +8 -20
- data/lib/noise/version.rb +1 -1
- data/noise.gemspec +0 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b575cce1d3b48ad4ef2df8bdf9e2306e42c7e17528c9dd3d7a7e115f4384e94f
|
4
|
+
data.tar.gz: a297a4c972d1341afb2ba4b21c155ddf69a319b362763983fc5b96a9931fa3da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a814b5fd365f3f56d91b14c2c69121bbe1f3d8fc869b4c9040b5e3d989305cfc755ddb9c6233a3fc2bbb081b99269bd3f08e45f07b1d56ed7fc1b1b6a06c84
|
7
|
+
data.tar.gz: b9b25f4cb0c217327527c266a81e004ce96055fd06339767287396d119306264327bd7c5448b59a1d96b7c16624815cb27ab86882699cba994a33e21bbe01b3e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'aead'
|
4
|
-
|
5
3
|
module Noise
|
6
4
|
module Functions
|
7
5
|
module Cipher
|
8
6
|
class AesGcm
|
9
7
|
def encrypt(k, n, ad, plaintext)
|
10
|
-
|
11
|
-
cipher =
|
12
|
-
cipher.
|
8
|
+
cipher = OpenSSL::Cipher::AES.new(256, :GCM).encrypt
|
9
|
+
cipher.key = k
|
10
|
+
cipher.iv = nonce_to_bytes(n)
|
11
|
+
cipher.auth_data = ad
|
12
|
+
cipher.update(plaintext) + cipher.final + cipher.auth_tag
|
13
13
|
end
|
14
14
|
|
15
15
|
def decrypt(k, n, ad, ciphertext)
|
16
|
-
|
17
|
-
cipher =
|
18
|
-
cipher.
|
16
|
+
cipher = OpenSSL::Cipher::AES.new(256, :GCM).decrypt
|
17
|
+
cipher.key = k
|
18
|
+
cipher.iv = nonce_to_bytes(n)
|
19
|
+
cipher.auth_data = ad
|
20
|
+
cipher.auth_tag = ciphertext[-16..-1]
|
21
|
+
cipher.update(ciphertext[0...-16]) + cipher.final
|
19
22
|
end
|
20
23
|
|
21
24
|
def nonce_to_bytes(n)
|
22
|
-
"\
|
25
|
+
"\x00" * 4 + format('%16x', n).htb
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -72,18 +72,12 @@ module Noise
|
|
72
72
|
@symmetric_state.mix_key(dh_fn.dh(@e[0], @re[1]))
|
73
73
|
next
|
74
74
|
when 'es'
|
75
|
-
|
76
|
-
|
77
|
-
else
|
78
|
-
@symmetric_state.mix_key(dh_fn.dh(@s[0], @re[1]))
|
79
|
-
end
|
75
|
+
private_key, public_key = @initiator ? [@e[0], @rs[1]] : [@s[0], @re[1]]
|
76
|
+
@symmetric_state.mix_key(dh_fn.dh(private_key, public_key))
|
80
77
|
next
|
81
78
|
when 'se'
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
@symmetric_state.mix_key(dh_fn.dh(@e[0], @rs[1]))
|
86
|
-
end
|
79
|
+
private_key, public_key = @initiator ? [@s[0], @re[1]] : [@e[0], @rs[1]]
|
80
|
+
@symmetric_state.mix_key(dh_fn.dh(private_key, public_key))
|
87
81
|
next
|
88
82
|
when 'ss'
|
89
83
|
@symmetric_state.mix_key(dh_fn.dh(@s[0], @rs[1]))
|
@@ -119,18 +113,12 @@ module Noise
|
|
119
113
|
@symmetric_state.mix_key(dh_fn.dh(@e[0], @re[1]))
|
120
114
|
next
|
121
115
|
when 'es'
|
122
|
-
|
123
|
-
|
124
|
-
else
|
125
|
-
@symmetric_state.mix_key(dh_fn.dh(@s[0], @re[1]))
|
126
|
-
end
|
116
|
+
private_key, public_key = @initiator ? [@e[0], @rs[1]] : [@s[0], @re[1]]
|
117
|
+
@symmetric_state.mix_key(dh_fn.dh(private_key, public_key))
|
127
118
|
next
|
128
119
|
when 'se'
|
129
|
-
|
130
|
-
|
131
|
-
else
|
132
|
-
@symmetric_state.mix_key(dh_fn.dh(@e[0], @rs[1]))
|
133
|
-
end
|
120
|
+
private_key, public_key = @initiator ? [@s[0], @re[1]] : [@e[0], @rs[1]]
|
121
|
+
@symmetric_state.mix_key(dh_fn.dh(private_key, public_key))
|
134
122
|
next
|
135
123
|
when 'ss'
|
136
124
|
@symmetric_state.mix_key(dh_fn.dh(@s[0], @rs[1]))
|
data/lib/noise/version.rb
CHANGED
data/noise.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
|
28
|
-
spec.add_runtime_dependency 'aead'
|
29
28
|
spec.add_runtime_dependency 'secp256k1-ruby'
|
30
29
|
spec.add_runtime_dependency 'ecdsa'
|
31
30
|
spec.add_runtime_dependency 'rbnacl'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noise-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: aead
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: secp256k1-ruby
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
178
|
version: '0'
|
193
179
|
requirements: []
|
194
180
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.7.3
|
196
182
|
signing_key:
|
197
183
|
specification_version: 4
|
198
184
|
summary: A Ruby implementation of the Noise Protocol framework
|