summaryrefslogtreecommitdiff
path: root/authfile.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-08-31 22:41:14 +1000
committerDamien Miller <djm@mindrot.org>2010-08-31 22:41:14 +1000
commiteb8b60e320cdade9f4c07e2abacfb92c52e01348 (patch)
tree4e5bc25790566402e5b7ae00cefd2c57e867ef09 /authfile.c
parentda108ece6843f1268aa36d7c8ed0030dc53acd15 (diff)
- djm@cvs.openbsd.org 2010/08/31 11:54:45
[PROTOCOL PROTOCOL.agent PROTOCOL.certkeys auth2-jpake.c authfd.c] [authfile.c buffer.h dns.c kex.c kex.h key.c key.h monitor.c] [monitor_wrap.c myproposal.h packet.c packet.h pathnames.h readconf.c] [ssh-add.1 ssh-add.c ssh-agent.1 ssh-agent.c ssh-keygen.1 ssh-keygen.c] [ssh-keyscan.1 ssh-keyscan.c ssh-keysign.8 ssh.1 ssh.c ssh2.h] [ssh_config.5 sshconnect.c sshconnect2.c sshd.8 sshd.c sshd_config.5] [uuencode.c uuencode.h bufec.c kexecdh.c kexecdhc.c kexecdhs.c ssh-ecdsa.c] Implement Elliptic Curve Cryptography modes for key exchange (ECDH) and host/user keys (ECDSA) as specified by RFC5656. ECDH and ECDSA offer better performance than plain DH and DSA at the same equivalent symmetric key length, as well as much shorter keys. Only the mandatory sections of RFC5656 are implemented, specifically the three REQUIRED curves nistp256, nistp384 and nistp521 and only ECDH and ECDSA. Point compression (optional in RFC5656 is NOT implemented). Certificate host and user keys using the new ECDSA key types are supported. Note that this code has not been tested for interoperability and may be subject to change. feedback and ok markus@
Diffstat (limited to 'authfile.c')
-rw-r--r--authfile.c32
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__);