1
1

Improve dh_import() functions.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@505 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Andreas Schneider 2009-04-16 14:50:53 +00:00
родитель e8a9cb25fe
Коммит c6eb54c39e
4 изменённых файлов: 28 добавлений и 9 удалений

Просмотреть файл

@ -525,8 +525,8 @@ void ssh_crypto_finalize(void);
STRING *dh_get_e(SSH_SESSION *session);
STRING *dh_get_f(SSH_SESSION *session);
void dh_import_f(SSH_SESSION *session,STRING *f_string);
void dh_import_e(SSH_SESSION *session, STRING *e_string);
int dh_import_f(SSH_SESSION *session,STRING *f_string);
int dh_import_e(SSH_SESSION *session, STRING *e_string);
void dh_import_pubkey(SSH_SESSION *session,STRING *pubkey_string);
void dh_build_k(SSH_SESSION *session);
int make_sessionid(SSH_SESSION *session);

Просмотреть файл

@ -251,7 +251,11 @@ static int dh_handshake(SSH_SESSION *session) {
rc = SSH_ERROR;
goto error;
}
dh_import_f(session, f);
if (dh_import_f(session, f) < 0) {
ssh_set_error(session, SSH_FATAL, "Cannot import f number");
rc = SSH_ERROR;
goto error;
}
string_burn(f);
string_free(f);

Просмотреть файл

@ -380,19 +380,31 @@ void dh_import_pubkey(SSH_SESSION *session, STRING *pubkey_string) {
session->next_crypto->server_pubkey = pubkey_string;
}
void dh_import_f(SSH_SESSION *session,STRING *f_string){
session->next_crypto->f=make_string_bn(f_string);
int dh_import_f(SSH_SESSION *session, STRING *f_string) {
session->next_crypto->f = make_string_bn(f_string);
if (session->next_crypto->f == NULL) {
return -1;
}
#ifdef DEBUG_CRYPTO
ssh_print_bignum("f",session->next_crypto->f);
ssh_print_bignum("f",session->next_crypto->f);
#endif
return 0;
}
/* used by the server implementation */
void dh_import_e(SSH_SESSION *session, STRING *e_string){
session->next_crypto->e=make_string_bn(e_string);
int dh_import_e(SSH_SESSION *session, STRING *e_string) {
session->next_crypto->e = make_string_bn(e_string);
if (session->next_crypto->e == NULL) {
return -1;
}
#ifdef DEBUG_CRYPTO
ssh_print_bignum("e",session->next_crypto->e);
#endif
return 0;
}
void dh_build_k(SSH_SESSION *session){

Просмотреть файл

@ -272,7 +272,10 @@ static int dh_handshake_server(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"No e number in client request");
return -1;
}
dh_import_e(session,e);
if (dh_import_e(session, e) < 0) {
ssh_set_error(session,SSH_FATAL,"Cannot import e number");
return -1;
}
free(e);
if (dh_generate_y(session) < 0) {
ssh_set_error(session,SSH_FATAL,"Could not create y number");