From baf2eaf16503ae6c2ed36614fa1b5f2c31bdca1e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 16 Apr 2009 14:31:06 +0000 Subject: Add return value to dh_generate_e(). git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@500 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/dh.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'libssh/dh.c') 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){ -- cgit