diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-04-03 23:16:07 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-04-04 23:26:10 -0600 |
commit | 504377b9b13b642d3a0607d046f391619d986f6b (patch) | |
tree | f91bad072c87e3e12a7bfe09f63ba69efa953db0 | |
parent | locales: add Italian translation (diff) | |
download | wireguard-windows-504377b9b13b642d3a0607d046f391619d986f6b.tar.xz wireguard-windows-504377b9b13b642d3a0607d046f391619d986f6b.zip |
syntax: insist on 256-bit keys, not 257-bit or 258-bit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | ui/syntax/highlighter.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/ui/syntax/highlighter.c b/ui/syntax/highlighter.c index 1913e359..e0d4e04e 100644 --- a/ui/syntax/highlighter.c +++ b/ui/syntax/highlighter.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ #include <stdbool.h> @@ -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; } |