rbnacl 4.0.0 → 4.0.2

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
  SHA1:
3
- metadata.gz: b98225b2e645925d76a0189adf330c81c7b34f68
4
- data.tar.gz: 8ccf325edde59b1ba96e29ca0c018a3a1cd0abc8
3
+ metadata.gz: 06b62936ca905b101e22418710c37dfc78cd5d11
4
+ data.tar.gz: 0b8b8ba5efb7e6673bb8811e19695a7fbb714fbd
5
5
  SHA512:
6
- metadata.gz: 2460addc91d22d5f6e846f8a43aa7e4e582a0763482884700f29be44ee48176f5bd3ca492fe78554a2c0c8f3e10be57d9b4b24c32b670b9441440eec6ac5aa86
7
- data.tar.gz: 9d0cc147b8897251d7329aafa78049bd7099fa1726af94249c0c1062a3ff67c069b77d2228983b914d7e6a2b2ae95ca326e64ee2848956b72b91ac6a3c5f4376
6
+ metadata.gz: 69a6b4e5aaeee71020409df122943399ba64c1b46a76c4a75b4abaf113fb6d3d93c553f128f8b42e2a52d57a7e8081e45749b6c585b6aca434cbda1eea972fb7
7
+ data.tar.gz: 20d228a8f6a56e5c710288fb6e73b16ad39d0185f369bd29b519f8742c1da1b5523388ea6bdfea8e1d21df892019761cc99e6e920f44bfdae8e671fa2cb00fe3
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.0
data/.travis.yml CHANGED
@@ -12,6 +12,7 @@ rvm:
12
12
  - jruby-9.1.6.0
13
13
  - 2.2.6
14
14
  - 2.3.3
15
+ - 2.4.0
15
16
 
16
17
  env:
