diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index ac73bc02..8e606d5a 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -429,7 +429,7 @@ LIBSSH_API int ssh_pki_import_privkey_base64(ssh_session session, const char *b64_key, const char *passphrase, ssh_key *pkey); -LIBSSH_API int ssh_key_import_private(ssh_session session, +LIBSSH_API int ssh_pki_import_privkey_file(ssh_session session, const char *filename, const char *passphrase, ssh_key *pkey); diff --git a/src/bind.c b/src/bind.c index 0dd1ebb5..7a2f049b 100644 --- a/src/bind.c +++ b/src/bind.c @@ -309,7 +309,7 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) { } if (sshbind->dsakey) { - rc = ssh_key_import_private(session, sshbind->dsakey, NULL, &dsa); + rc = ssh_pki_import_privkey_file(session, sshbind->dsakey, NULL, &dsa); if (rc == SSH_ERROR) { return SSH_ERROR; } @@ -321,7 +321,7 @@ int ssh_bind_accept(ssh_bind sshbind, ssh_session session) { } if (sshbind->rsakey) { - rc = ssh_key_import_private(session, sshbind->rsakey, NULL, &rsa); + rc = ssh_pki_import_privkey_file(session, sshbind->rsakey, NULL, &rsa); if (rc == SSH_ERROR) { return SSH_ERROR; } diff --git a/src/legacy.c b/src/legacy.c index ee74b343..ee5f896e 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -274,7 +274,7 @@ ssh_private_key privatekey_from_file(ssh_session session, (void) type; /* unused */ - rc = ssh_key_import_private(session, filename, passphrase, &key); + rc = ssh_pki_import_privkey_file(session, filename, passphrase, &key); if (rc == SSH_ERROR) { return NULL; } diff --git a/src/pki.c b/src/pki.c index 73e2edde..7685dfa1 100644 --- a/src/pki.c +++ b/src/pki.c @@ -200,19 +200,27 @@ int ssh_key_is_private(ssh_key k) { } /** - * @brief import a key from a file - * @param[out] key the ssh_key to update - * @param[in] session The SSH Session to use. If a key decryption callback is set, it will - * be used to ask for the passphrase. + * @brief Import a key from a file. + * + * @param[in] session The SSH Session to use. If a authentication callback is + * set, it will be used to ask for the passphrase. + * * @param[in] filename The filename of the the private key. - * @param[in] passphrase The passphrase to decrypt the private key. Set to null + * + * @param[in] passphrase The passphrase to decrypt the private key. Set to NULL * if none is needed or it is unknown. + * + * @param[out] pkey A pointer to store the ssh_key. You need to free the + * key. + * * @returns SSH_OK on success, SSH_ERROR otherwise. + * + * @see ssh_key_free() **/ -int ssh_key_import_private(ssh_session session, - const char *filename, - const char *passphrase, - ssh_key *pkey) { +int ssh_pki_import_privkey_file(ssh_session session, + const char *filename, + const char *passphrase, + ssh_key *pkey) { struct stat sb; char *key_buf; ssh_key key;