aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-12-28 18:21:47 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:04 +0100
commitf35c284761359b4b71c0f8228126fa920430ad66 (patch)
treedaf2aa48e326644b673352045effdd14d9369c7e /src/pki.c
parentfa37965ab08ce66875be15f340e54f4c283075d9 (diff)
downloadlibssh-f35c284761359b4b71c0f8228126fa920430ad66.tar.gz
libssh-f35c284761359b4b71c0f8228126fa920430ad66.tar.xz
libssh-f35c284761359b4b71c0f8228126fa920430ad66.zip
pki: Add support to import ecdsa pubkeys.
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/pki.c b/src/pki.c
index 00bca82e..0d17050c 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -625,6 +625,35 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
}
break;
case SSH_KEYTYPE_ECDSA:
+#ifdef HAVE_ECC
+ {
+ ssh_string e;
+ ssh_string i;
+ int nid;
+
+ i = buffer_get_ssh_string(buffer);
+ if (i == NULL) {
+ goto fail;
+ }
+ nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(i));
+ ssh_string_free(i);
+ if (nid == -1) {
+ goto fail;
+ }
+
+
+ e = buffer_get_ssh_string(buffer);
+ if (e == NULL) {
+ goto fail;
+ }
+
+ rc = pki_pubkey_build_ecdsa(key, nid, e);
+
+ ssh_string_burn(e);
+ ssh_string_free(e);
+ }
+ break;
+#endif
case SSH_KEYTYPE_UNKNOWN:
ssh_pki_log("Unknown public key protocol %d", type);
goto fail;
@@ -701,6 +730,7 @@ 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) {
@@ -727,11 +757,18 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
}
type = ssh_key_type_from_name(ssh_string_get_char(type_s));
- ssh_string_free(type_s);
if (type == SSH_KEYTYPE_UNKNOWN) {
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);