diff options
Diffstat (limited to 'lib/Crypt/Mac/OMAC.pm')
-rw-r--r-- | lib/Crypt/Mac/OMAC.pm | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/lib/Crypt/Mac/OMAC.pm b/lib/Crypt/Mac/OMAC.pm index c9a48802..47027b7c 100644 --- a/lib/Crypt/Mac/OMAC.pm +++ b/lib/Crypt/Mac/OMAC.pm @@ -6,7 +6,7 @@ use strict; use warnings;
use Exporter 'import';
-our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 )] );
+our %EXPORT_TAGS = ( all => [qw( omac omac_hex omac_b64 omac_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
@@ -17,8 +17,9 @@ 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_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;
@@ -34,9 +35,10 @@ Crypt::Mac::OMAC - Message authentication code OMAC 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_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;
@@ -45,9 +47,10 @@ Crypt::Mac::OMAC - Message authentication code OMAC $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_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
@@ -85,15 +88,21 @@ Logically joins all arguments into a single string, and returns its OMAC message =head2 omac_b64
-Logically joins all arguments into a single string, and returns its OMAC message authentication code encoded as a BASE64 string.
+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');
-=head1 METHODS
+=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).
-The OO interface provides the same set of functions as L<Crypt::Mac>.
+ $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
@@ -131,6 +140,10 @@ The OO interface provides the same set of functions as L<Crypt::Mac>. $result_b64 = $d->b64mac();
+=head2 b64umac
+
+ $result_b64url = $d->b64umac();
+
=head1 SEE ALSO
=over 4
|