rbnacl 3.1.0 → 3.1.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
  SHA1:
3
- metadata.gz: da04c0339f10665de0880687721eb137edb0db2d
4
- data.tar.gz: 4f149d92ee6701f70fa6f8715e6132357b6064fc
3
+ metadata.gz: ff876d588d1e3d16c902b3316141585d4172eab5
4
+ data.tar.gz: 7a22f5b8ea0fd18cdbc0a52d06880e81a53a742b
5
5
  SHA512:
6
- metadata.gz: 7150574a248de534fa8f141eb891cc3db27a92988e319d55848d21f8323aa0f133416ffc5d4761c62b9d7dcaac7ef0ab70b7df2f45b42d540c857fc852b390a1
7
- data.tar.gz: 08f8dfd718c3c75a436a826cc564beacb5533878f7b77d12ea0a057afc1750d421265b0c1172704e98953bece3c893926275aa991f6f86ba7d2d6ca2f85689b1
6
+ metadata.gz: e67a5a0fdc8293c993ddcf79cf1c21e92c68a31b393b37b8684b93cda182072441321fbb2eebc3612bb4061859c0d6d750d28417534200f5276beb9d221f6c24
7
+ data.tar.gz: 80220efc75c5d404172c70e589a5446d0e6b7d560ad85f530c57747f46ce63e3e72d2bcb3daed67d9d31c43dc5f9dd972cd102e2d20c014f79466ab29e85fecc
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ script: "LD_LIBRARY_PATH=lib bundle exec rake ci"
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.1
6
+ - 2.1.2
7
7
  - ruby-head
8
8
  - jruby
9
9
  - jruby-head
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 3.1.1 (2014-06-14)
2
+ ------------------
3
+ * Fix undefined variable warning
4
+ * RSpec 3 fixups
5
+ * RuboCop
6
+
1
7
  3.1.0 (2014-05-22)
2
8
  ------------------
3
9
  * The scrypt password hashing function: RbNaCl::PasswordHash.scrypt
data/lib/rbnacl.rb CHANGED
@@ -88,4 +88,4 @@ end
88
88
  Thread.exclusive { RbNaCl::Init.sodium_init }
89
89
 
90
90
  # Perform self test on load
91
- require "rbnacl/self_test" unless $RBNACL_SELF_TEST == false
91
+ require "rbnacl/self_test" unless defined?($RBNACL_SELF_TEST) && $RBNACL_SELF_TEST == false
@@ -1,5 +1,5 @@
1
1
  # encoding: binary
2
2
  module RbNaCl
3
3
  # The library's version
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.1"
5
5
  end
@@ -11,11 +11,11 @@ describe RbNaCl::PrivateKey do
11
11
  let(:secret_key) { RbNaCl::PrivateKey.generate }
12
12
 
13
13
  it "returns a secret key" do
14
- secret_key.should be_a RbNaCl::PrivateKey
14
+ expect(secret_key).to be_a RbNaCl::PrivateKey
15
15
  end
16
16
 
17
17
  it "has the public key also set" do
18
- secret_key.public_key.should be_a RbNaCl::PublicKey
18
+ expect(secret_key.public_key).to be_a RbNaCl::PublicKey
19
19
  end
20
20
  end
21
21
 
@@ -35,23 +35,23 @@ describe RbNaCl::PrivateKey do
35
35
 
36
36
  context "public_key" do
37
37
  it "returns a public key" do
38
- subject.public_key.should be_a RbNaCl::PublicKey
38
+ expect(subject.public_key).to be_a RbNaCl::PublicKey
39
39
  end
40
40
 
41
41
  it "returns the correct public key" do
42
- subject.public_key.to_s.should eql bobpk
42
+ expect(subject.public_key.to_s).to eql bobpk
43
43
  end
44
44
  end
45
45
 
46
46
  context "#to_bytes" do
47
47
  it "returns the bytes of the key" do
48
- subject.to_s.should eq bobsk
48
+ expect(subject.to_s).to eq bobsk
49
49
  end
50
50
  end
51
51
 
52
52
  context "#to_s" do
53
53
  it "returns the raw bytes of the key" do
54
- subject.to_bytes.should eq bobsk
54
+ expect(subject.to_bytes).to eq bobsk
55
55
  end
56
56
  end
57
57
 
@@ -22,13 +22,13 @@ describe RbNaCl::PublicKey do
22
22
 
23
23
  context "#to_bytes" do
24
24
  it "returns the bytes of the key" do
