Skip to content

Commit

Permalink
Update self-tests for new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
namelessjon committed Oct 30, 2013
1 parent 626c366 commit dc49c40
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions lib/rbnacl/self_test.rb
Expand Up @@ -42,16 +42,12 @@ def box_common_test(box)
#:nocov:
end

begin
passed = false
corrupt_ct = ciphertext.dup
corrupt_ct[23] = ' '
corrupt_ct
box.decrypt(nonce, corrupt_ct)
rescue CryptoError
passed = true
ensure
passed or raise SelfTestFailure, "failed to detect corrupt ciphertext"
corrupt_ct = ciphertext.dup
corrupt_ct[23] = ' '
if box.decrypt!(nonce, corrupt_ct)
#:nocov:
raise SelfTestFailure, "failed to detect corrupt ciphertext"
#:nocov:
end
end

Expand Down Expand Up @@ -82,7 +78,7 @@ def digital_signature_test

bad_signature = signature[0,63] + '0'

unless verify_key.verify(bad_signature, message) == false
unless verify_key.verify!(bad_signature, message) == false
#:nocov:
raise SelfTestFailure, "failed to detect an invalid signature"
#:nocov:
Expand Down Expand Up @@ -111,13 +107,13 @@ def hmac_test(klass, tag)
#:nocov:
end

unless authenticator.verify(vector(tag), message)
unless authenticator.verify!(vector(tag), message)
#:nocov:
raise SelfTestFailure, "#{klass} failed to verify correct authentication tag"
#:nocov:
end

if authenticator.verify(vector(tag), message + ' ')
if authenticator.verify!(vector(tag), message + ' ')
#:nocov:
raise SelfTestFailure, "#{klass} failed to detect invalid authentication tag"
#:nocov:
Expand Down

0 comments on commit dc49c40

Please sign in to comment.