View | Details | Raw Unified | Return to bug 1023 | Differences between
and this patch

Collapse All | Expand All

(-)kex.c (+5 lines)
Lines 44-49 RCSID("$OpenBSD: kex.c,v 1.65 2005/11/04 Link Here
44
44
45
#define KEX_COOKIE_LEN	16
45
#define KEX_COOKIE_LEN	16
46
46
47
extern const EVP_MD *evp_ssh_sha256(void);
48
47
/* prototype */
49
/* prototype */
48
static void kex_kexinit_finish(Kex *);
50
static void kex_kexinit_finish(Kex *);
49
static void kex_choose_conf(Kex *);
51
static void kex_choose_conf(Kex *);
Lines 301-306 choose_kex(Kex *k, char *client, char *s Link Here
301
	} else if (strcmp(k->name, KEX_DHGEX_SHA1) == 0) {
303
	} else if (strcmp(k->name, KEX_DHGEX_SHA1) == 0) {
302
		k->kex_type = KEX_DH_GEX_SHA1;
304
		k->kex_type = KEX_DH_GEX_SHA1;
303
		k->evp_md = EVP_sha1();
305
		k->evp_md = EVP_sha1();
306
	} else if (strcmp(k->name, KEX_DHGEX_SHA256) == 0) {
307
		k->kex_type = KEX_DH_GEX_SHA256;
308
		k->evp_md = evp_ssh_sha256();
304
	} else
309
	} else
305
		fatal("bad kex alg %s", k->name);
310
		fatal("bad kex alg %s", k->name);
306
}
311
}
(-)kex.h (+2 lines)
Lines 34-39 Link Here
34
#define	KEX_DH1			"diffie-hellman-group1-sha1"
34
#define	KEX_DH1			"diffie-hellman-group1-sha1"
35
#define	KEX_DH14		"diffie-hellman-group14-sha1"
35
#define	KEX_DH14		"diffie-hellman-group14-sha1"
36
#define	KEX_DHGEX_SHA1		"diffie-hellman-group-exchange-sha1"
36
#define	KEX_DHGEX_SHA1		"diffie-hellman-group-exchange-sha1"
37
#define	KEX_DHGEX_SHA256	"diffie-hellman-group-exchange-sha256"
37
38
38
#define COMP_NONE	0
39
#define COMP_NONE	0
39
#define COMP_ZLIB	1
40
#define COMP_ZLIB	1
Lines 63-68 enum kex_exchange { Link Here
63
	KEX_DH_GRP1_SHA1,
64
	KEX_DH_GRP1_SHA1,
64
	KEX_DH_GRP14_SHA1,
65
	KEX_DH_GRP14_SHA1,
65
	KEX_DH_GEX_SHA1,
66
	KEX_DH_GEX_SHA1,
67
	KEX_DH_GEX_SHA256,
66
	KEX_MAX
68
	KEX_MAX
67
};
69
};
68
70
(-)md-sha256.c (+71 lines)
Added Link Here
1
/*
2
 * Copyright (c) 2005 Damien Miller <djm@openbsd.org>
3
 *
4
 * Permission to use, copy, modify, and distribute this software for any
5
 * purpose with or without fee is hereby granted, provided that the above
6
 * copyright notice and this permission notice appear in all copies.
7
 *
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 */
16
17
/* EVP wrapper for SHA256 */
18
19
#include "includes.h"
20
#include <openssl/evp.h>
21
#include <sha2.h>
22
23
RCSID("$OpenBSD$");
24
25
const EVP_MD *evp_ssh_sha256(void);
26
27
static int
28
ssh_sha256_init(EVP_MD_CTX *ctxt)
29
{
30
	SHA256_Init(ctxt->md_data);
31
	return (1);
32
}
33
34
static int
35
ssh_sha256_update(EVP_MD_CTX *ctxt, const void *data, unsigned long len)
36
{
37
	SHA256_Update(ctxt->md_data, data, len);
38
	return (1);
39
}
40
41
static int
42
ssh_sha256_final(EVP_MD_CTX *ctxt, unsigned char *digest)
43
{
44
	SHA256_Final(digest, ctxt->md_data);
45
	return (1);
46
}
47
48
static int
49
ssh_sha256_cleanup(EVP_MD_CTX *ctxt)
50
{
51
	memset(ctxt->md_data, 0, sizeof(SHA256_CTX));
52
	return (1);
53
}
54
55
const EVP_MD *
56
evp_ssh_sha256(void)
57
{
58
	static EVP_MD ssh_sha256;
59
60
	memset(&ssh_sha256, 0, sizeof(ssh_sha256));
61
	ssh_sha256.type = NID_undef;
62
	ssh_sha256.md_size = SHA256_DIGEST_LENGTH;
63
	ssh_sha256.init = ssh_sha256_init;
64
	ssh_sha256.update = ssh_sha256_update;
65
	ssh_sha256.final = ssh_sha256_final;
66
	ssh_sha256.cleanup = ssh_sha256_cleanup;
67
	ssh_sha256.block_size = SHA256_BLOCK_LENGTH;
68
	ssh_sha256.ctx_size = sizeof(SHA256_CTX);
69
70
	return (&ssh_sha256);
71
}
(-)monitor.c (-1 / +6 lines)
Lines 473-479 mm_answer_sign(int sock, Buffer *m) Link Here
473
	keyid = buffer_get_int(m);
