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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e5b9a60ad373cac4331e555d8372ea83ddfa64c0
4
- data.tar.gz: 23eba0e2151a9c9515654cc6f864120e8db6bf51
2
+ SHA256:
3
+ metadata.gz: b575cce1d3b48ad4ef2df8bdf9e2306e42c7e17528c9dd3d7a7e115f4384e94f
4
+ data.tar.gz: a297a4c972d1341afb2ba4b21c155ddf69a319b362763983fc5b96a9931fa3da
5
5
  SHA512:
6
- metadata.gz: 3f618a4552c53fc5134d5acb82737e0b4764707f5e78544b2433993fed3a13c842b7cdbe7d1f3031e17a6f49d73265f67912f1b1170cf546563850d29036e206
7
- data.tar.gz: e186f84ae901a3aa3a4cac973785ba3fa7c4779009b457e0a2ea69d8b59753e53e4ee9c62c973bdddc5adf4116b91a01c69399b96a58af5061e9ac831cdaa833
6
+ metadata.gz: f8a814b5fd365f3f56d91b14c2c69121bbe1f3d8fc869b4c9040b5e3d989305cfc755ddb9c6233a3fc2bbb081b99269bd3f08e45f07b1d56ed7fc1b1b6a06c84
7
+ data.tar.gz: b9b25f4cb0c217327527c266a81e004ce96055fd06339767287396d119306264327bd7c5448b59a1d96b7c16624815cb27ab86882699cba994a33e21bbe01b3e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.5.0
data/Gemfile CHANGED
@@ -6,5 +6,3 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in noise.gemspec
8
8
  gemspec
9
-
10
- gem 'aead', git: 'https://github.com/FredericHeihoff/aead.git', branch: :master
data/README.md CHANGED
@@ -29,6 +29,11 @@ This library requires [libsecp256k1](https://github.com/bitcoin-core/secp256k1).
29
29
  $ make
30
30
  $ sudo make install
31
31
 
32
+ In addition, libsodium is required.
33
+
34
+ $ brew install libsodium
35
+
36
+
32
37
  Add this line to your application's Gemfile:
33
38
 
34
39
  ```
@@ -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
- mode = AEAD::Cipher.new('AES-256-GCM')
11
- cipher = mode.new(k)
12
- cipher.encrypt(nonce_to_bytes(n), ad, plaintext)
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
- mode = AEAD::Cipher.new('AES-256-GCM')
17
- cipher = mode.new(k)
18
- cipher.decrypt(nonce_to_bytes(n), ad, ciphertext)
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
- "\00" * 4 + format('%16x', n).htb
25
+ "\x00" * 4 + format('%16x', n).htb
23
26
  end
24
27
  end
25
28
  end
@@ -15,7 +15,7 @@ module Noise
15
15
  end
16
16
 
17
17
  def nonce_to_bytes(n)
18
- "\00" * 4 + format('%16x', n).htb.reverse
18
+ "\x00" * 4 + format('%16x', n).htb.reverse
19
19
  end
20
20
  end
21
21
  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
- if @initiator
76
- @symmetric_state.mix_key(dh_fn.dh(@e[0], @rs[1]))
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
- if @initiator
83
- @symmetric_state.mix_key(dh_fn.dh(@s[0], @re[1]))
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
- if @initiator
123
- @symmetric_state.mix_key(dh_fn.dh(@e[0], @rs[1]))
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
- if @initiator
130
- @symmetric_state.mix_key(dh_fn.dh(@s[0], @re[1]))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Noise
4
- VERSION = '0.5.3'
4
+ VERSION = '0.6.0'
5
5
  end
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.5.3
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-01-16 00:00:00.000000000 Z
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.6.11
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