Skip to content

Commit

Permalink
Rename RandomNonceBox => SimpleBox
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Apr 14, 2014
1 parent bc713cc commit 6563d74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/rbnacl.rb
Expand Up @@ -7,7 +7,7 @@
require "rbnacl/auth"
require "rbnacl/util"
require "rbnacl/random"
require "rbnacl/random_nonce_box"
require "rbnacl/simple_box"
require "rbnacl/test_vectors"
require "rbnacl/init"

Expand Down
Expand Up @@ -27,7 +27,7 @@ module RbNaCl
# * The confidentiality of your messages is assured with this strategy, but
# there is no protection against messages being reordered and replayed by an
# active adversary.
class RandomNonceBox
class SimpleBox
extend Forwardable
def_delegators :@box, :nonce_bytes, :primitive

Expand Down
@@ -1,7 +1,7 @@
# encoding: binary
require 'spec_helper'

describe RbNaCl::RandomNonceBox do
describe RbNaCl::SimpleBox do
let(:secret_key) { vector :secret_key }
let(:secret_box) { RbNaCl::SecretBox.new(secret_key) }
let(:alicepk) { vector :alice_public }
Expand All @@ -11,33 +11,33 @@

context "instantiation" do
it "can be instantiated from an already existing box" do
expect { RbNaCl::RandomNonceBox.new(secret_box) }.not_to raise_error
expect { described_class.new(secret_box) }.not_to raise_error
end

it "can be instantiated from a secret key" do
RbNaCl::RandomNonceBox.from_secret_key(secret_key).should be_a RbNaCl::RandomNonceBox
described_class.from_secret_key(secret_key).should be_a described_class
end

it "raises TypeError when given a nil secret key" do
expect { RbNaCl::RandomNonceBox.from_secret_key(nil) }.to raise_error(TypeError)
expect { described_class.from_secret_key(nil) }.to raise_error(TypeError)
end

it "can be instantiated from a key-pair" do
RbNaCl::RandomNonceBox.from_keypair(alicepk, bobsk).should be_a RbNaCl::RandomNonceBox
described_class.from_keypair(alicepk, bobsk).should be_a described_class
end

it "raises TypeError when given nil secret keys in the pair" do
expect { RbNaCl::RandomNonceBox.from_keypair(nil, bobsk) }.to raise_error(TypeError)
expect { RbNaCl::RandomNonceBox.from_keypair(alicepk, nil) }.to raise_error(TypeError)
expect { described_class.from_keypair(nil, bobsk) }.to raise_error(TypeError)
expect { described_class.from_keypair(alicepk, nil) }.to raise_error(TypeError)
end
end

context "cryptography" do
let(:nonce) { vector :box_nonce }
let(:message) { vector :box_message }
let(:ciphertext) { vector :box_ciphertext }
let(:alice) { RbNaCl::RandomNonceBox.from_keypair(bobpk, alicesk) }
let(:bob) { RbNaCl::RandomNonceBox.from_keypair(alicepk, bobsk) }
let(:alice) { described_class.from_keypair(bobpk, alicesk) }
let(:bob) { described_class.from_keypair(alicepk, bobsk) }

describe "bob" do
it "decrypts a message from alice" do
Expand Down

0 comments on commit 6563d74

Please sign in to comment.