25
- subject.to_bytes.should eq alicepk
25
+ expect(subject.to_bytes).to eq alicepk
26
26
  end
27
27
  end
28
28
 
29
29
  context "#to_s" do
30
30
  it "returns the bytes of the key" do
31
- subject.to_s.should eq alicepk
31
+ expect(subject.to_s).to eq alicepk
32
32
  end
33
33
  end
34
34
 
@@ -9,11 +9,11 @@ describe RbNaCl::Box do
9
9
 
10
10
  context "new" do
11
11
  it "accepts strings" do
12
- expect { RbNaCl::Box.new(alicepk, bobsk) }.to_not raise_error(Exception)
12
+ expect { RbNaCl::Box.new(alicepk, bobsk) }.to_not raise_error
13
13
  end
14
14
 
15
15
  it "accepts KeyPairs" do
16
- expect { RbNaCl::Box.new(alice_key, bob_key) }.to_not raise_error(Exception)
16
+ expect { RbNaCl::Box.new(alice_key, bob_key) }.to_not raise_error
17
17
  end
18
18
 
19
19
  it "raises TypeError on a nil public key" do
@@ -12,15 +12,15 @@ describe RbNaCl::GroupElement do
12
12
  subject { described_class.new(bob_public) }
13
13
 
14
14
  it "multiplies integers with the base point" do
15
- described_class.base.mult(alice_private).to_s.should eq alice_public
15
+ expect(described_class.base.mult(alice_private).to_s).to eq alice_public
16
16
  end
17
17
 
18
18
  it "multiplies integers with arbitrary points" do
19
- described_class.new(bob_public).mult(alice_private).to_s.should eq alice_mult_bob
19
+ expect(described_class.new(bob_public).mult(alice_private).to_s).to eq alice_mult_bob
20
20
  end
21
21
 
22
22
  it "serializes to bytes" do
23
- subject.to_bytes.should eq bob_public
23
+ expect(subject.to_bytes).to eq bob_public
24
24
  end
25
25
 
26
26
  include_examples "serializable"
@@ -8,15 +8,15 @@ describe RbNaCl::Hash do
8
8
  let(:empty_string_hash) { vector :sha256_empty }
9
9
 
10
10
  it "calculates the correct hash for a reference string" do
11
- RbNaCl::Hash.sha256(reference_string).should eq reference_string_hash
11
+ expect(RbNaCl::Hash.sha256(reference_string)).to eq reference_string_hash
12
12
  end
13
13
 
14
14
  it "calculates the correct hash for an empty string" do
15
- RbNaCl::Hash.sha256("").should eq empty_string_hash
15
+ expect(RbNaCl::Hash.sha256("")).to eq empty_string_hash
16
16
  end
17
17
 
18
18
  it "doesn't raise on a null byte" do
19
- expect { RbNaCl::Hash.sha256("\0") }.to_not raise_error(/ArgumentError: string contains null byte/)
19
+ expect { RbNaCl::Hash.sha256("\0") }.to_not raise_error
20
20
  end
21
21
  end
22
22
 
@@ -26,15 +26,15 @@ describe RbNaCl::Hash do
26
26
  let(:empty_string_hash) { vector :sha512_empty }
27
27
 
28
28
  it "calculates the correct hash for a reference string" do
29
- RbNaCl::Hash.sha512(reference_string).should eq reference_string_hash
29
+ expect(RbNaCl::Hash.sha512(reference_string)).to eq reference_string_hash
30
30
  end
31
31
 
32
32
  it "calculates the correct hash for an empty string" do
33
- RbNaCl::Hash.sha512("").should eq empty_string_hash
33
+ expect(RbNaCl::Hash.sha512("")).to eq empty_string_hash
34
34
  end
35
35
 
36
36
  it "doesn't raise on a null byte" do
37
- expect { RbNaCl::Hash.sha512("\0") }.to_not raise_error(/ArgumentError: string contains null byte/)
37
+ expect { RbNaCl::Hash.sha512("\0") }.to_not raise_error
38
38
  end
39
39
  end
40
40
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: binary
2
2
  describe RbNaCl::Random do
3
3
  it "produces random bytes" do
4
- RbNaCl::Random.random_bytes(16).bytesize.should == 16
4
+ expect(RbNaCl::Random.random_bytes(16).bytesize).to eq(16)
5
5
  end
6
6
  it "produces different random bytes" do
7
- RbNaCl::Random.random_bytes(16).should_not == RbNaCl::Random.random_bytes(16)
7
+ expect(RbNaCl::Random.random_bytes(16)).not_to eq(RbNaCl::Random.random_bytes(16))
8
8
  end
