[packages/perl-Crypt-OpenPGP] - Pari is broken; don't use it if there are other alternatives - use Crypt::OpenSSL::Random if avail

adwol adwol at pld-linux.org
Sat Sep 29 13:09:03 CEST 2018


commit 5ecac8fd7c760cf0003252f7b055e85a1eb6d056
Author: Adam Osuchowski <adwol at pld-linux.org>
Date:   Sat Sep 29 13:06:45 2018 +0200

    - Pari is broken; don't use it if there are other alternatives
    - use Crypt::OpenSSL::Random if available
    - add /usr/bin/pgplet
    - rel 2

 perl-Crypt-OpenPGP-openssl.patch | 42 ++++++++++++++++++++++++++++++++++++++++
 perl-Crypt-OpenPGP.spec          |  5 ++++-
 2 files changed, 46 insertions(+), 1 deletion(-)
---
diff --git a/perl-Crypt-OpenPGP.spec b/perl-Crypt-OpenPGP.spec
index 3e62300..0a0fc05 100644
--- a/perl-Crypt-OpenPGP.spec
+++ b/perl-Crypt-OpenPGP.spec
@@ -9,12 +9,13 @@ Summary:	Crypt::OpenPGP Perl module - pure Perl implementation of the OpenPGP st
 Summary(pl.UTF-8):	Moduł Perla Crypt::OpenPGP - czysto perlowa implementacja standardu OpenPGP
 Name:		perl-Crypt-OpenPGP
 Version:	1.12
-Release:	1
+Release:	2
 # same as perl
 License:	GPL v1+ or Artistic
 Group:		Development/Languages/Perl
 Source0:	http://www.cpan.org/modules/by-module/%{pdir}/%{pdir}-%{pnam}-%{version}.tar.gz
 # Source0-md5:	ab55adcc68487b36d8146fa6081f9997
+Patch0:		%{name}-openssl.patch
 URL:		http://search.cpan.org/dist/Crypt-OpenPGP/
 BuildRequires:	perl-Crypt-DSA
 BuildRequires:	perl-Crypt-RSA
@@ -64,6 +65,7 @@ Crypt::RIPEMD160 dla RIPE-MD/160).
 
 %prep
 %setup -q -n %{pdir}-%{pnam}-%{version}
+%patch0 -p1
 
 %build
 %{__perl} Makefile.PL </dev/null \
@@ -83,6 +85,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
+%attr(755,root,root) %{_bindir}/pgplet
 %doc Changes README
 %{perl_vendorlib}/Crypt/OpenPGP.pm
 %{perl_vendorlib}/Crypt/OpenPGP
diff --git a/perl-Crypt-OpenPGP-openssl.patch b/perl-Crypt-OpenPGP-openssl.patch
new file mode 100644
index 0000000..2d2d547
--- /dev/null
+++ b/perl-Crypt-OpenPGP-openssl.patch
@@ -0,0 +1,42 @@
+diff -ruN Crypt-OpenPGP-1.12.orig/lib/Crypt/OpenPGP/Util.pm Crypt-OpenPGP-1.12/lib/Crypt/OpenPGP/Util.pm
+--- Crypt-OpenPGP-1.12.orig/lib/Crypt/OpenPGP/Util.pm	2015-08-16 13:28:26.000000000 +0200
++++ Crypt-OpenPGP-1.12/lib/Crypt/OpenPGP/Util.pm	2018-09-29 13:02:24.187621578 +0200
+@@ -2,7 +2,7 @@
+ use strict;
+ 
+ # For some reason, FastCalc causes problems. Restrict to one of these 3 backends
+-use Math::BigInt only => 'Pari,GMP,Calc';
++use Math::BigInt only => 'GMP,Calc';
+ 
+ use vars qw( @EXPORT_OK @ISA );
+ use Exporter;
+@@ -101,7 +101,10 @@
+ 
+ sub get_random_bytes {
+ 	my $length = shift;
+-	if (eval 'require Crypt::Random; 1;') {
++	if (eval 'require Crypt::OpenSSL::Random; 1;') {
++		return Crypt::OpenSSL::Random::random_bytes($length);
++	}
++	elsif (eval 'require Crypt::Random; 1;') {
+ 		return Crypt::Random::makerandom_octet( Length => $length);
+ 	}
+ 	elsif (eval 'require Bytes::Random::Secure; 1;') {
+@@ -114,7 +117,16 @@
+ 
+ sub get_random_bigint {
+ 	my $bits = shift;
+-	if (eval 'require Crypt::Random; 1;') {
++	if (eval 'require Crypt::OpenSSL::Random; 1;') {
++		my $hex = unpack('H*', Crypt::OpenSSL::Random::random_bytes(int(($bits + 7) / 8));
++		my $val = Math::BigInt->new("0x$hex");
++		# Get exactly the correct number of bits.
++		$val->brsft(8 - ($bits & 7)) if ($bits & 7);
++		# Make sure the top bit is set.
++		$val->bior(Math::BigInt->bone->blsft($bits-1));
++		return $val;
++        }
++	elsif (eval 'require Crypt::Random; 1;') {
+ 		my $pari = Crypt::Random::makerandom( Size => $bits, Strength => 0 );
+ 		return Math::BigInt->new($pari);
+ 	}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/perl-Crypt-OpenPGP.git/commitdiff/5ecac8fd7c760cf0003252f7b055e85a1eb6d056



More information about the pld-cvs-commit mailing list