Add return value to dh_generate_f().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@501 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
родитель
baf2eaf165
Коммит
1a22d18afa
@ -514,11 +514,11 @@ void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBU
|
|||||||
|
|
||||||
/* in dh.c */
|
/* in dh.c */
|
||||||
/* DH key generation */
|
/* DH key generation */
|
||||||
int dh_generate_e(SSH_SESSION *session);
|
|
||||||
void ssh_print_bignum(const char *which,bignum num);
|
void ssh_print_bignum(const char *which,bignum num);
|
||||||
|
int dh_generate_e(SSH_SESSION *session);
|
||||||
|
int dh_generate_f(SSH_SESSION *session);
|
||||||
int dh_generate_x(SSH_SESSION *session);
|
int dh_generate_x(SSH_SESSION *session);
|
||||||
int dh_generate_y(SSH_SESSION *session);
|
int dh_generate_y(SSH_SESSION *session);
|
||||||
void dh_generate_f(SSH_SESSION *session);
|
|
||||||
|
|
||||||
int ssh_crypto_init(void);
|
int ssh_crypto_init(void);
|
||||||
void ssh_crypto_finalize(void);
|
void ssh_crypto_finalize(void);
|
||||||
|
26
libssh/dh.c
26
libssh/dh.c
@ -285,22 +285,34 @@ int dh_generate_e(SSH_SESSION *session) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dh_generate_f(SSH_SESSION *session){
|
int dh_generate_f(SSH_SESSION *session) {
|
||||||
#ifdef HAVE_LIBCRYPTO
|
#ifdef HAVE_LIBCRYPTO
|
||||||
bignum_CTX ctx=bignum_ctx_new();
|
bignum_CTX ctx = bignum_ctx_new();
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
session->next_crypto->f=bignum_new();
|
|
||||||
|
session->next_crypto->f = bignum_new();
|
||||||
|
if (session->next_crypto->f == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
bignum_mod_exp(session->next_crypto->f,g,session->next_crypto->y,p);
|
bignum_mod_exp(session->next_crypto->f, g, session->next_crypto->y, p);
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
bignum_mod_exp(session->next_crypto->f,g,session->next_crypto->y,p,ctx);
|
bignum_mod_exp(session->next_crypto->f, g, session->next_crypto->y, p, ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_bignum("f",session->next_crypto->f);
|
ssh_print_bignum("f", session->next_crypto->f);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBCRYPTO
|
#ifdef HAVE_LIBCRYPTO
|
||||||
bignum_ctx_free(ctx);
|
bignum_ctx_free(ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *make_bignum_string(bignum num){
|
STRING *make_bignum_string(bignum num){
|
||||||
|
@ -278,7 +278,10 @@ static int dh_handshake_server(SSH_SESSION *session){
|
|||||||
ssh_set_error(session,SSH_FATAL,"Could not create y number");
|
ssh_set_error(session,SSH_FATAL,"Could not create y number");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dh_generate_f(session);
|
if (dh_generate_f(session) < 0) {
|
||||||
|
ssh_set_error(session,SSH_FATAL,"Could not create f number");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
f=dh_get_f(session);
|
f=dh_get_f(session);
|
||||||
switch(session->hostkeys){
|
switch(session->hostkeys){
|
||||||
case TYPE_DSS:
|
case TYPE_DSS:
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user