diff options
Diffstat (limited to 'authfile.c')
-rw-r--r-- | authfile.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/authfile.c b/authfile.c index 2bd887845..865e7faf9 100644 --- a/authfile.c +++ b/authfile.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: authfile.c,v 1.82 2010/08/04 05:49:22 djm Exp $ */ | 1 | /* $OpenBSD: authfile.c,v 1.83 2010/08/31 11:54:45 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -213,6 +213,10 @@ key_save_private_pem(Key *key, const char *filename, const char *_passphrase, | |||
213 | success = PEM_write_DSAPrivateKey(fp, key->dsa, | 213 | success = PEM_write_DSAPrivateKey(fp, key->dsa, |
214 | cipher, passphrase, len, NULL, NULL); | 214 | cipher, passphrase, len, NULL, NULL); |
215 | break; | 215 | break; |
216 | case KEY_ECDSA: | ||
217 | success = PEM_write_ECPrivateKey(fp, key->ecdsa, | ||
218 | cipher, passphrase, len, NULL, NULL); | ||
219 | break; | ||
216 | case KEY_RSA: | 220 | case KEY_RSA: |
217 | success = PEM_write_RSAPrivateKey(fp, key->rsa, | 221 | success = PEM_write_RSAPrivateKey(fp, key->rsa, |
218 | cipher, passphrase, len, NULL, NULL); | 222 | cipher, passphrase, len, NULL, NULL); |
@@ -231,6 +235,7 @@ key_save_private(Key *key, const char *filename, const char *passphrase, | |||
231 | return key_save_private_rsa1(key, filename, passphrase, | 235 | return key_save_private_rsa1(key, filename, passphrase, |
232 | comment); | 236 | comment); |
233 | case KEY_DSA: | 237 | case KEY_DSA: |
238 | case KEY_ECDSA: | ||
234 | case KEY_RSA: | 239 | case KEY_RSA: |
235 | return key_save_private_pem(key, filename, passphrase, | 240 | return key_save_private_pem(key, filename, passphrase, |
236 | comment); | 241 | comment); |
@@ -510,6 +515,29 @@ key_load_private_pem(int fd, int type, const char *passphrase, | |||
510 | #ifdef DEBUG_PK | 515 | #ifdef DEBUG_PK |
511 | DSA_print_fp(stderr, prv->dsa, 8); | 516 | DSA_print_fp(stderr, prv->dsa, 8); |
512 | #endif | 517 | #endif |
518 | } else if (pk->type == EVP_PKEY_EC && | ||
519 | (type == KEY_UNSPEC||type==KEY_ECDSA)) { | ||
520 | prv = key_new(KEY_UNSPEC); | ||
521 | prv->ecdsa = EVP_PKEY_get1_EC_KEY(pk); | ||
522 | prv->type = KEY_ECDSA; | ||
523 | prv->ecdsa_nid = key_ecdsa_group_to_nid( | ||
524 | EC_KEY_get0_group(prv->ecdsa)); | ||
525 | if (key_curve_nid_to_name(prv->ecdsa_nid) == NULL) { | ||
526 | key_free(prv); | ||
527 | prv = NULL; | ||
528 | } | ||
529 | if (key_ec_validate_public(EC_KEY_get0_group(prv->ecdsa), | ||
530 | EC_KEY_get0_public_key(prv->ecdsa)) != 0 || | ||
531 | key_ec_validate_private(prv->ecdsa) != 0) { | ||
532 | error("%s: bad ECDSA key", __func__); | ||
533 | key_free(prv); | ||
534 | prv = NULL; | ||
535 | } | ||
536 | name = "dsa w/o comment"; | ||
537 | #ifdef DEBUG_PK | ||
538 | if (prv->ecdsa != NULL) | ||
539 | key_dump_ec_key(prv->ecdsa); | ||
540 | #endif | ||
513 | } else { | 541 | } else { |
514 | error("PEM_read_PrivateKey: mismatch or " | 542 | error("PEM_read_PrivateKey: mismatch or " |
515 | "unknown EVP_PKEY save_type %d", pk->save_type); | 543 | "unknown EVP_PKEY save_type %d", pk->save_type); |
@@ -581,6 +609,7 @@ key_load_private_type(int type, const char *filename, const char *passphrase, | |||
581 | commentp); | 609 | commentp); |
582 | /* closes fd */ | 610 | /* closes fd */ |
583 | case KEY_DSA: | 611 | case KEY_DSA: |
612 | case KEY_ECDSA: | ||
584 | case KEY_RSA: | 613 | case KEY_RSA: |
585 | case KEY_UNSPEC: | 614 | case KEY_UNSPEC: |
586 | return key_load_private_pem(fd, type, passphrase, commentp); | 615 | return key_load_private_pem(fd, type, passphrase, commentp); |
@@ -721,6 +750,7 @@ key_load_private_cert(int type, const char *filename, const char *passphrase, | |||
721 | switch (type) { | 750 | switch (type) { |
722 | case KEY_RSA: | 751 | case KEY_RSA: |
723 | case KEY_DSA: | 752 | case KEY_DSA: |
753 | case KEY_ECDSA: | ||
724 | break; | 754 | break; |
725 | default: | 755 | default: |
726 | error("%s: unsupported key type", __func__); | 756 | error("%s: unsupported key type", __func__); |