mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Simplify signature_from_string() a bit.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@548 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -855,7 +855,8 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,
|
|||||||
STRING *rs = NULL;
|
STRING *rs = NULL;
|
||||||
STRING *type_s = NULL;
|
STRING *type_s = NULL;
|
||||||
STRING *e = NULL;
|
STRING *e = NULL;
|
||||||
char *type = NULL;
|
char *type_c = NULL;
|
||||||
|
int type;
|
||||||
int len;
|
int len;
|
||||||
int rsalen;
|
int rsalen;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
@@ -893,41 +894,23 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = string_to_char(type_s);
|
type_c = string_to_char(type_s);
|
||||||
free(type_s);
|
string_free(type_s);
|
||||||
if (type == NULL) {
|
if (type_c == NULL) {
|
||||||
signature_free(sign);
|
signature_free(sign);
|
||||||
buffer_free(tmpbuf);
|
buffer_free(tmpbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
type = ssh_type_from_name(type_c);
|
||||||
|
SAFE_FREE(type_c);
|
||||||
|
|
||||||
switch(needed_type) {
|
if (needed_type != type) {
|
||||||
case TYPE_DSS:
|
ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s",
|
||||||
if (strcmp(type, "ssh-dss") != 0) {
|
ssh_type_to_char(type));
|
||||||
ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s", type);
|
signature_free(sign);
|
||||||
signature_free(sign);
|
buffer_free(tmpbuf);
|
||||||
buffer_free(tmpbuf);
|
return NULL;
|
||||||
SAFE_FREE(type);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TYPE_RSA:
|
|
||||||
if (strcmp(type, "ssh-rsa")) {
|
|
||||||
ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s", type);
|
|
||||||
signature_free(sign);
|
|
||||||
buffer_free(tmpbuf);
|
|
||||||
SAFE_FREE(type);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s", type);
|
|
||||||
signature_free(sign);
|
|
||||||
buffer_free(tmpbuf);
|
|
||||||
SAFE_FREE(type);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
SAFE_FREE(type);
|
|
||||||
|
|
||||||
switch(needed_type) {
|
switch(needed_type) {
|
||||||
case TYPE_DSS:
|
case TYPE_DSS:
|
||||||
|
|||||||
Reference in New Issue
Block a user