summaryrefslogtreecommitdiff
path: root/lib/Crypt/Mac/XCBC.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Crypt/Mac/XCBC.pm')
-rw-r--r--lib/Crypt/Mac/XCBC.pm37
1 files changed, 25 insertions, 12 deletions
diff --git a/lib/Crypt/Mac/XCBC.pm b/lib/Crypt/Mac/XCBC.pm
index c152c010..c5b2a1f5 100644
--- a/lib/Crypt/Mac/XCBC.pm
+++ b/lib/Crypt/Mac/XCBC.pm
@@ -6,7 +6,7 @@ use strict;
use warnings;
use Exporter 'import';
-our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 )] );
+our %EXPORT_TAGS = ( all => [qw( xcbc xcbc_hex xcbc_b64 xcbc_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 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_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;
@@ -34,9 +35,10 @@ Crypt::Mac::XCBC - Message authentication code XCBC
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_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;
@@ -45,9 +47,10 @@ Crypt::Mac::XCBC - Message authentication code XCBC
$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 XCBC message
=head2 xcbc_b64
-Logically joins all arguments into a single string, and returns its XCBC message authentication code encoded as a BASE64 string.
+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');
-=head1 METHODS
+=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).
-The OO interface provides the same set of functions as L<Crypt::Mac>.
+ $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
@@ -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