mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
pki: Add ssh_pki_convert_key_to_privatekey().
This commit is contained in:
@@ -54,6 +54,7 @@ ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf,
|
|||||||
|
|
||||||
/* temporary functions, to be removed after migration to ssh_key */
|
/* temporary functions, to be removed after migration to ssh_key */
|
||||||
ssh_public_key ssh_pki_convert_key_to_publickey(ssh_key key);
|
ssh_public_key ssh_pki_convert_key_to_publickey(ssh_key key);
|
||||||
|
ssh_private_key ssh_pki_convert_key_to_privatekey(ssh_key key);
|
||||||
|
|
||||||
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey);
|
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey);
|
||||||
|
|
||||||
|
16
src/pki.c
16
src/pki.c
@@ -293,6 +293,22 @@ ssh_public_key ssh_pki_convert_key_to_publickey(ssh_key key) {
|
|||||||
return pub;
|
return pub;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_private_key ssh_pki_convert_key_to_privatekey(ssh_key key) {
|
||||||
|
ssh_private_key privkey;
|
||||||
|
|
||||||
|
privkey = malloc(sizeof(struct ssh_private_key_struct));
|
||||||
|
if (privkey == NULL) {
|
||||||
|
ssh_key_free(key);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
privkey->type = key->type;
|
||||||
|
privkey->dsa_priv = key->dsa;
|
||||||
|
privkey->rsa_priv = key->rsa;
|
||||||
|
|
||||||
|
return privkey;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief import a base64 formated key from a memory c-string
|
/** @brief import a base64 formated key from a memory c-string
|
||||||
*
|
*
|
||||||
* @param key The key to fill, created with ssh_key_new()
|
* @param key The key to fill, created with ssh_key_new()
|
||||||
|
Reference in New Issue
Block a user