version 1.27, 2018/02/07 02:06:51 |
version 1.28, 2018/09/13 02:08:33 |
|
|
{ |
{ |
struct kex *kex = ssh->kex; |
struct kex *kex = ssh->kex; |
BIGNUM *p = NULL, *g = NULL; |
BIGNUM *p = NULL, *g = NULL; |
|
const BIGNUM *pub_key; |
int r, bits; |
int r, bits; |
|
|
debug("got SSH2_MSG_KEX_DH_GEX_GROUP"); |
debug("got SSH2_MSG_KEX_DH_GEX_GROUP"); |
|
|
p = g = NULL; /* belong to kex->dh now */ |
p = g = NULL; /* belong to kex->dh now */ |
|
|
/* generate and send 'e', client DH public key */ |
/* generate and send 'e', client DH public key */ |
if ((r = dh_gen_key(kex->dh, kex->we_need * 8)) != 0 || |
if ((r = dh_gen_key(kex->dh, kex->we_need * 8)) != 0) |
(r = sshpkt_start(ssh, SSH2_MSG_KEX_DH_GEX_INIT)) != 0 || |
goto out; |
(r = sshpkt_put_bignum2(ssh, kex->dh->pub_key)) != 0 || |
DH_get0_key(kex->dh, &pub_key, NULL); |
|
if ((r = sshpkt_start(ssh, SSH2_MSG_KEX_DH_GEX_INIT)) != 0 || |
|
(r = sshpkt_put_bignum2(ssh, pub_key)) != 0 || |
(r = sshpkt_send(ssh)) != 0) |
(r = sshpkt_send(ssh)) != 0) |
goto out; |
goto out; |
debug("SSH2_MSG_KEX_DH_GEX_INIT sent"); |
debug("SSH2_MSG_KEX_DH_GEX_INIT sent"); |
#ifdef DEBUG_KEXDH |
#ifdef DEBUG_KEXDH |
DHparams_print_fp(stderr, kex->dh); |
DHparams_print_fp(stderr, kex->dh); |
fprintf(stderr, "pub= "); |
fprintf(stderr, "pub= "); |
BN_print_fp(stderr, kex->dh->pub_key); |
BN_print_fp(stderr, pub_key); |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
#endif |
#endif |
ssh_dispatch_set(ssh, SSH2_MSG_KEX_DH_GEX_GROUP, NULL); |
ssh_dispatch_set(ssh, SSH2_MSG_KEX_DH_GEX_GROUP, NULL); |
|
|
{ |
{ |
struct kex *kex = ssh->kex; |
struct kex *kex = ssh->kex; |
BIGNUM *dh_server_pub = NULL, *shared_secret = NULL; |
BIGNUM *dh_server_pub = NULL, *shared_secret = NULL; |
|
const BIGNUM *pub_key, *dh_p, *dh_g; |
struct sshkey *server_host_key = NULL; |
struct sshkey *server_host_key = NULL; |
u_char *kbuf = NULL, *signature = NULL, *server_host_key_blob = NULL; |
u_char *kbuf = NULL, *signature = NULL, *server_host_key_blob = NULL; |
u_char hash[SSH_DIGEST_MAX_LENGTH]; |
u_char hash[SSH_DIGEST_MAX_LENGTH]; |
|
|
kex->min = kex->max = -1; |
kex->min = kex->max = -1; |
|
|
/* calc and verify H */ |
/* calc and verify H */ |
|
DH_get0_key(kex->dh, &pub_key, NULL); |
|
DH_get0_pqg(kex->dh, &dh_p, NULL, &dh_g); |
hashlen = sizeof(hash); |
hashlen = sizeof(hash); |
if ((r = kexgex_hash( |
if ((r = kexgex_hash( |
kex->hash_alg, |
kex->hash_alg, |
|
|
sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), |
sshbuf_ptr(kex->peer), sshbuf_len(kex->peer), |
server_host_key_blob, sbloblen, |
server_host_key_blob, sbloblen, |
kex->min, kex->nbits, kex->max, |
kex->min, kex->nbits, kex->max, |
kex->dh->p, kex->dh->g, |
dh_p, dh_g, |
kex->dh->pub_key, |
pub_key, |
dh_server_pub, |
dh_server_pub, |
shared_secret, |
shared_secret, |
hash, &hashlen)) != 0) |
hash, &hashlen)) != 0) |