| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Archive::BagIt::Role::OpenSSL::Async; |
|
2
|
13
|
|
|
13
|
|
277997
|
use strict; |
|
|
13
|
|
|
|
|
29
|
|
|
|
13
|
|
|
|
|
556
|
|
|
3
|
13
|
|
|
13
|
|
64
|
use warnings; |
|
|
13
|
|
|
|
|
27
|
|
|
|
13
|
|
|
|
|
608
|
|
|
4
|
13
|
|
|
13
|
|
1187
|
use Moo; |
|
|
13
|
|
|
|
|
18583
|
|
|
|
13
|
|
|
|
|
86
|
|
|
5
|
13
|
|
|
13
|
|
9893
|
use namespace::autoclean; |
|
|
13
|
|
|
|
|
51512
|
|
|
|
13
|
|
|
|
|
95
|
|
|
6
|
13
|
|
|
13
|
|
13667
|
use IO::Async::Loop; |
|
|
13
|
|
|
|
|
524859
|
|
|
|
13
|
|
|
|
|
581
|
|
|
7
|
13
|
|
|
13
|
|
9518
|
use IO::Async::Stream; |
|
|
13
|
|
|
|
|
637149
|
|
|
|
13
|
|
|
|
|
599
|
|
|
8
|
13
|
|
|
13
|
|
9767
|
use Net::SSLeay (); |
|
|
13
|
|
|
|
|
156157
|
|
|
|
13
|
|
|
|
|
998
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.101'; # VERSION |
|
10
|
|
|
|
|
|
|
# ABSTRACT: handles asynchronous digest calculation using openssl |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BEGIN { |
|
13
|
13
|
|
|
13
|
|
1993
|
Net::SSLeay::OpenSSL_add_all_digests(); |
|
14
|
13
|
|
|
|
|
6007
|
is => 'rw', |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'name' => ( |
|
19
|
|
|
|
|
|
|
required => 1, |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has '_io_loop' => ( |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
lazy => 1, |
|
26
|
|
|
|
|
|
|
default => sub { |
|
27
|
|
|
|
|
|
|
IO::Async::Loop->new |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has '_digest' => ( |
|
32
|
|
|
|
|
|
|
is => 'ro', |
|
33
|
|
|
|
|
|
|
lazy => 1, |
|
34
|
|
|
|
|
|
|
builder => '_init_digest', |
|
35
|
|
|
|
|
|
|
init_arg => undef, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _init_digest { |
|
39
|
540
|
|
|
540
|
|
6363
|
my ($self) = @_; |
|
40
|
540
|
|
|
|
|
4082
|
my $md = Net::SSLeay::EVP_get_digestbyname($self->name); |
|
41
|
540
|
|
|
|
|
1474
|
my $digest = Net::SSLeay::EVP_MD_CTX_create(); |
|
42
|
540
|
|
|
|
|
25181
|
Net::SSLeay::EVP_DigestInit($digest, $md); |
|
43
|
540
|
|
|
|
|
6909
|
return $digest; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub calc_digest { |
|
49
|
540
|
|
|
540
|
0
|
1188
|
my ($self, $fh, $blksize)=@_; |
|
50
|
540
|
|
|
|
|
11798
|
my $loop = $self->_io_loop(); |
|
51
|
|
|
|
|
|
|
my $stream = IO::Async::Stream->new( |
|
52
|
|
|
|
|
|
|
read_handle => $fh, |
|
53
|
|
|
|
|
|
|
read_len => 1000 * $blksize, |
|
54
|
|
|
|
|
|
|
on_read => sub { |
|
55
|
1074
|
|
|
1074
|
|
221875
|
my ($s, $buffref, $eof) = @_; |
|
56
|
1074
|
100
|
|
|
|
3034
|
if (defined $$buffref) { |
|
57
|
540
|
|
|
|
|
17826
|
Net::SSLeay::EVP_DigestUpdate($self->_digest, $$buffref); |
|
58
|
540
|
|
|
|
|
926
|
$$buffref = undef; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
1074
|
|
|
|
|
3638
|
return 0; |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
|
|
|
|
|
|
on_read_eof => sub { |
|
63
|
540
|
|
|
540
|
|
16074
|
$loop->stop(); |
|
64
|
|
|
|
|
|
|
}, |
|
65
|
|
|
|
|
|
|
close_on_read_eof => 0, |
|
66
|
|
|
|
|
|
|
on_error => sub { |
|
67
|
0
|
|
|
0
|
|
0
|
croak (@_); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
540
|
|
|
|
|
62324
|
); |
|
70
|
540
|
|
|
|
|
113388
|
$loop->add($stream); |
|
71
|
540
|
|
|
|
|
137676
|
$loop->run(); |
|
72
|
540
|
|
|
|
|
28680
|
$loop->remove($stream); |
|
73
|
540
|
|
|
|
|
122870
|
my $result = Net::SSLeay::EVP_DigestFinal($self->_digest); |
|
74
|
540
|
|
|
|
|
17689
|
Net::SSLeay::EVP_MD_CTX_destroy($self->_digest); |
|
75
|
540
|
|
|
|
|
4266
|
delete $self->{_digest}; |
|
76
|
540
|
|
|
|
|
11611
|
return unpack('H*', $result); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
13
|
|
|
13
|
|
147
|
no Moo; |
|
|
13
|
|
|
|
|
59
|
|
|
|
13
|
|
|
|
|
120
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |