line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
274201
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
149
|
|
2
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
206
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::Key; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Key object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
20
|
use Carp; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
306
|
|
10
|
4
|
|
|
4
|
|
2377
|
use Moo; |
|
4
|
|
|
|
|
317343
|
|
|
4
|
|
|
|
|
23
|
|
11
|
4
|
|
|
4
|
|
2370021
|
use Types::Standard qw( Str InstanceOf Int ); |
|
4
|
|
|
|
|
5095347
|
|
|
4
|
|
|
|
|
39
|
|
12
|
4
|
|
|
4
|
|
4346
|
use Path::Tiny; |
|
4
|
|
|
|
|
22565
|
|
|
4
|
|
|
|
|
342
|
|
13
|
4
|
|
|
4
|
|
92309
|
use Capture::Tiny qw( :all ); |
|
4
|
|
|
|
|
5045988
|
|
|
4
|
|
|
|
|
831
|
|
14
|
4
|
|
|
4
|
|
2112
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1292
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Tiny::OpenSSL::Role::Entity'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has password => ( is => 'rw', isa => Str ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has bits => |
21
|
|
|
|
|
|
|
( is => 'rw', isa => Int, default => sub { $CONFIG->{key}{bits} } ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub create { |
24
|
4
|
|
|
4
|
1
|
3668
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
4
|
|
|
|
|
9
|
my @args = @{ $CONFIG->{key}{opts} }; |
|
4
|
|
|
|
|
22
|
|
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
11
|
my $pass_file; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
|
|
|
65
|
if ( $self->password ) { |
31
|
4
|
|
|
|
|
1163
|
$pass_file = Path::Tiny->tempfile; |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
1902
|
$pass_file->spew( $self->password ); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
36848
|
push( @args, '-passout', sprintf( 'file:%s', $pass_file ) ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
50
|
push( @args, '-out', $self->file ); |
39
|
4
|
|
|
|
|
2033
|
push( @args, $self->bits ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
42
|
4
|
|
|
4
|
|
1514895
|
system( $CONFIG->{openssl}, @args ); |
43
|
4
|
|
|
|
|
1967
|
}; |
44
|
|
|
|
|
|
|
|
45
|
4
|
50
|
|
|
|
177098
|
if ( $exit != 0 ) { |
46
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot create key: %s', $stderr ) ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
62
|
$self->ascii( $self->file->slurp ); |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
4007
|
return 1; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |