mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-27 13:21:11 +03:00
Change PRIVATE_KEY * to ssh_private_key
This commit is contained in:
@@ -75,8 +75,8 @@ extern "C" {
|
|||||||
typedef struct ssh_string_struct STRING;
|
typedef struct ssh_string_struct STRING;
|
||||||
typedef struct ssh_buffer_struct BUFFER;
|
typedef struct ssh_buffer_struct BUFFER;
|
||||||
typedef struct ssh_public_key_struct PUBLIC_KEY;
|
typedef struct ssh_public_key_struct PUBLIC_KEY;
|
||||||
#endif
|
|
||||||
typedef struct ssh_private_key_struct PRIVATE_KEY;
|
typedef struct ssh_private_key_struct PRIVATE_KEY;
|
||||||
|
#endif
|
||||||
typedef struct ssh_channel_struct CHANNEL;
|
typedef struct ssh_channel_struct CHANNEL;
|
||||||
typedef struct ssh_agent_struct AGENT;
|
typedef struct ssh_agent_struct AGENT;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -264,11 +264,11 @@ void publickey_free(ssh_public_key key);
|
|||||||
|
|
||||||
/* in keyfiles.c */
|
/* in keyfiles.c */
|
||||||
|
|
||||||
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int type, const char *passphrase);
|
int type, const char *passphrase);
|
||||||
ssh_string publickey_to_string(ssh_public_key key);
|
ssh_string publickey_to_string(ssh_public_key key);
|
||||||
ssh_public_key publickey_from_privatekey(PRIVATE_KEY *prv);
|
ssh_public_key publickey_from_privatekey(ssh_private_key prv);
|
||||||
void privatekey_free(PRIVATE_KEY *prv);
|
void privatekey_free(ssh_private_key prv);
|
||||||
ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
|
ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int *type);
|
int *type);
|
||||||
int ssh_is_server_known(SSH_SESSION *session);
|
int ssh_is_server_known(SSH_SESSION *session);
|
||||||
@@ -375,7 +375,7 @@ int ssh_userauth_list(SSH_SESSION *session, const char *username);
|
|||||||
int ssh_userauth_none(SSH_SESSION *session, const char *username);
|
int ssh_userauth_none(SSH_SESSION *session, const char *username);
|
||||||
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
|
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
|
||||||
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, ssh_string publickey);
|
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, ssh_string publickey);
|
||||||
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, ssh_string publickey, PRIVATE_KEY *privatekey);
|
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, ssh_string publickey, ssh_private_key privatekey);
|
||||||
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
||||||
ssh_public_key publickey);
|
ssh_public_key publickey);
|
||||||
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
|
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
|
||||||
|
|||||||
@@ -388,8 +388,8 @@ struct ssh_session {
|
|||||||
struct ssh_kbdint *kbdint;
|
struct ssh_kbdint *kbdint;
|
||||||
int version; /* 1 or 2 */
|
int version; /* 1 or 2 */
|
||||||
/* server host keys */
|
/* server host keys */
|
||||||
PRIVATE_KEY *rsa_key;
|
ssh_private_key rsa_key;
|
||||||
PRIVATE_KEY *dsa_key;
|
ssh_private_key dsa_key;
|
||||||
/* auths accepted by server */
|
/* auths accepted by server */
|
||||||
int auth_methods;
|
int auth_methods;
|
||||||
int hostkeys; /* contains type of host key wanted by client, in server impl */
|
int hostkeys; /* contains type of host key wanted by client, in server impl */
|
||||||
@@ -650,7 +650,7 @@ char *ssh_find_matching(const char *in_d, const char *what_d);
|
|||||||
|
|
||||||
/* in keyfiles.c */
|
/* in keyfiles.c */
|
||||||
|
|
||||||
PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
ssh_private_key _privatekey_from_file(void *session, const char *filename,
|
||||||
int type);
|
int type);
|
||||||
ssh_string try_publickey_from_file(SSH_SESSION *session,
|
ssh_string try_publickey_from_file(SSH_SESSION *session,
|
||||||
struct ssh_keys_struct keytab,
|
struct ssh_keys_struct keytab,
|
||||||
@@ -660,10 +660,10 @@ ssh_string try_publickey_from_file(SSH_SESSION *session,
|
|||||||
const char *ssh_type_to_char(int type);
|
const char *ssh_type_to_char(int type);
|
||||||
int ssh_type_from_name(const char *name);
|
int ssh_type_from_name(const char *name);
|
||||||
|
|
||||||
PRIVATE_KEY *privatekey_make_dss(SSH_SESSION *session, ssh_buffer buffer);
|
ssh_private_key privatekey_make_dss(SSH_SESSION *session, ssh_buffer buffer);
|
||||||
PRIVATE_KEY *privatekey_make_rsa(SSH_SESSION *session, ssh_buffer buffer,
|
ssh_private_key privatekey_make_rsa(SSH_SESSION *session, ssh_buffer buffer,
|
||||||
const char *type);
|
const char *type);
|
||||||
PRIVATE_KEY *privatekey_from_string(SSH_SESSION *session, ssh_string privkey_s);
|
ssh_private_key privatekey_from_string(SSH_SESSION *session, ssh_string privkey_s);
|
||||||
|
|
||||||
ssh_public_key publickey_make_dss(SSH_SESSION *session, ssh_buffer buffer);
|
ssh_public_key publickey_make_dss(SSH_SESSION *session, ssh_buffer buffer);
|
||||||
ssh_public_key publickey_make_rsa(SSH_SESSION *session, ssh_buffer buffer, int type);
|
ssh_public_key publickey_make_rsa(SSH_SESSION *session, ssh_buffer buffer, int type);
|
||||||
@@ -673,8 +673,8 @@ void signature_free(SIGNATURE *sign);
|
|||||||
ssh_string ssh_do_sign_with_agent(struct ssh_session *session,
|
ssh_string ssh_do_sign_with_agent(struct ssh_session *session,
|
||||||
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
|
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
|
||||||
ssh_string ssh_do_sign(SSH_SESSION *session,ssh_buffer sigbuf,
|
ssh_string ssh_do_sign(SSH_SESSION *session,ssh_buffer sigbuf,
|
||||||
PRIVATE_KEY *privatekey);
|
ssh_private_key privatekey);
|
||||||
ssh_string ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey);
|
ssh_string ssh_sign_session_id(SSH_SESSION *session, ssh_private_key privatekey);
|
||||||
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_key key);
|
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_key key);
|
||||||
/* channel.c */
|
/* channel.c */
|
||||||
void channel_handle(SSH_SESSION *session, int type);
|
void channel_handle(SSH_SESSION *session, int type);
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ error:
|
|||||||
* @see ssh_userauth_offer_pubkey()
|
* @see ssh_userauth_offer_pubkey()
|
||||||
*/
|
*/
|
||||||
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username,
|
||||||
ssh_string publickey, PRIVATE_KEY *privatekey) {
|
ssh_string publickey, ssh_private_key privatekey) {
|
||||||
ssh_string user = NULL;
|
ssh_string user = NULL;
|
||||||
ssh_string service = NULL;
|
ssh_string service = NULL;
|
||||||
ssh_string method = NULL;
|
ssh_string method = NULL;
|
||||||
@@ -797,7 +797,7 @@ static struct ssh_keys_struct keytab[] = {
|
|||||||
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
||||||
struct ssh_public_key_struct *publickey;
|
struct ssh_public_key_struct *publickey;
|
||||||
ssh_string pubkey;
|
ssh_string pubkey;
|
||||||
PRIVATE_KEY *privkey;
|
ssh_private_key privkey;
|
||||||
char *privkeyfile = NULL;
|
char *privkeyfile = NULL;
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ int ssh_userauth1_offer_pubkey(SSH_SESSION *session, const char *username,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int ssh_userauth_pubkey(SSH_SESSION *session, char *username, ssh_string publickey, PRIVATE_KEY *privatekey){
|
int ssh_userauth_pubkey(SSH_SESSION *session, char *username, ssh_string publickey, ssh_private_key privatekey){
|
||||||
ssh_string user;
|
ssh_string user;
|
||||||
ssh_string service;
|
ssh_string service;
|
||||||
ssh_string method;
|
ssh_string method;
|
||||||
|
|||||||
@@ -609,10 +609,10 @@ static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
|
|||||||
* \see privatekey_free()
|
* \see privatekey_free()
|
||||||
* \see publickey_from_privatekey()
|
* \see publickey_from_privatekey()
|
||||||
*/
|
*/
|
||||||
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
ssh_private_key privatekey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int type, const char *passphrase) {
|
int type, const char *passphrase) {
|
||||||
ssh_auth_callback auth_cb = NULL;
|
ssh_auth_callback auth_cb = NULL;
|
||||||
PRIVATE_KEY *privkey = NULL;
|
ssh_private_key privkey = NULL;
|
||||||
void *auth_ud = NULL;
|
void *auth_ud = NULL;
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
@@ -719,7 +719,7 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
|
|
||||||
privkey = malloc(sizeof(PRIVATE_KEY));
|
privkey = malloc(sizeof(struct ssh_private_key_struct));
|
||||||
if (privkey == NULL) {
|
if (privkey == NULL) {
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_sexp_release(dsa);
|
gcry_sexp_release(dsa);
|
||||||
@@ -739,9 +739,9 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* same that privatekey_from_file() but without any passphrase things. */
|
/* same that privatekey_from_file() but without any passphrase things. */
|
||||||
PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
ssh_private_key _privatekey_from_file(void *session, const char *filename,
|
||||||
int type) {
|
int type) {
|
||||||
PRIVATE_KEY *privkey = NULL;
|
ssh_private_key privkey = NULL;
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_sexp_t dsa = NULL;
|
gcry_sexp_t dsa = NULL;
|
||||||
@@ -807,7 +807,7 @@ PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
privkey = malloc(sizeof(PRIVATE_KEY));
|
privkey = malloc(sizeof(struct ssh_private_key_struct));
|
||||||
if (privkey == NULL) {
|
if (privkey == NULL) {
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_sexp_release(dsa);
|
gcry_sexp_release(dsa);
|
||||||
@@ -829,7 +829,7 @@ PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
|||||||
/** \brief deallocate a private key
|
/** \brief deallocate a private key
|
||||||
* \param prv a PRIVATE_KEY object
|
* \param prv a PRIVATE_KEY object
|
||||||
*/
|
*/
|
||||||
void privatekey_free(PRIVATE_KEY *prv) {
|
void privatekey_free(ssh_private_key prv) {
|
||||||
if (prv == NULL) {
|
if (prv == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -841,7 +841,7 @@ void privatekey_free(PRIVATE_KEY *prv) {
|
|||||||
DSA_free(prv->dsa_priv);
|
DSA_free(prv->dsa_priv);
|
||||||
RSA_free(prv->rsa_priv);
|
RSA_free(prv->rsa_priv);
|
||||||
#endif
|
#endif
|
||||||
memset(prv, 0, sizeof(PRIVATE_KEY));
|
memset(prv, 0, sizeof(struct ssh_private_key_struct));
|
||||||
SAFE_FREE(prv);
|
SAFE_FREE(prv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ error:
|
|||||||
* \returns the public key
|
* \returns the public key
|
||||||
* \see publickey_to_string()
|
* \see publickey_to_string()
|
||||||
*/
|
*/
|
||||||
ssh_public_key publickey_from_privatekey(PRIVATE_KEY *prv) {
|
ssh_public_key publickey_from_privatekey(ssh_private_key prv) {
|
||||||
ssh_public_key key = NULL;
|
ssh_public_key key = NULL;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
gcry_sexp_t sexp;
|
gcry_sexp_t sexp;
|
||||||
@@ -1151,7 +1151,7 @@ ssh_string ssh_do_sign_with_agent(struct ssh_session *session,
|
|||||||
* This function signs the session id (known as H) as a string then
|
* This function signs the session id (known as H) as a string then
|
||||||
* the content of sigbuf */
|
* the content of sigbuf */
|
||||||
ssh_string ssh_do_sign(SSH_SESSION *session, ssh_buffer sigbuf,
|
ssh_string ssh_do_sign(SSH_SESSION *session, ssh_buffer sigbuf,
|
||||||
PRIVATE_KEY *privatekey) {
|
ssh_private_key privatekey) {
|
||||||
CRYPTO *crypto = session->current_crypto ? session->current_crypto :
|
CRYPTO *crypto = session->current_crypto ? session->current_crypto :
|
||||||
session->next_crypto;
|
session->next_crypto;
|
||||||
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
||||||
@@ -1315,7 +1315,7 @@ ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, ssh_public_ke
|
|||||||
|
|
||||||
|
|
||||||
/* this function signs the session id */
|
/* this function signs the session id */
|
||||||
ssh_string ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey) {
|
ssh_string ssh_sign_session_id(SSH_SESSION *session, ssh_private_key privatekey) {
|
||||||
CRYPTO *crypto=session->current_crypto ? session->current_crypto :
|
CRYPTO *crypto=session->current_crypto ? session->current_crypto :
|
||||||
session->next_crypto;
|
session->next_crypto;
|
||||||
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind) {
|
|||||||
|
|
||||||
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind) {
|
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind) {
|
||||||
SSH_SESSION *session;
|
SSH_SESSION *session;
|
||||||
PRIVATE_KEY *dsa = NULL;
|
ssh_private_key dsa = NULL;
|
||||||
PRIVATE_KEY *rsa = NULL;
|
ssh_private_key rsa = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
if (ssh_bind->bindfd < 0) {
|
if (ssh_bind->bindfd < 0) {
|
||||||
@@ -330,7 +330,7 @@ static int dh_handshake_server(SSH_SESSION *session) {
|
|||||||
ssh_string pubkey;
|
ssh_string pubkey;
|
||||||
ssh_string sign;
|
ssh_string sign;
|
||||||
ssh_public_key pub;
|
ssh_public_key pub;
|
||||||
PRIVATE_KEY *prv;
|
ssh_private_key prv;
|
||||||
|
|
||||||
if (packet_wait(session, SSH2_MSG_KEXDH_INIT, 1) != SSH_OK) {
|
if (packet_wait(session, SSH2_MSG_KEXDH_INIT, 1) != SSH_OK) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user