version 1.1, 2003/02/16 17:09:57 |
version 1.1.16.2, 2006/10/06 03:19:32 |
|
|
|
/* $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 "includes.h" |
#include <sys/param.h> |
RCSID("$OpenBSD$"); |
|
|
|
|
#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" |
#include "dh.h" |
#include "dh.h" |
#include "ssh2.h" |
#include "ssh2.h" |
#include "compat.h" |
#include "compat.h" |
|
#ifdef GSSAPI |
|
#include "ssh-gss.h" |
|
#endif |
#include "monitor_wrap.h" |
#include "monitor_wrap.h" |
|
|
void |
void |
|
|
Key *server_host_key; |
Key *server_host_key; |
DH *dh; |
DH *dh; |
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; |
u_char *kbuf, *hash, *signature = NULL, *server_host_key_blob = NULL; |
u_int sbloblen, klen, kout, slen; |
u_int sbloblen, klen, kout, slen, hashlen; |
int min = -1, max = -1, nbits = -1, type; |
int min = -1, max = -1, nbits = -1, type; |
|
|
if (kex->load_host_key == NULL) |
if (kex->load_host_key == NULL) |
|
|
if (type == SSH2_MSG_KEX_DH_GEX_REQUEST_OLD) |
if (type == SSH2_MSG_KEX_DH_GEX_REQUEST_OLD) |
min = max = -1; |
min = max = -1; |
|
|
/* calc H */ /* XXX depends on 'kex' */ |
/* calc H */ |
hash = kexgex_hash( |
kexgex_hash( |
|
kex->evp_md, |
kex->client_version_string, |
kex->client_version_string, |
kex->server_version_string, |
kex->server_version_string, |
buffer_ptr(&kex->peer), buffer_len(&kex->peer), |
buffer_ptr(&kex->peer), buffer_len(&kex->peer), |
|
|
dh->p, dh->g, |
dh->p, dh->g, |
dh_client_pub, |
dh_client_pub, |
dh->pub_key, |
dh->pub_key, |
shared_secret |
shared_secret, |
|
&hash, &hashlen |
); |
); |
BN_clear_free(dh_client_pub); |
BN_clear_free(dh_client_pub); |
|
|
/* save session id := H */ |
/* save session id := H */ |
/* XXX hashlen depends on KEX */ |
|
if (kex->session_id == NULL) { |
if (kex->session_id == NULL) { |
kex->session_id_len = 20; |
kex->session_id_len = hashlen; |
kex->session_id = xmalloc(kex->session_id_len); |
kex->session_id = xmalloc(kex->session_id_len); |
memcpy(kex->session_id, hash, kex->session_id_len); |
memcpy(kex->session_id, hash, kex->session_id_len); |
} |
} |
|
|
/* sign H */ |
/* sign H */ |
/* XXX hashlen depends on KEX */ |
PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, hashlen)); |
PRIVSEP(key_sign(server_host_key, &signature, &slen, hash, 20)); |
|
|
|
/* destroy_sensitive_data(); */ |
/* destroy_sensitive_data(); */ |
|
|
|
|
/* have keys, free DH */ |
/* have keys, free DH */ |
DH_free(dh); |
DH_free(dh); |
|
|
kex_derive_keys(kex, hash, shared_secret); |
kex_derive_keys(kex, hash, hashlen, shared_secret); |
BN_clear_free(shared_secret); |
BN_clear_free(shared_secret); |
|
|
kex_finish(kex); |
kex_finish(kex); |