From dc49c40a82e64cd852db5df8720c4781e38b7423 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Oct 2013 22:35:40 +0000 Subject: [PATCH] Update self-tests for new methods --- lib/rbnacl/self_test.rb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/rbnacl/self_test.rb b/lib/rbnacl/self_test.rb index a61b20b..86fd335 100644 --- a/lib/rbnacl/self_test.rb +++ b/lib/rbnacl/self_test.rb @@ -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 @@ -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: @@ -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: