blib/lib/Crypt/Sodium/XS/stream.pm

filter: Statementstmt 87.5% 63 / 72 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 14 / 22 Podpod 100% 1 / 1 totaltotal 82.1% 78 / 95 CC 1 SCAR 3.1
CC
1
Cov
88%
__ANON__
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.4
« blib/lib/Crypt/Sodium/XS/scalarmult.pm ↑ Summary blib/lib/Crypt/Sodium/XS/Base.pm »
1 package Crypt::Sodium::XS::stream;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Crypt::Sodium::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 _define_constants();
9  
10 {
11 1 my @constant_bases = qw(
12 KEYBYTES
13 MESSAGEBYTES_MAX
14 NONCEBYTES
15 );
16  
17 1 my @bases = qw(
18 keygen
19 nonce
20 xor
21 );
22  
23 my $default = [
24 "stream",
25 "stream_xor_ic",
26 3 (map { "stream_$_" } @bases),
27 1 (map { "stream_$_" } @constant_bases, "PRIMITIVE"),
28 ];
29  
30 my $chacha20 = [
31 "stream_chacha20",
32 "stream_chacha20_xor_ic",
33 3 (map { "stream_chacha20_$_" } @bases),
34 1 (map { "stream_chacha20_$_" } @constant_bases),
35 ];
36  
37 my $chacha20_ietf = [
38 "stream_chacha20_ietf",
39 "stream_chacha20_ietf_xor_ic",
40 3 (map { "stream_chacha20_ietf_$_" } @bases),
41 1 (map { "stream_chacha20_ietf_$_" } @constant_bases),
42 ];
43  
44 my $salsa20 = [
45 "stream_salsa20",
46 "stream_salsa20_xor_ic",
47 3 (map { "stream_salsa20_$_" } @bases),
48 1 (map { "stream_salsa20_$_" } @constant_bases),
49 ];
50  
51 my $salsa2012 = [
52 "stream_salsa2012",
53 3 (map { "stream_salsa2012_$_" } @bases),
54 1 (map { "stream_salsa2012_$_" } @constant_bases),
55 ];
56  
57 my $xchacha20 = [
58 "stream_xchacha20",
59 "stream_xchacha20_xor_ic",
60 3 (map { "stream_xchacha20_$_" } @bases),
61 1 (map { "stream_xchacha20_$_" } @constant_bases),
62 ];
63  
64 my $xsalsa20 = [
65 "stream_xsalsa20",
66 "stream_xsalsa20_xor_ic",
67 3 (map { "stream_xsalsa20_$_" } @bases),
68 1 (map { "stream_xsalsa20_$_" } @constant_bases),
69 ];
70  
71 1 our %EXPORT_TAGS = (
72 all => [ @$default, @$chacha20, @$chacha20_ietf, @$salsa20,
73 @$salsa2012, @$xchacha20, @$xsalsa20 ],
74 default => $default,
75 chacha20 => $chacha20,
76 chacha20_ietf => $chacha20_ietf,
77 salsa20 => $salsa20,
78 salsa2012 => $salsa2012,
79 xchacha20 => $xchacha20,
80 xsalsa20 => $xsalsa20,
81 );
82  
83 1 our @EXPORT_OK = @{$EXPORT_TAGS{all}};
84 }
85  
86 package Crypt::Sodium::XS::OO::stream;
87 1 ▶use parent 'Crypt::Sodium::XS::OO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 my %methods = (
90 default => {
91 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_KEYBYTES,
92 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_MESSAGEBYTES_MAX,
93 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_NONCEBYTES,
94 PRIMITIVE => \&Crypt::Sodium::XS::stream::stream_PRIMITIVE,
95 keygen => \&Crypt::Sodium::XS::stream::stream_keygen,
96 nonce => \&Crypt::Sodium::XS::stream::stream_nonce,
97 stream => \&Crypt::Sodium::XS::stream::stream,
98 xor => \&Crypt::Sodium::XS::stream::stream_xor,
99 xor_ic => \&Crypt::Sodium::XS::stream::stream_xor_ic,
100 },
101 chacha20 => {
102 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_chacha20_KEYBYTES,
103 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_chacha20_MESSAGEBYTES_MAX,
104 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_chacha20_NONCEBYTES,
105 0 ▶ PRIMITIVE => sub { 'chacha20' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 keygen => \&Crypt::Sodium::XS::stream::stream_chacha20_keygen,
107 nonce => \&Crypt::Sodium::XS::stream::stream_chacha20_nonce,
108 stream => \&Crypt::Sodium::XS::stream::stream_chacha20,
109 xor => \&Crypt::Sodium::XS::stream::stream_chacha20_xor,
110 xor_ic => \&Crypt::Sodium::XS::stream::stream_chacha20_xor_ic,
111 },
112 chacha20_ietf => {
113 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_KEYBYTES,
114 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_MESSAGEBYTES_MAX,
115 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_NONCEBYTES,
116 0 ▶ PRIMITIVE => sub { 'chacha20_ietf' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
117 keygen => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_keygen,
118 nonce => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_nonce,
119 stream => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf,
120 xor => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_xor,
121 xor_ic => \&Crypt::Sodium::XS::stream::stream_chacha20_ietf_xor_ic,
122 },
123 salsa20 => {
124 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_salsa20_KEYBYTES,
125 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_salsa20_MESSAGEBYTES_MAX,
126 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_salsa20_NONCEBYTES,
127 0 ▶ PRIMITIVE => sub { 'salsa20' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
128 keygen => \&Crypt::Sodium::XS::stream::stream_salsa20_keygen,
129 nonce => \&Crypt::Sodium::XS::stream::stream_salsa20_nonce,
130 stream => \&Crypt::Sodium::XS::stream::stream_salsa20,
131 xor => \&Crypt::Sodium::XS::stream::stream_salsa20_xor,
132 xor_ic => \&Crypt::Sodium::XS::stream::stream_salsa20_xor_ic,
133 },
134 salsa2012 => {
135 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_salsa2012_KEYBYTES,
136 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_salsa2012_MESSAGEBYTES_MAX,
137 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_salsa2012_NONCEBYTES,
138 0 ▶ PRIMITIVE => sub { 'salsa2012' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
139 keygen => \&Crypt::Sodium::XS::stream::stream_salsa2012_keygen,
140 nonce => \&Crypt::Sodium::XS::stream::stream_salsa2012_nonce,
141 stream => \&Crypt::Sodium::XS::stream::stream_salsa2012,
142 xor => \&Crypt::Sodium::XS::stream::stream_salsa2012_xor,
143 0 ▶ xor_ic => sub { die "xor_ic not supported for salsa2012 primitive" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
144 },
145 xchacha20 => {
146 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_xchacha20_KEYBYTES,
147 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_xchacha20_MESSAGEBYTES_MAX,
148 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_xchacha20_NONCEBYTES,
149 0 ▶ PRIMITIVE => sub { 'xchacha20' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
150 keygen => \&Crypt::Sodium::XS::stream::stream_xchacha20_keygen,
151 nonce => \&Crypt::Sodium::XS::stream::stream_xchacha20_nonce,
152 stream => \&Crypt::Sodium::XS::stream::stream_xchacha20,
153 xor => \&Crypt::Sodium::XS::stream::stream_xchacha20_xor,
154 xor_ic => \&Crypt::Sodium::XS::stream::stream_xchacha20_xor_ic,
155 },
156 xsalsa20 => {
157 KEYBYTES => \&Crypt::Sodium::XS::stream::stream_xsalsa20_KEYBYTES,
158 MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::stream::stream_xsalsa20_MESSAGEBYTES_MAX,
159 NONCEBYTES => \&Crypt::Sodium::XS::stream::stream_xsalsa20_NONCEBYTES,
160 0 ▶ PRIMITIVE => sub { 'xsalsa20' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
161 1 keygen => \&Crypt::Sodium::XS::stream::stream_xsalsa20_keygen,
162 nonce => \&Crypt::Sodium::XS::stream::stream_xsalsa20_nonce,
163 stream => \&Crypt::Sodium::XS::stream::stream_xsalsa20,
164 xor => \&Crypt::Sodium::XS::stream::stream_xsalsa20_xor,
165 xor_ic => \&Crypt::Sodium::XS::stream::stream_xsalsa20_xor_ic,
166 },
167 );
168  
169 8 ▶sub Crypt::Sodium::XS::stream::primitives { keys %methods }
Subroutine primitives: called CC=1 SCAR=0.0
Pod documented
170 1 *primitives = \&Crypt::Sodium::XS::stream::primitives;
171  
172 14 ▶sub KEYBYTES { my $self = shift; goto $methods{$self->{primitive}}->{KEYBYTES}; }
Subroutine KEYBYTES: called CC=1 SCAR=0.0
173 7 ▶sub MESSAGEBYTES_MAX { my $self = shift; goto $methods{$self->{primitive}}->{MESSAGEBYTES_MAX}; }
Subroutine MESSAGEBYTES_MAX: called CC=1 SCAR=0.0
174 14 ▶sub NONCEBYTES { my $self = shift; goto $methods{$self->{primitive}}->{NONCEBYTES}; }
Subroutine NONCEBYTES: called CC=1 SCAR=0.0
175 0 ▶sub PRIMITIVE { my $self = shift; goto $methods{$self->{primitive}}->{PRIMITIVE}; }
Subroutine PRIMITIVE: not called CC=1 SCAR=6.9
176 7 ▶sub keygen { my $self = shift; goto $methods{$self->{primitive}}->{keygen}; }
Subroutine keygen: called CC=1 SCAR=0.0
177 11 ▶sub nonce { my $self = shift; goto $methods{$self->{primitive}}->{nonce}; }
Subroutine nonce: called CC=1 SCAR=0.0
178 7 ▶sub stream { my $self = shift; goto $methods{$self->{primitive}}->{stream}; }
Subroutine stream: called CC=1 SCAR=0.0
179 27 ▶sub xor { my $self = shift; goto $methods{$self->{primitive}}->{xor}; }
Subroutine xor: called CC=1 SCAR=0.0
180 12 ▶sub xor_ic { my $self = shift; goto $methods{$self->{primitive}}->{xor_ic}; }
Subroutine xor_ic: called CC=1 SCAR=0.0
181  
182 1 1;
183  
184 __END__
« blib/lib/Crypt/Sodium/XS/scalarmult.pm ↑ Summary blib/lib/Crypt/Sodium/XS/Base.pm »