Reformat signature_verify() and fix match check.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@512 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
родитель
55791d1fe6
Коммит
07506763ff
20
libssh/dh.c
20
libssh/dh.c
@ -968,43 +968,51 @@ static int sig_verify(SSH_SESSION *session, PUBLIC_KEY *pubkey,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int signature_verify(SSH_SESSION *session, STRING *signature) {
|
int signature_verify(SSH_SESSION *session, STRING *signature) {
|
||||||
PUBLIC_KEY *pubkey;
|
PUBLIC_KEY *pubkey = NULL;
|
||||||
SIGNATURE *sign;
|
SIGNATURE *sign = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
|
|
||||||
if (session->options->dont_verify_hostkey) {
|
if (session->options->dont_verify_hostkey) {
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS, "Host key wasn't verified");
|
ssh_log(session, SSH_LOG_FUNCTIONS, "Host key wasn't verified");
|
||||||
leave_function();
|
leave_function();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pubkey = publickey_from_string(session,session->next_crypto->server_pubkey);
|
pubkey = publickey_from_string(session,session->next_crypto->server_pubkey);
|
||||||
if(!pubkey){
|
if(pubkey == NULL) {
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session->options->wanted_methods[SSH_HOSTKEYS]) {
|
if (session->options->wanted_methods[SSH_HOSTKEYS]) {
|
||||||
if(match(session->options->wanted_methods[SSH_HOSTKEYS],pubkey->type_c)){
|
if(!match(session->options->wanted_methods[SSH_HOSTKEYS],pubkey->type_c)) {
|
||||||
ssh_set_error(session,SSH_FATAL,"Public key from server (%s) doesn't match user preference (%s)",
|
ssh_set_error(session, SSH_FATAL,
|
||||||
|
"Public key from server (%s) doesn't match user preference (%s)",
|
||||||
pubkey->type_c, session->options->wanted_methods[SSH_HOSTKEYS]);
|
pubkey->type_c, session->options->wanted_methods[SSH_HOSTKEYS]);
|
||||||
publickey_free(pubkey);
|
publickey_free(pubkey);
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sign = signature_from_string(session, signature, pubkey, pubkey->type);
|
sign = signature_from_string(session, signature, pubkey, pubkey->type);
|
||||||
if(!sign){
|
if (sign == NULL) {
|
||||||
ssh_set_error(session, SSH_FATAL, "Invalid signature blob");
|
ssh_set_error(session, SSH_FATAL, "Invalid signature blob");
|
||||||
publickey_free(pubkey);
|
publickey_free(pubkey);
|
||||||
leave_function();
|
leave_function();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_log(session, SSH_LOG_FUNCTIONS,
|
ssh_log(session, SSH_LOG_FUNCTIONS,
|
||||||
"Going to verify a %s type signature", pubkey->type_c);
|
"Going to verify a %s type signature", pubkey->type_c);
|
||||||
|
|
||||||
err = sig_verify(session,pubkey,sign,session->next_crypto->session_id);
|
err = sig_verify(session,pubkey,sign,session->next_crypto->session_id);
|
||||||
signature_free(sign);
|
signature_free(sign);
|
||||||
session->next_crypto->server_pubkey_type = pubkey->type_c;
|
session->next_crypto->server_pubkey_type = pubkey->type_c;
|
||||||
publickey_free(pubkey);
|
publickey_free(pubkey);
|
||||||
|
|
||||||
leave_function();
|
leave_function();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user