This commit is contained in:
4fury-c3440d8
2021-12-21 05:58:34 +03:00
parent 4cc32cb55f
commit 75c5ae6e4b
4 changed files with 210 additions and 42 deletions
@@ -0,0 +1,199 @@
From 1a8dc0ea64c6bbe187babdb1079bc0cf05926e59 Mon Sep 17 00:00:00 2001
From: Robert Scheck <robert@fedoraproject.org>
Date: Fri, 10 Dec 2021 00:21:56 +0100
Subject: [PATCH] Use Digest::SHA instead of Digest::SHA1
Switch from Digest::SHA1 to Digest::SHA, because: Digest::SHA is a bit
faster than Digest::SHA1, Digest::SHA1 has been removed from some Linux
distributions, Digest::SHA is a core library (as of Perl >= 5.10.0) and
Digest::SHA1 is not (and never will be). See also:
- https://src.fedoraproject.org/rpms/perl-Razor-Agent/c/75fa8a6c1f1fdf779312dac68f331a288bd2920f?branch=rawhide
- https://stackoverflow.com/questions/3420720/what-are-the-advantages-of-digestsha-over-digestsha1
Original author: Warren Togami <wtogami@redhat.com>
---
INSTALL | 2 +-
META.json | 2 +-
META.yml | 2 +-
Makefile.PL | 2 +-
lib/Razor2/Client/Engine.pm | 1 -
lib/Razor2/Signature/Ephemeral.pm | 14 +++++++-------
lib/Razor2/Signature/Whiplash.pm | 14 ++++++--------
lib/Razor2/String.pm | 17 +++++++----------
8 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/INSTALL b/INSTALL
index 2de1b42..1852ba0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -25,7 +25,7 @@ option, like so:
following Perl modules from CPAN:
Time::HiRes
- Digest::SHA1
+ Digest::SHA
MIME::Base64
Test::Simple
Test::Harness
diff --git a/META.json b/META.json
index f893748..e616292 100644
--- a/META.json
+++ b/META.json
@@ -33,7 +33,7 @@
},
"runtime" : {
"requires" : {
- "Digest::SHA1" : "0",
+ "Digest::SHA" : "0",
"File::Copy" : "0",
"File::Spec" : "0",
"Getopt::Long" : "0",
diff --git a/META.yml b/META.yml
index 4a0831c..314b0fc 100644
--- a/META.yml
+++ b/META.yml
@@ -19,7 +19,7 @@ no_index:
- t
- inc
requires:
- Digest::SHA1: '0'
+ Digest::SHA: '0'
File::Copy: '0'
File::Spec: '0'
Getopt::Long: '0'
diff --git a/Makefile.PL b/Makefile.PL
index 833d1dc..095f7e3 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -22,7 +22,7 @@ WriteMakefile(
( $ExtUtils::MakeMaker::VERSION >= 6.3002 ? ( 'LICENSE' => 'perl', ) : () ),
EXE_FILES => [qw( bin/razor-client bin/razor-admin bin/razor-check bin/razor-report bin/razor-revoke )],
PREREQ_PM => {
- 'Digest::SHA1' => 0,
+ 'Digest::SHA' => 0,
'File::Copy' => 0,
'File::Spec' => 0,
'Getopt::Long' => 0,
diff --git a/lib/Razor2/Client/Engine.pm b/lib/Razor2/Client/Engine.pm
index 98f2f44..f3610b4 100644
--- a/lib/Razor2/Client/Engine.pm
+++ b/lib/Razor2/Client/Engine.pm
@@ -1,7 +1,6 @@
package Razor2::Client::Engine;
use strict;
-use Digest::SHA1 qw(sha1_hex);
use Data::Dumper;
use Razor2::Signature::Ephemeral;
use Razor2::Engine::VR8;
diff --git a/lib/Razor2/Signature/Ephemeral.pm b/lib/Razor2/Signature/Ephemeral.pm
index 4310b6c..6764e8e 100644
--- a/lib/Razor2/Signature/Ephemeral.pm
+++ b/lib/Razor2/Signature/Ephemeral.pm
@@ -2,9 +2,13 @@
package Razor2::Signature::Ephemeral;
use strict;
-use Digest::SHA1;
use Data::Dumper;
+BEGIN {
+ eval { require Digest::SHA; import Digest::SHA qw(sha1_hex); 1 }
+ or do { require Digest::SHA1; import Digest::SHA1 qw(sha1_hex) }
+}
+
sub new {
my ( $class, %args ) = @_;
@@ -88,17 +92,13 @@ sub hexdigest {
}
my $digest;
- my $ctx = Digest::SHA1->new;
if ( $seclength > 128 ) {
- $ctx->add($section1);
- $ctx->add($section2);
- $digest = $ctx->hexdigest;
+ $digest = sha1_hex($section1, $section2);
}
else {
debug("Sections too small... reverting back to orginal content.");
- $ctx->add($content);
- $digest = $ctx->hexdigest;
+ $digest = sha1_hex($content);
}
debug("Computed e-hash is $digest");
diff --git a/lib/Razor2/Signature/Whiplash.pm b/lib/Razor2/Signature/Whiplash.pm
index 2977371..40ace61 100644
--- a/lib/Razor2/Signature/Whiplash.pm
+++ b/lib/Razor2/Signature/Whiplash.pm
@@ -7,7 +7,10 @@
package Razor2::Signature::Whiplash;
-use Digest::SHA1;
+BEGIN {
+ eval { require Digest::SHA; import Digest::SHA qw(sha1_hex); 1 }
+ or do { require Digest::SHA1; import Digest::SHA1 qw(sha1_hex) }
+}
sub new {
@@ -682,13 +685,8 @@ sub whiplash {
# the value of length to the nearest multiple of ``length_error''.
# Take the first 20 hex chars from SHA1 and call it the signature.
- my $sha1 = Digest::SHA1->new();
-
- $sha1->add($host);
- $sig = substr $sha1->hexdigest, 0, 12;
-
- $sha1->add($corrected_length);
- $sig .= substr $sha1->hexdigest, 0, 4;
+ $sig = substr sha1_hex($host), 0, 12;
+ $sig .= substr sha1_hex($corrected_length), 0, 4;
push @sigs, $sig;
$sig_meta{$sig} = [ $host, $corrected_length ];
diff --git a/lib/Razor2/String.pm b/lib/Razor2/String.pm
index dbcb903..b623917 100644
--- a/lib/Razor2/String.pm
+++ b/lib/Razor2/String.pm
@@ -1,11 +1,15 @@
# $Id: String.pm,v 1.48 2005/06/13 21:09:59 vipul Exp $
package Razor2::String;
-use Digest::SHA1 qw(sha1_hex);
use URI::Escape;
use Razor2::Preproc::enBase64;
use Data::Dumper;
+BEGIN {
+ eval { require Digest::SHA; import Digest::SHA qw(sha1_hex); 1 }
+ or do { require Digest::SHA1; import Digest::SHA1 qw(sha1_hex) }
+}
+
#use MIME::Parser;
require Exporter;
@@ -65,15 +69,8 @@ sub hmac2_sha1 {
return unless $text && $iv1 && $iv2;
die "no ref's allowed" if ref($text);
- my $ctx = Digest::SHA1->new;
- $ctx->add($iv2);
- $ctx->add($text);
- my $digest = $ctx->hexdigest;
-
- $ctx = Digest::SHA1->new;
- $ctx->add($iv1);
- $ctx->add($digest);
- $digest = $ctx->hexdigest;
+ my $digest = sha1_hex($iv2, $text);
+ $digest = sha1_hex($iv1, $digest);
return ( hextobase64($digest), $digest );
}
@@ -1,15 +0,0 @@
diff -uprw razor-agents-2.85.orig/Makefile.PL razor-agents-2.85/Makefile.PL
--- razor-agents-2.85.orig/Makefile.PL 2007-05-09 01:47:53.000000000 +0300
+++ razor-agents-2.85/Makefile.PL 2015-06-14 20:36:23.677213987 +0300
@@ -140,9 +140,9 @@ sub MY::install {
my $inherited = $self->SUPER::install(@_);
my $man5 = q{ \\
- $(INST_MAN5DIR) $(INSTALLMAN5DIR)};
+ "$(INST_MAN5DIR)" "$(INSTALLMAN5DIR)"};
- $inherited =~ s/(\$\((?:DEST)?INSTALL\w*MAN1DIR\))/$1$man5/gm;
+ $inherited =~ s/("?\$\((?:DEST)?INSTALL\w*MAN1DIR\)"?)/$1$man5/gm;
return $inherited;
}
@@ -1,22 +0,0 @@
--- a/lib/Razor2/Client/Version.pm 2007-05-10 22:32:10.000000000 +0200
+++ b/lib/Razor2/Client/Version.pm 2010-03-25 11:11:36.911409707 +0100
@@ -14,7 +14,7 @@
$PROTOCOL = 3;
-$VERSION = '2.84';
+$VERSION = '2.85';
1;
--- a/META.yml 2007-05-23 20:29:34.000000000 +0200
+++ b/META.yml 2010-03-25 11:11:43.691408628 +0100
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: razor-agents
-version: 2.84
+version: 2.85
version_from: lib/Razor2/Client/Version.pm
installdirs: site
requires:
+11 -5
View File
@@ -3,7 +3,7 @@
<PISI>
<Source>
<Name>razor</Name>
<Homepage>http://razor.sourceforge.net/</Homepage>
<Homepage>https://github.com/toddr/Razor2-Client-Agent</Homepage>
<Packager>
<Name>fury</Name>
<Email>uglyside@yandex.ru</Email>
@@ -13,15 +13,14 @@
<PartOf>network.mail</PartOf>
<Summary>Razor is a distributed, collaborative, spam detection and filtering network.</Summary>
<Description>Vipul's Razor is a distributed, collaborative, spam detection and filtering network. Through user contribution, Razor establishes a distributed and constantly updating catalogue of spam in propagation that is consulted by email clients to filter out known spam. Detection is done with statistical and randomized signatures that efficiently spot mutating spam content. User input is validated through reputation assignments based on consensus on report and revoke assertions which in turn is used for computing confidence values associated with individual signatures.</Description>
<Archive sha1sum="bf5797ae9faf20f7e3635883767a95cdf0739ba9" type="tarbz2">
mirrors://sourceforge/project/razor/razor-agents/2.85/razor-agents-2.85.tar.bz2
<Archive sha1sum="bc00a1a4076f60a31d53d501a501adc285ec82b2" type="targz">
https://cpan.metacpan.org/authors/id/T/TO/TODDR/Razor2-Client-Agent-2.86.tar.gz
</Archive>
<BuildDependencies>
<Dependency>perl</Dependency>
</BuildDependencies>
<Patches>
<Patch level="1">makefile_quoting_fix.patch</Patch>
<Patch level="1">version_fix.patch</Patch>
<Patch level="1">Use_Digest::SHA_instead_of_Digest::SHA1.patch</Patch>
</Patches>
</Source>
@@ -42,6 +41,13 @@
</Package>
<History>
<Update release="2">
<Date>2021-12-20</Date>
<Version>2.86</Version>
<Comment>Rebuild</Comment>
<Name>fury</Name>
<Email>uglyside@yandex.ru</Email>
</Update>
<Update release="1">
<Date>2021-09-18</Date>
<Version>2.85</Version>