line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
81854
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
135
|
|
2
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
286
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::Key; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Key object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.3'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
26
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
391
|
|
10
|
5
|
|
|
5
|
|
3525
|
use Moo; |
|
5
|
|
|
|
|
60381
|
|
|
5
|
|
|
|
|
29
|
|
11
|
5
|
|
|
5
|
|
9855
|
use Types::Standard qw( Str InstanceOf Int ); |
|
5
|
|
|
|
|
449455
|
|
|
5
|
|
|
|
|
67
|
|
12
|
5
|
|
|
5
|
|
6874
|
use Path::Tiny; |
|
5
|
|
|
|
|
18956
|
|
|
5
|
|
|
|
|
343
|
|
13
|
5
|
|
|
5
|
|
3433
|
use Capture::Tiny qw( :all ); |
|
5
|
|
|
|
|
112968
|
|
|
5
|
|
|
|
|
795
|
|
14
|
5
|
|
|
5
|
|
2165
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
2241
|
|
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
|
7
|
|
|
7
|
1
|
5118
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
|
|
19
|
my @args = @{ $CONFIG->{key}{opts} }; |
|
7
|
|
|
|
|
46
|
|
27
|
|
|
|
|
|
|
|
28
|
7
|
100
|
66
|
|
|
35
|
if ( -f $self->file && $self->file->lines > 0 ) { |
29
|
1
|
|
|
|
|
260
|
$self->load; |
30
|
1
|
|
|
|
|
5
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
3900
|
my $pass_file; |
34
|
|
|
|
|
|
|
|
35
|
6
|
100
|
|
|
|
98
|
if ( $self->password ) { |
36
|
4
|
|
|
|
|
1188
|
$pass_file = Path::Tiny->tempfile; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
1827
|
$pass_file->spew( $self->password ); |
39
|
4
|
|
|
|
|
1837
|
push( @args, sprintf( '-%s', $CONFIG->{key}{block_cipher} ) ); |
40
|
4
|
|
|
|
|
24
|
push( @args, '-passout', sprintf( 'file:%s', $pass_file ) ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
622
|
push( @args, '-out', $self->file ); |
44
|
6
|
|
|
|
|
245
|
push( @args, $self->bits ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
47
|
6
|
|
|
6
|
|
4853357
|
system( $CONFIG->{openssl}, @args ); |
48
|
6
|
|
|
|
|
2690
|
}; |
49
|
|
|
|
|
|
|
|
50
|
6
|
50
|
|
|
|
10214
|
if ( $exit != 0 ) { |
51
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot create key: %s', $stderr ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
6
|
|
|
|
|
371
|
$self->ascii( $self->file->slurp ); |
55
|
|
|
|
|
|
|
|
56
|
6
|
|
|
|
|
9120
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |