Skip Menu |

This queue is for tickets about the Crypt-RSA CPAN distribution.

Report information
The Basics
Id: 64883
Status: new
Priority: 0/
Queue: Crypt-RSA

People
Owner: Nobody in particular
Requestors: aff [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.99
Fixed in: (no value)



Subject: Make errstr from check after write more intuitive
Crypt::RSA::Key::Private::check will fail and yield a rather confusing "n is not a number" error message if Crypt::RSA::Key::Private::write is called. While the fact that write() calls hide() is documented, I think it is confusing to novice users that a call to write() disqualifies the object reference from further use. I suggest the attached simple patch which changes the error message to "Cannot check hidden key - call reveal first." to allow non-expert users to understand the inner workings of Crypt::RSA::Key::Private better. # check.pl use strict; use warnings; use Crypt::RSA; my $rsa = new Crypt::RSA; my ($public, $private) = $rsa->keygen( Identity => 'Lord Macbeth <macbeth@glamis.com>', Size => 1024, Password => 'A day so foul & fair', Verbosity => 0, ) or die $rsa->errstr(); $private->write(Filename => 'rsakey-secure.private'); $private->check or die $private->errstr(); __END__ $ perl check.pl n is not a number. # Apply patch $ perl check.pl Cannot check hidden key - call reveal first.
Subject: Private.pm.patch
--- /opt/perl/lib/site_perl/5.10.0/Crypt/RSA/Key/Private.pm 2009-06-07 02:22:38.000000000 +0200 +++ /opt/perl/lib/site_perl/5.10.0/Crypt/RSA/Key/Private.pm.new 2011-01-18 13:50:40.000000000 +0100 @@ -86,6 +86,7 @@ delete $$self{private}; delete $$self{Password}; + $self->{Hidden} = 1; } @@ -99,6 +100,7 @@ $$self{private}{$_} = PARI($$self{private_encrypted}{$_}); } + $self->{Hidden} = 0; } @@ -106,6 +108,8 @@ my ($self) = @_; + return $self->error ("Cannot check hidden key - call reveal first.") + if $self->{Hidden}; return 1 if $self->{Checked}; return $self->error ("Incomplete key.") unless