9
9
  end
@@ -6,7 +6,7 @@ describe RbNaCl::SecretBox do
6
6
 
7
7
  context "new" do
8
8
  it "accepts strings" do
9
- expect { RbNaCl::SecretBox.new(key) }.to_not raise_error(Exception)
9
+ expect { RbNaCl::SecretBox.new(key) }.to_not raise_error
10
10
  end
11
11
 
12
12
  it "raises on a nil key" do
@@ -9,15 +9,15 @@ describe RbNaCl::SigningKey do
9
9
  subject { described_class.new(signing_key) }
10
10
 
11
11
  it "generates keys" do
12
- described_class.generate.should be_a described_class
12
+ expect(described_class.generate).to be_a described_class
13
13
  end
14
14
 
15
15
  it "signs messages as bytes" do
16
- subject.sign(message).should eq signature
16
+ expect(subject.sign(message)).to eq signature
17
17
  end
18
18
 
19
19
  it "serializes to bytes" do
20
- subject.to_bytes.should eq signing_key
20
+ expect(subject.to_bytes).to eq signing_key
21
21
  end
22
22
 
23
23
  include_examples "key equality" do
@@ -10,7 +10,7 @@ describe RbNaCl::VerifyKey do
10
10
  subject { RbNaCl::SigningKey.new(signing_key).verify_key }
11
11
 
12
12
  it "verifies correct signatures" do
13
- subject.verify(signature, message).should be_true
13
+ expect(subject.verify(signature, message)).to eq true
14
14
  end
15
15
 
16
16
  it "raises when asked to verify a bad signature" do
@@ -22,11 +22,11 @@ describe RbNaCl::VerifyKey do
22
22
  end
23
23
 
24
24
  it "serializes to bytes" do
25
- subject.to_bytes.should eq verify_key
25
+ expect(subject.to_bytes).to eq verify_key
26
26
  end
27
27
 
28
28
  it "initializes from bytes" do
29
- described_class.new(verify_key).to_s.should eq verify_key
29
+ expect(described_class.new(verify_key).to_s).to eq verify_key
30
30
  end
31
31
 
32
32
  include_examples "key equality" do
@@ -15,7 +15,7 @@ describe RbNaCl::SimpleBox do
15
15
  end
16
16
 
17
17
  it "can be instantiated from a secret key" do
18
- described_class.from_secret_key(secret_key).should be_a described_class
18
+ expect(described_class.from_secret_key(secret_key)).to be_a described_class
19
19
  end
20
20
 
21
21
  it "raises TypeError when given a nil secret key" do
@@ -23,7 +23,7 @@ describe RbNaCl::SimpleBox do
23
23
  end
24
24
 
25
25
  it "can be instantiated from a key-pair" do
26
- described_class.from_keypair(alicepk, bobsk).should be_a described_class
26
+ expect(described_class.from_keypair(alicepk, bobsk)).to be_a described_class
27
27
  end
28
28
 
29
29
  it "raises TypeError when given nil secret keys in the pair" do
@@ -42,16 +42,16 @@ describe RbNaCl::SimpleBox do
42
42
  describe "bob" do
43
43
  it "decrypts a message from alice" do
44
44
  alices_ciphertext = alice.encrypt(message)
45
- bob.decrypt(alices_ciphertext).should eql message
45
+ expect(bob.decrypt(alices_ciphertext)).to eql message
46
46
  end
47
47
 
48
48
  it "decrypts own message" do
49
49
  bobs_ciphertext = bob.encrypt(message)
50
- bob.decrypt(bobs_ciphertext).should eql message
50
+ expect(bob.decrypt(bobs_ciphertext)).to eql message
51
51
  end
52
52
 
53
53
  it "decrypts a message with a 'random' nonce" do
54
- bob.decrypt(nonce+ciphertext).should eql message
54
+ expect(bob.decrypt(nonce+ciphertext)).to eql message
55
55
  end
56
56
  end
57
57
  end
@@ -8,12 +8,12 @@ describe RbNaCl::Util do
8
8
  let (:long_msg) { RbNaCl::Util.zeros(33) }
9
9
 
10
10
  it "confirms identical messages are identical" do
11
- RbNaCl::Util.verify32!(msg, identical_msg).should be true
11
+ expect(RbNaCl::Util.verify32!(msg, identical_msg)).to be true
12
12
  end
13
13
 
14
14
  it "confirms non-identical messages are non-identical" do
