aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-16 01:17:24 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-16 01:17:24 +0200
commit330c713fdbbf79d591028cf2fe5ae3b868db1514 (patch)
tree76890812be728ac628313bfd5e8d1b99e50b7bcc /tests
parent42dda7b958a480f288ff7b627ef0d93d4fd9459b (diff)
downloadlibssh-330c713fdbbf79d591028cf2fe5ae3b868db1514.tar.gz
libssh-330c713fdbbf79d591028cf2fe5ae3b868db1514.tar.xz
libssh-330c713fdbbf79d591028cf2fe5ae3b868db1514.zip
pki: Add test torture_pki_publickey_dsa_base64().
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_pki.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 42082b1..cbad331 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -278,6 +278,42 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
ssh_key_free(pubkey);
}
+static void torture_pki_publickey_dsa_base64(void **state)
+{
+ ssh_session session = *state;
+ enum ssh_keytypes_e type;
+ char *key_buf, *p;
+ const char *q;
+ unsigned char *b64_key;
+ ssh_key key;
+ int rc;
+
+ key_buf = read_file(LIBSSH_DSA_TESTKEY ".pub");
+ assert_true(key_buf != NULL);
+
+ q = p = key_buf;
+ while (*p != ' ') p++;
+ *p = '\0';
+
+ type = ssh_key_type_from_name(q);
+ assert_true(type == SSH_KEYTYPE_DSS);
+
+ q = ++p;
+ while (*p != ' ') p++;
+ *p = '\0';
+
+ rc = ssh_pki_import_pubkey_base64(session, q, type, &key);
+ assert_true(rc == 0);
+
+ rc = ssh_pki_publickey_to_base64(key, &b64_key, &type);
+ assert_true(rc == 0);
+
+ assert_string_equal(q, b64_key);
+
+ free(key_buf);
+ ssh_key_free(key);
+}
+
static void torture_pki_publickey_rsa_base64(void **state)
{
ssh_session session = *state;
@@ -345,6 +381,9 @@ int torture_run_tests(void) {
setup_dsa_key,
teardown),
/* public key */
+ unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
+ setup_dsa_key,
+ teardown),
unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
setup_rsa_key,
teardown),