diff options
author | Lucas Kanashiro <kanashiro@debian.org> | 2017-06-25 00:00:40 -0300 |
---|---|---|
committer | Lucas Kanashiro <kanashiro@debian.org> | 2017-06-25 00:00:40 -0300 |
commit | ea35d105ec8dbf421ad1803bcb72e097d2295a18 (patch) | |
tree | 2aa3f333938fb6886d020d7deb5bc7b4d010afca /lib/Crypt/Mac |
Import original source of CryptX 0.048
Diffstat (limited to 'lib/Crypt/Mac')
-rw-r--r-- | lib/Crypt/Mac/BLAKE2b.pm | 156 | ||||
-rw-r--r-- | lib/Crypt/Mac/BLAKE2s.pm | 156 | ||||
-rw-r--r-- | lib/Crypt/Mac/F9.pm | 156 | ||||
-rw-r--r-- | lib/Crypt/Mac/HMAC.pm | 160 | ||||
-rw-r--r-- | lib/Crypt/Mac/OMAC.pm | 158 | ||||
-rw-r--r-- | lib/Crypt/Mac/PMAC.pm | 158 | ||||
-rw-r--r-- | lib/Crypt/Mac/Pelican.pm | 156 | ||||
-rw-r--r-- | lib/Crypt/Mac/Poly1305.pm | 156 | ||||
-rw-r--r-- | lib/Crypt/Mac/XCBC.pm | 158 |
9 files changed, 1414 insertions, 0 deletions
diff --git a/lib/Crypt/Mac/BLAKE2b.pm b/lib/Crypt/Mac/BLAKE2b.pm new file mode 100644 index 00000000..657a94c3 --- /dev/null +++ b/lib/Crypt/Mac/BLAKE2b.pm @@ -0,0 +1,156 @@ +package Crypt::Mac::BLAKE2b; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( blake2b blake2b_hex blake2b_b64 blake2b_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +sub new { my $class = shift; _new(@_) } +sub blake2b { Crypt::Mac::BLAKE2b->new(shift, shift)->add(@_)->mac } +sub blake2b_hex { Crypt::Mac::BLAKE2b->new(shift, shift)->add(@_)->hexmac } +sub blake2b_b64 { Crypt::Mac::BLAKE2b->new(shift, shift)->add(@_)->b64mac } +sub blake2b_b64u { Crypt::Mac::BLAKE2b->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::BLAKE2b - Message authentication code BLAKE2b MAC (RFC 7693) + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::BLAKE2b qw( blake2b blake2b_hex ); + + # calculate MAC from string/buffer + $blake2b_raw = blake2b($size, $key, 'data buffer'); + $blake2b_hex = blake2b_hex($size, $key, 'data buffer'); + $blake2b_b64 = blake2b_b64($size, $key, 'data buffer'); + $blake2b_b64u = blake2b_b64u($size, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::BLAKE2b; + + $d = Crypt::Mac::BLAKE2b->new($size, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the BLAKE2b message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::BLAKE2b qw(blake2b blake2b_hex ); + +Or all of them at once: + + use Crypt::Mac::BLAKE2b ':all'; + +=head1 FUNCTIONS + +=head2 blake2b + +Logically joins all arguments into a single string, and returns its BLAKE2b message authentication code encoded as a binary string. + + $blake2b_raw = blake2b($size, $key, 'data buffer'); + #or + $blake2b_raw = blake2b($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2b_hex + +Logically joins all arguments into a single string, and returns its BLAKE2b message authentication code encoded as a hexadecimal string. + + $blake2b_hex = blake2b_hex($size, $key, 'data buffer'); + #or + $blake2b_hex = blake2b_hex($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2b_b64 + +Logically joins all arguments into a single string, and returns its BLAKE2b message authentication code encoded as a Base64 string. + + $blake2b_b64 = blake2b_b64($size, $key, 'data buffer'); + #or + $blake2b_b64 = blake2b_b64($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2b_b64u + +Logically joins all arguments into a single string, and returns its BLAKE2b message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $blake2b_b64url = blake2b_b64u($size, $key, 'data buffer'); + #or + $blake2b_b64url = blake2b_b64u($size, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::BLAKE2b->new($size, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://tools.ietf.org/html/rfc7693|https://tools.ietf.org/html/rfc7693> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/BLAKE2s.pm b/lib/Crypt/Mac/BLAKE2s.pm new file mode 100644 index 00000000..c696abc3 --- /dev/null +++ b/lib/Crypt/Mac/BLAKE2s.pm @@ -0,0 +1,156 @@ +package Crypt::Mac::BLAKE2s; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( blake2s blake2s_hex blake2s_b64 blake2s_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +sub new { my $class = shift; _new(@_) } +sub blake2s { Crypt::Mac::BLAKE2s->new(shift, shift)->add(@_)->mac } +sub blake2s_hex { Crypt::Mac::BLAKE2s->new(shift, shift)->add(@_)->hexmac } +sub blake2s_b64 { Crypt::Mac::BLAKE2s->new(shift, shift)->add(@_)->b64mac } +sub blake2s_b64u { Crypt::Mac::BLAKE2s->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::BLAKE2s - Message authentication code BLAKE2s MAC (RFC 7693) + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::BLAKE2s qw( blake2s blake2s_hex ); + + # calculate MAC from string/buffer + $blake2s_raw = blake2s($size, $key, 'data buffer'); + $blake2s_hex = blake2s_hex($size, $key, 'data buffer'); + $blake2s_b64 = blake2s_b64($size, $key, 'data buffer'); + $blake2s_b64u = blake2s_b64u($size, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::BLAKE2s; + + $d = Crypt::Mac::BLAKE2s->new($size, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the BLAKE2s message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::BLAKE2s qw(blake2s blake2s_hex ); + +Or all of them at once: + + use Crypt::Mac::BLAKE2s ':all'; + +=head1 FUNCTIONS + +=head2 blake2s + +Logically joins all arguments into a single string, and returns its BLAKE2s message authentication code encoded as a binary string. + + $blake2s_raw = blake2s($size, $key, 'data buffer'); + #or + $blake2s_raw = blake2s($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2s_hex + +Logically joins all arguments into a single string, and returns its BLAKE2s message authentication code encoded as a hexadecimal string. + + $blake2s_hex = blake2s_hex($size, $key, 'data buffer'); + #or + $blake2s_hex = blake2s_hex($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2s_b64 + +Logically joins all arguments into a single string, and returns its BLAKE2s message authentication code encoded as a Base64 string. + + $blake2s_b64 = blake2s_b64($size, $key, 'data buffer'); + #or + $blake2s_b64 = blake2s_b64($size, $key, 'any data', 'more data', 'even more data'); + +=head2 blake2s_b64u + +Logically joins all arguments into a single string, and returns its BLAKE2s message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $blake2s_b64url = blake2s_b64u($size, $key, 'data buffer'); + #or + $blake2s_b64url = blake2s_b64u($size, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::BLAKE2s->new($size, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://tools.ietf.org/html/rfc7693|https://tools.ietf.org/html/rfc7693> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/F9.pm b/lib/Crypt/Mac/F9.pm new file mode 100644 index 00000000..3caf72c6 --- /dev/null +++ b/lib/Crypt/Mac/F9.pm @@ -0,0 +1,156 @@ +package Crypt::Mac::F9; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( f9 f9_hex f9_b64 f9_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +use Crypt::Cipher; + +sub new { my $class = shift; _new(Crypt::Cipher::_trans_cipher_name(shift), @_) } +sub f9 { Crypt::Mac::F9->new(shift, shift)->add(@_)->mac } +sub f9_hex { Crypt::Mac::F9->new(shift, shift)->add(@_)->hexmac } +sub f9_b64 { Crypt::Mac::F9->new(shift, shift)->add(@_)->b64mac } +sub f9_b64u { Crypt::Mac::F9->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::F9 - Message authentication code F9 + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::F9 qw( f9 f9_hex ); + + # calculate MAC from string/buffer + $f9_raw = f9($cipher_name, $key, 'data buffer'); + $f9_hex = f9_hex($cipher_name, $key, 'data buffer'); + $f9_b64 = f9_b64($cipher_name, $key, 'data buffer'); + $f9_b64u = f9_b64u($cipher_name, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::F9; + + $d = Crypt::Mac::F9->new($cipher_name, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the F9 message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::F9 qw(f9 f9_hex ); + +Or all of them at once: + + use Crypt::Mac::F9 ':all'; + +=head1 FUNCTIONS + +=head2 f9 + +Logically joins all arguments into a single string, and returns its F9 message authentication code encoded as a binary string. + + $f9_raw = f9($cipher_name, $key, 'data buffer'); + #or + $f9_raw = f9($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 f9_hex + +Logically joins all arguments into a single string, and returns its F9 message authentication code encoded as a hexadecimal string. + + $f9_hex = f9_hex($cipher_name, $key, 'data buffer'); + #or + $f9_hex = f9_hex($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 f9_b64 + +Logically joins all arguments into a single string, and returns its F9 message authentication code encoded as a Base64 string. + + $f9_b64 = f9_b64($cipher_name, $key, 'data buffer'); + #or + $f9_b64 = f9_b64($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 f9_b64u + +Logically joins all arguments into a single string, and returns its F9 message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $f9_b64url = f9_b64u($cipher_name, $key, 'data buffer'); + #or + $f9_b64url = f9_b64u($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::F9->new($cipher_name, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/HMAC.pm b/lib/Crypt/Mac/HMAC.pm new file mode 100644 index 00000000..8a2567f3 --- /dev/null +++ b/lib/Crypt/Mac/HMAC.pm @@ -0,0 +1,160 @@ +package Crypt::Mac::HMAC; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( hmac hmac_hex hmac_b64 hmac_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +use Crypt::Digest; + +sub new { my $class = shift; _new(Crypt::Digest::_trans_digest_name(shift), @_) } +sub hmac { Crypt::Mac::HMAC->new(shift, shift)->add(@_)->mac } +sub hmac_hex { Crypt::Mac::HMAC->new(shift, shift)->add(@_)->hexmac } +sub hmac_b64 { Crypt::Mac::HMAC->new(shift, shift)->add(@_)->b64mac } +sub hmac_b64u { Crypt::Mac::HMAC->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::HMAC - Message authentication code HMAC + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::HMAC qw( hmac hmac_hex ); + + # calculate MAC from string/buffer + $hmac_raw = hmac('SHA256', $key, 'data buffer'); + $hmac_hex = hmac_hex('SHA256', $key, 'data buffer'); + $hmac_b64 = hmac_b64('SHA256', $key, 'data buffer'); + $hmac_b64u = hmac_b64u('SHA256', $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::HMAC; + + $d = Crypt::Mac::HMAC->new('SHA256', $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the HMAC message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::HMAC qw(hmac hmac_hex ); + +Or all of them at once: + + use Crypt::Mac::HMAC ':all'; + +=head1 FUNCTIONS + +=head2 hmac + +Logically joins all arguments into a single string, and returns its HMAC message authentication code encoded as a binary string. + + $hmac_raw = hmac($hash_name, $key, 'data buffer'); + #or + $hmac_raw = hmac($hash_name, $key, 'any data', 'more data', 'even more data'); + +=head2 hmac_hex + +Logically joins all arguments into a single string, and returns its HMAC message authentication code encoded as a hexadecimal string. + + $hmac_hex = hmac_hex($hash_name, $key, 'data buffer'); + #or + $hmac_hex = hmac_hex($hash_name, $key, 'any data', 'more data', 'even more data'); + +=head2 hmac_b64 + +Logically joins all arguments into a single string, and returns its HMAC message authentication code encoded as a Base64 string. + + $hmac_b64 = hmac_b64($hash_name, $key, 'data buffer'); + #or + $hmac_b64 = hmac_b64($hash_name, $key, 'any data', 'more data', 'even more data'); + +=head2 hmac_b64u + +Logically joins all arguments into a single string, and returns its HMAC message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $hmac_b64url = hmac_b64u($hash_name, $key, 'data buffer'); + #or + $hmac_b64url = hmac_b64u($hash_name, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::HMAC->new($hash_name, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://en.wikipedia.org/wiki/Hmac|https://en.wikipedia.org/wiki/Hmac> + +=item * L<https://tools.ietf.org/html/rfc2104|https://tools.ietf.org/html/rfc2104> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/OMAC.pm b/lib/Crypt/Mac/OMAC.pm new file mode 100644 index 00000000..3d752f07 --- /dev/null +++ b/lib/Crypt/Mac/OMAC.pm @@ -0,0 +1,158 @@ +package Crypt::Mac::OMAC; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +use Crypt::Cipher; + +sub new { my $class = shift; _new(Crypt::Cipher::_trans_cipher_name(shift), @_) } +sub omac { Crypt::Mac::OMAC->new(shift, shift)->add(@_)->mac } +sub omac_hex { Crypt::Mac::OMAC->new(shift, shift)->add(@_)->hexmac } +sub omac_b64 { Crypt::Mac::OMAC->new(shift, shift)->add(@_)->b64mac } +sub omac_b64u { Crypt::Mac::OMAC->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::OMAC - Message authentication code OMAC + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::OMAC qw( omac omac_hex ); + + # calculate MAC from string/buffer + $omac_raw = omac($cipher_name, $key, 'data buffer'); + $omac_hex = omac_hex($cipher_name, $key, 'data buffer'); + $omac_b64 = omac_b64($cipher_name, $key, 'data buffer'); + $omac_b64u = omac_b64u($cipher_name, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::OMAC; + + $d = Crypt::Mac::OMAC->new($cipher_name, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the OMAC message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::OMAC qw(omac omac_hex ); + +Or all of them at once: + + use Crypt::Mac::OMAC ':all'; + +=head1 FUNCTIONS + +=head2 omac + +Logically joins all arguments into a single string, and returns its OMAC message authentication code encoded as a binary string. + + $omac_raw = omac($cipher_name, $key, 'data buffer'); + #or + $omac_raw = omac($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 omac_hex + +Logically joins all arguments into a single string, and returns its OMAC message authentication code encoded as a hexadecimal string. + + $omac_hex = omac_hex($cipher_name, $key, 'data buffer'); + #or + $omac_hex = omac_hex($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 omac_b64 + +Logically joins all arguments into a single string, and returns its OMAC message authentication code encoded as a Base64 string. + + $omac_b64 = omac_b64($cipher_name, $key, 'data buffer'); + #or + $omac_b64 = omac_b64($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 omac_b64u + +Logically joins all arguments into a single string, and returns its OMAC message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $omac_b64url = omac_b64u($cipher_name, $key, 'data buffer'); + #or + $omac_b64url = omac_b64u($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::OMAC->new($cipher_name, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://en.wikipedia.org/wiki/OMAC_%28cryptography%29|https://en.wikipedia.org/wiki/OMAC_%28cryptography%29> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/PMAC.pm b/lib/Crypt/Mac/PMAC.pm new file mode 100644 index 00000000..04917ded --- /dev/null +++ b/lib/Crypt/Mac/PMAC.pm @@ -0,0 +1,158 @@ +package Crypt::Mac::PMAC; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( pmac pmac_hex pmac_b64 pmac_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +use Crypt::Cipher; + +sub new { my $class = shift; _new(Crypt::Cipher::_trans_cipher_name(shift), @_) } +sub pmac { Crypt::Mac::PMAC->new(shift, shift)->add(@_)->mac } +sub pmac_hex { Crypt::Mac::PMAC->new(shift, shift)->add(@_)->hexmac } +sub pmac_b64 { Crypt::Mac::PMAC->new(shift, shift)->add(@_)->b64mac } +sub pmac_b64u { Crypt::Mac::PMAC->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::PMAC - Message authentication code PMAC + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::PMAC qw( pmac pmac_hex ); + + # calculate MAC from string/buffer + $pmac_raw = pmac($cipher_name, $key, 'data buffer'); + $pmac_hex = pmac_hex($cipher_name, $key, 'data buffer'); + $pmac_b64 = pmac_b64($cipher_name, $key, 'data buffer'); + $pmac_b64u = pmac_b64u($cipher_name, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::PMAC; + + $d = Crypt::Mac::PMAC->new($cipher_name, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the PMAC message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::PMAC qw(pmac pmac_hex ); + +Or all of them at once: + + use Crypt::Mac::PMAC ':all'; + +=head1 FUNCTIONS + +=head2 pmac + +Logically joins all arguments into a single string, and returns its PMAC message authentication code encoded as a binary string. + + $pmac_raw = pmac($cipher_name, $key, 'data buffer'); + #or + $pmac_raw = pmac($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 pmac_hex + +Logically joins all arguments into a single string, and returns its PMAC message authentication code encoded as a hexadecimal string. + + $pmac_hex = pmac_hex($cipher_name, $key, 'data buffer'); + #or + $pmac_hex = pmac_hex($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 pmac_b64 + +Logically joins all arguments into a single string, and returns its PMAC message authentication code encoded as a Base64 string. + + $pmac_b64 = pmac_b64($cipher_name, $key, 'data buffer'); + #or + $pmac_b64 = pmac_b64($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 pmac_b64u + +Logically joins all arguments into a single string, and returns its PMAC message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $pmac_b64url = pmac_b64u($cipher_name, $key, 'data buffer'); + #or + $pmac_b64url = pmac_b64u($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::PMAC->new($cipher_name, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://en.wikipedia.org/wiki/PMAC_%28cryptography%29|https://en.wikipedia.org/wiki/PMAC_%28cryptography%29> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/Pelican.pm b/lib/Crypt/Mac/Pelican.pm new file mode 100644 index 00000000..374b5c99 --- /dev/null +++ b/lib/Crypt/Mac/Pelican.pm @@ -0,0 +1,156 @@ +package Crypt::Mac::Pelican; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( pelican pelican_hex pelican_b64 pelican_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +sub new { my $class = shift; _new(@_) } +sub pelican { Crypt::Mac::Pelican->new(shift)->add(@_)->mac } +sub pelican_hex { Crypt::Mac::Pelican->new(shift)->add(@_)->hexmac } +sub pelican_b64 { Crypt::Mac::Pelican->new(shift)->add(@_)->b64mac } +sub pelican_b64u { Crypt::Mac::Pelican->new(shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::Pelican - Message authentication code Pelican (AES based MAC) + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::Pelican qw( pelican pelican_hex ); + + # calculate MAC from string/buffer + $pelican_raw = pelican($key, 'data buffer'); + $pelican_hex = pelican_hex($key, 'data buffer'); + $pelican_b64 = pelican_b64($key, 'data buffer'); + $pelican_b64u = pelican_b64u($key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::Pelican; + + $d = Crypt::Mac::Pelican->new($key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the Pelican message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::Pelican qw(pelican pelican_hex ); + +Or all of them at once: + + use Crypt::Mac::Pelican ':all'; + +=head1 FUNCTIONS + +=head2 pelican + +Logically joins all arguments into a single string, and returns its Pelican message authentication code encoded as a binary string. + + $pelican_raw = pelican($key, 'data buffer'); + #or + $pelican_raw = pelican($key, 'any data', 'more data', 'even more data'); + +=head2 pelican_hex + +Logically joins all arguments into a single string, and returns its Pelican message authentication code encoded as a hexadecimal string. + + $pelican_hex = pelican_hex($key, 'data buffer'); + #or + $pelican_hex = pelican_hex($key, 'any data', 'more data', 'even more data'); + +=head2 pelican_b64 + +Logically joins all arguments into a single string, and returns its Pelican message authentication code encoded as a Base64 string. + + $pelican_b64 = pelican_b64($key, 'data buffer'); + #or + $pelican_b64 = pelican_b64($key, 'any data', 'more data', 'even more data'); + +=head2 pelican_b64u + +Logically joins all arguments into a single string, and returns its Pelican message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $pelican_b64url = pelican_b64u($key, 'data buffer'); + #or + $pelican_b64url = pelican_b64u($key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::Pelican->new($key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<http://eprint.iacr.org/2005/088.pdf|http://eprint.iacr.org/2005/088.pdf> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/Poly1305.pm b/lib/Crypt/Mac/Poly1305.pm new file mode 100644 index 00000000..1d9bf08f --- /dev/null +++ b/lib/Crypt/Mac/Poly1305.pm @@ -0,0 +1,156 @@ +package Crypt::Mac::Poly1305; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( poly1305 poly1305_hex poly1305_b64 poly1305_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +sub new { my $class = shift; _new(@_) } +sub poly1305 { Crypt::Mac::Poly1305->new(shift)->add(@_)->mac } +sub poly1305_hex { Crypt::Mac::Poly1305->new(shift)->add(@_)->hexmac } +sub poly1305_b64 { Crypt::Mac::Poly1305->new(shift)->add(@_)->b64mac } +sub poly1305_b64u { Crypt::Mac::Poly1305->new(shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::Poly1305 - Message authentication code Poly1305 (RFC 7539) + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::Poly1305 qw( poly1305 poly1305_hex ); + + # calculate MAC from string/buffer + $poly1305_raw = poly1305($key, 'data buffer'); + $poly1305_hex = poly1305_hex($key, 'data buffer'); + $poly1305_b64 = poly1305_b64($key, 'data buffer'); + $poly1305_b64u = poly1305_b64u($key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::Poly1305; + + $d = Crypt::Mac::Poly1305->new($key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the Poly1305 message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::Poly1305 qw(poly1305 poly1305_hex ); + +Or all of them at once: + + use Crypt::Mac::Poly1305 ':all'; + +=head1 FUNCTIONS + +=head2 poly1305 + +Logically joins all arguments into a single string, and returns its Poly1305 message authentication code encoded as a binary string. + + $poly1305_raw = poly1305($key, 'data buffer'); + #or + $poly1305_raw = poly1305($key, 'any data', 'more data', 'even more data'); + +=head2 poly1305_hex + +Logically joins all arguments into a single string, and returns its Poly1305 message authentication code encoded as a hexadecimal string. + + $poly1305_hex = poly1305_hex($key, 'data buffer'); + #or + $poly1305_hex = poly1305_hex($key, 'any data', 'more data', 'even more data'); + +=head2 poly1305_b64 + +Logically joins all arguments into a single string, and returns its Poly1305 message authentication code encoded as a Base64 string. + + $poly1305_b64 = poly1305_b64($key, 'data buffer'); + #or + $poly1305_b64 = poly1305_b64($key, 'any data', 'more data', 'even more data'); + +=head2 poly1305_b64u + +Logically joins all arguments into a single string, and returns its Poly1305 message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $poly1305_b64url = poly1305_b64u($key, 'data buffer'); + #or + $poly1305_b64url = poly1305_b64u($key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::Poly1305->new($key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://www.ietf.org/rfc/rfc7539.txt|https://www.ietf.org/rfc/rfc7539.txt> + +=back + +=cut + +__END__
\ No newline at end of file diff --git a/lib/Crypt/Mac/XCBC.pm b/lib/Crypt/Mac/XCBC.pm new file mode 100644 index 00000000..61da2248 --- /dev/null +++ b/lib/Crypt/Mac/XCBC.pm @@ -0,0 +1,158 @@ +package Crypt::Mac::XCBC; + +### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY! + +use strict; +use warnings; +our $VERSION = '0.048'; + +use base qw(Crypt::Mac Exporter); +our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_b64u )] ); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = qw(); + +use CryptX; +use Crypt::Cipher; + +sub new { my $class = shift; _new(Crypt::Cipher::_trans_cipher_name(shift), @_) } +sub xcbc { Crypt::Mac::XCBC->new(shift, shift)->add(@_)->mac } +sub xcbc_hex { Crypt::Mac::XCBC->new(shift, shift)->add(@_)->hexmac } +sub xcbc_b64 { Crypt::Mac::XCBC->new(shift, shift)->add(@_)->b64mac } +sub xcbc_b64u { Crypt::Mac::XCBC->new(shift, shift)->add(@_)->b64umac } + +1; + +=pod + +=head1 NAME + +Crypt::Mac::XCBC - Message authentication code XCBC (RFC 3566) + +=head1 SYNOPSIS + + ### Functional interface: + use Crypt::Mac::XCBC qw( xcbc xcbc_hex ); + + # calculate MAC from string/buffer + $xcbc_raw = xcbc($cipher_name, $key, 'data buffer'); + $xcbc_hex = xcbc_hex($cipher_name, $key, 'data buffer'); + $xcbc_b64 = xcbc_b64($cipher_name, $key, 'data buffer'); + $xcbc_b64u = xcbc_b64u($cipher_name, $key, 'data buffer'); + + ### OO interface: + use Crypt::Mac::XCBC; + + $d = Crypt::Mac::XCBC->new($cipher_name, $key); + $d->add('any data'); + $d->addfile('filename.dat'); + $d->addfile(*FILEHANDLE); + $result_raw = $d->mac; # raw bytes + $result_hex = $d->hexmac; # hexadecimal form + $result_b64 = $d->b64mac; # Base64 form + $result_b64u = $d->b64umac; # Base64 URL Safe form + +=head1 DESCRIPTION + +Provides an interface to the XCBC message authentication code (MAC) algorithm. + +=head1 EXPORT + +Nothing is exported by default. + +You can export selected functions: + + use Crypt::Mac::XCBC qw(xcbc xcbc_hex ); + +Or all of them at once: + + use Crypt::Mac::XCBC ':all'; + +=head1 FUNCTIONS + +=head2 xcbc + +Logically joins all arguments into a single string, and returns its XCBC message authentication code encoded as a binary string. + + $xcbc_raw = xcbc($cipher_name, $key, 'data buffer'); + #or + $xcbc_raw = xcbc($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 xcbc_hex + +Logically joins all arguments into a single string, and returns its XCBC message authentication code encoded as a hexadecimal string. + + $xcbc_hex = xcbc_hex($cipher_name, $key, 'data buffer'); + #or + $xcbc_hex = xcbc_hex($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 xcbc_b64 + +Logically joins all arguments into a single string, and returns its XCBC message authentication code encoded as a Base64 string. + + $xcbc_b64 = xcbc_b64($cipher_name, $key, 'data buffer'); + #or + $xcbc_b64 = xcbc_b64($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head2 xcbc_b64u + +Logically joins all arguments into a single string, and returns its XCBC message authentication code encoded as a Base64 URL Safe string (see RFC 4648 section 5). + + $xcbc_b64url = xcbc_b64u($cipher_name, $key, 'data buffer'); + #or + $xcbc_b64url = xcbc_b64u($cipher_name, $key, 'any data', 'more data', 'even more data'); + +=head1 METHODS + +=head2 new + + $d = Crypt::Mac::XCBC->new($cipher_name, $key); + +=head2 clone + + $d->clone(); + +=head2 reset + + $d->reset(); + +=head2 add + + $d->add('any data'); + #or + $d->add('any data', 'more data', 'even more data'); + +=head2 addfile + + $d->addfile('filename.dat'); + #or + $d->addfile(*FILEHANDLE); + +=head2 mac + + $result_raw = $d->mac(); + +=head2 hexmac + + $result_hex = $d->hexmac(); + +=head2 b64mac + + $result_b64 = $d->b64mac(); + +=head2 b64umac + + $result_b64url = $d->b64umac(); + +=head1 SEE ALSO + +=over + +=item * L<CryptX|CryptX> + +=item * L<https://www.ietf.org/rfc/rfc3566.txt|https://www.ietf.org/rfc/rfc3566.txt> + +=back + +=cut + +__END__
\ No newline at end of file |