noise-ruby 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b575cce1d3b48ad4ef2df8bdf9e2306e42c7e17528c9dd3d7a7e115f4384e94f
4
- data.tar.gz: a297a4c972d1341afb2ba4b21c155ddf69a319b362763983fc5b96a9931fa3da
3
+ metadata.gz: 3f181a91afb5e9f6f0536ee4301c3b84b076cc73c3270d943186a2bb13903d93
4
+ data.tar.gz: dc57f6d9ff751739b38edb17b585ce691b8a169762e6e019a85528252b344d85
5
5
  SHA512:
6
- metadata.gz: f8a814b5fd365f3f56d91b14c2c69121bbe1f3d8fc869b4c9040b5e3d989305cfc755ddb9c6233a3fc2bbb081b99269bd3f08e45f07b1d56ed7fc1b1b6a06c84
7
- data.tar.gz: b9b25f4cb0c217327527c266a81e004ce96055fd06339767287396d119306264327bd7c5448b59a1d96b7c16624815cb27ab86882699cba994a33e21bbe01b3e
6
+ metadata.gz: 03fa1edf4511fb28e18b22b51aab27c7c94b542b9ee59894d8026505f42a198329a96b90e9d57ed9d13fc25ab3da44d6daf851ff329548c264646d9ed0ed2e10
7
+ data.tar.gz: eb1b9cf632528afef3c0cd5912aef01aef555f82b833fba2b82224ff64fba1d3e785fa07439cfc337a0df4da2e422df01316a9df2f1b36e9ccccdd69225e8d4b
data/README.md CHANGED
@@ -33,6 +33,14 @@ In addition, libsodium is required.
33
33
 
34
34
  $ brew install libsodium
35
35
 
36
+ or
37
+
38
+ $ git clone https://github.com/jedisct1/libsodium
39
+ $ cd libsodium
40
+ $ ./autogen.sh
41
+ $ ./configure
42
+ $ make
43
+ $ sudo make install
36
44
 
37
45
  Add this line to your application's Gemfile:
38
46
 
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Noise
4
4
  module Exceptions
5
+ autoload :DecryptError, 'noise/exceptions/decrypt_error'
6
+ autoload :EncryptError, 'noise/exceptions/encrypt_error'
7
+ autoload :InvalidPublicKeyError, 'noise/exceptions/invalid_public_key_error'
5
8
  autoload :MaxNonceError, 'noise/exceptions/max_nonce_error'
6
9
  autoload :ProtocolNameError, 'noise/exceptions/protocol_name_error'
7
10
  autoload :NoiseHandshakeError, 'noise/exceptions/noise_handshake_error'
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Noise
4
+ module Exceptions
5
+ class DecryptError < StandardError
6
+ def initialize(cause)
7
+ @cause = cause
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Noise
4
+ module Exceptions
5
+ class EncryptError < StandardError
6
+ def initialize(cause)
7
+ @cause = cause
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Noise
4
+ module Exceptions
5
+ class InvalidPublicKeyError < StandardError
6
+ def initialize(public_key)
7
+ @public_key = public_key
8
+ end
9
+ end
10
+ end
11
+ end
@@ -7,11 +7,15 @@ module Noise
7
7
  def encrypt(k, n, ad, plaintext)
8
8
  @cipher = RbNaCl::AEAD::ChaCha20Poly1305IETF.new(String.new(k).force_encoding('ASCII-8BIT'))
9
9
  @cipher.encrypt(nonce_to_bytes(n), plaintext, ad)
10
+ rescue ::RbNaCl::CryptoError => e
11
+ raise Noise::Exceptions::EncryptError.new(e)
10
12
  end
11
13
 
12
14
  def decrypt(k, n, ad, ciphertext)
13
15
  @cipher = RbNaCl::AEAD::ChaCha20Poly1305IETF.new(String.new(k).force_encoding('ASCII-8BIT'))
14
16
  @cipher.decrypt(nonce_to_bytes(n), ciphertext, ad)
17
+ rescue ::RbNaCl::CryptoError => e
18
+ raise Noise::Exceptions::DecryptError.new(e)
15
19
  end
16
20
 
17
21
  def nonce_to_bytes(n)
@@ -17,6 +17,8 @@ module Noise
17
17
  def dh(private_key, public_key)
18
18
  key = ::Secp256k1::PublicKey.new(pubkey: public_key, raw: true)
19
19
  key.ecdh(private_key)
20
+ rescue ::Secp256k1::AssertError => _
21
+ raise Noise::Exceptions::InvalidPublicKeyError.new(public_key)
20
22
  end
21
23
 
22
24
  def dhlen
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.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
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.6.0
4
+ version: 0.6.1
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-03-14 00:00:00.000000000 Z
11
+ date: 2018-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,9 @@ files:
129
129
  - lib/noise.rb
130
130
  - lib/noise/connection.rb
131
131
  - lib/noise/exceptions.rb
132
+ - lib/noise/exceptions/decrypt_error.rb
133
+ - lib/noise/exceptions/encrypt_error.rb
134
+ - lib/noise/exceptions/invalid_public_key_error.rb
132
135
  - lib/noise/exceptions/max_nonce_error.rb
133
136
  - lib/noise/exceptions/noise_handshake_error.rb
134
137
  - lib/noise/exceptions/noise_psk_error.rb