version 1.3.2.2, 2006/11/08 00:17:14 |
version 1.4, 2006/03/19 18:51:18 |
|
|
/* $OpenBSD$ */ |
|
/* |
/* |
* Copyright (c) 2000 Niels Provos. All rights reserved. |
* Copyright (c) 2000 Niels Provos. All rights reserved. |
* Copyright (c) 2001 Markus Friedl. All rights reserved. |
* Copyright (c) 2001 Markus Friedl. All rights reserved. |
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
*/ |
|
|
#include <sys/types.h> |
#include "includes.h" |
|
|
#include <stdio.h> |
|
#include <string.h> |
|
#include <signal.h> |
|
|
|
#include "xmalloc.h" |
#include "xmalloc.h" |
#include "buffer.h" |
|
#include "key.h" |
#include "key.h" |
#include "cipher.h" |
|
#include "kex.h" |
#include "kex.h" |
#include "log.h" |
#include "log.h" |
#include "packet.h" |
#include "packet.h" |
|
|
BIGNUM *p = NULL, *g = NULL; |
BIGNUM *p = NULL, *g = NULL; |
Key *server_host_key; |
Key *server_host_key; |
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; |
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; |
u_int klen, slen, sbloblen, hashlen; |
u_int klen, kout, slen, sbloblen, hashlen; |
int kout; |
|
int min, max, nbits; |
int min, max, nbits; |
DH *dh; |
DH *dh; |
|
|
|
|
if (kex->verify_host_key(server_host_key) == -1) |
if (kex->verify_host_key(server_host_key) == -1) |
fatal("server_host_key verification failed"); |
fatal("server_host_key verification failed"); |
|
|
/* DH parameter f, server public DH key */ |
/* DH paramter f, server public DH key */ |
if ((dh_server_pub = BN_new()) == NULL) |
if ((dh_server_pub = BN_new()) == NULL) |
fatal("dh_server_pub == NULL"); |
fatal("dh_server_pub == NULL"); |
packet_get_bignum2(dh_server_pub); |
packet_get_bignum2(dh_server_pub); |
|
|
|
|
klen = DH_size(dh); |
klen = DH_size(dh); |
kbuf = xmalloc(klen); |
kbuf = xmalloc(klen); |
if ((kout = DH_compute_key(kbuf, dh_server_pub, dh)) < 0) |
kout = DH_compute_key(kbuf, dh_server_pub, dh); |
fatal("DH_compute_key: failed"); |
|
#ifdef DEBUG_KEXDH |
#ifdef DEBUG_KEXDH |
dump_digest("shared secret", kbuf, kout); |
dump_digest("shared secret", kbuf, kout); |
#endif |
#endif |
if ((shared_secret = BN_new()) == NULL) |
if ((shared_secret = BN_new()) == NULL) |
fatal("kexgex_client: BN_new failed"); |
fatal("kexgex_client: BN_new failed"); |
if (BN_bin2bn(kbuf, kout, shared_secret) == NULL) |
BN_bin2bn(kbuf, kout, shared_secret); |
fatal("kexgex_client: BN_bin2bn failed"); |
|
memset(kbuf, 0, klen); |
memset(kbuf, 0, klen); |
xfree(kbuf); |
xfree(kbuf); |
|
|