File Coverage

blib/lib/Crypt/OpenSSL/RSA.pm
Criterion Covered Total %
statement 25 27 92.5
branch 7 8 87.5
condition n/a
subroutine 9 9 100.0
pod 4 4 100.0
total 45 48 93.7


line stmt bran cond sub pod time code
1             package Crypt::OpenSSL::RSA;
2              
3 4     4   688274 use strict;
  4         7  
  4         160  
4 4     4   21 use warnings;
  4         8  
  4         288  
5              
6 4     4   25 use Carp; # Removing carp will break the XS code.
  4         9  
  4         404  
7              
8             our $VERSION = '0.37';
9              
10 4     4   24 use XSLoader;
  4         8  
  4         355  
11             XSLoader::load 'Crypt::OpenSSL::RSA', $VERSION;
12              
13             BEGIN {
14 4     4   25 eval {
15 4         20 local $SIG{__DIE__}; # prevent outer handlers from being called
16 4         2212 require Crypt::OpenSSL::Bignum;
17             };
18             } ## no critic qw(RequireCheckingReturnValueOfEval);
19              
20             sub new_public_key {
21 4     4 1 603700 my ( $proto, $p_key_string ) = @_;
22 4 100       39 if ( $p_key_string =~ /^-----BEGIN RSA PUBLIC KEY-----/ ) {
    50          
23 3         4231 return $proto->_new_public_key_pkcs1($p_key_string);
24             }
25             elsif ( $p_key_string =~ /^-----BEGIN PUBLIC KEY-----/ ) {
26 1         1624 return $proto->_new_public_key_x509($p_key_string);
27             }
28             else {
29 0         0 croak "unrecognized key format";
30             }
31             }
32              
33             sub new_key_from_parameters {
34 8     8 1 244056 my ( $proto, $n, $e, $d, $p, $q ) = @_;
35 8 100       17 return $proto->_new_key_from_parameters( map { $_ ? $_->pointer_copy() : 0 } $n, $e, $d, $p, $q );
  40         20164  
36             }
37              
38             sub import_random_seed {
39 1     1 1 298754 until ( _random_status() ) {
40 0         0 _random_seed( Crypt::OpenSSL::Random::random_bytes(20) );
41             }
42             }
43              
44             sub get_key_parameters {
45 8 100   8 1 3003 return map { $_ ? Crypt::OpenSSL::Bignum->bless_pointer($_) : undef } shift->_get_key_parameters();
  64         171  
46             }
47              
48             1;
49              
50             __END__