line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Random::Provider::File; |
2
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
146
|
|
3
|
6
|
|
|
6
|
|
19
|
use Carp; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
289
|
|
4
|
6
|
|
|
6
|
|
28
|
use Math::Pari qw(pari2num); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
30
|
|
5
|
6
|
|
|
6
|
|
612
|
use Fcntl; |
|
6
|
|
|
|
|
55
|
|
|
6
|
|
|
|
|
3150
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub _defaultsource { |
8
|
0
|
|
|
0
|
|
0
|
return; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
|
14
|
1709
|
|
|
1709
|
0
|
298139
|
my ($class, %args) = @_; |
15
|
1709
|
|
33
|
|
|
8654
|
my $self = { Source => $args{File} || $args{Device} || $args{Filename} || $class->_defaultsource() }; |
16
|
1709
|
|
|
|
|
10924
|
return bless $self, $class; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_data { |
22
|
|
|
|
|
|
|
|
23
|
1709
|
|
|
1709
|
0
|
3996
|
my ($self, %params) = @_; |
24
|
1709
|
50
|
|
|
|
2737
|
$self = {} unless ref $self; |
25
|
|
|
|
|
|
|
|
26
|
1709
|
|
|
|
|
2014
|
my $size = $params{Size}; |
27
|
1709
|
|
50
|
|
|
5025
|
my $skip = $params{Skip} || $$self{Skip} || ''; |
28
|
1709
|
|
|
|
|
2236
|
my $q_skip = quotemeta($skip); |
29
|
|
|
|
|
|
|
|
30
|
1709
|
50
|
66
|
|
|
4034
|
if ($size && ref $size eq "Math::Pari") { |
31
|
0
|
|
|
|
|
0
|
$size = pari2num($size); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1709
|
|
66
|
|
|
4919
|
my $bytes = $params{Length} || (int($size / 8) + 1); |
35
|
|
|
|
|
|
|
|
36
|
1709
|
|
|
|
|
47071
|
sysopen RANDOM, $$self{Source}, O_RDONLY; |
37
|
|
|
|
|
|
|
|
38
|
1709
|
|
|
|
|
6462
|
my($r, $read, $rt) = ('', 0); |
39
|
1709
|
|
|
|
|
3287
|
while ($read < $bytes) { |
40
|
1742
|
|
|
|
|
10875
|
my $howmany = sysread RANDOM, $rt, $bytes - $read; |
41
|
1742
|
50
|
|
|
|
3517
|
next unless $howmany; |
42
|
1742
|
50
|
|
|
|
2443
|
if ($howmany == -1) { |
43
|
0
|
|
|
|
|
0
|
croak "Error while reading from $$self{Source}. $!" |
44
|
|
|
|
|
|
|
} |
45
|
1742
|
100
|
|
|
|
2526
|
$rt =~ s/[$q_skip]//g if $skip; |
46
|
1742
|
|
|
|
|
2693
|
$r .= $rt; |
47
|
1742
|
|
|
|
|
2872
|
$read = length $r; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
1709
|
|
|
|
|
6289
|
$r; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub available { |
56
|
705
|
|
|
705
|
0
|
1212
|
my ($class) = @_; |
57
|
705
|
|
|
|
|
1393
|
return -e $class->_defaultsource(); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|