summaryrefslogtreecommitdiff
path: root/test/openssl/test_pkey_rsa.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/openssl/test_pkey_rsa.rb')
-rw-r--r--test/openssl/test_pkey_rsa.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb
index 39b65e889b4..8592f0efa0c 100644
--- a/test/openssl/test_pkey_rsa.rb
+++ b/test/openssl/test_pkey_rsa.rb
@@ -48,6 +48,37 @@ class OpenSSL::TestPKeyRSA < Test::Unit::TestCase
assert_equal([], OpenSSL.errors)
end
+ def test_sign_verify
+ key = OpenSSL::PKey::RSA.new(512)
+ digest = OpenSSL::Digest::SHA1.new
+ data = 'Sign me!'
+ sig = key.sign(digest, data)
+ assert(key.verify(digest, sig, data))
+ end
+
+ def test_digest_state_irrelevant_sign
+ key = OpenSSL::PKey::RSA.new(512)
+ digest1 = OpenSSL::Digest::SHA1.new
+ digest2 = OpenSSL::Digest::SHA1.new
+ data = 'Sign me!'
+ digest1 << 'Change state of digest1'
+ sig1 = key.sign(digest1, data)
+ sig2 = key.sign(digest2, data)
+ assert_equal(sig1, sig2)
+ end
+
+ def test_digest_state_irrelevant_verify
+ key = OpenSSL::PKey::RSA.new(512)
+ digest1 = OpenSSL::Digest::SHA1.new
+ digest2 = OpenSSL::Digest::SHA1.new
+ data = 'Sign me!'
+ sig = key.sign(digest1, data)
+ digest1.reset
+ digest1 << 'Change state of digest1'
+ assert(key.verify(digest1, sig, data))
+ assert(key.verify(digest2, sig, data))
+ end
+
def test_read_RSAPublicKey
modulus = 10664264882656732240315063514678024569492171560814833397008094754351396057398262071307709191731289492697968568138092052265293364132872019762410446076526351
exponent = 65537