17
18
  - LIBSODIUM_VERSION=1.0.0 # Minimum supported
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
- 4.0.0 (2016-12-04)
2
- ----------------------
1
+ ## 4.0.2 (2016-03-12)
2
+
3
+ * [#157](https://github.com/cryptosphere/rbnacl/pull/157)
4
+ Raise error on degenerate keys (fixes #152).
5
+ ([@paragonie-scott], [@tarcieri])
6
+
7
+ ## 4.0.1 (2016-12-04)
8
+
9
+ * [#148](https://github.com/cryptosphere/rbnacl/pull/148)
10
+ Last minute changes to the ChaCha20Poly1305 API.
11
+ ([@tarcieri])
12
+
13
+ ## 4.0.0 (2016-12-04)
3
14
 
4
15
  * [#141](https://github.com/cryptosphere/rbnacl/pull/141)
5
16
  Add wrappers for ChaCha20Poly1305 AEAD ciphers.
@@ -13,18 +24,18 @@
13
24
  Require Ruby 2.2.6+.
14
25
  ([@tarcieri])
15
26
 
16
- 3.4.0 (2015-05-07)
17
- ------------------
27
+ ## 3.4.0 (2015-05-07)
28
+
18
29
  * [#135](https://github.com/cryptosphere/rbnacl/pull/135)
19
- Expose RbNaCl::Signatures::Ed25519#keypair_bytes.
30
+ Expose `RbNaCl::Signatures::Ed25519#keypair_bytes`.
20
31
  ([@grempe])
21
32
 
22
33
  * [#137](https://github.com/cryptosphere/rbnacl/pull/137)
23
34
  Expose HMAC-SHA512 (with 64-byte keys)
24
35
  ([@mwpastore])
25
36
 
26
- 3.3.0 (2015-12-29)
27
- ------------------
37
+ ## 3.3.0 (2015-12-29)
38
+
28
39
  * [#105](https://github.com/cryptosphere/rbnacl/pull/105)
29
40
  Add salt/personalisation strings for Blake2b.
30
41
  ([@namelessjon])
@@ -33,39 +44,39 @@
33
44
  Remove use of Thread.exclusive when initializing library.
34
45
  ([@tarcieri])
35
46
 
36
- 3.2.0 (2015-05-31)
37
- ------------------
47
+ ## 3.2.0 (2015-05-31)
48
+
38
49
  * Fix method signature for blake2b
39
50
  * RuboCop-friendly codebase
40
51
 
41
- 3.1.2 (2014-08-30)
42
- ------------------
52
+ ## 3.1.2 (2014-08-30)
53
+
43
54
  * Fix scrypt support with libsodium 0.7.0 (scryptsalsa208sha256)
44
55
 
45
- 3.1.1 (2014-06-14)
46
- ------------------
56
+ ## 3.1.1 (2014-06-14)
57
+
47
58
  * Fix undefined variable warning
48
59
  * RSpec 3 fixups
49
60
  * RuboCop
50
61
 
51
- 3.1.0 (2014-05-22)
52
- ------------------
53
- * The scrypt password hashing function: RbNaCl::PasswordHash.scrypt
62
+ ## 3.1.0 (2014-05-22)
63
+
64
+ * The scrypt password hashing function: `RbNaCl::PasswordHash.scrypt`
65
+
66
+ ## 3.0.1 (2014-05-12)
54
67
 
55
- 3.0.1 (2014-05-12)
56
- ------------------
57
- * Load gem from RBNACL_LIBSODIUM_GEM_LIB_PATH if set. Used by rbnacl-libsodium
68
+ * Load gem from `RBNACL_LIBSODIUM_GEM_LIB_PATH` if set. Used by rbnacl-libsodium
58
69
  gem to use libsodium compiled from a gem.
59
70
 
60
- 3.0.0 (2014-04-22)
61
- ------------------
71
+ ## 3.0.0 (2014-04-22)
72
+
62
73
  * Rename RandomNonceBox to SimpleBox (backwards compatibility preserved)
63
74
  * Reverse documented order of SimpleBox/RandomNonceBox initialize parameters.
64
75
  Technically backwards compatible, but confusing.
65
76
  * Ensure all strings are ASCII-8BIT/BINARY encoding prior to use
66
77
 
67
- 2.0.0 (2013-11-07)
68
- ------------------
78
+ ## 2.0.0 (2013-11-07)
79
+
69
80
  * Add encrypt/decrypt aliases for Crypto::RandomNonceBox
70
81
  * Rename Crypto module to RbNaCl module
71
82
  * RbNaCl::VerifyKey#verify operand order was reversed. New operand order is
@@ -84,15 +95,14 @@
84
95
  * Changes in the low level binding for libsodium and removal of the NaCl module
85
96
  * Add a mutex around calls to randombytes in libsodium
86
97
 
87
- 1.1.0 (2013-04-19)
88
- ------------------
98
+ ## 1.1.0 (2013-04-19)
89
99
 
90
100
  * Provide API for querying primitives and details about them, such as key
91
101
  lengths, nonce lengths, etc.
92
102
  * Fixed bug on passing null bytes to sha256, sha512 functions.
93
103
 
94
- 1.0.0 (2013-03-08)
95
- ------------------
104
+ ## 1.0.0 (2013-03-08)
105
+
96
106
  * Initial release
97
107
 
98
108
  [@namelessjon]: https://github.com/namelessjon
@@ -101,3 +111,4 @@
101
111
  [@grempe]: https://github.com/grempe
102
112
  [@mwpastore]: https://github.com/mwpastore
103
113
  [@elijh]: https://github.com/elijh
114
+ [@paragonie-scott]: https://github.com/paragonie-scott
data/LICENSE.txt CHANGED
@@ -1,5 +1,4 @@
1
- Copyright (c) 2012 Tony Arcieri
2
- Copyright (c) 2013 Jonathan Stott
1
+ Copyright (c) 2012-2017 Tony Arcieri, Jonathan Stott
3
2
 
4
3
  MIT License
5
4
 
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Coverage Status](https://coveralls.io/repos/cryptosphere/rbnacl/badge.svg?branch=master)](https://coveralls.io/r/cryptosphere/rbnacl)
7
7
  [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/cryptosphere/rbnacl/blob/master/LICENSE.txt)
8
8
 
9
- _NOTE: This is the 4.x **development** branch of RbNaCl. For the 3.x **stable**
9
+ _NOTE: This is the 4.x **stable** branch of RbNaCl. For the 3.x **legacy**
10
10
  branch, please see:_
11
11
 
12
12
  https://github.com/cryptosphere/rbnacl/tree/3-x-stable
@@ -151,7 +151,7 @@ are supported:
151
151
  Additional power-user features are available. Please see the Wiki for further
152
152
  information.
153
153
 
154
- [RDoc documentation][rdoc] is also available.
154
+ [YARD API documentation][yard] is also available.
155
155
 
156
156
  [wiki]: https://github.com/cryptosphere/rbnacl/wiki
157
157
  [simplebox]: https://github.com/cryptosphere/rbnacl/wiki/SimpleBox
@@ -160,7 +160,7 @@ information.
160
160
  [signatures]: https://github.com/cryptosphere/rbnacl/wiki/Digital-Signatures
161
161
  [macs]: https://github.com/cryptosphere/rbnacl/wiki/Authenticators
162
162
  [hashes]: https://github.com/cryptosphere/rbnacl/wiki/Hash-Functions
163
- [rdoc]: http://rubydoc.info/github/cryptosphere/rbnacl/master/frames
163
+ [yard]: http://www.rubydoc.info/gems/rbnacl
164
164
 
165
165
  ## Learn More
166
166
 
@@ -209,5 +209,7 @@ Sure, here you go:
209
209
 
210
210
  ## License
211
211
 
212
- Copyright (c) 2012-2016 Jonathan Stott, Tony Arcieri. Distributed under the MIT License.
213
- See LICENSE.txt for further details.
212
+ Copyright (c) 2012-2017 Tony Arcieri, Jonathan Stott. Distributed under the MIT License.
213
+ See [LICENSE.txt] for further details.
214
+
215
+ [LICENSE.txt]: https://github.com/cryptosphere/rbnacl/blob/master/LICENSE.txt
data/lib/rbnacl.rb CHANGED
@@ -12,7 +12,7 @@ require "rbnacl/random"
12
12
  require "rbnacl/simple_box"
13
13
  require "rbnacl/test_vectors"
14
14
  require "rbnacl/init"
15
- require "rbnacl/aead/aead"
15
+ require "rbnacl/aead/base"
16
16
 
17
17
  # NaCl/libsodium for Ruby
18
18
  module RbNaCl
@@ -79,7 +79,7 @@ module RbNaCl
79
79
  require "rbnacl/hmac/sha512"
80
80
 
81
81
  # AEAD: ChaCha20-Poly1305
82
- require "rbnacl/aead/chacha20poly1305"
82
+ require "rbnacl/aead/chacha20poly1305_legacy"
83
83
  require "rbnacl/aead/chacha20poly1305_ietf"
84
84
 
85
85
  #
@@ -3,14 +3,14 @@
3
3
 
4
4
  module RbNaCl
5
5
  module AEAD
6
- # Authenticated Encryption with Additional Data
6
+ # Abstract base class for Authenticated Encryption with Additional Data
7
7
  #
8
8
  # This construction encrypts a message, and computes an authentication
9
9
  # tag for the encrypted message and some optional additional data
10
10
  #
11
11
  # RbNaCl provides wrappers for both ChaCha20-Poly1305 AEAD implementations
12
12
  # in libsodium: the original, and the IETF version.
13
- class GenericAEAD
13
+ class Base
14
14
  # Number of bytes in a valid key
15
15
  KEYBYTES = 0
16
16
 
@@ -5,7 +5,7 @@ module RbNaCl
5
5
  module AEAD
6
6
  # This class contains wrappers for the IETF implementation of
7
7
  # Authenticated Encryption with Additional Data using ChaCha20-Poly1305
8
- class Chacha20Poly1305IETF < GenericAEAD
8
+ class ChaCha20Poly1305IETF < RbNaCl::AEAD::Base
9
9
  extend Sodium
10
10
  if Sodium::Version.supported_version?("1.0.9")
11
11
  sodium_type :aead
@@ -5,7 +5,7 @@ module RbNaCl
5
5
  module AEAD
6
6
  # This class contains wrappers for the original libsodium implementation of
7
7
  # Authenticated Encryption with Additional Data using ChaCha20-Poly1305
8
- class Chacha20Poly1305 < GenericAEAD
8
+ class ChaCha20Poly1305Legacy < RbNaCl::AEAD::Base
9
9
  extend Sodium
10
10
 
11
11
  sodium_type :aead
@@ -18,6 +18,9 @@ module RbNaCl
18
18
  # Order of the standard group
19
19
  STANDARD_GROUP_ORDER = 2**252 + 27_742_317_777_372_353_535_851_937_790_883_648_493
20
20
 
21
+ # Degenerate key (all-zeroes, results in an all-zero shared secret)
22
+ DEGENERATE_KEY = ("\0" * 32).freeze
23
+
21
24
  include KeyComparator
22
25
  include Serializable
23
26
 
@@ -44,6 +47,8 @@ module RbNaCl
44
47
  def initialize(point)
45
48
  @point = point.to_str
46
49
 
50
+ raise CryptoError, "degenerate key detected" if @point == DEGENERATE_KEY
51
+
47
52
  # FIXME: really should have a separate constant here for group element size
48
53
  # Group elements and scalars are both 32-bits, but that's for convenience
49
54
  Util.check_length(@point, SCALARBYTES, "group element")
@@ -61,8 +66,8 @@ module RbNaCl
61
66
  Util.check_length(integer, SCALARBYTES, "integer")
62
67
 
63
68
  result = Util.zeros(SCALARBYTES)
64
- self.class.scalarmult_curve25519(result, integer, @point)
65
69
 
70
+ raise CryptoError, "degenerate key detected" unless self.class.scalarmult_curve25519(result, integer, @point)
66
71
  self.class.new(result)
67
72
  end
68
73
 
@@ -79,6 +84,7 @@ module RbNaCl
79
84
  #
80
85
  # @return [RbNaCl::Point] standard base point (a.k.a. standard group element)
81
86
  def self.base
87
+ # TODO: better support fixed-based scalar multiplication (this glosses over native support)
82
88
  @base_point
83
89
  end
84
90
  class << self
@@ -4,5 +4,5 @@
4
4
  # NaCl/libsodium for Ruby
5
5
  module RbNaCl
6
6
  # The library's version
7
- VERSION = "4.0.0"
7
+ VERSION = "4.0.2"
8
8
  end
@@ -1,16 +1,14 @@
1
1
  # encoding: binary
2
2
  # frozen_string_literal: true
3
3
 
4
- RSpec.describe RbNaCl::AEAD::Chacha20Poly1305IETF do
4
+ RSpec.describe RbNaCl::AEAD::ChaCha20Poly1305IETF do
5
5
  if RbNaCl::Sodium::Version.supported_version?("1.0.9")
6
6
  include_examples "aead" do
7
- let(:key) {vector :aead_chacha20poly1305_ietf_key}
8
- let(:message) {vector :aead_chacha20poly1305_ietf_message}
9
- let(:nonce) {vector :aead_chacha20poly1305_ietf_nonce}
10
- let(:ad) {vector :aead_chacha20poly1305_ietf_ad}
11
- let(:ciphertext) {vector :aead_chacha20poly1305_ietf_ciphertext}
12
-
13
- let(:aead) { RbNaCl::AEAD::Chacha20Poly1305IETF.new(key) }
7
+ let(:key) { vector :aead_chacha20poly1305_ietf_key }
8
+ let(:message) { vector :aead_chacha20poly1305_ietf_message }
9
+ let(:nonce) { vector :aead_chacha20poly1305_ietf_nonce }
10
+ let(:ad) { vector :aead_chacha20poly1305_ietf_ad }
11
+ let(:ciphertext) { vector :aead_chacha20poly1305_ietf_ciphertext }
14
12
  end
15
13
  end
16
14
  end
@@ -0,0 +1,12 @@
1
+ # encoding: binary
2
+ # frozen_string_literal: true
3
+
4
+ RSpec.describe RbNaCl::AEAD::ChaCha20Poly1305Legacy do
5
+ include_examples "aead" do
6
+ let(:key) { vector :aead_chacha20poly1305_orig_key }
7
+ let(:message) { vector :aead_chacha20poly1305_orig_message }
8
+ let(:nonce) { vector :aead_chacha20poly1305_orig_nonce }
9
+ let(:ad) { vector :aead_chacha20poly1305_orig_ad }
10
+ let(:ciphertext) { vector :aead_chacha20poly1305_orig_ciphertext }
11
+ end
12
+ end
@@ -9,6 +9,8 @@ RSpec.describe RbNaCl::GroupElement do
9
9
 
10
10
  let(:alice_mult_bob) { vector :alice_mult_bob }
11
11
 
12
+ let(:degenerate_key) { RbNaCl::GroupElements::Curve25519::DEGENERATE_KEY }
13
+
12
14
  subject { described_class.new(bob_public) }
13
15
 
14
16
  it "multiplies integers with the base point" do
@@ -23,5 +25,9 @@ RSpec.describe RbNaCl::GroupElement do
23
25
  expect(subject.to_bytes).to eq bob_public
24
26
  end
25
27
 
28
+ it "detects degenerate keys" do
29
+ expect { described_class.new(degenerate_key).mult(alice_private) }.to raise_error RbNaCl::CryptoError
30
+ end
31
+
26
32
  include_examples "serializable"
27
33
  end
data/spec/shared/aead.rb CHANGED
@@ -2,13 +2,15 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  RSpec.shared_examples "aead" do
5
- let(:corrupt_ciphertext) { ciphertext.succ}
6
- let(:trunc_ciphertext) { ciphertext[0, 20]}
7
- let(:invalid_nonce) { nonce[0, nonce.bytesize/2] } # too short!
5
+ let(:corrupt_ciphertext) { ciphertext.succ }
6
+ let(:trunc_ciphertext) { ciphertext[0, 20] }
7
+ let(:invalid_nonce) { nonce[0, nonce.bytesize/2] } # too short!
8
8
  let(:invalid_nonce_long) { nonce + nonce } # too long!
9
- let(:nonce_error_regex) { /Nonce.*(Expected #{aead.nonce_bytes})/ }
10
- let(:corrupt_ad) {ad.succ}
11
- let(:trunc_ad) {ad[0, ad.bytesize/2]}
9
+ let(:nonce_error_regex) { %r{Nonce.*(Expected #{aead.nonce_bytes})} }
10
+ let(:corrupt_ad) { ad.succ }
11
+ let(:trunc_ad) { ad[0, ad.bytesize/2] }
12
+
13
+ let(:aead) { described_class.new(key) }
12
14
 
13
15
  context "new" do
14
16
  it "accepts strings" do
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: 4.0.0
4
+ version: 4.0.2
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: 2016-12-23 00:00:00.000000000 Z
12
+ date: 2017-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -66,9 +66,9 @@ files:
66
66
  - images/hash.png
67
67
  - images/logo.png
68
68
  - lib/rbnacl.rb
69
- - lib/rbnacl/aead/aead.rb
70
- - lib/rbnacl/aead/chacha20poly1305.rb
69
+ - lib/rbnacl/aead/base.rb
71
70
  - lib/rbnacl/aead/chacha20poly1305_ietf.rb
71
+ - lib/rbnacl/aead/chacha20poly1305_legacy.rb
72
72
  - lib/rbnacl/auth.rb
73
73
  - lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb
74
74
  - lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb
@@ -102,7 +102,7 @@ files:
102
102
  - lib/rbnacl/version.rb
103
103
  - rbnacl.gemspec
104
104
  - spec/rbnacl/aead/chacha20poly1305_ietf_spec.rb
105
- - spec/rbnacl/aead/chacha20poly1305_orig_spec.rb
105
+ - spec/rbnacl/aead/chacha20poly1305_legacy_spec.rb
106
106
  - spec/rbnacl/authenticators/poly1305_spec.rb
107
107
  - spec/rbnacl/boxes/curve25519xsalsa20poly1305/private_key_spec.rb
108
108
  - spec/rbnacl/boxes/curve25519xsalsa20poly1305/public_key_spec.rb
@@ -149,13 +149,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.5.2
152
+ rubygems_version: 2.6.10
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Ruby binding to the Networking and Cryptography (NaCl) library
156
156
  test_files:
157
157
  - spec/rbnacl/aead/chacha20poly1305_ietf_spec.rb
158
- - spec/rbnacl/aead/chacha20poly1305_orig_spec.rb
158
+ - spec/rbnacl/aead/chacha20poly1305_legacy_spec.rb
159
159
  - spec/rbnacl/authenticators/poly1305_spec.rb
160
160
  - spec/rbnacl/boxes/curve25519xsalsa20poly1305/private_key_spec.rb
161
161
  - spec/rbnacl/boxes/curve25519xsalsa20poly1305/public_key_spec.rb
@@ -1,14 +0,0 @@
1
- # encoding: binary
2
- # frozen_string_literal: true
3
-
4
- RSpec.describe RbNaCl::AEAD::Chacha20Poly1305 do
5
- include_examples "aead" do
6
- let(:key) {vector :aead_chacha20poly1305_orig_key}
7
- let(:message) {vector :aead_chacha20poly1305_orig_message}
8
- let(:nonce) {vector :aead_chacha20poly1305_orig_nonce}
9
- let(:ad) {vector :aead_chacha20poly1305_orig_ad}
10
- let(:ciphertext) {vector :aead_chacha20poly1305_orig_ciphertext}
11
-
12
- let(:aead) { RbNaCl::AEAD::Chacha20Poly1305.new(key) }
13
- end
14
- end