| 1 | package Crypt::Sodium::XS::box; | ||
| 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 | BEFORENMBYTES | ||
| 13 | MACBYTES | ||
| 14 | MESSAGEBYTES_MAX | ||
| 15 | NONCEBYTES | ||
| 16 | PUBLICKEYBYTES | ||
| 17 | SEALBYTES | ||
| 18 | SECRETKEYBYTES | ||
| 19 | SEEDBYTES | ||
| 20 | ); | ||
| 21 | |||
| 22 | 1 | my @bases = qw( | |
| 23 | beforenm | ||
| 24 | decrypt | ||
| 25 | decrypt_afternm | ||
| 26 | decrypt_detached | ||
| 27 | decrypt_detached_afternm | ||
| 28 | encrypt | ||
| 29 | encrypt_detached | ||
| 30 | encrypt_afternm | ||
| 31 | encrypt_detached_afternm | ||
| 32 | keypair | ||
| 33 | nonce | ||
| 34 | seal_encrypt | ||
| 35 | seal_decrypt | ||
| 36 | ); | ||
| 37 | |||
| 38 | my $default = [ | ||
| 39 | 13 | (map { "box_$_" } @bases), | |
| 40 | 1 | (map { "box_$_" } @constant_bases, "PRIMITIVE"), | |
| 41 | ]; | ||
| 42 | my $curve25519xchacha20poly1305 = [ | ||
| 43 | 13 | (map { "box_curve25519xchacha20poly1305_$_" } @bases), | |
| 44 | 1 | (map { "box_curve25519xchacha20poly1305_$_" } @constant_bases), | |
| 45 | ]; | ||
| 46 | my $curve25519xsalsa20poly1305 = [ | ||
| 47 | 13 | (map { "box_curve25519xsalsa20poly1305_$_" } @bases), | |
| 48 | 1 | (map { "box_curve25519xsalsa20poly1305_$_" } @constant_bases), | |
| 49 | ]; | ||
| 50 | |||
| 51 | 1 | our %EXPORT_TAGS = ( | |
| 52 | all => | ||
| 53 | [ @$default, @$curve25519xchacha20poly1305, @$curve25519xsalsa20poly1305 ], | ||
| 54 | default => $default, | ||
| 55 | curve25519xchacha20poly1305 => $curve25519xchacha20poly1305, | ||
| 56 | curve25519xsalsa20poly1305 => $curve25519xsalsa20poly1305, | ||
| 57 | ); | ||
| 58 | |||
| 59 | 1 | our @EXPORT_OK = @{$EXPORT_TAGS{all}}; | |
| 60 | } | ||
| 61 | |||
| 62 | package Crypt::Sodium::XS::OO::box; | ||
| 63 | 1 | ▶ | use parent 'Crypt::Sodium::XS::OO::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 64 | |||
| 65 | my %methods = ( | ||
| 66 | default => { | ||
| 67 | BEFORENMBYTES => \&Crypt::Sodium::XS::box::box_BEFORENMBYTES, | ||
| 68 | MACBYTES => \&Crypt::Sodium::XS::box::box_MACBYTES, | ||
| 69 | MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::box::box_MESSAGEBYTES_MAX, | ||
| 70 | NONCEBYTES => \&Crypt::Sodium::XS::box::box_NONCEBYTES, | ||
| 71 | PRIMITIVE => \&Crypt::Sodium::XS::box::box_PRIMITIVE, | ||
| 72 | PUBLICKEYBYTES => \&Crypt::Sodium::XS::box::box_PUBLICKEYBYTES, | ||
| 73 | SEALBYTES => \&Crypt::Sodium::XS::box::box_SEALBYTES, | ||
| 74 | SECRETKEYBYTES => \&Crypt::Sodium::XS::box::box_SECRETKEYBYTES, | ||
| 75 | SEEDBYTES => \&Crypt::Sodium::XS::box::box_SEEDBYTES, | ||
| 76 | beforenm => \&Crypt::Sodium::XS::box::box_beforenm, | ||
| 77 | decrypt => \&Crypt::Sodium::XS::box::box_decrypt, | ||
| 78 | decrypt_afternm => \&Crypt::Sodium::XS::box::box_decrypt_afternm, | ||
| 79 | decrypt_detached => \&Crypt::Sodium::XS::box::box_decrypt_detached, | ||
| 80 | decrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_decrypt_detached_afternm, | ||
| 81 | encrypt => \&Crypt::Sodium::XS::box::box_encrypt, | ||
| 82 | encrypt_detached => \&Crypt::Sodium::XS::box::box_encrypt_detached, | ||
| 83 | encrypt_afternm => \&Crypt::Sodium::XS::box::box_encrypt_afternm, | ||
| 84 | encrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_encrypt_detached_afternm, | ||
| 85 | keypair => \&Crypt::Sodium::XS::box::box_keypair, | ||
| 86 | nonce => \&Crypt::Sodium::XS::box::box_nonce, | ||
| 87 | seal_encrypt => \&Crypt::Sodium::XS::box::box_seal_encrypt, | ||
| 88 | seal_decrypt => \&Crypt::Sodium::XS::box::box_seal_decrypt, | ||
| 89 | }, | ||
| 90 | curve25519xchacha20poly1305 => { | ||
| 91 | BEFORENMBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_BEFORENMBYTES, | ||
| 92 | MACBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_MACBYTES, | ||
| 93 | MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX, | ||
| 94 | NONCEBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_NONCEBYTES, | ||
| 95 | 0 | ▶ | PRIMITIVE => sub { 'curve25519xchacha20poly1305' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 96 | PUBLICKEYBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_PUBLICKEYBYTES, | ||
| 97 | SEALBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_SEALBYTES, | ||
| 98 | SECRETKEYBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_SECRETKEYBYTES, | ||
| 99 | SEEDBYTES => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_SEEDBYTES, | ||
| 100 | beforenm => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_beforenm, | ||
| 101 | decrypt => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_decrypt, | ||
| 102 | decrypt_afternm => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_decrypt_afternm, | ||
| 103 | decrypt_detached => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_decrypt_detached, | ||
| 104 | decrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_decrypt_detached_afternm, | ||
| 105 | encrypt => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_encrypt, | ||
| 106 | encrypt_detached => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_encrypt_detached, | ||
| 107 | encrypt_afternm => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_encrypt_afternm, | ||
| 108 | encrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_encrypt_detached_afternm, | ||
| 109 | keypair => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_keypair, | ||
| 110 | nonce => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_nonce, | ||
| 111 | seal_encrypt => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_seal_encrypt, | ||
| 112 | seal_decrypt => \&Crypt::Sodium::XS::box::box_curve25519xchacha20poly1305_seal_decrypt, | ||
| 113 | }, | ||
| 114 | curve25519xsalsa20poly1305 => { | ||
| 115 | BEFORENMBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_BEFORENMBYTES, | ||
| 116 | MACBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_MACBYTES, | ||
| 117 | MESSAGEBYTES_MAX => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX, | ||
| 118 | NONCEBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_NONCEBYTES, | ||
| 119 | 0 | ▶ | PRIMITIVE => sub { 'curve25519xsalsa20poly1305' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 120 | 1 | PUBLICKEYBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, | |
| 121 | SEALBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_SEALBYTES, | ||
| 122 | SECRETKEYBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_SECRETKEYBYTES, | ||
| 123 | SEEDBYTES => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_SEEDBYTES, | ||
| 124 | beforenm => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_beforenm, | ||
| 125 | decrypt => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_decrypt, | ||
| 126 | decrypt_afternm => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_decrypt_afternm, | ||
| 127 | decrypt_detached => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_decrypt_detached, | ||
| 128 | decrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_decrypt_detached_afternm, | ||
| 129 | encrypt => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_encrypt, | ||
| 130 | encrypt_afternm => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_encrypt_afternm, | ||
| 131 | encrypt_detached => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_encrypt_detached, | ||
| 132 | encrypt_detached_afternm => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_encrypt_detached_afternm, | ||
| 133 | keypair => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_keypair, | ||
| 134 | nonce => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_nonce, | ||
| 135 | seal_encrypt => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_seal_encrypt, | ||
| 136 | seal_decrypt => \&Crypt::Sodium::XS::box::box_curve25519xsalsa20poly1305_seal_decrypt, | ||
| 137 | }, | ||
| 138 | ); | ||
| 139 | |||
| 140 | 4 | ▶ | sub Crypt::Sodium::XS::box::primitives { keys %methods } |
|
Subroutine
primitives: called CC=1 SCAR=0.0
Pod
documented
| |||
| 141 | 1 | *primitives = \&Crypt::Sodium::XS::box::primitives; | |
| 142 | |||
| 143 | 3 | ▶ | sub BEFORENMBYTES { my $self = shift; goto $methods{$self->{primitive}}->{BEFORENMBYTES}; } |
|
Subroutine
BEFORENMBYTES: called CC=1 SCAR=0.0
| |||
| 144 | 3 | ▶ | sub MACBYTES { my $self = shift; goto $methods{$self->{primitive}}->{MACBYTES}; } |
|
Subroutine
MACBYTES: called CC=1 SCAR=0.0
| |||
| 145 | 3 | ▶ | sub MESSAGEBYTES_MAX { my $self = shift; goto $methods{$self->{primitive}}->{MESSAGEBYTES_MAX}; } |
|
Subroutine
MESSAGEBYTES_MAX: called CC=1 SCAR=0.0
| |||
| 146 | 3 | ▶ | sub NONCEBYTES { my $self = shift; goto $methods{$self->{primitive}}->{NONCEBYTES}; } |
|
Subroutine
NONCEBYTES: called CC=1 SCAR=0.0
| |||
| 147 | 0 | ▶ | sub PRIMITIVE { my $self = shift; goto $methods{$self->{primitive}}->{PRIMITIVE}; } |
|
Subroutine
PRIMITIVE: not called CC=1 SCAR=6.9
| |||
| 148 | 3 | ▶ | sub PUBLICKEYBYTES { my $self = shift; goto $methods{$self->{primitive}}->{PUBLICKEYBYTES}; } |
|
Subroutine
PUBLICKEYBYTES: called CC=1 SCAR=0.0
| |||
| 149 | 3 | ▶ | sub SEALBYTES { my $self = shift; goto $methods{$self->{primitive}}->{SEALBYTES}; } |
|
Subroutine
SEALBYTES: called CC=1 SCAR=0.0
| |||
| 150 | 3 | ▶ | sub SECRETKEYBYTES { my $self = shift; goto $methods{$self->{primitive}}->{SECRETKEYBYTES}; } |
|
Subroutine
SECRETKEYBYTES: called CC=1 SCAR=0.0
| |||
| 151 | 9 | ▶ | sub SEEDBYTES { my $self = shift; goto $methods{$self->{primitive}}->{SEEDBYTES}; } |
|
Subroutine
SEEDBYTES: called CC=1 SCAR=0.0
| |||
| 152 | 12 | ▶ | sub beforenm { my $self = shift; goto $methods{$self->{primitive}}->{beforenm}; } |
|
Subroutine
beforenm: called CC=1 SCAR=0.0
| |||
| 153 | 6 | ▶ | sub decrypt { my $self = shift; goto $methods{$self->{primitive}}->{decrypt}; } |
|
Subroutine
decrypt: called CC=1 SCAR=0.0
| |||
| 154 | 0 | ▶ | sub decrypt_afternm { my $self = shift; goto $methods{$self->{primitive}}->{decrypt_afternm}; } |
|
Subroutine
decrypt_afternm: not called CC=1 SCAR=6.9
| |||
| 155 | 6 | ▶ | sub decrypt_detached { my $self = shift; goto $methods{$self->{primitive}}->{decrypt_detached}; } |
|
Subroutine
decrypt_detached: called CC=1 SCAR=0.0
| |||
| 156 | 0 | ▶ | sub decrypt_detached_afternm { my $self = shift; goto $methods{$self->{primitive}}->{decrypt_detached_afternm}; } |
|
Subroutine
decrypt_detached_afternm: not called CC=1 SCAR=6.9
| |||
| 157 | 6 | ▶ | sub encrypt { my $self = shift; goto $methods{$self->{primitive}}->{encrypt}; } |
|
Subroutine
encrypt: called CC=1 SCAR=0.0
| |||
| 158 | 0 | ▶ | sub encrypt_afternm { my $self = shift; goto $methods{$self->{primitive}}->{encrypt_afternm}; } |
|
Subroutine
encrypt_afternm: not called CC=1 SCAR=6.9
| |||
| 159 | 6 | ▶ | sub encrypt_detached { my $self = shift; goto $methods{$self->{primitive}}->{encrypt_detached}; } |
|
Subroutine
encrypt_detached: called CC=1 SCAR=0.0
| |||
| 160 | 0 | ▶ | sub encrypt_detached_afternm { my $self = shift; goto $methods{$self->{primitive}}->{encrypt_detached_afternm}; } |
|
Subroutine
encrypt_detached_afternm: not called CC=1 SCAR=6.9
| |||
| 161 | 24 | ▶ | sub keypair { my $self = shift; goto $methods{$self->{primitive}}->{keypair}; } |
|
Subroutine
keypair: called CC=1 SCAR=0.0
| |||
| 162 | 6 | ▶ | sub nonce { my $self = shift; goto $methods{$self->{primitive}}->{nonce}; } |
|
Subroutine
nonce: called CC=1 SCAR=0.0
| |||
| 163 | 6 | ▶ | sub seal_encrypt { my $self = shift; goto $methods{$self->{primitive}}->{seal_encrypt}; } |
|
Subroutine
seal_encrypt: called CC=1 SCAR=0.0
| |||
| 164 | 6 | ▶ | sub seal_decrypt { my $self = shift; goto $methods{$self->{primitive}}->{seal_decrypt}; } |
|
Subroutine
seal_decrypt: called CC=1 SCAR=0.0
| |||
| 165 | |||
| 166 | 1 | 1; | |
| 167 | |||
| 168 | __END__ | ||