mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
agent: Remove obsolete agent_sign_data().
This commit is contained in:
@@ -88,9 +88,6 @@ ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
|
|||||||
ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
|
ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
|
||||||
char **comment);
|
char **comment);
|
||||||
|
|
||||||
ssh_string agent_sign_data(struct ssh_session_struct *session,
|
|
||||||
struct ssh_buffer_struct *data,
|
|
||||||
struct ssh_public_key_struct *pubkey);
|
|
||||||
ssh_string ssh_agent_sign_data(ssh_session session,
|
ssh_string ssh_agent_sign_data(ssh_session session,
|
||||||
const ssh_key pubkey,
|
const ssh_key pubkey,
|
||||||
struct ssh_buffer_struct *data);
|
struct ssh_buffer_struct *data);
|
||||||
|
|||||||
84
src/agent.c
84
src/agent.c
@@ -400,90 +400,6 @@ ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_string agent_sign_data(struct ssh_session_struct *session,
|
|
||||||
struct ssh_buffer_struct *data,
|
|
||||||
struct ssh_public_key_struct *pubkey) {
|
|
||||||
struct ssh_string_struct *blob = NULL;
|
|
||||||
struct ssh_string_struct *sig = NULL;
|
|
||||||
struct ssh_buffer_struct *request = NULL;
|
|
||||||
struct ssh_buffer_struct *reply = NULL;
|
|
||||||
int type = SSH2_AGENT_FAILURE;
|
|
||||||
int flags = 0;
|
|
||||||
uint32_t dlen = 0;
|
|
||||||
|
|
||||||
/* create blob from the pubkey */
|
|
||||||
blob = publickey_to_string(pubkey);
|
|
||||||
|
|
||||||
request = ssh_buffer_new();
|
|
||||||
if (request == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create request */
|
|
||||||
if (buffer_add_u8(request, SSH2_AGENTC_SIGN_REQUEST) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* adds len + blob */
|
|
||||||
if (buffer_add_ssh_string(request, blob) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add data */
|
|
||||||
dlen = buffer_get_rest_len(data);
|
|
||||||
if (buffer_add_u32(request, htonl(dlen)) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (buffer_add_data(request, buffer_get_rest(data), dlen) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer_add_u32(request, htonl(flags)) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssh_string_free(blob);
|
|
||||||
|
|
||||||
reply = ssh_buffer_new();
|
|
||||||
if (reply == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* send the request */
|
|
||||||
if (agent_talk(session, request, reply) < 0) {
|
|
||||||
ssh_buffer_free(request);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ssh_buffer_free(request);
|
|
||||||
|
|
||||||
/* check if reply is valid */
|
|
||||||
if (buffer_get_u8(reply, (uint8_t *) &type) != sizeof(uint8_t)) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (agent_failed(type)) {
|
|
||||||
ssh_log(session, SSH_LOG_RARE, "Agent reports failure in signing the key");
|
|
||||||
ssh_buffer_free(reply);
|
|
||||||
return NULL;
|
|
||||||
} else if (type != SSH2_AGENT_SIGN_RESPONSE) {
|
|
||||||
ssh_set_error(session, SSH_FATAL, "Bad authentication response: %d", type);
|
|
||||||
ssh_buffer_free(reply);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sig = buffer_get_ssh_string(reply);
|
|
||||||
|
|
||||||
ssh_buffer_free(reply);
|
|
||||||
|
|
||||||
return sig;
|
|
||||||
error:
|
|
||||||
ssh_set_error(session, SSH_FATAL, "Not enough memory");
|
|
||||||
ssh_string_free(blob);
|
|
||||||
ssh_buffer_free(request);
|
|
||||||
ssh_buffer_free(reply);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int agent_is_running(ssh_session session) {
|
int agent_is_running(ssh_session session) {
|
||||||
if (session == NULL || session->agent == NULL) {
|
if (session == NULL || session->agent == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user