comparison signkey.c @ 801:7dcb46da72d9 ecc

merge in HEAD
author Matt Johnston <matt@ucc.asn.au>
date Tue, 21 May 2013 12:09:35 +0800
parents 7f604f9b3756 9a5438271556
children 75509065db53
comparison
equal deleted inserted replaced
799:c344607b7341 801:7dcb46da72d9
111 unsigned char* ident; 111 unsigned char* ident;
112 unsigned int len; 112 unsigned int len;
113 int keytype; 113 int keytype;
114 int ret = DROPBEAR_FAILURE; 114 int ret = DROPBEAR_FAILURE;
115 115
116 TRACE(("enter buf_get_pub_key")) 116 TRACE2(("enter buf_get_pub_key"))
117 117
118 ident = buf_getstring(buf, &len); 118 ident = buf_getstring(buf, &len);
119 keytype = signkey_type_from_name(ident, len); 119 keytype = signkey_type_from_name(ident, len);
120 m_free(ident); 120 m_free(ident);
121 121
122 if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) { 122 if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) {
123 TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type)) 123 TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type))
124 return DROPBEAR_FAILURE; 124 return DROPBEAR_FAILURE;
125 } 125 }
126 126
127 TRACE(("buf_get_pub_key keytype is %d", keytype)) 127 TRACE2(("buf_get_pub_key keytype is %d", keytype))
128 128
129 *type = keytype; 129 *type = keytype;
130 130
131 /* Rewind the buffer back before "ssh-rsa" etc */ 131 /* Rewind the buffer back before "ssh-rsa" etc */
132 buf_incrpos(buf, -len - 4); 132 buf_incrpos(buf, -len - 4);
161 ret = DROPBEAR_SUCCESS; 161 ret = DROPBEAR_SUCCESS;
162 } 162 }
163 } 163 }
164 #endif 164 #endif
165 165
166 TRACE(("leave buf_get_pub_key")) 166 TRACE2(("leave buf_get_pub_key"))
167 167
168 return ret; 168 return ret;
169 169
170 } 170 }
171 171
177 unsigned char* ident; 177 unsigned char* ident;
178 unsigned int len; 178 unsigned int len;
179 int keytype; 179 int keytype;
180 int ret = DROPBEAR_FAILURE; 180 int ret = DROPBEAR_FAILURE;
181 181
182 TRACE(("enter buf_get_priv_key")) 182 TRACE2(("enter buf_get_priv_key"))
183 183
184 ident = buf_getstring(buf, &len); 184 ident = buf_getstring(buf, &len);
185 keytype = signkey_type_from_name(ident, len); 185 keytype = signkey_type_from_name(ident, len);
186 m_free(ident); 186 m_free(ident);
187 187
225 ret = DROPBEAR_SUCCESS; 225 ret = DROPBEAR_SUCCESS;
226 } 226 }
227 } 227 }
228 #endif 228 #endif
229 229
230 TRACE(("leave buf_get_priv_key")) 230 TRACE2(("leave buf_get_priv_key"))
231 231
232 return ret; 232 return ret;
233 233
234 } 234 }
235 235
236 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */ 236 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */
237 void buf_put_pub_key(buffer* buf, sign_key *key, int type) { 237 void buf_put_pub_key(buffer* buf, sign_key *key, int type) {
238 238
239 buffer *pubkeys; 239 buffer *pubkeys;
240 240
241 TRACE(("enter buf_put_pub_key")) 241 TRACE2(("enter buf_put_pub_key"))
242 pubkeys = buf_new(MAX_PUBKEY_SIZE); 242 pubkeys = buf_new(MAX_PUBKEY_SIZE);
243 243
244 #ifdef DROPBEAR_DSS 244 #ifdef DROPBEAR_DSS
245 if (type == DROPBEAR_SIGNKEY_DSS) { 245 if (type == DROPBEAR_SIGNKEY_DSS) {
246 buf_put_dss_pub_key(pubkeys, key->dsskey); 246 buf_put_dss_pub_key(pubkeys, key->dsskey);
260 dropbear_exit("Bad key types in buf_put_pub_key"); 260 dropbear_exit("Bad key types in buf_put_pub_key");
261 } 261 }
262 262
263 buf_putbufstring(buf, pubkeys); 263 buf_putbufstring(buf, pubkeys);
264 buf_free(pubkeys); 264 buf_free(pubkeys);
265 TRACE(("leave buf_put_pub_key")) 265 TRACE2(("leave buf_put_pub_key"))
266 } 266 }
267 267
268 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */ 268 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */
269 void buf_put_priv_key(buffer* buf, sign_key *key, int type) { 269 void buf_put_priv_key(buffer* buf, sign_key *key, int type) {
270 270
294 dropbear_exit("Bad key types in put pub key"); 294 dropbear_exit("Bad key types in put pub key");
295 } 295 }
296 296
297 void sign_key_free(sign_key *key) { 297 void sign_key_free(sign_key *key) {
298 298
299 TRACE(("enter sign_key_free")) 299 TRACE2(("enter sign_key_free"))
300 300
301 #ifdef DROPBEAR_DSS 301 #ifdef DROPBEAR_DSS
302 dss_key_free(key->dsskey); 302 dss_key_free(key->dsskey);
303 key->dsskey = NULL; 303 key->dsskey = NULL;
304 #endif 304 #endif
314 #endif 314 #endif
315 315
316 m_free(key->filename); 316 m_free(key->filename);
317 317
318 m_free(key); 318 m_free(key);
319 TRACE(("leave sign_key_free")) 319 TRACE2(("leave sign_key_free"))
320 } 320 }
321 321
322 static char hexdig(unsigned char x) { 322 static char hexdig(unsigned char x) {
323 if (x > 0xf) 323 if (x > 0xf)
324 return 'X'; 324 return 'X';