spec/rbnacl/hash/blake2b_spec.rb in rbnacl-3.2.0 vs spec/rbnacl/hash/blake2b_spec.rb in rbnacl-3.3.0

- old
+ new

@@ -25,6 +25,38 @@ it "doesn't accept empty strings as a key" do expect { RbNaCl::Hash.blake2b(reference_string, key: "") }.to raise_exception end end + + context "personalized" do + let(:reference_string) { vector :blake2b_message } + let(:reference_personal) { vector :blake2b_personal } + let(:reference_personal_hash) { vector :blake2b_personal_digest } + let(:reference_personal_short) { vector :blake2b_personal_short } + let(:reference_personal_short_hash) { vector :blake2b_personal_short_digest } + + it "calculates personalised hashes correctly" do + expect(RbNaCl::Hash.blake2b(reference_string, personal: reference_personal)).to eq reference_personal_hash + end + + it "calculates personalised hashes correctly with a short personal" do + expect(RbNaCl::Hash.blake2b(reference_string, personal: reference_personal_short)).to eq reference_personal_short_hash + end + end + + context "salted" do + let(:reference_string) { vector :blake2b_message } + let(:reference_salt) { vector :blake2b_salt } + let(:reference_salt_hash) { vector :blake2b_salt_digest } + let(:reference_salt_short) { vector :blake2b_salt_short } + let(:reference_salt_short_hash) { vector :blake2b_salt_short_digest } + + it "calculates saltised hashes correctly" do + expect(RbNaCl::Hash.blake2b(reference_string, salt: reference_salt)).to eq reference_salt_hash + end + + it "calculates saltised hashes correctly with a short salt" do + expect(RbNaCl::Hash.blake2b(reference_string, salt: reference_salt_short)).to eq reference_salt_short_hash + end + end end