summaryrefslogtreecommitdiff
path: root/kexgexs.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-02-27 07:55:05 +1100
committerDamien Miller <djm@mindrot.org>2010-02-27 07:55:05 +1100
commit0a80ca190a39943029719facf7edb990def7ae62 (patch)
treee423e30d8412de67170b8240ba919df10ed8e391 /kexgexs.c
parentd27d85d5320bb946d4bb734dcf45a8d20bad6020 (diff)
- OpenBSD CVS Sync
- djm@cvs.openbsd.org 2010/02/26 20:29:54 [PROTOCOL PROTOCOL.agent PROTOCOL.certkeys addrmatch.c auth-options.c] [auth-options.h auth.h auth2-pubkey.c authfd.c dns.c dns.h hostfile.c] [hostfile.h kex.h kexdhs.c kexgexs.c key.c key.h match.h monitor.c] [myproposal.h servconf.c servconf.h ssh-add.c ssh-agent.c ssh-dss.c] [ssh-keygen.1 ssh-keygen.c ssh-rsa.c ssh.1 ssh.c ssh2.h sshconnect.c] [sshconnect2.c sshd.8 sshd.c sshd_config.5] Add support for certificate key types for users and hosts. OpenSSH certificate key types are not X.509 certificates, but a much simpler format that encodes a public key, identity information and some validity constraints and signs it with a CA key. CA keys are regular SSH keys. This certificate style avoids the attack surface of X.509 certificates and is very easy to deploy. Certified host keys allow automatic acceptance of new host keys when a CA certificate is marked as sh/known_hosts. see VERIFYING HOST KEYS in ssh(1) for details. Certified user keys allow authentication of users when the signing CA key is marked as trusted in authorized_keys. See "AUTHORIZED_KEYS FILE FORMAT" in sshd(8) for details. Certificates are minted using ssh-keygen(1), documentation is in the "CERTIFICATES" section of that manpage. Documentation on the format of certificates is in the file PROTOCOL.certkeys feedback and ok markus@
Diffstat (limited to 'kexgexs.c')
-rw-r--r--kexgexs.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/kexgexs.c b/kexgexs.c
index 8515568b3..f4156af96 100644
--- a/kexgexs.c
+++ b/kexgexs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: kexgexs.c,v 1.12 2009/06/21 07:37:15 dtucker Exp $ */ 1/* $OpenBSD: kexgexs.c,v 1.13 2010/02/26 20:29:54 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Niels Provos. All rights reserved. 3 * Copyright (c) 2000 Niels Provos. All rights reserved.
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -52,18 +52,24 @@ void
52kexgex_server(Kex *kex) 52kexgex_server(Kex *kex)
53{ 53{
54 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL; 54 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL;
55 Key *server_host_key; 55 Key *server_host_public, *server_host_private;
56 DH *dh; 56 DH *dh;
57 u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; 57 u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL;
58 u_int sbloblen, klen, slen, hashlen; 58 u_int sbloblen, klen, slen, hashlen;
59 int omin = -1, min = -1, omax = -1, max = -1, onbits = -1, nbits = -1; 59 int omin = -1, min = -1, omax = -1, max = -1, onbits = -1, nbits = -1;
60 int type, kout; 60 int type, kout;
61 61
62 if (kex->load_host_key == NULL) 62 if (kex->load_host_public_key == NULL ||
63 kex->load_host_private_key == NULL)
63 fatal("Cannot load hostkey"); 64 fatal("Cannot load hostkey");
64 server_host_key = kex->load_host_key(kex->hostkey_type); 65 server_host_public = kex->load_host_public_key(kex->hostkey_type);
65 if (server_host_key == NULL) 66 if (server_host_public == NULL)
66 fatal("Unsupported hostkey type %d", kex->hostkey_type); 67 fatal("Unsupported hostkey type %d", kex->hostkey_type);
68 server_host_private = kex->load_host_private_key(kex->hostkey_type);
69 if (server_host_private == NULL)
70 fatal("Missing private key for hostkey type %d",
71 kex->hostkey_type);
72
67 73
68 type = packet_read(); 74 type = packet_read();
69 switch (type) { 75 switch (type) {
@@ -149,7 +155,7 @@ kexgex_server(Kex *kex)
149 memset(kbuf, 0, klen); 155 memset(kbuf, 0, klen);
150 xfree(kbuf); 156 xfree(kbuf);
151 157
152 key_to_blob(server_host_key, &server_host_key_blob, &sbloblen); 158 key_to_blob(server_host_public, &server_host_key_blob, &sbloblen);
153 159
154 if (type == SSH2_MSG_KEX_DH_GEX_REQUEST_OLD) 160 if (type == SSH2_MSG_KEX_DH_GEX_REQUEST_OLD)
155 omin = min = omax = max = -1; 161 omin = min = omax = max = -1;
@@ -179,7 +185,7 @@ kexgex_server(Kex *kex)
179 } 185 }
180 186
181 /* sign H */ 187 /* sign H */
182 if (PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, 188 if (PRIVSEP(key_sign(server_host_private, &signature, &slen, hash,
183 hashlen)) < 0) 189 hashlen)) < 0)
184 fatal("kexgex_server: key_sign failed"); 190 fatal("kexgex_server: key_sign failed");
185 191