mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
tests: Cover comparison of public keys, which was missing
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
1f66414805
commit
9f178be1fa
@@ -682,6 +682,7 @@ static void torture_pki_dsa_duplicate_key(void **state)
|
||||
char *b64_key = NULL;
|
||||
char *b64_key_gen = NULL;
|
||||
ssh_key pubkey = NULL;
|
||||
ssh_key pubkey_dup = NULL;
|
||||
ssh_key privkey = NULL;
|
||||
ssh_key privkey_dup = NULL;
|
||||
|
||||
@@ -694,8 +695,6 @@ static void torture_pki_dsa_duplicate_key(void **state)
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key);
|
||||
assert_true(rc == 0);
|
||||
assert_non_null(b64_key);
|
||||
SSH_KEY_FREE(pubkey);
|
||||
|
||||
rc = ssh_pki_import_privkey_file(LIBSSH_DSA_TESTKEY,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -707,11 +706,11 @@ static void torture_pki_dsa_duplicate_key(void **state)
|
||||
privkey_dup = ssh_key_dup(privkey);
|
||||
assert_non_null(privkey_dup);
|
||||
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey);
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey_dup);
|
||||
assert_true(rc == SSH_OK);
|
||||
assert_non_null(pubkey);
|
||||
assert_non_null(pubkey_dup);
|
||||
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key_gen);
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey_dup, &b64_key_gen);
|
||||
assert_true(rc == 0);
|
||||
assert_non_null(b64_key_gen);
|
||||
|
||||
@@ -720,7 +719,12 @@ static void torture_pki_dsa_duplicate_key(void **state)
|
||||
rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE);
|
||||
assert_true(rc == 0);
|
||||
|
||||
rc = ssh_key_cmp(pubkey, pubkey_dup, SSH_KEY_CMP_PUBLIC);
|
||||
assert_true(rc == 0);
|
||||
|
||||
SSH_KEY_FREE(pubkey);
|
||||
SSH_KEY_FREE(pubkey_dup);
|
||||
|
||||
SSH_KEY_FREE(privkey);
|
||||
SSH_KEY_FREE(privkey_dup);
|
||||
SSH_STRING_FREE_CHAR(b64_key);
|
||||
|
||||
@@ -380,6 +380,7 @@ static void torture_pki_ecdsa_duplicate_key(void **state)
|
||||
char *b64_key = NULL;
|
||||
char *b64_key_gen = NULL;
|
||||
ssh_key pubkey = NULL;
|
||||
ssh_key pubkey_dup = NULL;
|
||||
ssh_key privkey = NULL;
|
||||
ssh_key privkey_dup = NULL;
|
||||
|
||||
@@ -391,7 +392,6 @@ static void torture_pki_ecdsa_duplicate_key(void **state)
|
||||
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key);
|
||||
assert_true(rc == 0);
|
||||
SSH_KEY_FREE(pubkey);
|
||||
assert_non_null(b64_key);
|
||||
|
||||
rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY,
|
||||
@@ -405,11 +405,11 @@ static void torture_pki_ecdsa_duplicate_key(void **state)
|
||||
privkey_dup = ssh_key_dup(privkey);
|
||||
assert_non_null(privkey_dup);
|
||||
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey);
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey_dup);
|
||||
assert_true(rc == SSH_OK);
|
||||
assert_non_null(pubkey);
|
||||
assert_non_null(pubkey_dup);
|
||||
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key_gen);
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey_dup, &b64_key_gen);
|
||||
assert_true(rc == 0);
|
||||
assert_non_null(b64_key_gen);
|
||||
|
||||
@@ -418,7 +418,11 @@ static void torture_pki_ecdsa_duplicate_key(void **state)
|
||||
rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE);
|
||||
assert_true(rc == 0);
|
||||
|
||||
rc = ssh_key_cmp(pubkey, pubkey_dup, SSH_KEY_CMP_PUBLIC);
|
||||
assert_true(rc == 0);
|
||||
|
||||
SSH_KEY_FREE(pubkey);
|
||||
SSH_KEY_FREE(pubkey_dup);
|
||||
SSH_KEY_FREE(privkey);
|
||||
SSH_KEY_FREE(privkey_dup);
|
||||
SSH_STRING_FREE_CHAR(b64_key);
|
||||
|
||||
@@ -411,6 +411,7 @@ static void torture_pki_rsa_duplicate_key(void **state)
|
||||
char *b64_key = NULL;
|
||||
char *b64_key_gen = NULL;
|
||||
ssh_key pubkey = NULL;
|
||||
ssh_key pubkey_dup = NULL;
|
||||
ssh_key privkey = NULL;
|
||||
ssh_key privkey_dup = NULL;
|
||||
|
||||
@@ -422,7 +423,6 @@ static void torture_pki_rsa_duplicate_key(void **state)
|
||||
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key);
|
||||
assert_true(rc == 0);
|
||||
SSH_KEY_FREE(pubkey);
|
||||
assert_non_null(b64_key);
|
||||
|
||||
rc = ssh_pki_import_privkey_file(LIBSSH_RSA_TESTKEY,
|
||||
@@ -436,11 +436,11 @@ static void torture_pki_rsa_duplicate_key(void **state)
|
||||
privkey_dup = ssh_key_dup(privkey);
|
||||
assert_non_null(privkey_dup);
|
||||
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey);
|
||||
rc = ssh_pki_export_privkey_to_pubkey(privkey, &pubkey_dup);
|
||||
assert_true(rc == SSH_OK);
|
||||
assert_non_null(pubkey);
|
||||
assert_non_null(pubkey_dup);
|
||||
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey, &b64_key_gen);
|
||||
rc = ssh_pki_export_pubkey_base64(pubkey_dup, &b64_key_gen);
|
||||
assert_true(rc == 0);
|
||||
assert_non_null(b64_key_gen);
|
||||
|
||||
@@ -449,7 +449,11 @@ static void torture_pki_rsa_duplicate_key(void **state)
|
||||
rc = ssh_key_cmp(privkey, privkey_dup, SSH_KEY_CMP_PRIVATE);
|
||||
assert_true(rc == 0);
|
||||
|
||||
rc = ssh_key_cmp(pubkey, pubkey_dup, SSH_KEY_CMP_PUBLIC);
|
||||
assert_true(rc == 0);
|
||||
|
||||
SSH_KEY_FREE(pubkey);
|
||||
SSH_KEY_FREE(pubkey_dup);
|
||||
SSH_KEY_FREE(privkey);
|
||||
SSH_KEY_FREE(privkey_dup);
|
||||
SSH_STRING_FREE_CHAR(b64_key);
|
||||
|
||||
Reference in New Issue
Block a user