line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Random::Source; # git description: v0.10-12-g08685fe |
2
|
|
|
|
|
|
|
# ABSTRACT: Get weak or strong random data from pluggable sources |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
22834
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
20
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
12
|
use Sub::Exporter -setup => { |
11
|
|
|
|
|
|
|
exports => [qw( |
12
|
|
|
|
|
|
|
get get_weak get_strong |
13
|
|
|
|
|
|
|
factory |
14
|
|
|
|
|
|
|
)], |
15
|
|
|
|
|
|
|
groups => { default => [qw(get get_weak get_strong)] }, |
16
|
1
|
|
|
1
|
|
903
|
}; |
|
1
|
|
|
|
|
14838
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
1076
|
use Crypt::Random::Source::Factory; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
379
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our ( $factory, $weak, $strong, $any ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# silence some stupid destructor warnings |
23
|
1
|
|
|
1
|
|
2
|
END { undef $weak; undef $strong; undef $any; undef $factory } |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
33
|
1
|
0
|
18
|
sub factory () { $factory ||= Crypt::Random::Source::Factory->new } |
26
|
1
|
|
33
|
1
|
|
8
|
sub _weak () { $weak ||= factory->get_weak } |
27
|
0
|
|
0
|
0
|
|
0
|
sub _strong () { $strong ||= factory->get_strong } |
28
|
0
|
|
0
|
0
|
|
0
|
sub _any () { $any ||= factory->get } |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
0
|
sub get ($;@) { _any->get(@_) } |
31
|
1
|
|
|
1
|
1
|
706
|
sub get_weak ($;@) { _weak->get(@_) } |
32
|
0
|
|
|
0
|
1
|
|
sub get_strong ($;@) { _strong->get(@_) } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# silence some stupid destructor warnings |
35
|
1
|
|
|
1
|
|
112
|
END { undef $weak; undef $strong; undef $any; undef $factory } |
|
1
|
|
|
|
|
385
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=encoding UTF-8 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Crypt::Random::Source - Get weak or strong random data from pluggable sources |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
version 0.11 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
use Crypt::Random::Source qw(get_strong); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# get 10 cryptographically strong random bytes from an available source |
56
|
|
|
|
|
|
|
my $bytes = get_strong(10); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This module provides implementations for a number of byte oriented sources of |
61
|
|
|
|
|
|
|
random data. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See L for a more powerful way to locate |
64
|
|
|
|
|
|
|
sources, and the various sources for specific implementations. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 EXPORTS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item get |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item get_weak |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item get_strong |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
These functions delegate to a source chosen by an instance of |
77
|
|
|
|
|
|
|
L, calling get |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L, L |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SUPPORT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Bugs may be submitted through L |
88
|
|
|
|
|
|
|
(or L). |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=for stopwords Karen Etheridge Florian Ragwitz Graham Knop David Pottage Max Kanat-Alexander |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Karen Etheridge |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Florian Ragwitz |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Graham Knop |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
David Pottage |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Max Kanat-Alexander |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Yuval Kogman. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |