line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
54
|
|
|
54
|
|
1129566
|
use strict; |
|
54
|
|
|
|
|
122
|
|
|
54
|
|
|
|
|
1419
|
|
2
|
54
|
|
|
54
|
|
278
|
use warnings; |
|
54
|
|
|
|
|
91
|
|
|
54
|
|
|
|
|
3607
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#ABSTRACT: NaCl compatible modern, easy-to-use library for encryption, decryption, signatures, password hashing and more |
5
|
|
|
|
|
|
|
package Crypt::NaCl::Sodium; |
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:AJGB'; |
7
|
|
|
|
|
|
|
$Crypt::NaCl::Sodium::VERSION = '1.0.7.0'; |
8
|
54
|
|
|
54
|
|
279
|
use Carp qw( croak ); |
|
54
|
|
|
|
|
103
|
|
|
54
|
|
|
|
|
3663
|
|
9
|
54
|
|
|
54
|
|
47155
|
use Sub::Exporter; |
|
54
|
|
|
|
|
742907
|
|
|
54
|
|
|
|
|
342
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require XSLoader; |
12
|
|
|
|
|
|
|
XSLoader::load('Crypt::NaCl::Sodium', $Crypt::NaCl::Sodium::{VERSION} ? |
13
|
|
|
|
|
|
|
${ $Crypt::NaCl::Sodium::{VERSION} } : () |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @funcs = qw( |
17
|
|
|
|
|
|
|
bin2hex hex2bin |
18
|
|
|
|
|
|
|
memcmp compare memzero |
19
|
|
|
|
|
|
|
increment |
20
|
|
|
|
|
|
|
random_bytes |
21
|
|
|
|
|
|
|
random_number |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Sub::Exporter::setup_exporter( |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
exports => \@funcs, |
27
|
|
|
|
|
|
|
groups => { |
28
|
|
|
|
|
|
|
all => \@funcs, |
29
|
|
|
|
|
|
|
utils => \@funcs, |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
1
|
|
|
1
|
1
|
17
|
my ($proto, $submodule) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
4
|
if ( ! $submodule ) { |
38
|
1
|
|
|
|
|
2
|
my $o = 0; |
39
|
1
|
|
|
|
|
5
|
return bless \$o, $proto; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
0
|
if ( my $m = $proto->can($submodule) ) { |
43
|
0
|
|
|
|
|
0
|
return $m->(); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
croak "Unknown submodule $submodule\n"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub secretbox { |
50
|
5
|
|
|
5
|
1
|
399
|
return Crypt::NaCl::Sodium::secretbox->new(); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub auth { |
54
|
8
|
|
|
8
|
1
|
718
|
return Crypt::NaCl::Sodium::auth->new(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub aead { |
58
|
6
|
|
|
6
|
1
|
1108
|
return Crypt::NaCl::Sodium::aead->new(); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub box { |
62
|
5
|
|
|
5
|
1
|
407
|
return Crypt::NaCl::Sodium::box->new(); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub sign { |
66
|
4
|
|
|
4
|
1
|
363
|
return Crypt::NaCl::Sodium::sign->new(); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub generichash { |
70
|
5
|
|
|
5
|
1
|
419
|
return Crypt::NaCl::Sodium::generichash->new(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub shorthash { |
74
|
4
|
|
|
4
|
1
|
368
|
return Crypt::NaCl::Sodium::shorthash->new(); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub pwhash { |
78
|
4
|
|
|
4
|
1
|
362
|
return Crypt::NaCl::Sodium::pwhash->new(); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub hash { |
82
|
8
|
|
|
8
|
1
|
453
|
return Crypt::NaCl::Sodium::hash->new(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub onetimeauth { |
86
|
5
|
|
|
5
|
1
|
655
|
return Crypt::NaCl::Sodium::onetimeauth->new(); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub scalarmult { |
90
|
5
|
|
|
5
|
1
|
36261
|
return Crypt::NaCl::Sodium::scalarmult->new(); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub stream { |
94
|
8
|
|
|
8
|
1
|
422
|
return Crypt::NaCl::Sodium::stream->new(); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
package |
98
|
|
|
|
|
|
|
Data::BytesLocker; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
our $DEFAULT_LOCKED = 0; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
package |
103
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::secretbox; |
104
|
|
|
|
|
|
|
|
105
|
5
|
|
|
5
|
|
25
|
sub new { return bless {}, __PACKAGE__ } |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package |
108
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::auth; |
109
|
|
|
|
|
|
|
|
110
|
8
|
|
|
8
|
|
37
|
sub new { return bless {}, __PACKAGE__ } |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
package |
113
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::aead; |
114
|
|
|
|
|
|
|
|
115
|
6
|
|
|
6
|
|
31
|
sub new { return bless {}, __PACKAGE__ } |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
package |
118
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::box; |
119
|
|
|
|
|
|
|
|
120
|
5
|
|
|
5
|
|
25
|
sub new { return bless {}, __PACKAGE__ } |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
package |
123
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::sign; |
124
|
|
|
|
|
|
|
|
125
|
4
|
|
|
4
|
|
18
|
sub new { return bless {}, __PACKAGE__ } |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package |
128
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::generichash; |
129
|
|
|
|
|
|
|
|
130
|
5
|
|
|
5
|
|
25
|
sub new { return bless {}, __PACKAGE__ } |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
package |
133
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::shorthash; |
134
|
|
|
|
|
|
|
|
135
|
4
|
|
|
4
|
|
16
|
sub new { return bless {}, __PACKAGE__ } |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
package |
138
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::pwhash; |
139
|
|
|
|
|
|
|
|
140
|
4
|
|
|
4
|
|
19
|
sub new { return bless {}, __PACKAGE__ } |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
package |
143
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::hash; |
144
|
|
|
|
|
|
|
|
145
|
8
|
|
|
8
|
|
53
|
sub new { return bless {}, __PACKAGE__ } |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
package |
148
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::onetimeauth; |
149
|
|
|
|
|
|
|
|
150
|
5
|
|
|
5
|
|
24
|
sub new { return bless {}, __PACKAGE__ } |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
package |
153
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::scalarmult; |
154
|
|
|
|
|
|
|
|
155
|
5
|
|
|
5
|
|
24
|
sub new { return bless {}, __PACKAGE__ } |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
package |
158
|
|
|
|
|
|
|
Crypt::NaCl::Sodium::stream; |
159
|
|
|
|
|
|
|
|
160
|
8
|
|
|
8
|
|
34
|
sub new { return bless {}, __PACKAGE__ } |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |