diff options
author | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-18 22:50:35 +0000 |
---|---|---|
committer | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-18 22:50:35 +0000 |
commit | 1fae66fca28167ca0e25625091c5df49405b8023 (patch) | |
tree | b322dfadaa45d14281b3977433f1427a2caa5a80 /test | |
parent | 7f7fef1813b1022d0c11694515fb98929953a6b1 (diff) | |
download | ruby-1fae66fca28167ca0e25625091c5df49405b8023.tar.gz |
* test/openssl/test_pkey_rsa.rb: Add tests for sign/verify.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/openssl/test_pkey_rsa.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index 39b65e889b..8592f0efa0 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 |