diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-10-17 10:49:39 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-10-17 10:49:39 +0900 |
commit | 41944f14ad191a7853c567c3807a711fa2c24226 (patch) | |
tree | cbabe5fb4bd4f800eaef1bf8c3a0e5baae698dcd /test/test_pkey_ec.rb | |
parent | 9e0df41444612d794300f2a7bd26d515f6c4662c (diff) | |
parent | a9ef251697602d6ab419094ed64654c6cd7c17ac (diff) | |
download | ruby-openssl-41944f14ad191a7853c567c3807a711fa2c24226.tar.gz |
Merge branch 'topic/test-static-test-vector'
* topic/test-static-test-vector:
test/test_pkey_*: refine sign/verify tests
Diffstat (limited to 'test/test_pkey_ec.rb')
-rw-r--r-- | test/test_pkey_ec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_pkey_ec.rb b/test/test_pkey_ec.rb index 0058d8bf..e281f80c 100644 --- a/test/test_pkey_ec.rb +++ b/test/test_pkey_ec.rb @@ -73,6 +73,20 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase assert_raise(OpenSSL::PKey::ECError) { key2.check_key } end + def test_sign_verify + data = "Sign me!" + signature = P256.sign("SHA1", data) + assert_equal true, P256.verify("SHA1", signature, data) + + signature0 = (<<~'end;').unpack("m")[0] + MEQCIEOTY/hD7eI8a0qlzxkIt8LLZ8uwiaSfVbjX2dPAvN11AiAQdCYx56Fq + QdBp1B4sxJoA8jvODMMklMyBKVmudboA6A== + end; + assert_equal true, P256.verify("SHA256", signature0, data) + signature1 = signature0.succ + assert_equal false, P256.verify("SHA256", signature1, data) + end + def test_dsa_sign_verify data1 = "foo" data2 = "bar" |