| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::NaCl::Tweet; |
|
2
|
8
|
|
|
8
|
|
920201
|
use strict; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
285
|
|
|
3
|
8
|
|
|
8
|
|
35
|
use warnings; |
|
|
8
|
|
|
|
|
53
|
|
|
|
8
|
|
|
|
|
745
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
8
|
|
|
8
|
|
31
|
our $VERSION = '0.06'; |
|
6
|
8
|
|
|
|
|
35
|
require XSLoader; |
|
7
|
8
|
|
|
|
|
5792
|
XSLoader::load(__PACKAGE__, $VERSION); |
|
8
|
|
|
|
|
|
|
} |
|
9
|
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
66
|
use Exporter 'import'; |
|
|
8
|
|
|
|
|
30
|
|
|
|
8
|
|
|
|
|
2030
|
|
|
11
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
12
|
|
|
|
|
|
|
box => [qw[ |
|
13
|
|
|
|
|
|
|
box_PRIMITIVE |
|
14
|
|
|
|
|
|
|
box_PUBLICKEYBYTES |
|
15
|
|
|
|
|
|
|
box_SECRETKEYBYTES |
|
16
|
|
|
|
|
|
|
box_BEFORENMBYTES |
|
17
|
|
|
|
|
|
|
box_NONCEBYTES |
|
18
|
|
|
|
|
|
|
box_ZEROBYTES |
|
19
|
|
|
|
|
|
|
box_BOXZEROBYTES |
|
20
|
|
|
|
|
|
|
box |
|
21
|
|
|
|
|
|
|
box_afternm |
|
22
|
|
|
|
|
|
|
box_beforenm |
|
23
|
|
|
|
|
|
|
box_keypair |
|
24
|
|
|
|
|
|
|
box_open |
|
25
|
|
|
|
|
|
|
box_open_afternm |
|
26
|
|
|
|
|
|
|
]], |
|
27
|
|
|
|
|
|
|
core => [qw[ |
|
28
|
|
|
|
|
|
|
core_hsalsa20_CONTSBYTES |
|
29
|
|
|
|
|
|
|
core_hsalsa20_KEYBYTES |
|
30
|
|
|
|
|
|
|
core_hsalsa20_INPUTBYTES |
|
31
|
|
|
|
|
|
|
core_hsalsa20_OUTPUTBYTES |
|
32
|
|
|
|
|
|
|
core_salsa20_CONTSBYTES |
|
33
|
|
|
|
|
|
|
core_salsa20_KEYBYTES |
|
34
|
|
|
|
|
|
|
core_salsa20_INPUTBYTES |
|
35
|
|
|
|
|
|
|
core_salsa20_OUTPUTBYTES |
|
36
|
|
|
|
|
|
|
core_hsalsa20 |
|
37
|
|
|
|
|
|
|
core_salsa20 |
|
38
|
|
|
|
|
|
|
]], |
|
39
|
|
|
|
|
|
|
hash => [qw[ |
|
40
|
|
|
|
|
|
|
hash_BYTES |
|
41
|
|
|
|
|
|
|
hash_PRIMITIVE |
|
42
|
|
|
|
|
|
|
hash |
|
43
|
|
|
|
|
|
|
]], |
|
44
|
|
|
|
|
|
|
hashblocks => [qw[ |
|
45
|
|
|
|
|
|
|
hashblocks_BLOCKBYTES |
|
46
|
|
|
|
|
|
|
hashblocks_PRIMITIVE |
|
47
|
|
|
|
|
|
|
hashblocks |
|
48
|
|
|
|
|
|
|
]], |
|
49
|
|
|
|
|
|
|
onetimeauth => [qw[ |
|
50
|
|
|
|
|
|
|
onetimeauth_BYTES |
|
51
|
|
|
|
|
|
|
onetimeauth_KEYBYTES |
|
52
|
|
|
|
|
|
|
onetimeauth_PRIMITIVE |
|
53
|
|
|
|
|
|
|
onetimeauth |
|
54
|
|
|
|
|
|
|
onetimeauth_keygen |
|
55
|
|
|
|
|
|
|
onetimeauth_verify |
|
56
|
|
|
|
|
|
|
]], |
|
57
|
|
|
|
|
|
|
random => [qw[ random_bytes ]], |
|
58
|
|
|
|
|
|
|
secretbox => [qw[ |
|
59
|
|
|
|
|
|
|
secretbox_KEYBYTES |
|
60
|
|
|
|
|
|
|
secretbox_NONCEBYTES |
|
61
|
|
|
|
|
|
|
secretbox_PRIMITIVE |
|
62
|
|
|
|
|
|
|
secretbox_ZEROBYTES |
|
63
|
|
|
|
|
|
|
secretbox_BOXZEROBYTES |
|
64
|
|
|
|
|
|
|
secretbox |
|
65
|
|
|
|
|
|
|
secretbox_open |
|
66
|
|
|
|
|
|
|
]], |
|
67
|
|
|
|
|
|
|
scalarmult => [qw[ |
|
68
|
|
|
|
|
|
|
scalarmult_BYTES |
|
69
|
|
|
|
|
|
|
scalarmult_PRIMITIVE |
|
70
|
|
|
|
|
|
|
scalarmult_SCALARBYTES |
|
71
|
|
|
|
|
|
|
scalarmult |
|
72
|
|
|
|
|
|
|
scalarmult_base |
|
73
|
|
|
|
|
|
|
]], |
|
74
|
|
|
|
|
|
|
sign => [qw[ |
|
75
|
|
|
|
|
|
|
sign_BYTES |
|
76
|
|
|
|
|
|
|
sign_PRIMITIVE |
|
77
|
|
|
|
|
|
|
sign_PUBLICKEYBYTES |
|
78
|
|
|
|
|
|
|
sign_SECRETKEYBYTES |
|
79
|
|
|
|
|
|
|
sign |
|
80
|
|
|
|
|
|
|
sign_keypair |
|
81
|
|
|
|
|
|
|
sign_open |
|
82
|
|
|
|
|
|
|
]], |
|
83
|
|
|
|
|
|
|
stream => [qw[ |
|
84
|
|
|
|
|
|
|
stream_KEYBYTES |
|
85
|
|
|
|
|
|
|
stream_NONCEBYTES |
|
86
|
|
|
|
|
|
|
stream_PRIMITIVE |
|
87
|
|
|
|
|
|
|
stream |
|
88
|
|
|
|
|
|
|
stream_keygen |
|
89
|
|
|
|
|
|
|
stream_xor |
|
90
|
|
|
|
|
|
|
]], |
|
91
|
|
|
|
|
|
|
verify => [qw[ |
|
92
|
|
|
|
|
|
|
verify_BYTES |
|
93
|
|
|
|
|
|
|
verify_16_BYTES |
|
94
|
|
|
|
|
|
|
verify_32_BYTES |
|
95
|
|
|
|
|
|
|
verify |
|
96
|
|
|
|
|
|
|
verify_16 |
|
97
|
|
|
|
|
|
|
verify_32 |
|
98
|
|
|
|
|
|
|
]], |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; |
|
101
|
|
|
|
|
|
|
$EXPORT_TAGS{all} = [ @EXPORT_OK ]; |
|
102
|
|
|
|
|
|
|
|
|
103
|
8
|
|
|
8
|
|
117
|
use constant box_PRIMITIVE => "curve25519xsalsa20poly1305"; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
813
|
|
|
104
|
8
|
|
|
8
|
|
42
|
use constant box_PUBLICKEYBYTES => 32; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
463
|
|
|
105
|
8
|
|
|
8
|
|
38
|
use constant box_SECRETKEYBYTES => 32; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
324
|
|
|
106
|
8
|
|
|
8
|
|
55
|
use constant box_BEFORENMBYTES => 32; |
|
|
8
|
|
|
|
|
39
|
|
|
|
8
|
|
|
|
|
340
|
|
|
107
|
8
|
|
|
8
|
|
35
|
use constant box_NONCEBYTES => 24; |
|
|
8
|
|
|
|
|
27
|
|
|
|
8
|
|
|
|
|
348
|
|
|
108
|
8
|
|
|
8
|
|
35
|
use constant box_ZEROBYTES => 32; |
|
|
8
|
|
|
|
|
28
|
|
|
|
8
|
|
|
|
|
343
|
|
|
109
|
8
|
|
|
8
|
|
37
|
use constant box_BOXZEROBYTES => 16; |
|
|
8
|
|
|
|
|
22
|
|
|
|
8
|
|
|
|
|
348
|
|
|
110
|
8
|
|
|
8
|
|
36
|
use constant hash_BYTES => 64; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
353
|
|
|
111
|
8
|
|
|
8
|
|
33
|
use constant hash_PRIMITIVE => "sha512"; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
311
|
|
|
112
|
8
|
|
|
8
|
|
35
|
use constant hashblocks_BLOCKBYTES => 128; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
353
|
|
|
113
|
8
|
|
|
8
|
|
76
|
use constant hashblocks_PRIMITIVE => "sha512"; |
|
|
8
|
|
|
|
|
29
|
|
|
|
8
|
|
|
|
|
364
|
|
|
114
|
8
|
|
|
8
|
|
36
|
use constant hashblocks_STATEBYTES => 64; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
384
|
|
|
115
|
8
|
|
|
8
|
|
63
|
use constant onetimeauth_BYTES => 16; |
|
|
8
|
|
|
|
|
39
|
|
|
|
8
|
|
|
|
|
370
|
|
|
116
|
8
|
|
|
8
|
|
41
|
use constant onetimeauth_KEYBYTES => 32; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
409
|
|
|
117
|
8
|
|
|
8
|
|
39
|
use constant onetimeauth_PRIMITIVE => "poly1305"; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
314
|
|
|
118
|
8
|
|
|
8
|
|
68
|
use constant scalarmult_BYTES => 32; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
371
|
|
|
119
|
8
|
|
|
8
|
|
38
|
use constant scalarmult_PRIMITIVE => "curve25519"; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
353
|
|
|
120
|
8
|
|
|
8
|
|
34
|
use constant scalarmult_SCALARBYTES => 32; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
375
|
|
|
121
|
8
|
|
|
8
|
|
46
|
use constant secretbox_KEYBYTES => 32; |
|
|
8
|
|
|
|
|
39
|
|
|
|
8
|
|
|
|
|
432
|
|
|
122
|
8
|
|
|
8
|
|
38
|
use constant secretbox_NONCEBYTES => 24; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
367
|
|
|
123
|
8
|
|
|
8
|
|
34
|
use constant secretbox_PRIMITIVE => "xsalsa20poly1305"; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
359
|
|
|
124
|
8
|
|
|
8
|
|
36
|
use constant secretbox_ZEROBYTES => 32; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
385
|
|
|
125
|
8
|
|
|
8
|
|
36
|
use constant secretbox_BOXZEROBYTES => 16; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
320
|
|
|
126
|
8
|
|
|
8
|
|
39
|
use constant sign_BYTES => 64; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
359
|
|
|
127
|
8
|
|
|
8
|
|
36
|
use constant sign_PRIMITIVE => "ed25519"; |
|
|
8
|
|
|
|
|
33
|
|
|
|
8
|
|
|
|
|
420
|
|
|
128
|
8
|
|
|
8
|
|
37
|
use constant sign_PUBLICKEYBYTES => 32; |
|
|
8
|
|
|
|
|
22
|
|
|
|
8
|
|
|
|
|
392
|
|
|
129
|
8
|
|
|
8
|
|
54
|
use constant sign_SECRETKEYBYTES => 64; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
424
|
|
|
130
|
8
|
|
|
8
|
|
55
|
use constant stream_KEYBYTES => 32; |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
325
|
|
|
131
|
8
|
|
|
8
|
|
34
|
use constant stream_NONCEBYTES => 24; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
390
|
|
|
132
|
8
|
|
|
8
|
|
34
|
use constant stream_PRIMITIVE => "xsalsa20"; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
292
|
|
|
133
|
8
|
|
|
8
|
|
32
|
use constant verify_BYTES => 16; |
|
|
8
|
|
|
|
|
11
|
|
|
|
8
|
|
|
|
|
285
|
|
|
134
|
8
|
|
|
8
|
|
32
|
use constant verify_16_BYTES => 16; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
285
|
|
|
135
|
8
|
|
|
8
|
|
37
|
use constant verify_32_BYTES => 32; |
|
|
8
|
|
|
|
|
22
|
|
|
|
8
|
|
|
|
|
2865
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub box_keypair { |
|
138
|
0
|
|
|
0
|
1
|
|
my $sk = random_bytes(32); |
|
139
|
0
|
|
|
|
|
|
my $pk = scalarmult_base($sk); |
|
140
|
0
|
|
|
|
|
|
return ($pk, $sk); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
0
|
1
|
|
sub onetimeauth_keygen { random_bytes(onetimeauth_KEYBYTES) } |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
1
|
|
sub stream_keygen { random_bytes(stream_KEYBYTES) } |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub random_bytes; |
|
148
|
|
|
|
|
|
|
if (eval { require Sys::GetRandom; 1; }) { |
|
149
|
|
|
|
|
|
|
*random_bytes = sub { Sys::GetRandom::random_bytes($_[0]) }; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
elsif (eval { require Crypt::PRNG; 1; }) { |
|
152
|
|
|
|
|
|
|
*random_bytes = sub { Crypt::PRNG::random_bytes($_[0]) }; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
elsif (eval { require Crypt::URandom; 1; }) { |
|
155
|
|
|
|
|
|
|
*random_bytes = sub { Crypt::URandom::urandom($_[0]); }; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
# probably others... |
|
158
|
|
|
|
|
|
|
else { |
|
159
|
|
|
|
|
|
|
*random_bytes = sub { |
|
160
|
0
|
|
|
0
|
|
|
die "no random_bytes implementation is available on this system. ", |
|
161
|
|
|
|
|
|
|
"you could install Sys::GetRandom, Crypt::PRNG, or Crypt::URandom." |
|
162
|
|
|
|
|
|
|
}; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
__END__ |