aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-08-10 13:56:43 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-08-10 13:57:47 +0200
commitd54a1ab7981644b8d6f8e1ea58e5ba997f0b0cd6 (patch)
tree96668f09096c2706d06dfeceb5c46a43f170b3d6
parente1081796aff82812d877a43e240c779408a36171 (diff)
downloadlibssh-d54a1ab7981644b8d6f8e1ea58e5ba997f0b0cd6.tar.gz
libssh-d54a1ab7981644b8d6f8e1ea58e5ba997f0b0cd6.tar.xz
libssh-d54a1ab7981644b8d6f8e1ea58e5ba997f0b0cd6.zip
tests: Add checks for ssh_key_is_private()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_pki.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 027322a5..d880a5a5 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -212,6 +212,9 @@ static void torture_pki_import_privkey_base64_RSA(void **state) {
type = ssh_key_type(key);
assert_true(type == SSH_KEYTYPE_RSA);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
rc = ssh_key_is_public(key);
assert_true(rc == 1);
@@ -281,6 +284,9 @@ static void torture_pki_import_privkey_base64_ECDSA(void **state) {
rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
free(key_str);
ssh_key_free(key);
}
@@ -300,6 +306,10 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
NULL,
&key);
assert_true(rc == 0);
+
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
ssh_key_free(key);
/* test if it returns -1 if passphrase is wrong */
@@ -329,6 +339,10 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
NULL,
&key);
assert_true(rc == 0);
+
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
ssh_key_free(key);
/* test if it returns -1 if passphrase is wrong */
@@ -358,6 +372,10 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
NULL,
&key);
assert_true(rc == 0);
+
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
ssh_key_free(key);
/* test if it returns -1 if passphrase is wrong */
@@ -388,6 +406,9 @@ static void torture_pki_import_privkey_base64_ed25519(void **state){
type = ssh_key_type(key);
assert_true(type == SSH_KEYTYPE_ED25519);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
rc = ssh_key_is_public(key);
assert_true(rc == 1);
@@ -411,6 +432,9 @@ static void torture_pki_pki_publickey_from_privatekey_RSA(void **state) {
&key);
assert_true(rc == 0);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey);
assert_true(rc == SSH_OK);
@@ -433,6 +457,9 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
&key);
assert_true(rc == 0);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey);
assert_true(rc == SSH_OK);
@@ -455,6 +482,9 @@ static void torture_pki_pki_publickey_from_privatekey_ed25519(void **state){
&key);
assert_true(rc == 0);
+ rc = ssh_key_is_private(key);
+ assert_true(rc == 1);
+
rc = ssh_pki_export_privkey_to_pubkey(key, &pubkey);
assert_true(rc == SSH_OK);