15
- RbNaCl::Util.verify32!(msg, other_msg).should be false
16
- RbNaCl::Util.verify32!(other_msg, msg).should be false
15
+ expect(RbNaCl::Util.verify32!(msg, other_msg)).to be false
16
+ expect(RbNaCl::Util.verify32!(other_msg, msg)).to be false
17
17
  end
18
18
 
19
19
  it "raises descriptively on a short message in position 1" do
@@ -38,16 +38,16 @@ describe RbNaCl::Util do
38
38
  let (:long_msg) { RbNaCl::Util.zeros(33) }
39
39
 
40
40
  it "confirms identical messages are identical" do
41
- RbNaCl::Util.verify32(msg, identical_msg).should be true
41
+ expect(RbNaCl::Util.verify32(msg, identical_msg)).to be true
42
42
  end
43
43
 
44
44
  it "confirms non-identical messages are non-identical" do
45
- RbNaCl::Util.verify32(msg, other_msg).should be false
46
- RbNaCl::Util.verify32(other_msg, msg).should be false
47
- RbNaCl::Util.verify32(short_msg, msg).should be false
48
- RbNaCl::Util.verify32(msg, short_msg).should be false
49
- RbNaCl::Util.verify32(long_msg, msg).should be false
50
- RbNaCl::Util.verify32(msg, long_msg).should be false
45
+ expect(RbNaCl::Util.verify32(msg, other_msg)).to be false
46
+ expect(RbNaCl::Util.verify32(other_msg, msg)).to be false
47
+ expect(RbNaCl::Util.verify32(short_msg, msg)).to be false
48
+ expect(RbNaCl::Util.verify32(msg, short_msg)).to be false
49
+ expect(RbNaCl::Util.verify32(long_msg, msg)).to be false
50
+ expect(RbNaCl::Util.verify32(msg, long_msg)).to be false
51
51
  end
52
52
 
53
53
  end
@@ -60,12 +60,12 @@ describe RbNaCl::Util do
60
60
  let (:long_msg) { RbNaCl::Util.zeros(17) }
61
61
 
62
62
  it "confirms identical messages are identical" do
63
- RbNaCl::Util.verify16!(msg, identical_msg).should be true
63
+ expect(RbNaCl::Util.verify16!(msg, identical_msg)).to be true
64
64
  end
65
65
 
66
66
  it "confirms non-identical messages are non-identical" do
67
- RbNaCl::Util.verify16!(msg, other_msg).should be false
68
- RbNaCl::Util.verify16!(other_msg, msg).should be false
67
+ expect(RbNaCl::Util.verify16!(msg, other_msg)).to be false
68
+ expect(RbNaCl::Util.verify16!(other_msg, msg)).to be false
69
69
  end
70
70
 
71
71
  it "raises descriptively on a short message in position 1" do
@@ -90,16 +90,16 @@ describe RbNaCl::Util do
90
90
  let (:long_msg) { RbNaCl::Util.zeros(17) }
91
91
 
92
92
  it "confirms identical messages are identical" do
93
- RbNaCl::Util.verify16(msg, identical_msg).should be true
93
+ expect(RbNaCl::Util.verify16(msg, identical_msg)).to be true
94
94
  end
95
95
 
96
96
  it "confirms non-identical messages are non-identical" do
97
- RbNaCl::Util.verify16(msg, other_msg).should be false
98
- RbNaCl::Util.verify16(other_msg, msg).should be false
99
- RbNaCl::Util.verify16(short_msg, msg).should be false
100
- RbNaCl::Util.verify16(msg, short_msg).should be false
101
- RbNaCl::Util.verify16(long_msg, msg).should be false
102
- RbNaCl::Util.verify16(msg, long_msg).should be false
97
+ expect(RbNaCl::Util.verify16(msg, other_msg)).to be false
98
+ expect(RbNaCl::Util.verify16(other_msg, msg)).to be false
99
+ expect(RbNaCl::Util.verify16(short_msg, msg)).to be false
100
+ expect(RbNaCl::Util.verify16(msg, short_msg)).to be false
101
+ expect(RbNaCl::Util.verify16(long_msg, msg)).to be false
102
+ expect(RbNaCl::Util.verify16(msg, long_msg)).to be false
103
103
  end
104
104
  end
105
105
 
@@ -133,11 +133,11 @@ describe RbNaCl::Util do
133
133
  let (:hex) { "deadbeef" }
134
134
 
135
135
  it "encodes to hex with bin2hex" do
136
- RbNaCl::Util.bin2hex(bytes).should eq hex
136
+ expect(RbNaCl::Util.bin2hex(bytes)).to eq hex
137
137
  end
