rsa-sha256 for ssh-agent

This commit is contained in:
Matt Johnston 2020-05-25 20:23:02 +08:00
parent 701d43b859
commit c917807b1c
3 changed files with 13 additions and 4 deletions

View File

@ -32,6 +32,9 @@
#if DROPBEAR_CLI_AGENTFWD #if DROPBEAR_CLI_AGENTFWD
/* From OpenSSH authfd.h */
#define SSH_AGENT_RSA_SHA2_256 0x02
/* An agent reply can be reasonably large, as it can /* An agent reply can be reasonably large, as it can
* contain a list of all public keys held by the agent. * contain a list of all public keys held by the agent.
* 10000 is arbitrary */ * 10000 is arbitrary */
@ -40,7 +43,7 @@
/* client functions */ /* client functions */
void cli_load_agent_keys(m_list * ret_list); void cli_load_agent_keys(m_list * ret_list);
void agent_buf_sign(buffer *sigblob, sign_key *key, void agent_buf_sign(buffer *sigblob, sign_key *key,
const buffer *data_buf); const buffer *data_buf, enum signature_type type);
void cli_setup_agent(const struct Channel *channel); void cli_setup_agent(const struct Channel *channel);
#ifdef __hpux #ifdef __hpux

View File

@ -255,11 +255,12 @@ void cli_load_agent_keys(m_list *ret_list) {
} }
void agent_buf_sign(buffer *sigblob, sign_key *key, void agent_buf_sign(buffer *sigblob, sign_key *key,
const buffer *data_buf) { const buffer *data_buf, enum signature_type sigtype) {
buffer *request_data = NULL; buffer *request_data = NULL;
buffer *response = NULL; buffer *response = NULL;
unsigned int siglen; unsigned int siglen;
int packet_type; int packet_type;
int flags = 0;
/* Request format /* Request format
byte SSH2_AGENTC_SIGN_REQUEST byte SSH2_AGENTC_SIGN_REQUEST
@ -271,7 +272,12 @@ void agent_buf_sign(buffer *sigblob, sign_key *key,
buf_put_pub_key(request_data, key, key->type); buf_put_pub_key(request_data, key, key->type);
buf_putbufstring(request_data, data_buf); buf_putbufstring(request_data, data_buf);
buf_putint(request_data, 0); #if DROPBEAR_RSA_SHA256
if (sigtype == DROPBEAR_SIGNATURE_RSA_SHA256) {
flags |= SSH_AGENT_RSA_SHA2_256;
}
#endif
buf_putint(request_data, flags);
response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data); response = agent_request(SSH2_AGENTC_SIGN_REQUEST, request_data);

View File

@ -130,7 +130,7 @@ static void cli_buf_put_sign(buffer* buf, sign_key *key, enum signature_type sig
/* Format the agent signature ourselves, as buf_put_sign would. */ /* Format the agent signature ourselves, as buf_put_sign would. */
buffer *sigblob; buffer *sigblob;
sigblob = buf_new(MAX_PUBKEY_SIZE); sigblob = buf_new(MAX_PUBKEY_SIZE);
agent_buf_sign(sigblob, key, data_buf); agent_buf_sign(sigblob, key, data_buf, sigtype);
buf_putbufstring(buf, sigblob); buf_putbufstring(buf, sigblob);
buf_free(sigblob); buf_free(sigblob);
} else } else