diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-18 12:02:34 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-18 12:02:34 +0000 |
commit | db2ff033922b1177fdab4996ee52f895541f8f0f (patch) | |
tree | 48d66dd5fbae1c1a78656ad73d75742bcfe4408f /libssh/keys.c | |
parent | dc5ef34b5404c2805fabd87dd2e2dbbf26aba54e (diff) | |
download | libssh-db2ff033922b1177fdab4996ee52f895541f8f0f.tar.gz libssh-db2ff033922b1177fdab4996ee52f895541f8f0f.tar.xz libssh-db2ff033922b1177fdab4996ee52f895541f8f0f.zip |
Simplify signature_from_string() a bit.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@548 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keys.c')
-rw-r--r-- | libssh/keys.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/libssh/keys.c b/libssh/keys.c index 34f4151..c1b48d8 100644 --- a/libssh/keys.c +++ b/libssh/keys.c @@ -855,7 +855,8 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature, STRING *rs = NULL; STRING *type_s = NULL; STRING *e = NULL; - char *type = NULL; + char *type_c = NULL; + int type; int len; int rsalen; #ifdef HAVE_LIBGCRYPT @@ -893,41 +894,23 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature, return NULL; } - type = string_to_char(type_s); - free(type_s); - if (type == NULL) { + type_c = string_to_char(type_s); + string_free(type_s); + if (type_c == NULL) { signature_free(sign); buffer_free(tmpbuf); return NULL; } + type = ssh_type_from_name(type_c); + SAFE_FREE(type_c); - switch(needed_type) { - case TYPE_DSS: - if (strcmp(type, "ssh-dss") != 0) { - ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s", type); - signature_free(sign); - buffer_free(tmpbuf); - 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; + if (needed_type != type) { + ssh_set_error(session, SSH_FATAL, "Invalid signature type: %s", + ssh_type_to_char(type)); + signature_free(sign); + buffer_free(tmpbuf); + return NULL; } - SAFE_FREE(type); switch(needed_type) { case TYPE_DSS: |