Mercurial > dropbear
comparison signkey.c @ 854:ccc76acaf4c7
merge ecc again
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 14 Nov 2013 20:45:46 +0800 |
parents | 7540c0822374 |
children | 04ede40a529a |
comparison
equal
deleted
inserted
replaced
845:774ad9b112ef | 854:ccc76acaf4c7 |
---|---|
37 "ssh-dss", | 37 "ssh-dss", |
38 #endif | 38 #endif |
39 #ifdef DROPBEAR_ECDSA | 39 #ifdef DROPBEAR_ECDSA |
40 "ecdsa-sha2-nistp256", | 40 "ecdsa-sha2-nistp256", |
41 "ecdsa-sha2-nistp384", | 41 "ecdsa-sha2-nistp384", |
42 "ecdsa-sha2-nistp521", | 42 "ecdsa-sha2-nistp521" |
43 "ecdsa" // for keygen | |
44 #endif // DROPBEAR_ECDSA | 43 #endif // DROPBEAR_ECDSA |
45 }; | 44 }; |
46 | 45 |
47 /* malloc a new sign_key and set the dss and rsa keys to NULL */ | 46 /* malloc a new sign_key and set the dss and rsa keys to NULL */ |
48 sign_key * new_sign_key() { | 47 sign_key * new_sign_key() { |
179 m_free(key->rsakey); | 178 m_free(key->rsakey); |
180 } | 179 } |
181 } | 180 } |
182 #endif | 181 #endif |
183 #ifdef DROPBEAR_ECDSA | 182 #ifdef DROPBEAR_ECDSA |
184 { | 183 if (signkey_is_ecdsa(keytype)) { |
185 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); | 184 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); |
186 if (eck) { | 185 if (eck) { |
187 if (*eck) { | 186 if (*eck) { |
188 ecc_free(*eck); | 187 ecc_free(*eck); |
189 *eck = NULL; | 188 *eck = NULL; |
247 m_free(key->rsakey); | 246 m_free(key->rsakey); |
248 } | 247 } |
249 } | 248 } |
250 #endif | 249 #endif |
251 #ifdef DROPBEAR_ECDSA | 250 #ifdef DROPBEAR_ECDSA |
252 { | 251 if (signkey_is_ecdsa(keytype)) { |
253 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); | 252 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); |
254 if (eck) { | 253 if (eck) { |
255 if (*eck) { | 254 if (*eck) { |
256 ecc_free(*eck); | 255 ecc_free(*eck); |
257 *eck = NULL; | 256 *eck = NULL; |
287 if (type == DROPBEAR_SIGNKEY_RSA) { | 286 if (type == DROPBEAR_SIGNKEY_RSA) { |
288 buf_put_rsa_pub_key(pubkeys, key->rsakey); | 287 buf_put_rsa_pub_key(pubkeys, key->rsakey); |
289 } | 288 } |
290 #endif | 289 #endif |
291 #ifdef DROPBEAR_ECDSA | 290 #ifdef DROPBEAR_ECDSA |
292 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP256 | 291 if (signkey_is_ecdsa(type)) { |
293 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP384 | |
294 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) | |
295 { | |
296 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 292 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
297 if (eck) { | 293 if (eck) { |
298 buf_put_ecdsa_pub_key(pubkeys, *eck); | 294 buf_put_ecdsa_pub_key(pubkeys, *eck); |
299 } | 295 } |
300 } | 296 } |
327 TRACE(("leave buf_put_priv_key: rsa done")) | 323 TRACE(("leave buf_put_priv_key: rsa done")) |
328 return; | 324 return; |
329 } | 325 } |
330 #endif | 326 #endif |
331 #ifdef DROPBEAR_ECDSA | 327 #ifdef DROPBEAR_ECDSA |
332 { | 328 if (signkey_is_ecdsa(type)) { |
333 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 329 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
334 if (eck) { | 330 if (eck) { |
335 buf_put_ecdsa_priv_key(buf, *eck); | 331 buf_put_ecdsa_priv_key(buf, *eck); |
336 TRACE(("leave buf_put_priv_key: ecdsa done")) | 332 TRACE(("leave buf_put_priv_key: ecdsa done")) |
337 return; | 333 return; |
352 #ifdef DROPBEAR_RSA | 348 #ifdef DROPBEAR_RSA |
353 rsa_key_free(key->rsakey); | 349 rsa_key_free(key->rsakey); |
354 key->rsakey = NULL; | 350 key->rsakey = NULL; |
355 #endif | 351 #endif |
356 #ifdef DROPBEAR_ECDSA | 352 #ifdef DROPBEAR_ECDSA |
353 #ifdef DROPBEAR_ECC_256 | |
357 if (key->ecckey256) { | 354 if (key->ecckey256) { |
358 ecc_free(key->ecckey256); | 355 ecc_free(key->ecckey256); |
359 key->ecckey256 = NULL; | 356 key->ecckey256 = NULL; |
360 } | 357 } |
358 #endif | |
359 #ifdef DROPBEAR_ECC_384 | |
361 if (key->ecckey384) { | 360 if (key->ecckey384) { |
362 ecc_free(key->ecckey384); | 361 ecc_free(key->ecckey384); |
363 key->ecckey384 = NULL; | 362 key->ecckey384 = NULL; |
364 } | 363 } |
364 #endif | |
365 #ifdef DROPBEAR_ECC_521 | |
365 if (key->ecckey521) { | 366 if (key->ecckey521) { |
366 ecc_free(key->ecckey521); | 367 ecc_free(key->ecckey521); |
367 key->ecckey521 = NULL; | 368 key->ecckey521 = NULL; |
368 } | 369 } |
370 #endif | |
369 #endif | 371 #endif |
370 | 372 |
371 m_free(key->filename); | 373 m_free(key->filename); |
372 | 374 |
373 m_free(key); | 375 m_free(key); |
482 if (type == DROPBEAR_SIGNKEY_RSA) { | 484 if (type == DROPBEAR_SIGNKEY_RSA) { |
483 buf_put_rsa_sign(sigblob, key->rsakey, data_buf); | 485 buf_put_rsa_sign(sigblob, key->rsakey, data_buf); |
484 } | 486 } |
485 #endif | 487 #endif |
486 #ifdef DROPBEAR_ECDSA | 488 #ifdef DROPBEAR_ECDSA |
487 { | 489 if (signkey_is_ecdsa(type)) { |
488 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 490 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
489 if (eck) { | 491 if (eck) { |
490 buf_put_ecdsa_sign(sigblob, *eck, data_buf); | 492 buf_put_ecdsa_sign(sigblob, *eck, data_buf); |
491 } | 493 } |
492 } | 494 } |
533 } | 535 } |
534 return buf_rsa_verify(buf, key->rsakey, data_buf); | 536 return buf_rsa_verify(buf, key->rsakey, data_buf); |
535 } | 537 } |
536 #endif | 538 #endif |
537 #ifdef DROPBEAR_ECDSA | 539 #ifdef DROPBEAR_ECDSA |
538 { | 540 if (signkey_is_ecdsa(type)) { |
539 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 541 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
540 if (eck) { | 542 if (eck) { |
541 return buf_ecdsa_verify(buf, *eck, data_buf); | 543 return buf_ecdsa_verify(buf, *eck, data_buf); |
542 } | 544 } |
543 } | 545 } |