noise-ruby 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/noise/exceptions.rb +3 -0
- data/lib/noise/exceptions/decrypt_error.rb +11 -0
- data/lib/noise/exceptions/encrypt_error.rb +11 -0
- data/lib/noise/exceptions/invalid_public_key_error.rb +11 -0
- data/lib/noise/functions/cipher/cha_cha_poly.rb +4 -0
- data/lib/noise/functions/dh/secp256k1.rb +2 -0
- data/lib/noise/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f181a91afb5e9f6f0536ee4301c3b84b076cc73c3270d943186a2bb13903d93
|
4
|
+
data.tar.gz: dc57f6d9ff751739b38edb17b585ce691b8a169762e6e019a85528252b344d85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/noise/exceptions.rb
CHANGED
@@ -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'
|
@@ -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
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.
|
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-
|
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
|