aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-30 09:35:44 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-09-02 23:10:23 +0200
commita0e3facac70a58ea3025d4706b9198f4da11eba3 (patch)
tree28d882a4fb506bf0b17adc7251edf48d9594173f
parent6dc7ddde3f75b7714d12570025bee2b79f9562dd (diff)
downloadlibssh-a0e3facac70a58ea3025d4706b9198f4da11eba3.tar.gz
libssh-a0e3facac70a58ea3025d4706b9198f4da11eba3.tar.xz
libssh-a0e3facac70a58ea3025d4706b9198f4da11eba3.zip
pki: Add ecdsa key support.
-rw-r--r--include/libssh/pki.h6
-rw-r--r--src/pki.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/include/libssh/pki.h b/include/libssh/pki.h
index 7784deb9..04aa3b1f 100644
--- a/include/libssh/pki.h
+++ b/include/libssh/pki.h
@@ -30,13 +30,19 @@ struct ssh_key_struct {
enum ssh_keytypes_e type;
int flags;
const char *type_c; /* Don't free it ! it is static */
+ int ecdsa_nid;
#ifdef HAVE_LIBGCRYPT
gcry_sexp_t dsa;
gcry_sexp_t rsa;
+ void *ecdsa;
#elif HAVE_LIBCRYPTO
DSA *dsa;
RSA *rsa;
+#ifdef HAVE_OPENSSL_ECC
+ EC_KEY *ecdsa;
+#else
void *ecdsa;
+#endif /* HAVE_OPENSSL_EC_H */
#endif
void *cert;
};
diff --git a/src/pki.c b/src/pki.c
index 0774f90e..935f3680 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -125,15 +125,21 @@ void ssh_key_clean (ssh_key key){
#ifdef HAVE_LIBGCRYPT
if(key->dsa) gcry_sexp_release(key->dsa);
if(key->rsa) gcry_sexp_release(key->rsa);
+ if(key->ecdsa) gcry_sexp_release(key->ecdsa);
#elif defined HAVE_LIBCRYPTO
if(key->dsa) DSA_free(key->dsa);
if(key->rsa) RSA_free(key->rsa);
+#ifdef HAVE_OPENSSL_ECC
+ if(key->ecdsa) EC_KEY_free(key->ecdsa);
+#endif /* HAVE_OPENSSL_ECC */
#endif
key->flags=SSH_KEY_FLAG_EMPTY;
key->type=SSH_KEYTYPE_UNKNOWN;
+ key->ecdsa_nid = 0;
key->type_c=NULL;
key->dsa = NULL;
key->rsa = NULL;
+ key->ecdsa = NULL;
}
/**
@@ -214,6 +220,7 @@ enum ssh_keytypes_e ssh_key_type_from_name(const char *name) {
|| strcmp(name, "ecdsa-sha2-nistp256") == 0
|| strcmp(name, "ecdsa-sha2-nistp384") == 0
|| strcmp(name, "ecdsa-sha2-nistp521") == 0) {
+ return SSH_KEYTYPE_ECDSA;
}
return SSH_KEYTYPE_UNKNOWN;