diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2017-06-11 00:21:03 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2017-06-11 00:21:03 +0200 |
commit | a726497a953a263c6115706e449a5b78c86647ac (patch) | |
tree | 9a1a50207fc3d2f3446715af29ded1d3e8967497 | |
parent | fa4dafd4be9dbd6d119c510197e7760f4a0ba0c8 (diff) | |
download | libssh-a726497a953a263c6115706e449a5b78c86647ac.tar.gz libssh-a726497a953a263c6115706e449a5b78c86647ac.tar.xz libssh-a726497a953a263c6115706e449a5b78c86647ac.zip |
dh: don't preallocate e&f
-rw-r--r-- | src/dh.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -133,9 +133,12 @@ int ssh_dh_init_common(ssh_session session){ struct ssh_crypto_struct *crypto=session->next_crypto; crypto->x = bignum_new(); crypto->y = bignum_new(); - crypto->e = bignum_new(); - crypto->f = bignum_new(); + crypto->e = NULL; + crypto->f = NULL; crypto->k = bignum_new(); + crypto->g = NULL; + crypto->p = NULL; + crypto->dh_group_is_mutable = 0; if (session->next_crypto->kex_type == SSH_KEX_DH_GROUP1_SHA1){ session->next_crypto->p = p_group1; session->next_crypto->dh_group_bits = 1024; @@ -148,8 +151,8 @@ int ssh_dh_init_common(ssh_session session){ session->next_crypto->dh_group_is_mutable = 0; } - if (crypto->x == NULL || crypto->y == NULL || crypto->e == NULL || - crypto->f == NULL || crypto->k == NULL){ + if (crypto->x == NULL || crypto->y == NULL || crypto->k == NULL){ + ssh_set_error_oom(session); return SSH_ERROR; } else { return SSH_OK; @@ -278,6 +281,10 @@ int ssh_client_dh_init(ssh_session session){ if (rc == SSH_ERROR){ goto error; } + session->next_crypto->e = bignum_new(); + if (session->next_crypto->e == NULL){ + goto error; + } bignum_mod_exp(session->next_crypto->e, session->next_crypto->g, session->next_crypto->x, session->next_crypto->p, ctx); @@ -393,6 +400,10 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dh_init){ goto error; } + session->next_crypto->f = bignum_new(); + if (session->next_crypto->f == NULL){ + goto error; + } bignum_mod_exp(session->next_crypto->f, session->next_crypto->g, session->next_crypto->y, session->next_crypto->p, ctx); bignum_ctx_free(ctx); |