File Coverage

blib/lib/Crypt/NaCl/Sodium.pm
Criterion Covered Total %
statement 40 43 93.0
branch 1 4 25.0
condition n/a
subroutine 29 29 100.0
pod 13 13 100.0
total 83 89 93.2


line stmt bran cond sub pod time code
1             package Crypt::NaCl::Sodium;
2              
3             our $VERSION = '2.003';
4             our $XS_VERSION = $VERSION;
5              
6 54     54   7109946 use strict;
  54         117  
  54         2214  
7 54     54   287 use warnings;
  54         119  
  54         4223  
8              
9 54     54   372 use Carp qw( croak );
  54         133  
  54         3770  
10 54     54   44628 use Sub::Exporter;
  54         1067666  
  54         434  
11              
12             require XSLoader;
13             XSLoader::load('Crypt::NaCl::Sodium', $XS_VERSION);
14              
15             my @funcs = qw(
16             bin2hex hex2bin
17             memcmp compare memzero
18             increment
19             random_bytes
20             random_number
21             );
22              
23             Sub::Exporter::setup_exporter(
24             {
25             exports => \@funcs,
26             groups => {
27             all => \@funcs,
28             utils => \@funcs,
29             }
30             }
31             );
32              
33             sub new {
34 2     2 1 551896 my ($proto, $submodule) = @_;
35              
36 2 50       12 if ( ! $submodule ) {
37 2         12 my $o = 0;
38 2         13 return bless \$o, $proto;
39             }
40              
41 0 0       0 if ( my $m = $proto->can($submodule) ) {
42 0         0 return $m->();
43             }
44              
45 0         0 croak "Unknown submodule $submodule\n";
46             }
47              
48             sub secretbox {
49 5     5 1 844776 return Crypt::NaCl::Sodium::secretbox->new();
50             }
51              
52             sub auth {
53 8     8 1 1854404 return Crypt::NaCl::Sodium::auth->new();
54             }
55              
56             sub aead {
57 6     6 1 1302519 return Crypt::NaCl::Sodium::aead->new();
58             }
59              
60             sub box {
61 5     5 1 937527 return Crypt::NaCl::Sodium::box->new();
62             }
63              
64             sub sign {
65 4     4 1 826543 return Crypt::NaCl::Sodium::sign->new();
66             }
67              
68             sub generichash {
69 5     5 1 959335 return Crypt::NaCl::Sodium::generichash->new();
70             }
71              
72             sub shorthash {
73 4     4 1 688669 return Crypt::NaCl::Sodium::shorthash->new();
74             }
75              
76             sub pwhash {
77 4     4 1 732759 return Crypt::NaCl::Sodium::pwhash->new();
78             }
79              
80             sub hash {
81 8     8 1 1677043 return Crypt::NaCl::Sodium::hash->new();
82             }
83              
84             sub onetimeauth {
85 5     5 1 1077469 return Crypt::NaCl::Sodium::onetimeauth->new();
86             }
87              
88             sub scalarmult {
89 5     5 1 761119 return Crypt::NaCl::Sodium::scalarmult->new();
90             }
91              
92             sub stream {
93 8     8 1 999866 return Crypt::NaCl::Sodium::stream->new();
94             }
95              
96             package
97             Data::BytesLocker;
98              
99             our $DEFAULT_LOCKED = 0;
100              
101             package
102             Crypt::NaCl::Sodium::secretbox;
103              
104 5     5   33 sub new { return bless {}, __PACKAGE__ }
105              
106             package
107             Crypt::NaCl::Sodium::auth;
108              
109 8     8   62 sub new { return bless {}, __PACKAGE__ }
110              
111             package
112             Crypt::NaCl::Sodium::aead;
113              
114 6     6   76 sub new { return bless {}, __PACKAGE__ }
115              
116             package
117             Crypt::NaCl::Sodium::box;
118              
119 5     5   70 sub new { return bless {}, __PACKAGE__ }
120              
121             package
122             Crypt::NaCl::Sodium::sign;
123              
124 4     4   27 sub new { return bless {}, __PACKAGE__ }
125              
126             package
127             Crypt::NaCl::Sodium::generichash;
128              
129 5     5   49 sub new { return bless {}, __PACKAGE__ }
130              
131             package
132             Crypt::NaCl::Sodium::shorthash;
133              
134 4     4   24 sub new { return bless {}, __PACKAGE__ }
135              
136             package
137             Crypt::NaCl::Sodium::pwhash;
138              
139 4     4   46 sub new { return bless {}, __PACKAGE__ }
140              
141             package
142             Crypt::NaCl::Sodium::hash;
143              
144 8     8   57 sub new { return bless {}, __PACKAGE__ }
145              
146             package
147             Crypt::NaCl::Sodium::onetimeauth;
148              
149 5     5   27 sub new { return bless {}, __PACKAGE__ }
150              
151             package
152             Crypt::NaCl::Sodium::scalarmult;
153              
154 5     5   31 sub new { return bless {}, __PACKAGE__ }
155              
156             package
157             Crypt::NaCl::Sodium::stream;
158              
159 8     8   43 sub new { return bless {}, __PACKAGE__ }
160              
161              
162             1;
163              
164             __END__