aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/torture_pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-16 00:06:01 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-16 00:47:43 +0200
commit47ebcac4cd83af0ef58982b3c77da57b220d36fd (patch)
tree5da4f6a9c1cbcaac1bbaf11da1d5b4b93f4be40d /tests/unittests/torture_pki.c
parent977d6fc089d3fb33d5d22f3a47438e5a48706d66 (diff)
downloadlibssh-47ebcac4cd83af0ef58982b3c77da57b220d36fd.tar.gz
libssh-47ebcac4cd83af0ef58982b3c77da57b220d36fd.tar.xz
libssh-47ebcac4cd83af0ef58982b3c77da57b220d36fd.zip
torture: Add torture_pki_publickey_rsa_base64 test.
Diffstat (limited to 'tests/unittests/torture_pki.c')
-rw-r--r--tests/unittests/torture_pki.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 8e1d07de..6425d6d7 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -278,6 +278,38 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
ssh_key_free(pubkey);
}
+static void torture_pki_publickey_rsa_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_RSA_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_RSA) ||
+ (type == SSH_KEYTYPE_RSA1)));
+
+ q = ++p;
+ while (*p != ' ') p++;
+ *p = '\0';
+
+ rc = ssh_pki_import_pubkey_base64(session, q, type, &key);
+ assert_true(rc == 0);
+
+ free(key_buf);
+ ssh_key_free(key);
+}
+
int torture_run_tests(void) {
int rc;
const UnitTest tests[] = {
@@ -307,6 +339,10 @@ int torture_run_tests(void) {
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_DSA,
setup_dsa_key,
teardown),
+ /* public key */
+ unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
+ setup_rsa_key,
+ teardown),