version 1.26, 2019/01/21 09:55:52 |
version 1.27, 2019/01/21 10:00:23 |
|
|
#include "sshkey.h" |
#include "sshkey.h" |
#include "cipher.h" |
#include "cipher.h" |
#include "digest.h" |
#include "digest.h" |
|
#include "dh.h" |
#include "kex.h" |
#include "kex.h" |
#include "log.h" |
#include "log.h" |
#include "packet.h" |
#include "packet.h" |
#include "dh.h" |
|
#include "ssh2.h" |
#include "ssh2.h" |
#include "dispatch.h" |
#include "dispatch.h" |
#include "compat.h" |
#include "compat.h" |
|
|
const BIGNUM *pub_key; |
const BIGNUM *pub_key; |
|
|
/* generate and send 'e', client DH public key */ |
/* generate and send 'e', client DH public key */ |
switch (kex->kex_type) { |
if ((r = kex_dh_keygen(kex)) != 0) |
case KEX_DH_GRP1_SHA1: |
|
kex->dh = dh_new_group1(); |
|
break; |
|
case KEX_DH_GRP14_SHA1: |
|
case KEX_DH_GRP14_SHA256: |
|
kex->dh = dh_new_group14(); |
|
break; |
|
case KEX_DH_GRP16_SHA512: |
|
kex->dh = dh_new_group16(); |
|
break; |
|
case KEX_DH_GRP18_SHA512: |
|
kex->dh = dh_new_group18(); |
|
break; |
|
default: |
|
r = SSH_ERR_INVALID_ARGUMENT; |
|
goto out; |
goto out; |
} |
|
if (kex->dh == NULL) { |
|
r = SSH_ERR_ALLOC_FAIL; |
|
goto out; |
|
} |
|
debug("sending SSH2_MSG_KEXDH_INIT"); |
debug("sending SSH2_MSG_KEXDH_INIT"); |
if ((r = dh_gen_key(kex->dh, kex->we_need * 8)) != 0) |
|
goto out; |
|
DH_get0_key(kex->dh, &pub_key, NULL); |
DH_get0_key(kex->dh, &pub_key, NULL); |
if ((r = sshpkt_start(ssh, SSH2_MSG_KEXDH_INIT)) != 0 || |
if ((r = sshpkt_start(ssh, SSH2_MSG_KEXDH_INIT)) != 0 || |
(r = sshpkt_put_bignum2(ssh, pub_key)) != 0 || |
(r = sshpkt_put_bignum2(ssh, pub_key)) != 0 || |