From 6e48ddf3f98302d28e371556e7b4dee2fc6e205e Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sat, 23 May 2015 15:19:44 +0200 Subject: [PATCH] add autodetect for AUTHTYPE_SSL_CLIENTCERTFP --- src/auth.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/auth.c b/src/auth.c index edc773efa..6905a78b2 100644 --- a/src/auth.c +++ b/src/auth.c @@ -66,6 +66,23 @@ int Auth_AutoDetectHashType(char *hash) char *saltstr, *hashstr; int bits; + if (!strchr(hash, '$')) + { + /* SHA256 SSL fingerprint perhaps? + * These are exactly 64 bytes (00112233..etc..) or 95 bytes (00:11:22:33:etc) in size. + */ + if ((strlen(hash) == 64) || (strlen(hash) == 95)) + { + char *p; + char hexchars[16] = "0123456789abcdef"; + for (p = hash; *p; p++) + if ((*hash != ':') && !strchr(hexchars, *p)) + return AUTHTYPE_PLAINTEXT; /* not hex and not colon */ + + return AUTHTYPE_SSL_CLIENTCERTFP; + } + } + if ((*hash != '$') || !strchr(hash+1, '$')) return AUTHTYPE_PLAINTEXT;