File Coverage

blib/lib/Crypt/OpenSSL/PKCS10.pm
Criterion Covered Total %
statement 30 30 100.0
branch 10 10 100.0
condition 2 3 66.6
subroutine 5 5 100.0
pod 2 2 100.0
total 49 50 98.0


line stmt bran cond sub pod time code
1             package Crypt::OpenSSL::PKCS10;
2              
3 4     4   846596 use 5.008000;
  4         13  
4 4     4   19 use strict;
  4         6  
  4         96  
5 4     4   15 use warnings;
  4         6  
  4         1655  
6             require Exporter;
7              
8             our @ISA = qw(Exporter);
9              
10             # Items to export into callers namespace by default. Note: do not export
11             # names by default without a very good reason. Use EXPORT_OK instead.
12             # Do not simply export all your public functions/methods/constants.
13              
14             # This allows declaration use Crypt::OpenSSL::PKCS10 ':all';
15             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
16             # will save memory.
17             our @NIDS = qw(
18             NID_key_usage NID_subject_alt_name NID_netscape_cert_type NID_netscape_comment
19             NID_ext_key_usage
20             );
21              
22             our %EXPORT_TAGS = (
23             'all' => [ @NIDS ],
24             'const' => [ @NIDS ],
25             );
26              
27             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
28              
29             #our @EXPORT = qw(
30            
31             #);
32              
33             our $VERSION = '0.37';
34              
35             require XSLoader;
36             XSLoader::load('Crypt::OpenSSL::PKCS10', $VERSION);
37              
38             # Preloaded methods go here.
39              
40             sub new_from_rsa {
41 2     2 1 85352 my $self = shift;
42 2         6 my $rsa = shift;
43 2   66     19 my ($options) = shift || ();
44              
45 2         298 my $priv = $rsa->get_private_key_string();
46 2         10 $self->_new_from_rsa($rsa, $priv, \%{$options});
  2         8307  
47              
48             }
49              
50             sub new {
51 36     36 1 1470370 my $self = shift;
52              
53 36         245 my $keylen;
54             my $options;
55              
56 36         153 my $args = scalar @_;
57              
58 36 100       469 if ($args eq 0) {
    100          
    100          
59 3         14 $keylen = 1024;
60             } elsif ($args eq 1) {
61 24 100       137 if (ref ($_[0]) eq 'HASH') {
62 19         49 $keylen = 1024;
63 19         46 ($options) = $_[0];
64             } else {
65 5         36 $keylen = $_[0];
66             }
67             } elsif ($args eq 2) {
68 7 100       77 if (ref $_[0] eq 'HASH') {
69 2         33 die('Wrong order for arguements: [$keysize], [%options]');
70             }
71 5         18 $keylen = $_[0];
72 5         28 ($options) = $_[1];
73             } else {
74 2         41 die ('Maximum 2 optional arguements [$keysize], [%options]');
75             }
76              
77 32         83 $self->_new($keylen, \%{$options});
  32         23314208  
78             }
79              
80             1;
81             __END__