This function can check all types of keys and not only the public key.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
return 1;
}
-sub publickey_is_valid($) {
+sub key_is_valid($) {
my $key = shift;
# Try to decode the key
}
# Check the public key
- unless (&Wireguard::publickey_is_valid($cgiparams{'PUBLIC_KEY'})) {
+ unless (&Wireguard::key_is_valid($cgiparams{'PUBLIC_KEY'})) {
push(@errormessages, $Lang::tr{'wg invalid public key'});
}
# Check PSK
if ($cgiparams{'PSK'} eq '') {
# The PSK may be empty
- } elsif (!&Wireguard::publickey_is_valid($cgiparams{'PSK'})) {
+ } elsif (!&Wireguard::key_is_valid($cgiparams{'PSK'})) {
push(@errormessages, $Lang::tr{'wg invalid psk'});
}