aboutsummaryrefslogtreecommitdiff
path: root/src/pki.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-12-30 11:02:06 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-02-04 18:37:04 +0100
commitb309dd8fb72d1deaa16536f6d3391711594bbca5 (patch)
treedb77df97da3ca0611b04c4954e1b68defd985c8a /src/pki.c
parent91372e298d8effb5b3f8904449ebd5ca84afff2f (diff)
downloadlibssh-b309dd8fb72d1deaa16536f6d3391711594bbca5.tar.gz
libssh-b309dd8fb72d1deaa16536f6d3391711594bbca5.tar.xz
libssh-b309dd8fb72d1deaa16536f6d3391711594bbca5.zip
pki: Add support to generate ecdsa keys.
Diffstat (limited to 'src/pki.c')
-rw-r--r--src/pki.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/pki.c b/src/pki.c
index 0d17050c..1ebc84a2 100644
--- a/src/pki.c
+++ b/src/pki.c
@@ -870,7 +870,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
* @param[in] parameter Parameter to the creation of key:
* rsa : length of the key in bits (e.g. 1024, 2048, 4096)
* dsa : length of the key in bits (e.g. 1024, 2048, 3072)
- * ecdsa : not implemented
+ * ecdsa : bits of the key (e.g. 256, 384, 512)
* @param[out] pkey A pointer to store the private key. You need to free the
* memory.
* @return SSH_OK on success, SSH_ERROR on error.
@@ -881,6 +881,11 @@ int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
ssh_key *pkey){
int rc;
ssh_key key = ssh_key_new();
+
+ key->type = type;
+ key->type_c = ssh_key_type_to_char(type);
+ key->flags = SSH_KEY_FLAG_PRIVATE | SSH_KEY_FLAG_PUBLIC;
+
switch(type){
case SSH_KEYTYPE_RSA:
case SSH_KEYTYPE_RSA1:
@@ -894,12 +899,16 @@ int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
goto error;
break;
case SSH_KEYTYPE_ECDSA:
+#ifdef HAVE_ECC
+ rc = pki_key_generate_ecdsa(key, parameter);
+ if(rc == SSH_ERROR)
+ goto error;
+ break;
+#endif
case SSH_KEYTYPE_UNKNOWN:
goto error;
}
- key->type = type;
- key->type_c = ssh_key_type_to_char(type);
- key->flags = SSH_KEY_FLAG_PRIVATE | SSH_KEY_FLAG_PUBLIC;
+
*pkey = key;
return SSH_OK;
error: