line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::BagIt::Role::OpenSSL::Sync; |
2
|
8
|
|
|
8
|
|
54
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
287
|
|
3
|
8
|
|
|
8
|
|
49
|
use warnings FATAL => 'all'; |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
434
|
|
4
|
8
|
|
|
8
|
|
52
|
use Moo; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
50
|
|
5
|
8
|
|
|
8
|
|
2717
|
use namespace::autoclean; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
48
|
|
6
|
8
|
|
|
8
|
|
5978
|
use Net::SSLeay (); |
|
8
|
|
|
|
|
104408
|
|
|
8
|
|
|
|
|
495
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.095'; # VERSION |
8
|
|
|
|
|
|
|
# ABSTRACT: handles synchronous digest calculation using openssl |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub BEGIN { |
11
|
8
|
|
|
8
|
|
2464
|
Net::SSLeay::OpenSSL_add_all_digests(); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'name' => ( |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '_digest' => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
lazy => 1, |
22
|
|
|
|
|
|
|
builder => '_init_digest', |
23
|
|
|
|
|
|
|
init_arg => undef, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _init_digest { |
27
|
549
|
|
|
549
|
|
4088
|
my ($self) = @_; |
28
|
549
|
|
|
|
|
2184
|
my $md = Net::SSLeay::EVP_get_digestbyname($self->name); |
29
|
549
|
|
|
|
|
1081
|
my $digest = Net::SSLeay::EVP_MD_CTX_create(); |
30
|
549
|
|
|
|
|
1706
|
Net::SSLeay::EVP_DigestInit($digest, $md); |
31
|
549
|
|
|
|
|
3143
|
return $digest; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub calc_digest { |
35
|
549
|
|
|
549
|
0
|
948
|
my ($self, $fh, $blksize)=@_; |
36
|
549
|
|
|
|
|
696
|
my $buffer; |
37
|
549
|
|
|
|
|
10006
|
while (read($fh, $buffer, $blksize)) { |
38
|
543
|
|
|
|
|
12285
|
Net::SSLeay::EVP_DigestUpdate($self->_digest(), $buffer); |
39
|
|
|
|
|
|
|
} |
40
|
549
|
|
|
|
|
9215
|
my $result = Net::SSLeay::EVP_DigestFinal($self->_digest); |
41
|
549
|
|
|
|
|
12634
|
Net::SSLeay::EVP_MD_CTX_destroy($self->_digest); |
42
|
549
|
|
|
|
|
3820
|
delete $self->{_digest}; |
43
|
549
|
|
|
|
|
2888
|
return unpack('H*', $result); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
8
|
|
|
8
|
|
95
|
no Moo; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
57
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |