Skip to content

Commit 3f63888

Browse files
committed
5-6 C1
1 parent 4b5cb0d commit 3f63888

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

contrib/win32/ssh-pubkey/pubkeyfd.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,38 @@
6666
(x == SSH_COM_AGENT2_FAILURE) || \
6767
(x == SSH2_AGENT_FAILURE))
6868

69+
int
70+
ssh_request_reply(int , struct sshbuf *, struct sshbuf *);
71+
6972

7073
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password) {
7174
struct sshbuf *msg;
72-
int r;
75+
u_char *blob = NULL, *status = NULL, *description = NULL, *lang_tag = NULL;
76+
size_t blen = 0;
77+
int r, status_code;
7378

7479
if ((msg = sshbuf_new()) == NULL)
7580
return SSH_ERR_ALLOC_FAIL;
76-
77-
if ((r = sshbuf_put_cstring(msg, PK_REQUEST_ADD)) != 0 )
78-
79-
80-
return 0;
81+
if ((r = sshkey_to_blob(key, &blob, &blen)) != 0)
82+
goto out;
83+
84+
if ((r = sshbuf_put_cstring(msg, PK_REQUEST_ADD)) != 0 ||
85+
(r = sshbuf_put_string(msg, blob, blen)) != 0 ||
86+
(r = sshbuf_put_u32(msg, 1)) != 0 ||
87+
(r = sshbuf_put_cstring(msg, "comment")) != 0 ||
88+
(r = sshbuf_put_cstring(msg, comment)) != 0 ||
89+
(r = sshbuf_put_u8(msg, 1)) != 0)
90+
goto out;
91+
92+
if ((r = ssh_request_reply(sock, msg, msg) != 0))
93+
goto out;
94+
95+
96+
97+
out:
98+
if (blob)
99+
free(blob);
100+
return r;
81101
}
82102

83103
int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp) {

contrib/win32/ssh-pubkey/pubkeyfd.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@
88
#define PK_REQUEST_REMOVE_ALL "removeall"
99
#define PK_REQUEST_REMOVE_BY_FP "removebyfp"
1010

11+
#define SSH_PUBLICKEY_SUCCESS 0
12+
#define SSH_PUBLICKEY_ACCESS_DENIED 1
13+
#define SSH_PUBLICKEY_STORAGE_EXCEEDED 2
14+
#define SSH_PUBLICKEY_VERSION_NOT_SUPPORTED 3
15+
#define SSH_PUBLICKEY_KEY_NOT_FOUND 4
16+
#define SSH_PUBLICKEY_KEY_NOT_SUPPORTED 5
17+
#define SSH_PUBLICKEY_KEY_ALREADY_PRESENT 6
18+
#define SSH_PUBLICKEY_GENERAL_FAILURE 7
19+
#define SSH_PUBLICKEY_REQUEST_NOT_SUPPORTED 8
20+
#define SSH_PUBLICKEY_ATTRIBUTE_NOT_SUPPORTED 9
21+
1122
int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password);
1223
int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp);
1324
int ssh_remove_pubkey(int sock, struct sshkey *key);

0 commit comments

Comments
 (0)