diff --git a/ChangeLog b/ChangeLog index 3996e476b2..0b499fd5dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu May 19 07:47:26 2011 Martin Bosslet + + * test/openssl/test_pkey_rsa.rb: Add tests for sign/verify. + Thu May 19 07:19:16 2011 Martin Bosslet * ext/openssl/ossl_pkey.c: Add documentation. 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