highlighter: insist on 256-bit keys, not 257-bit or 258-bit

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-04-03 23:14:07 -06:00
parent dc00c8c577
commit 20e28d2b0f
1 changed files with 22 additions and 1 deletions

View File

@ -62,11 +62,32 @@ static bool is_valid_key(string_span_t s)
if (s.len != 44 || s.s[43] != '=')
return false;
for (size_t i = 0; i < 43; ++i) {
for (size_t i = 0; i < 42; ++i) {
if (!is_decimal(s.s[i]) && !is_alphabet(s.s[i]) &&
s.s[i] != '/' && s.s[i] != '+')
return false;
}
switch (s.s[42]) {
case 'A':
case 'E':
case 'I':
case 'M':
case 'Q':
case 'U':
case 'Y':
case 'c':
case 'g':
case 'k':
case 'o':
case 's':
case 'w':
case '4':
case '8':
case '0':
break;
default:
return false;
}
return true;
}