summaryrefslogtreecommitdiff
path: root/openssl/src/sign.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@palantir.com>2016-11-15 22:06:20 +0100
committerSteven Fackler <sfackler@palantir.com>2016-11-15 22:06:20 +0100
commit7515510125396db580d3aaa4efd28c51b02aa708 (patch)
treea447f6a227b0d552e80633955197e03f5488ff67 /openssl/src/sign.rs
parentec0fa36714a082ac7529dac7e0a8928f95a5bef0 (diff)
downloadrust-openssl-7515510125396db580d3aaa4efd28c51b02aa708.zip
Test elliptic curve signatures
Diffstat (limited to 'openssl/src/sign.rs')
-rw-r--r--openssl/src/sign.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/openssl/src/sign.rs b/openssl/src/sign.rs
index 679a30aa..ca7986ca 100644
--- a/openssl/src/sign.rs
+++ b/openssl/src/sign.rs
@@ -210,6 +210,8 @@ mod test {
use hash::MessageDigest;
use sign::{Signer, Verifier};
+ use ec::{EcGroup, EcKey};
+ use nid;
use rsa::Rsa;
use dsa::Dsa;
use pkey::PKey;
@@ -394,4 +396,19 @@ mod test {
test_hmac(MessageDigest::sha1(), &tests);
}
+
+ #[test]
+ fn ec() {
+ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let key = EcKey::generate(&group).unwrap();
+ let key = PKey::from_ec_key(key).unwrap();
+
+ let mut signer = Signer::new(MessageDigest::sha256(), &key).unwrap();
+ signer.update(b"hello world").unwrap();
+ let signature = signer.finish().unwrap();
+
+ let mut verifier = Verifier::new(MessageDigest::sha256(), &key).unwrap();
+ verifier.update(b"hello world").unwrap();
+ assert!(verifier.finish(&signature).unwrap());
+ }
}