💾 Archived View for home.gegeweb.org › files › cleanfeed.local.patch captured on 2022-06-04 at 04:53:01.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
--- cleanfeed.local.orig 2021-02-09 07:45:35.000000000 +0100 +++ cleanfeed.local 2021-02-12 08:05:27.000000000 +0100 @@ -1,7 +1,7 @@ # vim: set syntax=perl ts=4 ai si: -use MIME::Base64(); -use Digest::SHA(); +use Digest::SHA qw( sha1_base64 sha256_base64 sha512_base64 ); +use Digest::MD5 qw( md5_base64 ); # # local_filter_cancel @@ -65,23 +65,30 @@ my %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; } 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"); next; } my $key; - if ($1 eq 'sha1') { - $key = Digest::SHA::sha1($2); } + if ($1 eq 'sha512') { + $key = sha512_base64($2); + } + elsif ($1 eq 'sha256') { + $key = sha256_base64($2); + } + elsif ($1 eq 'sha1') { + $key = sha1_base64($2); + } elsif ($1 eq 'md5') { - $key = Digest::MD5::md5($2); + $key = md5_base64($2); } - $key = MIME::Base64::encode_base64($key, ''); + $key = pad_b64digest($key); if (exists($lock{$key})) { # INN::syslog('notice', "Valid Cancel-Key $key found.$msg"); @@ -98,4 +105,12 @@ return "No Cancel-Key matches Cancel-Lock.$msg"; } +sub pad_b64digest($) { + my ($b64_digest) = @_; + while (length($b64_digest) % 4) { + $b64_digest .= '='; + } + return $b64_digest; +} + 1; \ No newline at end of file