rbnacl 7.0.0 → 7.1.0
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/.travis.yml +2 -11
- data/CHANGES.md +9 -0
- data/README.md +1 -3
- data/lib/rbnacl/hash/blake2b.rb +2 -7
- data/lib/rbnacl/signatures/ed25519/signing_key.rb +10 -3
- data/lib/rbnacl/signatures/ed25519/verify_key.rb +17 -3
- data/lib/rbnacl/version.rb +1 -1
- data/rbnacl.gemspec +0 -3
- data/spec/rbnacl/signatures/ed25519/signing_key_spec.rb +5 -0
- data/spec/rbnacl/signatures/ed25519/verify_key_spec.rb +16 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4d92c7a609efebd94247e98d2ede88a057b5325f6cdb0e00baa5896cd5051f6
|
4
|
+
data.tar.gz: 4d9e65d468bd0b813817b0e1bb63327bbf450505e6e47f818fc5921886d69110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23a083b6a009719564e5f87b1f179f1e70b8a0233118491e88cea60e34f7f64bfbb30efe5aab94f90e691f109b2820c29adaffd0ec27e79bdf3cf7466d9ff977
|
7
|
+
data.tar.gz: '02915f7b4c44c3d3d12350bc23380450ee6ea51323bcbcee74b01009a307887043da71631beb12ab43b45c3299dd2a47bac847f4ba6b3e1aae33541edb9d7351'
|
data/.travis.yml
CHANGED
@@ -1,19 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
|
4
|
-
before_install:
|
5
|
-
- sudo add-apt-repository -y ppa:chris-lea/libsodium
|
6
|
-
- sudo apt-get update -q
|
7
|
-
- sudo apt-get install libsodium-dev
|
8
|
-
- gem update --system
|
9
|
-
- gem --version
|
10
|
-
- gem install bundler -v 1.17.1
|
11
|
-
- bundle --version
|
4
|
+
before_install: sudo apt-get install libsodium18
|
12
5
|
|
13
6
|
rvm:
|
14
|
-
- jruby-9.
|
15
|
-
- 2.3
|
16
|
-
- 2.4
|
7
|
+
- jruby-9.2.8.0
|
17
8
|
- 2.5
|
18
9
|
- 2.6
|
19
10
|
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [7.1.0] (2019-09-07)
|
2
|
+
|
3
|
+
- Attached signature API ([#197], [#202])
|
4
|
+
- Fix the `generichash` state definition ([#200])
|
5
|
+
|
1
6
|
## [7.0.0] (2019-05-23)
|
2
7
|
|
3
8
|
- Drop support for Ruby 2.2 ([#194])
|
@@ -105,6 +110,10 @@
|
|
105
110
|
|
106
111
|
- Initial release
|
107
112
|
|
113
|
+
[7.1.0]: https://github.com/crypto-rb/rbnacl/pull/203
|
114
|
+
[#202]: https://github.com/crypto-rb/rbnacl/pull/202
|
115
|
+
[#200]: https://github.com/crypto-rb/rbnacl/pull/200
|
116
|
+
[#197]: https://github.com/crypto-rb/rbnacl/pull/197
|
108
117
|
[7.0.0]: https://github.com/crypto-rb/rbnacl/pull/195
|
109
118
|
[#194]: https://github.com/crypto-rb/rbnacl/pull/194
|
110
119
|
[6.0.1]: https://github.com/crypto-rb/rbnacl/pull/191
|
data/README.md
CHANGED
@@ -59,11 +59,9 @@ You can use RbNaCl on platforms libsodium is supported (see below).
|
|
59
59
|
This library aims to support and is [tested against][travis] the following Ruby
|
60
60
|
versions:
|
61
61
|
|
62
|
-
* Ruby 2.3
|
63
|
-
* Ruby 2.4
|
64
62
|
* Ruby 2.5
|
65
63
|
* Ruby 2.6
|
66
|
-
* JRuby 9.
|
64
|
+
* JRuby 9.2
|
67
65
|
|
68
66
|
If something doesn't work on one of these versions, it's a bug.
|
69
67
|
|
data/lib/rbnacl/hash/blake2b.rb
CHANGED
@@ -170,14 +170,9 @@ module RbNaCl
|
|
170
170
|
end
|
171
171
|
|
172
172
|
# The crypto_generichash_blake2b_state struct representation
|
173
|
-
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h#L23
|
173
|
+
# ref: jedisct1/libsodium/blob/c87df74c7b5969f4/src/libsodium/include/sodium/crypto_generichash_blake2b.h#L23-L25
|
174
174
|
class State < FFI::Struct
|
175
|
-
layout :
|
176
|
-
:t, [:uint64, 2],
|
177
|
-
:f, [:uint64, 2],
|
178
|
-
:buf, [:uint8, 2 * 128],
|
179
|
-
:buflen, :size_t,
|
180
|
-
:last_node, :uint8
|
175
|
+
layout :opaque, [:uint8, 384]
|
181
176
|
end
|
182
177
|
end
|
183
178
|
end
|
@@ -73,12 +73,19 @@ module RbNaCl
|
|
73
73
|
#
|
74
74
|
# @return [String] Signature as bytes
|
75
75
|
def sign(message)
|
76
|
+
sign_attached(message)[0, signature_bytes]
|
77
|
+
end
|
78
|
+
|
79
|
+
# Sign a message using this key, attaching the signature to the message
|
80
|
+
#
|
81
|
+
# @param message [String] Message to be signed by this key
|
82
|
+
#
|
83
|
+
# @return [String] Signature and the message as bytes
|
84
|
+
def sign_attached(message)
|
76
85
|
buffer = Util.prepend_zeros(signature_bytes, message)
|
77
86
|
buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)
|
78
|
-
|
79
87
|
self.class.sign_ed25519(buffer, buffer_len, message, message.bytesize, @signing_key)
|
80
|
-
|
81
|
-
buffer[0, signature_bytes]
|
88
|
+
buffer
|
82
89
|
end
|
83
90
|
|
84
91
|
# Return the raw seed value of this key
|
@@ -47,12 +47,26 @@ module RbNaCl
|
|
47
47
|
def verify(signature, message)
|
48
48
|
signature = signature.to_str
|
49
49
|
Util.check_length(signature, signature_bytes, "signature")
|
50
|
+
verify_attached(signature + message)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Verify a signature for a given signed message
|
54
|
+
#
|
55
|
+
# Raises if the signature is invalid.
|
56
|
+
#
|
57
|
+
# @param signed_message [String] Message combined with signature to be authenticated
|
58
|
+
#
|
59
|
+
# @raise [BadSignatureError] if the signature check fails
|
60
|
+
#
|
61
|
+
# @return [Boolean] was the signature authentic?
|
62
|
+
def verify_attached(signed_message)
|
63
|
+
raise LengthError, "Signed message can not be nil" if signed_message.nil?
|
64
|
+
raise LengthError, "Signed message can not be shorter than a signature" if signed_message.bytesize <= signature_bytes
|
50
65
|
|
51
|
-
|
52
|
-
buffer = Util.zeros(sig_and_msg.bytesize)
|
66
|
+
buffer = Util.zeros(signed_message.bytesize)
|
53
67
|
buffer_len = Util.zeros(FFI::Type::LONG_LONG.size)
|
54
68
|
|
55
|
-
success = self.class.sign_ed25519_open(buffer, buffer_len,
|
69
|
+
success = self.class.sign_ed25519_open(buffer, buffer_len, signed_message, signed_message.bytesize, @key)
|
56
70
|
raise(BadSignatureError, "signature was forged/corrupt") unless success
|
57
71
|
|
58
72
|
true
|
data/lib/rbnacl/version.rb
CHANGED
data/rbnacl.gemspec
CHANGED
@@ -20,10 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
21
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
22
|
spec.require_paths = ["lib"]
|
23
|
-
|
24
23
|
spec.required_ruby_version = ">= 2.3.0"
|
25
|
-
|
26
24
|
spec.add_runtime_dependency "ffi"
|
27
|
-
|
28
25
|
spec.add_development_dependency "bundler"
|
29
26
|
end
|
@@ -17,6 +17,11 @@ RSpec.describe RbNaCl::SigningKey do
|
|
17
17
|
expect(subject.sign(message)).to eq signature
|
18
18
|
end
|
19
19
|
|
20
|
+
it "signs messages, full version" do
|
21
|
+
expect(subject.sign_attached(message)[0, RbNaCl::SigningKey.signature_bytes]).to eq signature
|
22
|
+
expect(subject.sign_attached(message)[RbNaCl::SigningKey.signature_bytes, message.length]).to eq message
|
23
|
+
end
|
24
|
+
|
20
25
|
it "serializes to bytes" do
|
21
26
|
expect(subject.to_bytes).to eq signing_key
|
22
27
|
end
|
@@ -20,14 +20,30 @@ RSpec.describe RbNaCl::VerifyKey do
|
|
20
20
|
expect(subject.verify(signature, message)).to eq true
|
21
21
|
end
|
22
22
|
|
23
|
+
it "verifies correct signatures, full version" do
|
24
|
+
expect(subject.verify_attached(signature + message)).to eq true
|
25
|
+
end
|
26
|
+
|
23
27
|
it "raises when asked to verify a bad signature" do
|
24
28
|
expect { subject.verify(bad_signature, message) }.to raise_exception RbNaCl::BadSignatureError
|
25
29
|
end
|
26
30
|
|
31
|
+
it "raises when asked to verify a bad signature, full version" do
|
32
|
+
expect { subject.verify_attached(bad_signature + message) }.to raise_exception RbNaCl::BadSignatureError
|
33
|
+
end
|
34
|
+
|
27
35
|
it "raises when asked to verify a short signature" do
|
28
36
|
expect { subject.verify(bad_signature[0, 63], message) }.to raise_exception RbNaCl::LengthError
|
29
37
|
end
|
30
38
|
|
39
|
+
it "raises when asked to verify a nil signed message" do
|
40
|
+
expect { subject.verify_attached(nil) }.to raise_exception RbNaCl::LengthError
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises when asked to verify too short signed message" do
|
44
|
+
expect { subject.verify_attached(signature) }.to raise_exception RbNaCl::LengthError
|
45
|
+
end
|
46
|
+
|
31
47
|
it "serializes to bytes" do
|
32
48
|
expect(subject.to_bytes).to eq verify_key
|
33
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbnacl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -154,8 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
- !ruby/object:Gem::Version
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
|
-
|
158
|
-
rubygems_version: 2.7.4
|
157
|
+
rubygems_version: 3.0.3
|
159
158
|
signing_key:
|
160
159
|
specification_version: 4
|
161
160
|
summary: Ruby binding to the libsodium/NaCl cryptography library
|