473
	keyid = buffer_get_int(m);
474
	p = buffer_get_string(m, &datlen);
474
	p = buffer_get_string(m, &datlen);
475
475
476
	if (datlen != 20)
476
	/*
477
	 * Supported KEX types will only return SHA1 (20 byte) or 
478
	 * SHA256 (32 byte) hashes
479
	 */
480
	if (datlen != 20 && datlen != 32)
477
		fatal("%s: data length incorrect: %u", __func__, datlen);
481
		fatal("%s: data length incorrect: %u", __func__, datlen);
478
482
479
	/* save session id, it will be passed on the first call */
483
	/* save session id, it will be passed on the first call */
Lines 1375-1380 mm_get_kex(Buffer *m) Link Here
1375
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
1379
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
1376
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1380
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1377
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1381
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1382
	kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1378
	kex->server = 1;
1383
	kex->server = 1;
1379
	kex->hostkey_type = buffer_get_int(m);
1384
	kex->hostkey_type = buffer_get_int(m);
1380
	kex->kex_type = buffer_get_int(m);
1385
	kex->kex_type = buffer_get_int(m);
(-)myproposal.h (-3 / +5 lines)
Lines 23-31 Link Here
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
25
 */
26
#define KEX_DEFAULT_KEX		"diffie-hellman-group-exchange-sha1," \
26
#define KEX_DEFAULT_KEX		\
27
	"diffie-hellman-group14-sha1," \
27
	"diffie-hellman-group-exchange-sha256," \
28
	"diffie-hellman-group1-sha1"
28
	"diffie-hellman-group-exchange-sha1," \
29
 	"diffie-hellman-group14-sha1," \
30
 	"diffie-hellman-group1-sha1"
29
#define	KEX_DEFAULT_PK_ALG	"ssh-rsa,ssh-dss"
31
#define	KEX_DEFAULT_PK_ALG	"ssh-rsa,ssh-dss"
30
#define	KEX_DEFAULT_ENCRYPT \
32
#define	KEX_DEFAULT_ENCRYPT \
31
	"aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \
33
	"aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \
(-)ssh-keyscan.c (+1 lines)
Lines 341-346 keygrab_ssh2(con *c) Link Here
341
	c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
341
	c->c_kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
342
	c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
342
	c->c_kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
343
	c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
343
	c->c_kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
344
	c->c_kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
344
	c->c_kex->verify_host_key = hostjump;
345
	c->c_kex->verify_host_key = hostjump;
345
346
346
	if (!(j = setjmp(kexjmp))) {
347
	if (!(j = setjmp(kexjmp))) {
(-)sshconnect2.c (+1 lines)
Lines 120-125 ssh_kex2(char *host, struct sockaddr *ho Link Here
120
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
120
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client;
121
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
121
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client;
122
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
122
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_client;
123
	kex->kex[KEX_DH_GEX_SHA256] = kexgex_client;
123
	kex->client_version_string=client_version_string;
124
	kex->client_version_string=client_version_string;
124
	kex->server_version_string=server_version_string;
125
	kex->server_version_string=server_version_string;
125
	kex->verify_host_key=&verify_host_key_callback;
126
	kex->verify_host_key=&verify_host_key_callback;
(-)sshd.c (+1 lines)
Lines 1929-1934 do_ssh2_kex(void) Link Here
1929
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
1929
	kex->kex[KEX_DH_GRP1_SHA1] = kexdh_server;
1930
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1930
	kex->kex[KEX_DH_GRP14_SHA1] = kexdh_server;
1931
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1931
	kex->kex[KEX_DH_GEX_SHA1] = kexgex_server;
1932
	kex->kex[KEX_DH_GEX_SHA256] = kexgex_server;
1932
	kex->server = 1;
1933
	kex->server = 1;
1933
	kex->client_version_string=client_version_string;
1934
	kex->client_version_string=client_version_string;
1934
	kex->server_version_string=server_version_string;
1935
	kex->server_version_string=server_version_string;
(-)lib/Makefile (-1 / +1 lines)
Lines 11-17 SRCS= authfd.c authfile.c bufaux.c buffe Link Here
11
	key.c dispatch.c kex.c mac.c uidswap.c uuencode.c misc.c \
11
	key.c dispatch.c kex.c mac.c uidswap.c uuencode.c misc.c \
12
	ssh-dss.c ssh-rsa.c dh.c kexdh.c kexgex.c \
12
	ssh-dss.c ssh-rsa.c dh.c kexdh.c kexgex.c \
13
	kexdhc.c kexgexc.c scard.c msg.c progressmeter.c dns.c \
13
	kexdhc.c kexgexc.c scard.c msg.c progressmeter.c dns.c \
14
	monitor_fdpass.c
14
	monitor_fdpass.c md-sha256.c
15
15
16
DEBUGLIBS= no
16
DEBUGLIBS= no
17
NOPROFILE= yes
17
NOPROFILE= yes

Return to bug 1023