From fe713eb50dde13ab15c806663e0a7aa87c5992d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Mon, 17 Jun 2024 12:46:04 +0200 Subject: [PATCH] Add patch to rewrite usage of HMAC with same dependencies --- ...imple_rewrite_to_Digest-HMAC-helpers.patch | 93 +++++++++++++++++++ perl-Net-SNMP.spec | 11 ++- 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 Net-SNMP-v6.0.1-Simple_rewrite_to_Digest-HMAC-helpers.patch diff --git a/Net-SNMP-v6.0.1-Simple_rewrite_to_Digest-HMAC-helpers.patch b/Net-SNMP-v6.0.1-Simple_rewrite_to_Digest-HMAC-helpers.patch new file mode 100644 index 0000000..bd4968e --- /dev/null +++ b/Net-SNMP-v6.0.1-Simple_rewrite_to_Digest-HMAC-helpers.patch @@ -0,0 +1,93 @@ +From c84b7a235bdcaa37be39a927387c59429d2277c9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= + +Date: Tue, 5 Mar 2024 19:00:55 +0100 +Subject: [PATCH 03/11] Simple rewrite to Digest::HMAC helpers + +We need to concretize algorithms to defined place instead of composition +in code. Digest::HMAC_* helpers are in the same package as Digest::HMAC. + +Difference is that all code for algoritm is now in Digest::HMAC +distribution instead of previous situation when was composition +Digest::HMAC and Digest::SHA1 and Digest::MD5 in this code. +--- + Build.PL | 3 ++- + META.yml | 3 ++- + Makefile.PL | 3 ++- + lib/Net/SNMP/Security/USM.pm | 7 ++++--- + 4 files changed, 10 insertions(+), 6 deletions(-) + +diff --git a/Build.PL b/Build.PL +index 6002343..a8ae8dd 100644 +--- a/Build.PL ++++ b/Build.PL +@@ -39,7 +39,8 @@ Module::Build->new( + Crypt::DES => '2.03', # SNMPv3 + Digest::MD5 => '2.11', # SNMPv3 + Digest::SHA1 => '1.02', # SNMPv3 +- Digest::HMAC => '1.00', # SNMPv3 ++ Digest::HMAC_MD5 => '1.01', # SNMPv3 ++ Digest::HMAC_SHA1 => '1.03', # SNMPv3 + Crypt::Rijndael => '1.02', # SNMPv3 - AES Cipher Algorithm + }, + meta_merge => { +diff --git a/META.yml b/META.yml +index bf64bc6..0b1acd7 100644 +--- a/META.yml ++++ b/META.yml +@@ -62,7 +62,8 @@ provides: + recommends: + Crypt::DES: '2.03' + Crypt::Rijndael: '1.02' +- Digest::HMAC: '1.00' ++ Digest::HMAC_MD5: '1.01' ++ Digest::HMAC_SHA1: '1.03' + Digest::MD5: '2.11' + Digest::SHA1: '1.02' + requires: +diff --git a/Makefile.PL b/Makefile.PL +index a15243b..516b2f9 100644 +--- a/Makefile.PL ++++ b/Makefile.PL +@@ -41,7 +41,8 @@ WriteMakefile( + Crypt::DES => '2.03', # SNMPv3 + Digest::MD5 => '2.11', # SNMPv3 + Digest::SHA1 => '1.02', # SNMPv3 +- Digest::HMAC => '1.00', # SNMPv3 ++ Digest::HMAC_MD5 => '1.01', # SNMPv3 ++ Digest::HMAC_SHA1 => '1.03', # SNMPv3 + Socket => '2.000', + }, + dist => { +diff --git a/lib/Net/SNMP/Security/USM.pm b/lib/Net/SNMP/Security/USM.pm +index 4fb5742..0a2ab34 100644 +--- a/lib/Net/SNMP/Security/USM.pm ++++ b/lib/Net/SNMP/Security/USM.pm +@@ -26,7 +26,8 @@ use Net::SNMP::Message qw( + use Crypt::DES(); + use Digest::MD5(); + use Digest::SHA1(); +-use Digest::HMAC(); ++use Digest::HMAC_MD5(); ++use Digest::HMAC_SHA1(); + + ## Version of the Net::SNMP::Security::USM module + +@@ -1141,12 +1142,12 @@ sub _auth_data_init + if ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACMD5) { + + $this->{_auth_data} = +- Digest::HMAC->new($this->{_auth_key}, 'Digest::MD5'); ++ Digest::HMAC_MD5->new($this->{_auth_key}); + + } elsif ($this->{_auth_protocol} eq AUTH_PROTOCOL_HMACSHA) { + + $this->{_auth_data} = +- Digest::HMAC->new($this->{_auth_key}, 'Digest::SHA1'); ++ Digest::HMAC_SHA1->new($this->{_auth_key}); + + } else { + +-- +2.45.1 + diff --git a/perl-Net-SNMP.spec b/perl-Net-SNMP.spec index bbd7e2c..327972a 100644 --- a/perl-Net-SNMP.spec +++ b/perl-Net-SNMP.spec @@ -7,6 +7,7 @@ License: GPL-1.0-or-later OR Artistic-1.0-Perl URL: https://metacpan.org/release/Net-SNMP Source0: https://cpan.metacpan.org/authors/id/D/DT/DTOWN/Net-SNMP-v%{version}.tar.gz Patch0: Net-SNMP-v6.0.1-Switch_from_Socket6_to_Socket.patch +Patch1: Net-SNMP-v6.0.1-Simple_rewrite_to_Digest-HMAC-helpers.patch BuildArch: noarch BuildRequires: coreutils @@ -23,7 +24,8 @@ BuildRequires: perl(base) BuildRequires: perl(bytes) # Carp not used at tests # Crypt::DES 2.03 not used at tests -# Digest::HMAC 1.00 not used at tests +# Digest::HMAC_MD5 1.01 not used at tests +# Digest::HMAC_SHA1 1.03 not used at tests # Digest::MD5 2.11 not used at tests # Digest::SHA1 1.02 not used at tests BuildRequires: perl(Errno) @@ -38,14 +40,15 @@ BuildRequires: perl(Socket) BuildRequires: perl(Test) Requires: perl(Carp) Requires: perl(Crypt::DES) >= 2.03 -Requires: perl(Digest::HMAC) >= 1.00 +Requires: perl(Digest::HMAC_MD5) => 1.01 +Requires: perl(Digest::HMAC_SHA1) => 1.03 Requires: perl(Digest::MD5) >= 2.11 Requires: perl(Digest::SHA1) >= 1.02 # Optional run-time: # Crypt::Rijndael 1.02 # Filter under-specified dependencies -%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\((Crypt::DES|Digest::HMAC|Digest::MD5|Digest::SHA1)\\)$ +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\((Crypt::DES|Digest::HMAC_MD5|Digest::HMAC_SHA1|Digest::MD5|Digest::SHA1)\\)$ %description The Net::SNMP module implements an object oriented interface to the @@ -71,6 +74,7 @@ with "%{_libexecdir}/%{name}/test". %prep %setup -q -n Net-SNMP-v%{version} %patch -P0 -p1 +%patch -P1 -p1 perl -MConfig -pi -e 's|^#!.*perl|$Config{startperl}|' examples/*.pl chmod -c a-x examples/*.pl @@ -121,6 +125,7 @@ make test %changelog * Tue Jun 27 2024 Michal Josef Špaček - 6.0.1-42 +- Add patch to rewrite usage of HMAC with same dependencies - Improve patch for switch from Socket6 to Socket - Package tests - Rename patch to better name with source dist version