Mercurial > dropbear
comparison cli-authpubkey.c @ 760:f336d232fc63 ecc
Make _sign and _verify functions take a buffer* rather than void* and int
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 06 Apr 2013 16:00:37 +0800 |
parents | a8367733e8cd |
children | ac2158e3e403 |
comparison
equal
deleted
inserted
replaced
759:76fba0856749 | 760:f336d232fc63 |
---|---|
119 | 119 |
120 TRACE(("leave recv_msg_userauth_pk_ok")) | 120 TRACE(("leave recv_msg_userauth_pk_ok")) |
121 } | 121 } |
122 | 122 |
123 void cli_buf_put_sign(buffer* buf, sign_key *key, int type, | 123 void cli_buf_put_sign(buffer* buf, sign_key *key, int type, |
124 const unsigned char *data, unsigned int len) | 124 buffer *data_buf) { |
125 { | |
126 #ifdef ENABLE_CLI_AGENTFWD | 125 #ifdef ENABLE_CLI_AGENTFWD |
127 if (key->source == SIGNKEY_SOURCE_AGENT) { | 126 if (key->source == SIGNKEY_SOURCE_AGENT) { |
128 /* Format the agent signature ourselves, as buf_put_sign would. */ | 127 /* Format the agent signature ourselves, as buf_put_sign would. */ |
129 buffer *sigblob; | 128 buffer *sigblob; |
130 sigblob = buf_new(MAX_PUBKEY_SIZE); | 129 sigblob = buf_new(MAX_PUBKEY_SIZE); |
131 agent_buf_sign(sigblob, key, data, len); | 130 agent_buf_sign(sigblob, key, data_buf); |
132 buf_setpos(sigblob, 0); | 131 buf_putbufstring(buf, sigblob); |
133 buf_putstring(buf, buf_getptr(sigblob, sigblob->len), | |
134 sigblob->len); | |
135 | |
136 buf_free(sigblob); | 132 buf_free(sigblob); |
137 } else | 133 } else |
138 #endif /* ENABLE_CLI_AGENTFWD */ | 134 #endif /* ENABLE_CLI_AGENTFWD */ |
139 { | 135 { |
140 buf_put_sign(buf, key, type, data, len); | 136 buf_put_sign(buf, key, type, data_buf); |
141 } | 137 } |
142 } | 138 } |
143 | 139 |
144 /* TODO: make it take an agent reference to use as well */ | 140 /* TODO: make it take an agent reference to use as well */ |
145 static void send_msg_userauth_pubkey(sign_key *key, int type, int realsign) { | 141 static void send_msg_userauth_pubkey(sign_key *key, int type, int realsign) { |
172 if (realsign) { | 168 if (realsign) { |
173 TRACE(("realsign")) | 169 TRACE(("realsign")) |
174 /* We put the signature as well - this contains string(session id), then | 170 /* We put the signature as well - this contains string(session id), then |
175 * the contents of the write payload to this point */ | 171 * the contents of the write payload to this point */ |
176 sigbuf = buf_new(4 + SHA1_HASH_SIZE + ses.writepayload->len); | 172 sigbuf = buf_new(4 + SHA1_HASH_SIZE + ses.writepayload->len); |
177 buf_putstring(sigbuf, ses.session_id, SHA1_HASH_SIZE); | 173 buf_putbufstring(sigbuf, ses.session_id); |
178 buf_putbytes(sigbuf, ses.writepayload->data, ses.writepayload->len); | 174 buf_putbytes(sigbuf, ses.writepayload->data, ses.writepayload->len); |
179 cli_buf_put_sign(ses.writepayload, key, type, sigbuf->data, sigbuf->len); | 175 cli_buf_put_sign(ses.writepayload, key, type, sigbuf->data, sigbuf->len); |
180 buf_free(sigbuf); /* Nothing confidential in the buffer */ | 176 buf_free(sigbuf); /* Nothing confidential in the buffer */ |
181 } | 177 } |
182 | 178 |