aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-01-06 21:54:39 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:05 +0100
commit679cd9efd8e369f7a727314bb2bab00da211b999 (patch)
tree568877394e31aebdfd222d01b13330b1195ec4f0
parentae59049347eaa325315c3c2d77593ed8000faf7d (diff)
downloadlibssh-679cd9efd8e369f7a727314bb2bab00da211b999.tar.gz
libssh-679cd9efd8e369f7a727314bb2bab00da211b999.tar.xz
libssh-679cd9efd8e369f7a727314bb2bab00da211b999.zip
pki: Fix build if you don't have ECC support.
-rw-r--r--src/pki.c8
-rw-r--r--src/pki_crypto.c4
-rw-r--r--tests/unittests/torture_pki.c36
3 files changed, 34 insertions, 14 deletions
diff --git a/src/pki.c b/src/pki.c
index 1ebc84a2..ff8a5aac 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -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);
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index e6763217..0e54a38b 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -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;
}
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index 2c227dbe..31618a41 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -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;