mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
tests: Add test case for bug #147
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 577840d7f7)
This commit is contained in:
committed by
Andreas Schneider
parent
6f089a098b
commit
8752460df4
@@ -766,6 +766,37 @@ static void torture_pki_duplicate_key_ecdsa(void **state)
|
|||||||
ssh_string_free_char(b64_key);
|
ssh_string_free_char(b64_key);
|
||||||
ssh_string_free_char(b64_key_gen);
|
ssh_string_free_char(b64_key_gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test case for bug #147: Private ECDSA key duplication did not carry
|
||||||
|
* over parts of the key that then caused subsequent key demotion to
|
||||||
|
* fail.
|
||||||
|
*/
|
||||||
|
static void torture_pki_ecdsa_duplicate_then_demote(void **state)
|
||||||
|
{
|
||||||
|
ssh_key pubkey;
|
||||||
|
ssh_key privkey;
|
||||||
|
ssh_key privkey_dup;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
(void) state;
|
||||||
|
|
||||||
|
rc = ssh_pki_import_privkey_file(LIBSSH_ECDSA_TESTKEY,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&privkey);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
privkey_dup = ssh_key_dup(privkey);
|
||||||
|
assert_true(privkey_dup != NULL);
|
||||||
|
|
||||||
|
rc = ssh_pki_export_privkey_to_pubkey(privkey_dup, &pubkey);
|
||||||
|
assert_true(rc == 0);
|
||||||
|
|
||||||
|
ssh_key_free(pubkey);
|
||||||
|
ssh_key_free(privkey);
|
||||||
|
ssh_key_free(privkey_dup);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void torture_pki_generate_key_rsa(void **state)
|
static void torture_pki_generate_key_rsa(void **state)
|
||||||
@@ -1109,6 +1140,9 @@ int torture_run_tests(void) {
|
|||||||
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
||||||
setup_ecdsa_key,
|
setup_ecdsa_key,
|
||||||
teardown),
|
teardown),
|
||||||
|
unit_test_setup_teardown(torture_pki_ecdsa_duplicate_then_demote,
|
||||||
|
setup_ecdsa_key,
|
||||||
|
teardown),
|
||||||
#endif
|
#endif
|
||||||
/* public key */
|
/* public key */
|
||||||
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
||||||
|
|||||||
Reference in New Issue
Block a user