version 1.99, 2015/09/02 07:51:12 |
version 1.100, 2015/12/04 16:41:28 |
|
|
} |
} |
#endif |
#endif |
|
|
|
/* encode signature algoritm in flag bits, so we can keep the msg format */ |
|
static u_int |
|
agent_encode_alg(struct sshkey *key, const char *alg) |
|
{ |
|
if (alg != NULL && key->type == KEY_RSA) { |
|
if (strcmp(alg, "rsa-sha2-256") == 0) |
|
return SSH_AGENT_RSA_SHA2_256; |
|
else if (strcmp(alg, "rsa-sha2-512") == 0) |
|
return SSH_AGENT_RSA_SHA2_512; |
|
} |
|
return 0; |
|
} |
|
|
/* ask agent to sign data, returns err.h code on error, 0 on success */ |
/* ask agent to sign data, returns err.h code on error, 0 on success */ |
int |
int |
ssh_agent_sign(int sock, struct sshkey *key, |
ssh_agent_sign(int sock, struct sshkey *key, |
u_char **sigp, size_t *lenp, |
u_char **sigp, size_t *lenp, |
const u_char *data, size_t datalen, u_int compat) |
const u_char *data, size_t datalen, const char *alg, u_int compat) |
{ |
{ |
struct sshbuf *msg; |
struct sshbuf *msg; |
u_char *blob = NULL, type; |
u_char *blob = NULL, type; |
|
|
return SSH_ERR_ALLOC_FAIL; |
return SSH_ERR_ALLOC_FAIL; |
if ((r = sshkey_to_blob(key, &blob, &blen)) != 0) |
if ((r = sshkey_to_blob(key, &blob, &blen)) != 0) |
goto out; |
goto out; |
|
flags |= agent_encode_alg(key, alg); |
if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_SIGN_REQUEST)) != 0 || |
if ((r = sshbuf_put_u8(msg, SSH2_AGENTC_SIGN_REQUEST)) != 0 || |
(r = sshbuf_put_string(msg, blob, blen)) != 0 || |
(r = sshbuf_put_string(msg, blob, blen)) != 0 || |
(r = sshbuf_put_string(msg, data, datalen)) != 0 || |
(r = sshbuf_put_string(msg, data, datalen)) != 0 || |