5-6 C1
This commit is contained in:
parent
4b5cb0d646
commit
3f63888e81
|
@ -66,18 +66,38 @@
|
|||
(x == SSH_COM_AGENT2_FAILURE) || \
|
||||
(x == SSH2_AGENT_FAILURE))
|
||||
|
||||
int
|
||||
ssh_request_reply(int , struct sshbuf *, struct sshbuf *);
|
||||
|
||||
|
||||
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password) {
|
||||
struct sshbuf *msg;
|
||||
int r;
|
||||
u_char *blob = NULL, *status = NULL, *description = NULL, *lang_tag = NULL;
|
||||
size_t blen = 0;
|
||||
int r, status_code;
|
||||
|
||||
if ((msg = sshbuf_new()) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
if ((r = sshkey_to_blob(key, &blob, &blen)) != 0)
|
||||
goto out;
|
||||
|
||||
if ((r = sshbuf_put_cstring(msg, PK_REQUEST_ADD)) != 0 ||
|
||||
(r = sshbuf_put_string(msg, blob, blen)) != 0 ||
|
||||
(r = sshbuf_put_u32(msg, 1)) != 0 ||
|
||||
(r = sshbuf_put_cstring(msg, "comment")) != 0 ||
|
||||
(r = sshbuf_put_cstring(msg, comment)) != 0 ||
|
||||
(r = sshbuf_put_u8(msg, 1)) != 0)
|
||||
goto out;
|
||||
|
||||
if ((r = sshbuf_put_cstring(msg, PK_REQUEST_ADD)) != 0 )
|
||||
if ((r = ssh_request_reply(sock, msg, msg) != 0))
|
||||
goto out;
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
if (blob)
|
||||
free(blob);
|
||||
return r;
|
||||
}
|
||||
|
||||
int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp) {
|
||||
|
|
|
@ -8,6 +8,17 @@
|
|||
#define PK_REQUEST_REMOVE_ALL "removeall"
|
||||
#define PK_REQUEST_REMOVE_BY_FP "removebyfp"
|
||||
|
||||
#define SSH_PUBLICKEY_SUCCESS 0
|
||||
#define SSH_PUBLICKEY_ACCESS_DENIED 1
|
||||
#define SSH_PUBLICKEY_STORAGE_EXCEEDED 2
|
||||
#define SSH_PUBLICKEY_VERSION_NOT_SUPPORTED 3
|
||||
#define SSH_PUBLICKEY_KEY_NOT_FOUND 4
|
||||
#define SSH_PUBLICKEY_KEY_NOT_SUPPORTED 5
|
||||
#define SSH_PUBLICKEY_KEY_ALREADY_PRESENT 6
|
||||
#define SSH_PUBLICKEY_GENERAL_FAILURE 7
|
||||
#define SSH_PUBLICKEY_REQUEST_NOT_SUPPORTED 8
|
||||
#define SSH_PUBLICKEY_ATTRIBUTE_NOT_SUPPORTED 9
|
||||
|
||||
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password);
|
||||
int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp);
|
||||
int ssh_remove_pubkey(int sock, struct sshkey *key);
|
||||
|
|
Loading…
Reference in New Issue