aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-12-29 11:06:47 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:04 +0100
commit0e1992a9cccab655be345c115fc586ab9acbd404 (patch)
tree1ce10682d34fa9b4dfbf593d83d794b5bbaae709
parentecbdc589f4ef7d64226a1c97dea90f32157d4161 (diff)
downloadlibssh-0e1992a9cccab655be345c115fc586ab9acbd404.tar.gz
libssh-0e1992a9cccab655be345c115fc586ab9acbd404.tar.xz
libssh-0e1992a9cccab655be345c115fc586ab9acbd404.zip
tests: Add ecdsa publickey_from_privatekey test.
-rw-r--r--tests/unittests/torture_pki.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 9ca3d333..6e380851 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -360,6 +360,29 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
ssh_key_free(pubkey);
}
+static void torture_pki_publickey_from_privatekey_ECDSA(void **state) {
+ int rc;
+ char *key_str;
+ ssh_key key;
+ ssh_key pubkey;
+ const char *passphrase = NULL;
+
+ (void) state; /* unused */
+
+ key_str = read_file(LIBSSH_ECDSA_TESTKEY);
+ assert_true(key_str != NULL);
+
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
+ assert_true(rc == 0);
+
+ rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey);
+ assert_true(rc == SSH_OK);
+
+ free(key_str);
+ ssh_key_free(key);
+ ssh_key_free(pubkey);
+}
+
static void torture_pki_publickey_dsa_base64(void **state)
{
enum ssh_keytypes_e type;
@@ -811,6 +834,9 @@ int torture_run_tests(void) {
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_DSA,
setup_dsa_key,
teardown),
+ unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
+ setup_ecdsa_key,
+ teardown),
/* public key */
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
setup_dsa_key,