|
66 | 66 | (x == SSH_COM_AGENT2_FAILURE) || \
|
67 | 67 | (x == SSH2_AGENT_FAILURE))
|
68 | 68 |
|
| 69 | +int |
| 70 | +ssh_request_reply(int , struct sshbuf *, struct sshbuf *); |
| 71 | + |
69 | 72 |
|
70 | 73 | int ssh_add_pubkey(int sock, struct sshkey *key, const char *comment, const char* password) {
|
71 | 74 | 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; |
73 | 78 |
|
74 | 79 | if ((msg = sshbuf_new()) == NULL)
|
75 | 80 | 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; |
81 | 101 | }
|
82 | 102 |
|
83 | 103 | int ssh_list_pubkeys(int sock, struct ssh_identitylist **idlp) {
|
|
0 commit comments