mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
pki: Fix build if you don't have ECC support.
This commit is contained in:
@@ -730,7 +730,6 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
|
||||
ssh_buffer buffer;
|
||||
ssh_string type_s = NULL;
|
||||
enum ssh_keytypes_e type;
|
||||
int nid;
|
||||
int rc;
|
||||
|
||||
if (key_blob == NULL || pkey == NULL) {
|
||||
@@ -761,13 +760,6 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
|
||||
ssh_pki_log("Unknown key type found!");
|
||||
goto fail;
|
||||
}
|
||||
if (type == SSH_KEYTYPE_ECDSA) {
|
||||
nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(type_s));
|
||||
if (nid == -1) {
|
||||
ssh_pki_log("Unknown nid found!");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
ssh_string_free(type_s);
|
||||
|
||||
rc = pki_import_pubkey_buffer(buffer, type, pkey);
|
||||
|
@@ -403,6 +403,7 @@ int pki_key_generate_dss(ssh_key key, int parameter){
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENSSL_ECC
|
||||
int pki_key_generate_ecdsa(ssh_key key, int parameter) {
|
||||
int nid;
|
||||
int ok;
|
||||
@@ -436,6 +437,7 @@ int pki_key_generate_ecdsa(ssh_key key, int parameter) {
|
||||
|
||||
return SSH_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int pki_key_compare(const ssh_key k1,
|
||||
const ssh_key k2,
|
||||
@@ -654,7 +656,9 @@ fail:
|
||||
ssh_key_free(key);
|
||||
DSA_free(dsa);
|
||||
RSA_free(rsa);
|
||||
#ifdef HAVE_OPENSSL_ECC
|
||||
EC_KEY_free(ecdsa);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -245,6 +245,7 @@ static void torture_pki_import_privkey_base64_DSA(void **state) {
|
||||
ssh_key_free(key);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_pki_import_privkey_base64_ECDSA(void **state) {
|
||||
int rc;
|
||||
char *key_str;
|
||||
@@ -262,6 +263,7 @@ static void torture_pki_import_privkey_base64_ECDSA(void **state) {
|
||||
free(key_str);
|
||||
ssh_key_free(key);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void torture_pki_import_privkey_base64_passphrase(void **state) {
|
||||
int rc;
|
||||
@@ -360,6 +362,7 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
|
||||
ssh_key_free(pubkey);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_pki_publickey_from_privatekey_ECDSA(void **state) {
|
||||
int rc;
|
||||
char *key_str;
|
||||
@@ -382,6 +385,7 @@ static void torture_pki_publickey_from_privatekey_ECDSA(void **state) {
|
||||
ssh_key_free(key);
|
||||
ssh_key_free(pubkey);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void torture_pki_publickey_dsa_base64(void **state)
|
||||
{
|
||||
@@ -420,6 +424,7 @@ static void torture_pki_publickey_dsa_base64(void **state)
|
||||
ssh_key_free(key);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_pki_publickey_ecdsa_base64(void **state)
|
||||
{
|
||||
enum ssh_keytypes_e type;
|
||||
@@ -456,6 +461,7 @@ static void torture_pki_publickey_ecdsa_base64(void **state)
|
||||
free(key_buf);
|
||||
ssh_key_free(key);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void torture_pki_publickey_rsa_base64(void **state)
|
||||
{
|
||||
@@ -577,6 +583,7 @@ static void torture_generate_pubkey_from_privkey_dsa(void **state) {
|
||||
ssh_key_free(pubkey);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_generate_pubkey_from_privkey_ecdsa(void **state) {
|
||||
char pubkey_original[4096] = {0};
|
||||
char pubkey_generated[4096] = {0};
|
||||
@@ -617,6 +624,7 @@ static void torture_generate_pubkey_from_privkey_ecdsa(void **state) {
|
||||
ssh_key_free(privkey);
|
||||
ssh_key_free(pubkey);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void torture_pki_duplicate_key_rsa(void **state)
|
||||
{
|
||||
@@ -710,6 +718,7 @@ static void torture_pki_duplicate_key_dsa(void **state)
|
||||
ssh_string_free_char(b64_key_gen);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_pki_duplicate_key_ecdsa(void **state)
|
||||
{
|
||||
int rc;
|
||||
@@ -755,6 +764,7 @@ static void torture_pki_duplicate_key_ecdsa(void **state)
|
||||
ssh_string_free_char(b64_key);
|
||||
ssh_string_free_char(b64_key_gen);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void torture_pki_generate_key_rsa(void **state)
|
||||
{
|
||||
@@ -888,6 +898,7 @@ static void torture_pki_generate_key_dsa(void **state)
|
||||
ssh_free(session);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
static void torture_pki_generate_key_ecdsa(void **state)
|
||||
{
|
||||
int rc;
|
||||
@@ -931,6 +942,7 @@ static void torture_pki_generate_key_ecdsa(void **state)
|
||||
|
||||
ssh_free(session);
|
||||
}
|
||||
#endif
|
||||
|
||||
int torture_run_tests(void) {
|
||||
int rc;
|
||||
@@ -952,9 +964,11 @@ int torture_run_tests(void) {
|
||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_DSA,
|
||||
setup_dsa_key,
|
||||
teardown),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_ECDSA,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
#endif
|
||||
unit_test_setup_teardown(torture_pki_import_privkey_base64_passphrase,
|
||||
setup_both_keys_passphrase,
|
||||
teardown),
|
||||
@@ -965,29 +979,35 @@ int torture_run_tests(void) {
|
||||
unit_test_setup_teardown(torture_pki_pki_publickey_from_privatekey_DSA,
|
||||
setup_dsa_key,
|
||||
teardown),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test_setup_teardown(torture_pki_publickey_from_privatekey_ECDSA,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
#endif
|
||||
/* public key */
|
||||
unit_test_setup_teardown(torture_pki_publickey_dsa_base64,
|
||||
setup_dsa_key,
|
||||
teardown),
|
||||
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
unit_test_setup_teardown(torture_pki_publickey_rsa_base64,
|
||||
setup_rsa_key,
|
||||
teardown),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test_setup_teardown(torture_pki_publickey_ecdsa_base64,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
#endif
|
||||
|
||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_dsa,
|
||||
setup_dsa_key,
|
||||
teardown),
|
||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_rsa,
|
||||
setup_rsa_key,
|
||||
teardown),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test_setup_teardown(torture_generate_pubkey_from_privkey_ecdsa,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
#endif
|
||||
|
||||
unit_test_setup_teardown(torture_pki_duplicate_key_rsa,
|
||||
setup_rsa_key,
|
||||
@@ -995,13 +1015,17 @@ int torture_run_tests(void) {
|
||||
unit_test_setup_teardown(torture_pki_duplicate_key_dsa,
|
||||
setup_dsa_key,
|
||||
teardown),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test_setup_teardown(torture_pki_duplicate_key_ecdsa,
|
||||
setup_ecdsa_key,
|
||||
teardown),
|
||||
#endif
|
||||
unit_test(torture_pki_generate_key_rsa),
|
||||
unit_test(torture_pki_generate_key_rsa1),
|
||||
unit_test(torture_pki_generate_key_dsa),
|
||||
#ifdef HAVE_ECC
|
||||
unit_test(torture_pki_generate_key_ecdsa),
|
||||
#endif
|
||||
};
|
||||
|
||||
(void)setup_both_keys;
|
||||
|
Reference in New Issue
Block a user