Mercurial > dropbear
comparison signkey.c @ 849:754d7bee1068 ecc
Merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 08 Nov 2013 23:32:13 +0800 |
parents | f4bb964c8678 |
children | 7540c0822374 |
comparison
equal
deleted
inserted
replaced
848:6c69e7df3621 | 849:754d7bee1068 |
---|---|
179 m_free(key->rsakey); | 179 m_free(key->rsakey); |
180 } | 180 } |
181 } | 181 } |
182 #endif | 182 #endif |
183 #ifdef DROPBEAR_ECDSA | 183 #ifdef DROPBEAR_ECDSA |
184 { | 184 if (signkey_is_ecdsa(keytype)) { |
185 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); | 185 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); |
186 if (eck) { | 186 if (eck) { |
187 if (*eck) { | 187 if (*eck) { |
188 ecc_free(*eck); | 188 ecc_free(*eck); |
189 *eck = NULL; | 189 *eck = NULL; |
247 m_free(key->rsakey); | 247 m_free(key->rsakey); |
248 } | 248 } |
249 } | 249 } |
250 #endif | 250 #endif |
251 #ifdef DROPBEAR_ECDSA | 251 #ifdef DROPBEAR_ECDSA |
252 { | 252 if (signkey_is_ecdsa(keytype)) { |
253 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); | 253 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); |
254 if (eck) { | 254 if (eck) { |
255 if (*eck) { | 255 if (*eck) { |
256 ecc_free(*eck); | 256 ecc_free(*eck); |
257 *eck = NULL; | 257 *eck = NULL; |
287 if (type == DROPBEAR_SIGNKEY_RSA) { | 287 if (type == DROPBEAR_SIGNKEY_RSA) { |
288 buf_put_rsa_pub_key(pubkeys, key->rsakey); | 288 buf_put_rsa_pub_key(pubkeys, key->rsakey); |
289 } | 289 } |
290 #endif | 290 #endif |
291 #ifdef DROPBEAR_ECDSA | 291 #ifdef DROPBEAR_ECDSA |
292 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP256 | 292 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); | 293 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
297 if (eck) { | 294 if (eck) { |
298 buf_put_ecdsa_pub_key(pubkeys, *eck); | 295 buf_put_ecdsa_pub_key(pubkeys, *eck); |
299 } | 296 } |
300 } | 297 } |
327 TRACE(("leave buf_put_priv_key: rsa done")) | 324 TRACE(("leave buf_put_priv_key: rsa done")) |
328 return; | 325 return; |
329 } | 326 } |
330 #endif | 327 #endif |
331 #ifdef DROPBEAR_ECDSA | 328 #ifdef DROPBEAR_ECDSA |
332 { | 329 if (signkey_is_ecdsa(type)) { |
333 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 330 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
334 if (eck) { | 331 if (eck) { |
335 buf_put_ecdsa_priv_key(buf, *eck); | 332 buf_put_ecdsa_priv_key(buf, *eck); |
336 TRACE(("leave buf_put_priv_key: ecdsa done")) | 333 TRACE(("leave buf_put_priv_key: ecdsa done")) |
337 return; | 334 return; |
352 #ifdef DROPBEAR_RSA | 349 #ifdef DROPBEAR_RSA |
353 rsa_key_free(key->rsakey); | 350 rsa_key_free(key->rsakey); |
354 key->rsakey = NULL; | 351 key->rsakey = NULL; |
355 #endif | 352 #endif |
356 #ifdef DROPBEAR_ECDSA | 353 #ifdef DROPBEAR_ECDSA |
354 #ifdef DROPBEAR_ECC_256 | |
357 if (key->ecckey256) { | 355 if (key->ecckey256) { |
358 ecc_free(key->ecckey256); | 356 ecc_free(key->ecckey256); |
359 key->ecckey256 = NULL; | 357 key->ecckey256 = NULL; |
360 } | 358 } |
359 #endif | |
360 #ifdef DROPBEAR_ECC_384 | |
361 if (key->ecckey384) { | 361 if (key->ecckey384) { |
362 ecc_free(key->ecckey384); | 362 ecc_free(key->ecckey384); |
363 key->ecckey384 = NULL; | 363 key->ecckey384 = NULL; |
364 } | 364 } |
365 #endif | |
366 #ifdef DROPBEAR_ECC_521 | |
365 if (key->ecckey521) { | 367 if (key->ecckey521) { |
366 ecc_free(key->ecckey521); | 368 ecc_free(key->ecckey521); |
367 key->ecckey521 = NULL; | 369 key->ecckey521 = NULL; |
368 } | 370 } |
371 #endif | |
369 #endif | 372 #endif |
370 | 373 |
371 m_free(key->filename); | 374 m_free(key->filename); |
372 | 375 |
373 m_free(key); | 376 m_free(key); |
482 if (type == DROPBEAR_SIGNKEY_RSA) { | 485 if (type == DROPBEAR_SIGNKEY_RSA) { |
483 buf_put_rsa_sign(sigblob, key->rsakey, data_buf); | 486 buf_put_rsa_sign(sigblob, key->rsakey, data_buf); |
484 } | 487 } |
485 #endif | 488 #endif |
486 #ifdef DROPBEAR_ECDSA | 489 #ifdef DROPBEAR_ECDSA |
487 { | 490 if (signkey_is_ecdsa(type)) { |
488 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 491 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
489 if (eck) { | 492 if (eck) { |
490 buf_put_ecdsa_sign(sigblob, *eck, data_buf); | 493 buf_put_ecdsa_sign(sigblob, *eck, data_buf); |
491 } | 494 } |
492 } | 495 } |
533 } | 536 } |
534 return buf_rsa_verify(buf, key->rsakey, data_buf); | 537 return buf_rsa_verify(buf, key->rsakey, data_buf); |
535 } | 538 } |
536 #endif | 539 #endif |
537 #ifdef DROPBEAR_ECDSA | 540 #ifdef DROPBEAR_ECDSA |
538 { | 541 if (signkey_is_ecdsa(type)) { |
539 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); | 542 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); |
540 if (eck) { | 543 if (eck) { |
541 return buf_ecdsa_verify(buf, *eck, data_buf); | 544 return buf_ecdsa_verify(buf, *eck, data_buf); |
542 } | 545 } |
543 } | 546 } |