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
This commit is contained in:
Andreas Schneider
2009-04-16 14:31:06 +00:00
parent ece047171a
commit baf2eaf165
3 changed files with 23 additions and 9 deletions

View File

@@ -514,7 +514,7 @@ void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBU
/* in dh.c */
/* DH key generation */
void dh_generate_e(SSH_SESSION *session);
int dh_generate_e(SSH_SESSION *session);
void ssh_print_bignum(const char *which,bignum num);
int dh_generate_x(SSH_SESSION *session);
int dh_generate_y(SSH_SESSION *session);

View File

@@ -204,7 +204,9 @@ static int dh_handshake(SSH_SESSION *session) {
if (dh_generate_x(session) < 0) {
goto error;
}
dh_generate_e(session);
if (dh_generate_e(session) < 0) {
goto error;
}
e = dh_get_e(session);
if (e == NULL) {

View File

@@ -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){