filter_innd: Add sha256/sha512 for Cancel-Lock/Key.

Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
Thomas Hochstein 2023-05-20 15:33:16 +02:00
parent 0ed9a8166d
commit 57c4ee5c87

View file

@ -68,20 +68,24 @@ sub verify_cancel_key($$$) {
my %lock; my %lock;
for my $l(split(/\s+/, $cancel_lock)) { for my $l(split(/\s+/, $cancel_lock)) {
next unless($l =~ m/^(sha1|md5):(\S+)/); next unless($l =~ m/^(sha512|sha256|sha1|md5):(\S+)/);
$lock{$2} = $1; $lock{$2} = $1;
} }
for my $k(split(/\s+/, $cancel_key)) { for my $k(split(/\s+/, $cancel_key)) {
unless($k =~ m/^(sha1|md5):(\S+)/) { unless($k =~ m/^(sha512|sha256|sha1|md5):(\S+)/) {
INN::syslog('notice', "Invalid Cancel-Key syntax '$k'.$msg"); INN::syslog('notice', "Invalid Cancel-Key syntax '$k'.$msg");
next; next;
} }
my $key; my $key;
if ($1 eq 'sha1') { if ($1 eq 'sha512') {
$key = Digest::SHA::sha1($2); } $key = Digest::SHA::sha512($2);
elsif ($1 eq 'md5') { } elsif ($1 eq 'sha256') {
$key = Digest::SHA::sha256($2);
} elsif($1 eq 'sha1') {
$key = Digest::SHA::sha1($2);
} elsif ($1 eq 'md5') {
$key = Digest::MD5::md5($2); $key = Digest::MD5::md5($2);
} }
$key = MIME::Base64::encode_base64($key, ''); $key = MIME::Base64::encode_base64($key, '');