138
138
 
139
139
  it "decodes from hex with hex2bin" do
140
- RbNaCl::Util.hex2bin(hex).should eq bytes
140
+ expect(RbNaCl::Util.hex2bin(hex)).to eq bytes
141
141
  end
142
142
  end
143
143
  end
@@ -5,7 +5,7 @@ shared_examples "authenticator" do
5
5
 
6
6
  context ".new" do
7
7
  it "accepts a key" do
8
- expect { described_class.new(key) }.to_not raise_error(ArgumentError)
8
+ expect { described_class.new(key) }.to_not raise_error
9
9
  end
10
10
 
11
11
  it "requires a key" do
@@ -27,7 +27,7 @@ shared_examples "authenticator" do
27
27
 
28
28
  context ".auth" do
29
29
  it "produces an authenticator" do
30
- described_class.auth(key, message).should eq tag
30
+ expect(described_class.auth(key, message)).to eq tag
31
31
  end
32
32
 
33
33
  it "raises TypeError on a nil key" do
@@ -41,7 +41,7 @@ shared_examples "authenticator" do
41
41
 
42
42
  context ".verify" do
43
43
  it "verify an authenticator" do
44
- described_class.verify(key, tag, message).should eq true
44
+ expect(described_class.verify(key, tag, message)).to eq true
45
45
  end
46
46
 
47
47
  it "raises TypeError on a nil key" do
@@ -70,13 +70,13 @@ shared_examples "authenticator" do
70
70
 
71
71
  context "#auth" do
72
72
  it "produces an authenticator" do
73
- authenticator.auth(message).should eq tag
73
+ expect(authenticator.auth(message)).to eq tag
74
74
  end
75
75
  end
76
76
 
77
77
  context "#verify" do
78
78
  it "verifies an authenticator" do
79
- authenticator.verify(tag, message).should be true
79
+ expect(authenticator.verify(tag, message)).to be true
80
80
  end
81
81
 
82
82
  it "fails to validate an invalid authenticator" do
data/spec/shared/box.rb CHANGED
@@ -12,7 +12,7 @@ shared_examples "box" do
12
12
  context "box" do
13
13
 
14
14
  it "encrypts a message" do
15
- box.box(nonce, message).should eq ciphertext
15
+ expect(box.box(nonce, message)).to eq ciphertext
16
16
  end
17
17
 
18
18
  it "raises on a short nonce" do
@@ -27,7 +27,7 @@ shared_examples "box" do
27
27
  context "open" do
28
28
 
29
29
  it "decrypts a message" do
30
- box.open(nonce, ciphertext).should eq message
30
+ expect(box.open(nonce, ciphertext)).to eq message
31
31
  end
32
32
 
33
33
  it "raises on a truncated message to decrypt" do
@@ -2,25 +2,25 @@
2
2
  shared_examples "key equality" do
3
3
  context "equality" do
4
4
  it "equal keys are equal" do
5
- (described_class.new(key_bytes) == key).should be true
5
+ expect(described_class.new(key_bytes) == key).to be true
6
6
  end
7
7
  it "equal keys are equal to the string" do
8
- (key == key_bytes).should be true
8
+ expect(key == key_bytes).to be true
9
9
  end
10
10
  it "keys are not equal to zero" do
11
- (key == RbNaCl::Util.zeros(32)).should be false
11
+ expect(key == RbNaCl::Util.zeros(32)).to be false
12
12
  end
13
13
  it "keys are not equal to another key" do
14
- (key == other_key).should be false
14
+ expect(key == other_key).to be false
15
15
  end
16
16
  end
17
17
 
18
18
  context "lexicographic sorting" do
19
19
  it "can be compared lexicographically to a key smaller than it" do
20
- (key > RbNaCl::Util.zeros(32)).should be true
20
+ expect(key > RbNaCl::Util.zeros(32)).to be true
21
21
  end
22
22
  it "can be compared lexicographically to a key larger than it" do
23
- (described_class.new(RbNaCl::Util.zeros(32)) < key).should be true
23
+ expect(described_class.new(RbNaCl::Util.zeros(32)) < key).to be true
24
24
  end
25
25
  end
26
26
  end
data/tasks/rubocop.rake CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'rubocop/rake_task'
2
2
 
3
- Rubocop::RakeTask.new
3
+ RuboCop::RakeTask.new
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: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - bascule.cert
13
- date: 2014-05-23 00:00:00.000000000 Z
13
+ date: 2014-06-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi