diff options
Diffstat (limited to 'libssh/dh.c')
-rw-r--r-- | libssh/dh.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libssh/dh.c b/libssh/dh.c index f9684215..db916b87 100644 --- a/libssh/dh.c +++ b/libssh/dh.c @@ -255,22 +255,34 @@ int dh_generate_y(SSH_SESSION *session) { } /* used by server */ -void dh_generate_e(SSH_SESSION *session){ +int dh_generate_e(SSH_SESSION *session) { #ifdef HAVE_LIBCRYPTO - bignum_CTX ctx=bignum_ctx_new(); + bignum_CTX ctx = bignum_ctx_new(); + if (ctx == NULL) { + return -1; + } #endif - session->next_crypto->e=bignum_new(); + + session->next_crypto->e = bignum_new(); + if (session->next_crypto->e == NULL) { + return -1; + } + #ifdef HAVE_LIBGCRYPT - bignum_mod_exp(session->next_crypto->e,g,session->next_crypto->x,p); + bignum_mod_exp(session->next_crypto->e, g, session->next_crypto->x, p); #elif defined HAVE_LIBCRYPTO - bignum_mod_exp(session->next_crypto->e,g,session->next_crypto->x,p,ctx); + bignum_mod_exp(session->next_crypto->e, g, session->next_crypto->x, p, ctx); #endif + #ifdef DEBUG_CRYPTO - ssh_print_bignum("e",session->next_crypto->e); + ssh_print_bignum("e", session->next_crypto->e); #endif + #ifdef HAVE_LIBCRYPTO - bignum_ctx_free(ctx); + bignum_ctx_free(ctx); #endif + + return 0; } void dh_generate_f(SSH_SESSION *session){ |