aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-12-30 11:12:13 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:05 +0100
commitae59049347eaa325315c3c2d77593ed8000faf7d (patch)
tree2217b3461d72f7cc21a34a6755877838c616ac07
parentb1434fd09b4464da6c69a645e620d3c6eece3109 (diff)
downloadlibssh-ae59049347eaa325315c3c2d77593ed8000faf7d.tar.gz
libssh-ae59049347eaa325315c3c2d77593ed8000faf7d.tar.xz
libssh-ae59049347eaa325315c3c2d77593ed8000faf7d.zip
tests: Test ecdsa key generation and signing.
-rw-r--r--tests/unittests/torture_pki.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 258b2ef..2c227db 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -888,6 +888,50 @@ static void torture_pki_generate_key_dsa(void **state)
ssh_free(session);
}
+static void torture_pki_generate_key_ecdsa(void **state)
+{
+ int rc;
+ ssh_key key;
+ ssh_signature sign;
+ ssh_session session=ssh_new();
+ (void) state;
+
+ rc = ssh_pki_generate(SSH_KEYTYPE_ECDSA, 256, &key);
+ assert_true(rc == SSH_OK);
+ assert_true(key != NULL);
+ sign = pki_do_sign(key, HASH, 20);
+ assert_true(sign != NULL);
+ rc = pki_signature_verify(session,sign,key,HASH,20);
+ assert_true(rc == SSH_OK);
+ ssh_signature_free(sign);
+ ssh_key_free(key);
+ key=NULL;
+
+ rc = ssh_pki_generate(SSH_KEYTYPE_ECDSA, 384, &key);
+ assert_true(rc == SSH_OK);
+ assert_true(key != NULL);
+ sign = pki_do_sign(key, HASH, 20);
+ assert_true(sign != NULL);
+ rc = pki_signature_verify(session,sign,key,HASH,20);
+ assert_true(rc == SSH_OK);
+ ssh_signature_free(sign);
+ ssh_key_free(key);
+ key=NULL;
+
+ rc = ssh_pki_generate(SSH_KEYTYPE_ECDSA, 512, &key);
+ assert_true(rc == SSH_OK);
+ assert_true(key != NULL);
+ sign = pki_do_sign(key, HASH, 20);
+ assert_true(sign != NULL);
+ rc = pki_signature_verify(session,sign,key,HASH,20);
+ assert_true(rc == SSH_OK);
+ ssh_signature_free(sign);
+ ssh_key_free(key);
+ key=NULL;
+
+ ssh_free(session);
+}
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
@@ -957,6 +1001,7 @@ int torture_run_tests(void) {
unit_test(torture_pki_generate_key_rsa),
unit_test(torture_pki_generate_key_rsa1),
unit_test(torture_pki_generate_key_dsa),
+ unit_test(torture_pki_generate_key_ecdsa),
};
(void)setup_both_keys;