summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ssh-rsa.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ssh-rsa.c b/ssh-rsa.c
index 81dab05b3..6b8589522 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-rsa.c,v 1.55 2015/12/04 16:41:28 markus Exp $ */ 1/* $OpenBSD: ssh-rsa.c,v 1.56 2015/12/07 20:04:09 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org> 3 * Copyright (c) 2000, 2003 Markus Friedl <markus@openbsd.org>
4 * 4 *
@@ -53,16 +53,12 @@ rsa_hash_alg_ident(int hash_alg)
53static int 53static int
54rsa_hash_alg_from_ident(const char *ident) 54rsa_hash_alg_from_ident(const char *ident)
55{ 55{
56 if (ident == NULL || strlen(ident) == 0)
57 return SSH_DIGEST_SHA1;
58 if (strcmp(ident, "ssh-rsa") == 0) 56 if (strcmp(ident, "ssh-rsa") == 0)
59 return SSH_DIGEST_SHA1; 57 return SSH_DIGEST_SHA1;
60 if (strcmp(ident, "rsa-sha2-256") == 0) 58 if (strcmp(ident, "rsa-sha2-256") == 0)
61 return SSH_DIGEST_SHA256; 59 return SSH_DIGEST_SHA256;
62 if (strcmp(ident, "rsa-sha2-512") == 0) 60 if (strcmp(ident, "rsa-sha2-512") == 0)
63 return SSH_DIGEST_SHA512; 61 return SSH_DIGEST_SHA512;
64 if (strncmp(ident, "ssh-rsa-cert", strlen("ssh-rsa-cert")) == 0)
65 return SSH_DIGEST_SHA1;
66 return -1; 62 return -1;
67} 63}
68 64
@@ -97,7 +93,11 @@ ssh_rsa_sign(const struct sshkey *key, u_char **sigp, size_t *lenp,
97 if (sigp != NULL) 93 if (sigp != NULL)
98 *sigp = NULL; 94 *sigp = NULL;
99 95
100 hash_alg = rsa_hash_alg_from_ident(alg_ident); 96 if (alg_ident == NULL || strlen(alg_ident) == 0 ||
97 strncmp(alg_ident, "ssh-rsa-cert", strlen("ssh-rsa-cert")) == 0)
98 hash_alg = SSH_DIGEST_SHA1;
99 else
100 hash_alg = rsa_hash_alg_from_ident(alg_ident);
101 if (key == NULL || key->rsa == NULL || hash_alg == -1 || 101 if (key == NULL || key->rsa == NULL || hash_alg == -1 ||
102 sshkey_type_plain(key->type) != KEY_RSA || 102 sshkey_type_plain(key->type) != KEY_RSA ||
103 BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) 103 BN_num_bits(key->rsa->n) < SSH_RSA_MINIMUM_MODULUS_SIZE)