Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
package Crypt::AuthEnc;
use strict;
use warnings;
our $VERSION = '0.069';
### not used
1;
=pod
=head1 NAME
Crypt::AuthEnc - [internal only]
=cut

View File

@@ -0,0 +1,136 @@
package Crypt::AuthEnc::CCM;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( ccm_encrypt_authenticate ccm_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::CCM - Authenticated encryption in CCM mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::CCM;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::CCM->new("AES", $key, $iv, $adata, $tag_len, $pt_len);
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::CCM->new("AES", $key, $iv, $adata, $tag_len, $pt_len);
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::CCM qw(ccm_encrypt_authenticate ccm_decrypt_verify);
($ciphertext, $tag) = ccm_encrypt_authenticate('AES', $key, $nonce, $adata, $tag_len, $plaintext);
$plaintext = ccm_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
CCM is a encrypt+authenticate mode that is centered around using AES (or any 16-byte cipher) as a primitive.
Unlike EAX and OCB mode, it is only meant for packet mode where the length of the input is known in advance.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::CCM qw(ccm_encrypt_authenticate ccm_decrypt_verify);
=head1 FUNCTIONS
=head2 ccm_encrypt_authenticate
my ($ciphertext, $tag) = ccm_encrypt_authenticate($cipher, $key, $nonce, $adata, $tag_len, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... key of proper length (e.g. 128/192/256bits for AES)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
CCM parameters should follow L<http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf>
# tag length: 4, 6, 8, 10, 12, 14, 16 (reasonable minimum is 8)
# nonce length: 7, 8, 9, 10, 11, 12, 13 (if you are not sure, use 11)
# BEWARE nonce length determines max. enc/dec data size: max_data_size = 2^(8*(15-nonce_len))
=head2 ccm_decrypt_verify
my $plaintext = ccm_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::CCM->new($cipher, $key, $nonce, $adata, $tag_len, $pt_len);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... key of proper length (e.g. 128/192/256bits for AES)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
# $pt_len .. expected length of plaintext/ciphertext to encrypt/decrypt
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
my $tag = $ae->encrypt_done; # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/CCM_mode|https://en.wikipedia.org/wiki/CCM_mode>
=back
=cut

View File

@@ -0,0 +1,147 @@
package Crypt::AuthEnc::ChaCha20Poly1305;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::ChaCha20Poly1305 - Authenticated encryption in ChaCha20-Poly1305 mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::ChaCha20Poly1305;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::ChaCha20Poly1305 qw(chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify);
my ($ciphertext, $tag) = chacha20poly1305_encrypt_authenticate($key, $iv, $adata, $plaintext);
my $plaintext = chacha20poly1305_decrypt_verify($key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
Provides encryption and authentication based on ChaCha20 + Poly1305 as defined in RFC 7539 - L<https://tools.ietf.org/html/rfc7539>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::ChaCha20Poly1305 qw(chacha20poly1305_encrypt_authenticate chacha20poly1305_decrypt_verify);
=head1 FUNCTIONS
=head2 chacha20poly1305_encrypt_authenticate
my ($ciphertext, $tag) = chacha20poly1305_encrypt_authenticate($key, $iv, $adata, $plaintext);
# $key ..... key of proper length (128 or 256 bits / 16 or 32 bytes)
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
# $adata ... additional authenticated data (optional)
=head2 chacha20poly1305_decrypt_verify
my $plaintext = chacha20poly1305_decrypt_verify($key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key, $iv);
# $key ..... encryption key of proper length (128 or 256 bits / 16 or 32 bytes)
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
=head2 adata_add
Add B<additional authenticated data>.
Can be called before the first C<encrypt_add> or C<decrypt_add>;
$ae->adata_add($aad_data); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 set_iv
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv($iv);
# $iv ...... initialization vector (64 or 96 bits / 8 or 12 bytes)
=head2 set_iv_rfc7905
See L<https://tools.ietf.org/html/rfc7905>
my $ae = Crypt::AuthEnc::ChaCha20Poly1305->new($key)->set_iv_rfc7905($iv, $seqnum);
# $iv ...... initialization vector (96 bits / 12 bytes)
# $seqnum .. 64bit integer (sequence number)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://tools.ietf.org/html/rfc7539>
=back
=cut

View File

@@ -0,0 +1,142 @@
package Crypt::AuthEnc::EAX;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( eax_encrypt_authenticate eax_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
# obsolete, only for backwards compatibility
sub header_add { goto &adata_add }
sub aad_add { goto &adata_add }
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::EAX;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::EAX->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::EAX qw(eax_encrypt_authenticate eax_decrypt_verify);
my ($ciphertext, $tag) = eax_encrypt_authenticate('AES', $key, $iv, $adata, $plaintext);
my $plaintext = eax_decrypt_verify('AES', $key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
EAX is a mode that requires a cipher, CTR and OMAC support and provides encryption and authentication.
It is initialized with a random IV that can be shared publicly, additional authenticated data which can
be fixed and public, and a random secret symmetric key.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::EAX qw(eax_encrypt_authenticate eax_decrypt_verify);
=head1 FUNCTIONS
=head2 eax_encrypt_authenticate
my ($ciphertext, $tag) = eax_encrypt_authenticate($cipher, $key, $iv, $adata, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... unique initialization vector (no need to keep it secret)
# $adata ... additional authenticated data
=head2 eax_decrypt_verify
my $plaintext = eax_decrypt_verify($cipher, $key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv);
#or
my $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv, $adata);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... unique initialization vector (no need to keep it secret)
# $adata ... additional authenticated data (optional)
=head2 adata_add
$ae->adata_add($adata); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/EAX_mode|https://en.wikipedia.org/wiki/EAX_mode>
=back
=cut

View File

@@ -0,0 +1,148 @@
package Crypt::AuthEnc::GCM;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( gcm_encrypt_authenticate gcm_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::GCM - Authenticated encryption in GCM mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::GCM;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::GCM->new("AES", $key, $iv);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
my ($ciphertext, $tag) = gcm_encrypt_authenticate('AES', $key, $iv, $adata, $plaintext);
my $plaintext = gcm_decrypt_verify('AES', $key, $iv, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
Galois/Counter Mode (GCM) - provides encryption and authentication.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::GCM qw(gcm_encrypt_authenticate gcm_decrypt_verify);
=head1 FUNCTIONS
=head2 gcm_encrypt_authenticate
my ($ciphertext, $tag) = gcm_encrypt_authenticate($cipher, $key, $iv, $adata, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $iv ...... initialization vector
# $adata ... additional authenticated data
=head2 gcm_decrypt_verify
my $plaintext = gcm_decrypt_verify($cipher, $key, $iv, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::GCM->new($cipher, $key);
#or
my $ae = Crypt::AuthEnc::GCM->new($cipher, $key, $iv);
# $cipher .. 'AES' or name of any other cipher
# $key ..... encryption key of proper length
# $iv ...... initialization vector (optional, you can set it later via iv_add method)
=head2 iv_add
Set initialization vector (IV).
$ae->iv_add($iv_data); #can be called multiple times
=head2 adata_add
Add B<additional authenticated data>.
Can be called B<after> all C<iv_add> calls but before the first C<encrypt_add> or C<decrypt_add>.
$ae->adata_add($aad_data); # can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 reset
$ae->reset;
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>, L<Crypt::AuthEnc::OCB|Crypt::AuthEnc::OCB>
=item * L<https://en.wikipedia.org/wiki/Galois/Counter_Mode>
=back
=cut

View File

@@ -0,0 +1,155 @@
package Crypt::AuthEnc::OCB;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( ocb_encrypt_authenticate ocb_decrypt_verify )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
# obsolete, only for backwards compatibility
sub aad_add { goto &adata_add }
sub blocksize { return 16 }
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::AuthEnc::OCB - Authenticated encryption in OCBv3 mode
=head1 SYNOPSIS
### OO interface
use Crypt::AuthEnc::OCB;
# encrypt and authenticate
my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $ct = $ae->encrypt_add('data1');
$ct .= $ae->encrypt_add('data2');
$ct .= $ae->encrypt_add('data3');
$ct .= $ae->encrypt_last('rest of data');
my $tag = $ae->encrypt_done();
# decrypt and verify
my $ae = Crypt::AuthEnc::OCB->new("AES", $key, $nonce, $tag_len);
$ae->adata_add('additional_authenticated_data1');
$ae->adata_add('additional_authenticated_data2');
my $pt = $ae->decrypt_add('ciphertext1');
$pt .= $ae->decrypt_add('ciphertext2');
$pt .= $ae->decrypt_add('ciphertext3');
$pt .= $ae->decrypt_last('rest of data');
my $tag = $ae->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag;
#or
my $result = $ae->decrypt_done($expected_tag); # 0 or 1
### functional interface
use Crypt::AuthEnc::OCB qw(ocb_encrypt_authenticate ocb_decrypt_verify);
my ($ciphertext, $tag) = ocb_encrypt_authenticate('AES', $key, $nonce, $adata, $tag_len, $plaintext);
my $plaintext = ocb_decrypt_verify('AES', $key, $nonce, $adata, $ciphertext, $tag);
=head1 DESCRIPTION
This module implements OCB v3 according to L<https://tools.ietf.org/html/rfc7253>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::AuthEnc::OCB qw(ocb_encrypt_authenticate ocb_decrypt_verify);
=head1 FUNCTIONS
=head2 ocb_encrypt_authenticate
my ($ciphertext, $tag) = ocb_encrypt_authenticate($cipher, $key, $nonce, $adata, $tag_len, $plaintext);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $adata ... additional authenticated data
# $tag_len . required length of output tag
=head2 ocb_decrypt_verify
my $plaintext = ocb_decrypt_verify($cipher, $key, $nonce, $adata, $ciphertext, $tag);
# on error returns undef
=head1 METHODS
=head2 new
my $ae = Crypt::AuthEnc::OCB->new($cipher, $key, $nonce, $tag_len);
# $cipher .. 'AES' or name of any other cipher with 16-byte block len
# $key ..... AES key of proper length (128/192/256bits)
# $nonce ... unique nonce/salt (no need to keep it secret)
# $tag_len . required length of output tag
=head2 adata_add
$ae->adata_add($adata); #can be called multiple times
=head2 encrypt_add
$ciphertext = $ae->encrypt_add($data); # can be called multiple times
#BEWARE: size of $data has to be multiple of blocklen (16 for AES)
=head2 encrypt_last
$ciphertext = $ae->encrypt_last($data);
=head2 encrypt_done
$tag = $ae->encrypt_done(); # returns $tag value
=head2 decrypt_add
$plaintext = $ae->decrypt_add($ciphertext); # can be called multiple times
#BEWARE: size of $ciphertext has to be multiple of blocklen (16 for AES)
=head2 decrypt_last
$plaintext = $ae->decrypt_last($data);
=head2 decrypt_done
my $tag = $ae->decrypt_done; # returns $tag value
#or
my $result = $ae->decrypt_done($tag); # returns 1 (success) or 0 (failure)
=head2 clone
my $ae_new = $ae->clone;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::AuthEnc::CCM|Crypt::AuthEnc::CCM>, L<Crypt::AuthEnc::GCM|Crypt::AuthEnc::GCM>, L<Crypt::AuthEnc::EAX|Crypt::AuthEnc::EAX>
=item * L<https://en.wikipedia.org/wiki/OCB_mode>
=item * L<https://tools.ietf.org/html/rfc7253>
=back
=cut

View File

@@ -0,0 +1,194 @@
package Crypt::Blowfish;
require Exporter;
require DynaLoader;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter DynaLoader);
# @ISA = qw(Exporter DynaLoader Crypt::BlockCipher);
# Items to export into callers namespace by default
@EXPORT = qw();
# Other items we are prepared to export if requested
@EXPORT_OK = qw(
blocksize keysize min_keysize max_keysize
new encrypt decrypt
);
$VERSION = '2.14';
bootstrap Crypt::Blowfish $VERSION;
use strict;
use Carp;
sub usage
{
my ($package, $filename, $line, $subr) = caller(1);
$Carp::CarpLevel = 2;
croak "Usage: $subr(@_)";
}
sub blocksize { 8; } # /* byte my shiny metal.. */
sub keysize { 0; } # /* we'll leave this at 8 .. for now. */
sub min_keysize { 8; }
sub max_keysize { 56; }
sub new
{
usage("new Blowfish key") unless @_ == 2;
my $type = shift; my $self = {}; bless $self, $type;
$self->{'ks'} = Crypt::Blowfish::init(shift);
return $self;
}
sub encrypt
{
usage("encrypt data[8 bytes]") unless @_ == 2;
my ($self,$data) = @_;
Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 0);
return $data;
}
sub decrypt
{
usage("decrypt data[8 bytes]") unless @_ == 2;
my ($self,$data) = @_;
Crypt::Blowfish::crypt($data, $data, $self->{'ks'}, 1);
return $data;
}
1;
__END__
#
# Parts Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
# New Parts Copyright (C) 1999, 2001 W3Works, LLC (http://www.w3works.com/)
# All rights reserved.
#
=head1 NAME
Crypt::Blowfish - Perl Blowfish encryption module
=head1 SYNOPSIS
use Crypt::Blowfish;
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt($plaintext);
my $plaintext = $cipher->decrypt($ciphertext);
You probably want to use this in conjunction with
a block chaining module like Crypt::CBC.
=head1 DESCRIPTION
Blowfish is capable of strong encryption and can use key sizes up
to 56 bytes (a 448 bit key). You're encouraged to take advantage
of the full key size to ensure the strongest encryption possible
from this module.
Crypt::Blowfish has the following methods:
=over 4
blocksize()
keysize()
encrypt()
decrypt()
=back
=head1 FUNCTIONS
=over 4
=item blocksize
Returns the size (in bytes) of the block cipher.
Crypt::Blowfish doesn't return a key size due to its ability
to use variable-length keys. More accurately, it shouldn't,
but it does anyway to play nicely with others.
=item new
my $cipher = new Crypt::Blowfish $key;
This creates a new Crypt::Blowfish BlockCipher object, using $key,
where $key is a key of C<keysize()> bytes (minimum of eight bytes).
=item encrypt
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt($plaintext);
This function encrypts $plaintext and returns the $ciphertext
where $plaintext and $ciphertext must be of C<blocksize()> bytes.
(hint: Blowfish is an 8 byte block cipher)
=item decrypt
my $cipher = new Crypt::Blowfish $key;
my $plaintext = $cipher->decrypt($ciphertext);
This function decrypts $ciphertext and returns the $plaintext
where $plaintext and $ciphertext must be of C<blocksize()> bytes.
(hint: see previous hint)
=back
=head1 EXAMPLE
my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes
my $cipher = new Crypt::Blowfish $key;
my $ciphertext = $cipher->encrypt("plaintex"); # SEE NOTES
print unpack("H16", $ciphertext), "\n";
=head1 PLATFORMS
Please see the README document for platforms and performance
tests.
=head1 NOTES
The module is capable of being used with Crypt::CBC. You're
encouraged to read the perldoc for Crypt::CBC if you intend to
use this module for Cipher Block Chaining modes. In fact, if
you have any intentions of encrypting more than eight bytes of
data with this, or any other block cipher, you're going to need
B<some> type of block chaining help. Crypt::CBC tends to be
very good at this. If you're not going to encrypt more than
eight bytes, your data B<must> be B<exactly> eight bytes long.
If need be, do your own padding. "\0" as a null byte is perfectly
valid to use for this.
=head1 SEE ALSO
Crypt::CBC,
Crypt::DES,
Crypt::IDEA
Bruce Schneier, I<Applied Cryptography>, 1995, Second Edition,
published by John Wiley & Sons, Inc.
=head1 COPYRIGHT
The implementation of the Blowfish algorithm was developed by,
and is copyright of, A.M. Kuchling.
Other parts of the perl extension and module are
copyright of Systemics Ltd ( http://www.systemics.com/ ).
Code revisions, updates, and standalone release are copyright
1999-2010 W3Works, LLC.
=head1 AUTHOR
Original algorithm, Bruce Shneier. Original implementation, A.M.
Kuchling. Original Perl implementation, Systemics Ltd. Current
maintenance by W3Works, LLC.
Current revision and maintainer: Dave Paris <amused@pobox.com>

View File

@@ -0,0 +1,261 @@
package Crypt::CAST5_PP;
require 5.004;
use strict;
use AutoLoader qw( AUTOLOAD );
use Carp;
use integer;
use vars qw( @s1 @s2 @s3 @s4 @s5 @s6 @s7 @s8 $VERSION );
$VERSION = "1.04";
sub new {
my ($class, $key) = @_;
my $cast5 = { };
bless $cast5 => $class;
$cast5->init($key) if defined $key;
return $cast5;
} # new
sub blocksize { return 8 }
sub keysize { return 16 }
1 # end module
__END__
=head1 NAME
Crypt::CAST5_PP - CAST5 block cipher in pure Perl
=head1 SYNOPSIS
use Crypt::CBC;
my $crypt = Crypt::CBC->new({
key => "secret key",
cipher => "CAST5_PP",
});
my $message = "All mimsy were the borogoves";
my $ciphertext = $crypt->encrypt($message);
print unpack("H*", $ciphertext), "\n";
my $plaintext = $crypt->decrypt($ciphertext);
print $plaintext, "\n";
=head1 DESCRIPTION
This module provides a pure Perl implementation of the CAST5 block cipher.
CAST5 is also known as CAST-128. It is a product of the CAST design
procedure developed by C. Adams and S. Tavares.
The CAST5 cipher is available royalty-free.
=head1 FUNCTIONS
=head2 blocksize
Returns the CAST5 block size, which is 8 bytes. This function exists
so that Crypt::CAST5_PP can work with Crypt::CBC.
=head2 keysize
Returns the maximum CAST5 key size, 16 bytes.
=head2 new
$cast5 = Crypt::CAST5_PP->new($key);
Create a new encryption object. If the optional key parameter is given,
it will be passed to the init() function.
=head2 init
$cast5->init($key);
Set or change the encryption key to be used. The key must be from 40 bits
(5 bytes) to 128 bits (16 bytes) in length. Note that if the key used is
80 bits or less, encryption and decryption will be somewhat faster.
It is best for the key to be random binary data, not something printable
like a password. A message digest function may be useful for converting
a password to an encryption key; see L<Digest::SHA1> or L<Digest::MD5>.
Note that Crypt::CBC runs the given "key" through MD5 to get the actual
encryption key.
=head2 encrypt
$ciphertext = $cast5->encrypt($plaintext);
Encrypt a block of plaintext using the current encryption key, and return
the corresponding ciphertext. The input must be 8 bytes long, and the output
has the same length. Note that the encryption is in ECB mode, which means
that it encrypts each block independently. That can leave you vulnerable
to dictionary attacks, so it is generally best to use some form of chaining
between blocks; see L<Crypt::CBC>.
=head2 decrypt
$plaintext = $cast5->decrypt($ciphertext);
Decrypt the ciphertext and return the corresponding plaintext.
=head1 LIMITATIONS
Always produces untainted output, even if the input is tainted, because
that's what perl's pack() function does.
=head1 SEE ALSO
RFC 2144, "The CAST-128 Encryption Algorithm", C. Adams, May 1997
L<Crypt::CBC>
=head1 AUTHOR
Bob Mathews, <bobmathews@alumni.calpoly.edu>
=head1 COPYRIGHT
Copyright (c) 2006 Bob Mathews. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
sub init {
use strict;
use integer;
my ($cast5, $key) = @_;
croak "Key length must be 40 to 128 bits"
if length($key) < 5 || length($key) > 16;
require Crypt::CAST5_PP::Tables;
# untaint the key. this keeps the evals from blowing up later.
# arguably, a tainted key should result in tainted output. oh well.
$key =~ /^(.*)$/s and $key = $1;
# null-pad the key to 16 bytes, and then split it into 32-bit chunks
my ($s, $t, $u, $v) = unpack "N4", pack "a16", $key;
# compute the key schedule
# don't try to read this -- it's generated by mkschedule
my ($w, $x, $y, $z, @k);
for (1..2) {
$w=$s^$s5[$v>>16&255]^$s6[$v&255]^$s7[$v>>24&255]^$s8[$v>>8&255]^$s7[$u>>24&255];
$x=$u^$s5[$w>>24&255]^$s6[$w>>8&255]^$s7[$w>>16&255]^$s8[$w&255]^$s8[$u>>8&255];
$y=$v^$s5[$x&255]^$s6[$x>>8&255]^$s7[$x>>16&255]^$s8[$x>>24&255]^$s5[$u>>16&255];
$z=$t^$s5[$y>>8&255]^$s6[$y>>16&255]^$s7[$y&255]^$s8[$y>>24&255]^$s6[$u&255];
push@k,$s5[$y>>24&255]^$s6[$y>>16&255]^$s7[$x&255]^$s8[$x>>8&255]^$s5[$w>>8&255];
push@k,$s5[$y>>8&255]^$s6[$y&255]^$s7[$x>>16&255]^$s8[$x>>24&255]^$s6[$x>>8&255];
push@k,$s5[$z>>24&255]^$s6[$z>>16&255]^$s7[$w&255]^$s8[$w>>8&255]^$s7[$y>>16&255];
push@k,$s5[$z>>8&255]^$s6[$z&255]^$s7[$w>>16&255]^$s8[$w>>24&255]^$s8[$z>>24&255];
$s=$y^$s5[$x>>16&255]^$s6[$x&255]^$s7[$x>>24&255]^$s8[$x>>8&255]^$s7[$w>>24&255];
$t=$w^$s5[$s>>24&255]^$s6[$s>>8&255]^$s7[$s>>16&255]^$s8[$s&255]^$s8[$w>>8&255];
$u=$x^$s5[$t&255]^$s6[$t>>8&255]^$s7[$t>>16&255]^$s8[$t>>24&255]^$s5[$w>>16&255];
$v=$z^$s5[$u>>8&255]^$s6[$u>>16&255]^$s7[$u&255]^$s8[$u>>24&255]^$s6[$w&255];
push@k,$s5[$s&255]^$s6[$s>>8&255]^$s7[$v>>24&255]^$s8[$v>>16&255]^$s5[$u>>24&255];
push@k,$s5[$s>>16&255]^$s6[$s>>24&255]^$s7[$v>>8&255]^$s8[$v&255]^$s6[$v>>16&255];
push@k,$s5[$t&255]^$s6[$t>>8&255]^$s7[$u>>24&255]^$s8[$u>>16&255]^$s7[$s&255];
push@k,$s5[$t>>16&255]^$s6[$t>>24&255]^$s7[$u>>8&255]^$s8[$u&255]^$s8[$t&255];
$w=$s^$s5[$v>>16&255]^$s6[$v&255]^$s7[$v>>24&255]^$s8[$v>>8&255]^$s7[$u>>24&255];
$x=$u^$s5[$w>>24&255]^$s6[$w>>8&255]^$s7[$w>>16&255]^$s8[$w&255]^$s8[$u>>8&255];
$y=$v^$s5[$x&255]^$s6[$x>>8&255]^$s7[$x>>16&255]^$s8[$x>>24&255]^$s5[$u>>16&255];
$z=$t^$s5[$y>>8&255]^$s6[$y>>16&255]^$s7[$y&255]^$s8[$y>>24&255]^$s6[$u&255];
push@k,$s5[$w&255]^$s6[$w>>8&255]^$s7[$z>>24&255]^$s8[$z>>16&255]^$s5[$y>>16&255];
push@k,$s5[$w>>16&255]^$s6[$w>>24&255]^$s7[$z>>8&255]^$s8[$z&255]^$s6[$z>>24&255];
push@k,$s5[$x&255]^$s6[$x>>8&255]^$s7[$y>>24&255]^$s8[$y>>16&255]^$s7[$w>>8&255];
push@k,$s5[$x>>16&255]^$s6[$x>>24&255]^$s7[$y>>8&255]^$s8[$y&255]^$s8[$x>>8&255];
$s=$y^$s5[$x>>16&255]^$s6[$x&255]^$s7[$x>>24&255]^$s8[$x>>8&255]^$s7[$w>>24&255];
$t=$w^$s5[$s>>24&255]^$s6[$s>>8&255]^$s7[$s>>16&255]^$s8[$s&255]^$s8[$w>>8&255];
$u=$x^$s5[$t&255]^$s6[$t>>8&255]^$s7[$t>>16&255]^$s8[$t>>24&255]^$s5[$w>>16&255];
$v=$z^$s5[$u>>8&255]^$s6[$u>>16&255]^$s7[$u&255]^$s8[$u>>24&255]^$s6[$w&255];
push@k,$s5[$u>>24&255]^$s6[$u>>16&255]^$s7[$t&255]^$s8[$t>>8&255]^$s5[$s&255];
push@k,$s5[$u>>8&255]^$s6[$u&255]^$s7[$t>>16&255]^$s8[$t>>24&255]^$s6[$t&255];
push@k,$s5[$v>>24&255]^$s6[$v>>16&255]^$s7[$s&255]^$s8[$s>>8&255]^$s7[$u>>24&255];
push@k,$s5[$v>>8&255]^$s6[$v&255]^$s7[$s>>16&255]^$s8[$s>>24&255]^$s8[$v>>16&255];
}
for (16..31) { $k[$_] &= 31 }
delete $cast5->{encrypt};
delete $cast5->{decrypt};
$cast5->{rounds} = length($key) <= 10 ? 12 : 16;
$cast5->{key} = \@k;
return $cast5;
} # init
sub encrypt {
use strict;
use integer;
my ($cast5, $block) = @_;
croak "Block size must be 8" if length($block) != 8;
my $encrypt = $cast5->{encrypt};
unless ($encrypt) {
my $key = $cast5->{key} or croak "Call init() first";
my $f = 'sub{my($l,$r,$i)=unpack"N2",$_[0];';
my ($l, $r) = qw( $l $r );
my ($op1, $op2, $op3) = qw( + ^ - );
foreach my $round (0 .. $cast5->{rounds}-1) {
my $km = $key->[$round];
my $kr = $key->[$round+16];
my $rot = "";
if ($kr) {
my $mask = ~(~0<<$kr) & 0xffffffff;
my $kr2 = 32-$kr;
$rot = "\$i=\$i<<$kr|\$i>>$kr2&$mask;"
}
$f .= "\$i=$km$op1$r;$rot$l^=((\$s1[\$i>>24&255]$op2\$s2[\$i>>16&255])$op3\$s3[\$i>>8&255])$op1\$s4[\$i&255];";
($l, $r) = ($r, $l);
($op1, $op2, $op3) = ($op2, $op3, $op1);
}
$f .= 'pack"N2",$r&0xffffffff,$l&0xffffffff}';
$cast5->{encrypt} = $encrypt = eval $f;
}
return $encrypt->($block);
} # encrypt
sub decrypt {
use strict;
use integer;
my ($cast5, $block) = @_;
croak "Block size must be 8" if length($block) != 8;
my $decrypt = $cast5->{decrypt};
unless ($decrypt) {
my $key = $cast5->{key} or croak "Call init() first";
my $rounds = $cast5->{rounds};
my $f = 'sub{my($r,$l,$i)=unpack"N2",$_[0];';
my ($l, $r) = qw( $r $l );
my ($op1, $op2, $op3) = qw( - + ^ );
foreach (1 .. $rounds%3) { ($op1, $op2, $op3) = ($op2, $op3, $op1) }
foreach my $round (1 .. $rounds) {
my $km = $key->[$rounds-$round];
my $kr = $key->[$rounds-$round+16];
my $rot = "";
if ($kr) {
my $mask = ~(~0<<$kr) & 0xffffffff;
my $kr2 = 32-$kr;
$rot = "\$i=\$i<<$kr|\$i>>$kr2&$mask;"
}
$f .= "\$i=$km$op1$r;$rot$l^=((\$s1[\$i>>24&255]$op2\$s2[\$i>>16&255])$op3\$s3[\$i>>8&255])$op1\$s4[\$i&255];";
($l, $r) = ($r, $l);
($op1, $op2, $op3) = ($op3, $op1, $op2);
}
$f .= 'pack"N2",$l&0xffffffff,$r&0xffffffff}';
$cast5->{decrypt} = $decrypt = eval $f;
}
return $decrypt->($block);
} # decrypt
# end CAST5_PP.pm

View File

@@ -0,0 +1,375 @@
# Crypt::CAST5_PP::Tables
# S-box tables for CAST5 encryption
use strict;
use integer;
@Crypt::CAST5_PP::s1 = (
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3,
0x6003e540, 0xcf9fc949, 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675,
0x6e63a0e0, 0x15c361d2, 0xc2e7661d, 0x22d4ff8e, 0x28683b6f, 0xc07fd059,
0xff2379c8, 0x775f50e2, 0x43c340d3, 0xdf2f8656, 0x887ca41a, 0xa2d2bd2d,
0xa1c9e0d6, 0x346c4819, 0x61b76d87, 0x22540f2f, 0x2abe32e1, 0xaa54166b,
0x22568e3a, 0xa2d341d0, 0x66db40c8, 0xa784392f, 0x004dff2f, 0x2db9d2de,
0x97943fac, 0x4a97c1d8, 0x527644b7, 0xb5f437a7, 0xb82cbaef, 0xd751d159,
0x6ff7f0ed, 0x5a097a1f, 0x827b68d0, 0x90ecf52e, 0x22b0c054, 0xbc8e5935,
0x4b6d2f7f, 0x50bb64a2, 0xd2664910, 0xbee5812d, 0xb7332290, 0xe93b159f,
0xb48ee411, 0x4bff345d, 0xfd45c240, 0xad31973f, 0xc4f6d02e, 0x55fc8165,
0xd5b1caad, 0xa1ac2dae, 0xa2d4b76d, 0xc19b0c50, 0x882240f2, 0x0c6e4f38,
0xa4e4bfd7, 0x4f5ba272, 0x564c1d2f, 0xc59c5319, 0xb949e354, 0xb04669fe,
0xb1b6ab8a, 0xc71358dd, 0x6385c545, 0x110f935d, 0x57538ad5, 0x6a390493,
0xe63d37e0, 0x2a54f6b3, 0x3a787d5f, 0x6276a0b5, 0x19a6fcdf, 0x7a42206a,
0x29f9d4d5, 0xf61b1891, 0xbb72275e, 0xaa508167, 0x38901091, 0xc6b505eb,
0x84c7cb8c, 0x2ad75a0f, 0x874a1427, 0xa2d1936b, 0x2ad286af, 0xaa56d291,
0xd7894360, 0x425c750d, 0x93b39e26, 0x187184c9, 0x6c00b32d, 0x73e2bb14,
0xa0bebc3c, 0x54623779, 0x64459eab, 0x3f328b82, 0x7718cf82, 0x59a2cea6,
0x04ee002e, 0x89fe78e6, 0x3fab0950, 0x325ff6c2, 0x81383f05, 0x6963c5c8,
0x76cb5ad6, 0xd49974c9, 0xca180dcf, 0x380782d5, 0xc7fa5cf6, 0x8ac31511,
0x35e79e13, 0x47da91d0, 0xf40f9086, 0xa7e2419e, 0x31366241, 0x051ef495,
0xaa573b04, 0x4a805d8d, 0x548300d0, 0x00322a3c, 0xbf64cddf, 0xba57a68e,
0x75c6372b, 0x50afd341, 0xa7c13275, 0x915a0bf5, 0x6b54bfab, 0x2b0b1426,
0xab4cc9d7, 0x449ccd82, 0xf7fbf265, 0xab85c5f3, 0x1b55db94, 0xaad4e324,
0xcfa4bd3f, 0x2deaa3e2, 0x9e204d02, 0xc8bd25ac, 0xeadf55b3, 0xd5bd9e98,
0xe31231b2, 0x2ad5ad6c, 0x954329de, 0xadbe4528, 0xd8710f69, 0xaa51c90f,
0xaa786bf6, 0x22513f1e, 0xaa51a79b, 0x2ad344cc, 0x7b5a41f0, 0xd37cfbad,
0x1b069505, 0x41ece491, 0xb4c332e6, 0x032268d4, 0xc9600acc, 0xce387e6d,
0xbf6bb16c, 0x6a70fb78, 0x0d03d9c9, 0xd4df39de, 0xe01063da, 0x4736f464,
0x5ad328d8, 0xb347cc96, 0x75bb0fc3, 0x98511bfb, 0x4ffbcc35, 0xb58bcf6a,
0xe11f0abc, 0xbfc5fe4a, 0xa70aec10, 0xac39570a, 0x3f04442f, 0x6188b153,
0xe0397a2e, 0x5727cb79, 0x9ceb418f, 0x1cacd68d, 0x2ad37c96, 0x0175cb9d,
0xc69dff09, 0xc75b65f0, 0xd9db40d8, 0xec0e7779, 0x4744ead4, 0xb11c3274,
0xdd24cb9e, 0x7e1c54bd, 0xf01144f9, 0xd2240eb1, 0x9675b3fd, 0xa3ac3755,
0xd47c27af, 0x51c85f4d, 0x56907596, 0xa5bb15e6, 0x580304f0, 0xca042cf1,
0x011a37ea, 0x8dbfaadb, 0x35ba3e4a, 0x3526ffa0, 0xc37b4d09, 0xbc306ed9,
0x98a52666, 0x5648f725, 0xff5e569d, 0x0ced63d0, 0x7c63b2cf, 0x700b45e1,
0xd5ea50f1, 0x85a92872, 0xaf1fbda7, 0xd4234870, 0xa7870bf3, 0x2d3b4d79,
0x42e04198, 0x0cd0ede7, 0x26470db8, 0xf881814c, 0x474d6ad7, 0x7c0c5e5c,
0xd1231959, 0x381b7298, 0xf5d2f4db, 0xab838653, 0x6e2f1e23, 0x83719c9e,
0xbd91e046, 0x9a56456e, 0xdc39200c, 0x20c8c571, 0x962bda1c, 0xe1e696ff,
0xb141ab08, 0x7cca89b9, 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d,
0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf,
);
@Crypt::CAST5_PP::s2 = (
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a,
0x55889c94, 0x72fc0651, 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba,
0x99c430ef, 0x5f0c0794, 0x18dcdb7d, 0xa1d6eff3, 0xa0b52f7b, 0x59e83605,
0xee15b094, 0xe9ffd909, 0xdc440086, 0xef944459, 0xba83ccb3, 0xe0c3cdfb,
0xd1da4181, 0x3b092ab1, 0xf997f1c1, 0xa5e6cf7b, 0x01420ddb, 0xe4e7ef5b,
0x25a1ff41, 0xe180f806, 0x1fc41080, 0x179bee7a, 0xd37ac6a9, 0xfe5830a4,
0x98de8b7f, 0x77e83f4e, 0x79929269, 0x24fa9f7b, 0xe113c85b, 0xacc40083,
0xd7503525, 0xf7ea615f, 0x62143154, 0x0d554b63, 0x5d681121, 0xc866c359,
0x3d63cf73, 0xcee234c0, 0xd4d87e87, 0x5c672b21, 0x071f6181, 0x39f7627f,
0x361e3084, 0xe4eb573b, 0x602f64a4, 0xd63acd9c, 0x1bbc4635, 0x9e81032d,
0x2701f50c, 0x99847ab4, 0xa0e3df79, 0xba6cf38c, 0x10843094, 0x2537a95e,
0xf46f6ffe, 0xa1ff3b1f, 0x208cfb6a, 0x8f458c74, 0xd9e0a227, 0x4ec73a34,
0xfc884f69, 0x3e4de8df, 0xef0e0088, 0x3559648d, 0x8a45388c, 0x1d804366,
0x721d9bfd, 0xa58684bb, 0xe8256333, 0x844e8212, 0x128d8098, 0xfed33fb4,
0xce280ae1, 0x27e19ba5, 0xd5a6c252, 0xe49754bd, 0xc5d655dd, 0xeb667064,
0x77840b4d, 0xa1b6a801, 0x84db26a9, 0xe0b56714, 0x21f043b7, 0xe5d05860,
0x54f03084, 0x066ff472, 0xa31aa153, 0xdadc4755, 0xb5625dbf, 0x68561be6,
0x83ca6b94, 0x2d6ed23b, 0xeccf01db, 0xa6d3d0ba, 0xb6803d5c, 0xaf77a709,
0x33b4a34c, 0x397bc8d6, 0x5ee22b95, 0x5f0e5304, 0x81ed6f61, 0x20e74364,
0xb45e1378, 0xde18639b, 0x881ca122, 0xb96726d1, 0x8049a7e8, 0x22b7da7b,
0x5e552d25, 0x5272d237, 0x79d2951c, 0xc60d894c, 0x488cb402, 0x1ba4fe5b,
0xa4b09f6b, 0x1ca815cf, 0xa20c3005, 0x8871df63, 0xb9de2fcb, 0x0cc6c9e9,
0x0beeff53, 0xe3214517, 0xb4542835, 0x9f63293c, 0xee41e729, 0x6e1d2d7c,
0x50045286, 0x1e6685f3, 0xf33401c6, 0x30a22c95, 0x31a70850, 0x60930f13,
0x73f98417, 0xa1269859, 0xec645c44, 0x52c877a9, 0xcdff33a6, 0xa02b1741,
0x7cbad9a2, 0x2180036f, 0x50d99c08, 0xcb3f4861, 0xc26bd765, 0x64a3f6ab,
0x80342676, 0x25a75e7b, 0xe4e6d1fc, 0x20c710e6, 0xcdf0b680, 0x17844d3b,
0x31eef84d, 0x7e0824e4, 0x2ccb49eb, 0x846a3bae, 0x8ff77888, 0xee5d60f6,
0x7af75673, 0x2fdd5cdb, 0xa11631c1, 0x30f66f43, 0xb3faec54, 0x157fd7fa,
0xef8579cc, 0xd152de58, 0xdb2ffd5e, 0x8f32ce19, 0x306af97a, 0x02f03ef8,
0x99319ad5, 0xc242fa0f, 0xa7e3ebb0, 0xc68e4906, 0xb8da230c, 0x80823028,
0xdcdef3c8, 0xd35fb171, 0x088a1bc8, 0xbec0c560, 0x61a3c9e8, 0xbca8f54d,
0xc72feffa, 0x22822e99, 0x82c570b4, 0xd8d94e89, 0x8b1c34bc, 0x301e16e6,
0x273be979, 0xb0ffeaa6, 0x61d9b8c6, 0x00b24869, 0xb7ffce3f, 0x08dc283b,
0x43daf65a, 0xf7e19798, 0x7619b72f, 0x8f1c9ba4, 0xdc8637a0, 0x16a7d3b1,
0x9fc393b7, 0xa7136eeb, 0xc6bcc63e, 0x1a513742, 0xef6828bc, 0x520365d6,
0x2d6a77ab, 0x3527ed4b, 0x821fd216, 0x095c6e2e, 0xdb92f2fb, 0x5eea29cb,
0x145892f5, 0x91584f7f, 0x5483697b, 0x2667a8cc, 0x85196048, 0x8c4bacea,
0x833860d4, 0x0d23e0f9, 0x6c387e8a, 0x0ae6d249, 0xb284600c, 0xd835731d,
0xdcb1c647, 0xac4c56ea, 0x3ebd81b3, 0x230eabb0, 0x6438bc87, 0xf0b5b1fa,
0x8f5ea2b3, 0xfc184642, 0x0a036b7a, 0x4fb089bd, 0x649da589, 0xa345415e,
0x5c038323, 0x3e5d3bb9, 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef,
0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1,
);
@Crypt::CAST5_PP::s3 = (
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b,
0x8c1fc644, 0xaececa90, 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae,
0x920e8806, 0xf0ad0548, 0xe13c8d83, 0x927010d5, 0x11107d9f, 0x07647db9,
0xb2e3e4d4, 0x3d4f285e, 0xb9afa820, 0xfade82e0, 0xa067268b, 0x8272792e,
0x553fb2c0, 0x489ae22b, 0xd4ef9794, 0x125e3fbc, 0x21fffcee, 0x825b1bfd,
0x9255c5ed, 0x1257a240, 0x4e1a8302, 0xbae07fff, 0x528246e7, 0x8e57140e,
0x3373f7bf, 0x8c9f8188, 0xa6fc4ee8, 0xc982b5a5, 0xa8c01db7, 0x579fc264,
0x67094f31, 0xf2bd3f5f, 0x40fff7c1, 0x1fb78dfc, 0x8e6bd2c1, 0x437be59b,
0x99b03dbf, 0xb5dbc64b, 0x638dc0e6, 0x55819d99, 0xa197c81c, 0x4a012d6e,
0xc5884a28, 0xccc36f71, 0xb843c213, 0x6c0743f1, 0x8309893c, 0x0feddd5f,
0x2f7fe850, 0xd7c07f7e, 0x02507fbf, 0x5afb9a04, 0xa747d2d0, 0x1651192e,
0xaf70bf3e, 0x58c31380, 0x5f98302e, 0x727cc3c4, 0x0a0fb402, 0x0f7fef82,
0x8c96fdad, 0x5d2c2aae, 0x8ee99a49, 0x50da88b8, 0x8427f4a0, 0x1eac5790,
0x796fb449, 0x8252dc15, 0xefbd7d9b, 0xa672597d, 0xada840d8, 0x45f54504,
0xfa5d7403, 0xe83ec305, 0x4f91751a, 0x925669c2, 0x23efe941, 0xa903f12e,
0x60270df2, 0x0276e4b6, 0x94fd6574, 0x927985b2, 0x8276dbcb, 0x02778176,
0xf8af918d, 0x4e48f79e, 0x8f616ddf, 0xe29d840e, 0x842f7d83, 0x340ce5c8,
0x96bbb682, 0x93b4b148, 0xef303cab, 0x984faf28, 0x779faf9b, 0x92dc560d,
0x224d1e20, 0x8437aa88, 0x7d29dc96, 0x2756d3dc, 0x8b907cee, 0xb51fd240,
0xe7c07ce3, 0xe566b4a1, 0xc3e9615e, 0x3cf8209d, 0x6094d1e3, 0xcd9ca341,
0x5c76460e, 0x00ea983b, 0xd4d67881, 0xfd47572c, 0xf76cedd9, 0xbda8229c,
0x127dadaa, 0x438a074e, 0x1f97c090, 0x081bdb8a, 0x93a07ebe, 0xb938ca15,
0x97b03cff, 0x3dc2c0f8, 0x8d1ab2ec, 0x64380e51, 0x68cc7bfb, 0xd90f2788,
0x12490181, 0x5de5ffd4, 0xdd7ef86a, 0x76a2e214, 0xb9a40368, 0x925d958f,
0x4b39fffa, 0xba39aee9, 0xa4ffd30b, 0xfaf7933b, 0x6d498623, 0x193cbcfa,
0x27627545, 0x825cf47a, 0x61bd8ba0, 0xd11e42d1, 0xcead04f4, 0x127ea392,
0x10428db7, 0x8272a972, 0x9270c4a8, 0x127de50b, 0x285ba1c8, 0x3c62f44f,
0x35c0eaa5, 0xe805d231, 0x428929fb, 0xb4fcdf82, 0x4fb66a53, 0x0e7dc15b,
0x1f081fab, 0x108618ae, 0xfcfd086d, 0xf9ff2889, 0x694bcc11, 0x236a5cae,
0x12deca4d, 0x2c3f8cc5, 0xd2d02dfe, 0xf8ef5896, 0xe4cf52da, 0x95155b67,
0x494a488c, 0xb9b6a80c, 0x5c8f82bc, 0x89d36b45, 0x3a609437, 0xec00c9a9,
0x44715253, 0x0a874b49, 0xd773bc40, 0x7c34671c, 0x02717ef6, 0x4feb5536,
0xa2d02fff, 0xd2bf60c4, 0xd43f03c0, 0x50b4ef6d, 0x07478cd1, 0x006e1888,
0xa2e53f55, 0xb9e6d4bc, 0xa2048016, 0x97573833, 0xd7207d67, 0xde0f8f3d,
0x72f87b33, 0xabcc4f33, 0x7688c55d, 0x7b00a6b0, 0x947b0001, 0x570075d2,
0xf9bb88f8, 0x8942019e, 0x4264a5ff, 0x856302e0, 0x72dbd92b, 0xee971b69,
0x6ea22fde, 0x5f08ae2b, 0xaf7a616d, 0xe5c98767, 0xcf1febd2, 0x61efc8c2,
0xf1ac2571, 0xcc8239c2, 0x67214cb8, 0xb1e583d1, 0xb7dc3e62, 0x7f10bdce,
0xf90a5c38, 0x0ff0443d, 0x606e6dc6, 0x60543a49, 0x5727c148, 0x2be98a1d,
0x8ab41738, 0x20e1be24, 0xaf96da0f, 0x68458425, 0x99833be5, 0x600d457d,
0x282f9350, 0x8334b362, 0xd91d1120, 0x2b6d8da0, 0x642b1e31, 0x9c305a00,
0x52bce688, 0x1b03588a, 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5,
0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783,
);
@Crypt::CAST5_PP::s4 = (
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57,
0x85510443, 0xfa020ed1, 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120,
0xfd059d43, 0x6497b7b1, 0xf3641f63, 0x241e4adf, 0x28147f5f, 0x4fa2b8cd,
0xc9430040, 0x0cc32220, 0xfdd30b30, 0xc0a5374f, 0x1d2d00d9, 0x24147b15,
0xee4d111a, 0x0fca5167, 0x71ff904c, 0x2d195ffe, 0x1a05645f, 0x0c13fefe,
0x081b08ca, 0x05170121, 0x80530100, 0xe83e5efe, 0xac9af4f8, 0x7fe72701,
0xd2b8ee5f, 0x06df4261, 0xbb9e9b8a, 0x7293ea25, 0xce84ffdf, 0xf5718801,
0x3dd64b04, 0xa26f263b, 0x7ed48400, 0x547eebe6, 0x446d4ca0, 0x6cf3d6f5,
0x2649abdf, 0xaea0c7f5, 0x36338cc1, 0x503f7e93, 0xd3772061, 0x11b638e1,
0x72500e03, 0xf80eb2bb, 0xabe0502e, 0xec8d77de, 0x57971e81, 0xe14f6746,
0xc9335400, 0x6920318f, 0x081dbb99, 0xffc304a5, 0x4d351805, 0x7f3d5ce3,
0xa6c866c6, 0x5d5bcca9, 0xdaec6fea, 0x9f926f91, 0x9f46222f, 0x3991467d,
0xa5bf6d8e, 0x1143c44f, 0x43958302, 0xd0214eeb, 0x022083b8, 0x3fb6180c,
0x18f8931e, 0x281658e6, 0x26486e3e, 0x8bd78a70, 0x7477e4c1, 0xb506e07c,
0xf32d0a25, 0x79098b02, 0xe4eabb81, 0x28123b23, 0x69dead38, 0x1574ca16,
0xdf871b62, 0x211c40b7, 0xa51a9ef9, 0x0014377b, 0x041e8ac8, 0x09114003,
0xbd59e4d2, 0xe3d156d5, 0x4fe876d5, 0x2f91a340, 0x557be8de, 0x00eae4a7,
0x0ce5c2ec, 0x4db4bba6, 0xe756bdff, 0xdd3369ac, 0xec17b035, 0x06572327,
0x99afc8b0, 0x56c8c391, 0x6b65811c, 0x5e146119, 0x6e85cb75, 0xbe07c002,
0xc2325577, 0x893ff4ec, 0x5bbfc92d, 0xd0ec3b25, 0xb7801ab7, 0x8d6d3b24,
0x20c763ef, 0xc366a5fc, 0x9c382880, 0x0ace3205, 0xaac9548a, 0xeca1d7c7,
0x041afa32, 0x1d16625a, 0x6701902c, 0x9b757a54, 0x31d477f7, 0x9126b031,
0x36cc6fdb, 0xc70b8b46, 0xd9e66a48, 0x56e55a79, 0x026a4ceb, 0x52437eff,
0x2f8f76b4, 0x0df980a5, 0x8674cde3, 0xedda04eb, 0x17a9be04, 0x2c18f4df,
0xb7747f9d, 0xab2af7b4, 0xefc34d20, 0x2e096b7c, 0x1741a254, 0xe5b6a035,
0x213d42f6, 0x2c1c7c26, 0x61c2f50f, 0x6552daf9, 0xd2c231f8, 0x25130f69,
0xd8167fa2, 0x0418f2c8, 0x001a96a6, 0x0d1526ab, 0x63315c21, 0x5e0a72ec,
0x49bafefd, 0x187908d9, 0x8d0dbd86, 0x311170a7, 0x3e9b640c, 0xcc3e10d7,
0xd5cad3b6, 0x0caec388, 0xf73001e1, 0x6c728aff, 0x71eae2a1, 0x1f9af36e,
0xcfcbd12f, 0xc1de8417, 0xac07be6b, 0xcb44a1d8, 0x8b9b0f56, 0x013988c3,
0xb1c52fca, 0xb4be31cd, 0xd8782806, 0x12a3a4e2, 0x6f7de532, 0x58fd7eb6,
0xd01ee900, 0x24adffc2, 0xf4990fc5, 0x9711aac5, 0x001d7b95, 0x82e5e7d2,
0x109873f6, 0x00613096, 0xc32d9521, 0xada121ff, 0x29908415, 0x7fbb977f,
0xaf9eb3db, 0x29c9ed2a, 0x5ce2a465, 0xa730f32c, 0xd0aa3fe8, 0x8a5cc091,
0xd49e2ce7, 0x0ce454a9, 0xd60acd86, 0x015f1919, 0x77079103, 0xdea03af6,
0x78a8565e, 0xdee356df, 0x21f05cbe, 0x8b75e387, 0xb3c50651, 0xb8a5c3ef,
0xd8eeb6d2, 0xe523be77, 0xc2154529, 0x2f69efdf, 0xafe67afb, 0xf470c4b2,
0xf3e0eb5b, 0xd6cc9876, 0x39e4460c, 0x1fda8538, 0x1987832f, 0xca007367,
0xa99144f8, 0x296b299e, 0x492fc295, 0x9266beab, 0xb5676e69, 0x9bd3ddda,
0xdf7e052f, 0xdb25701c, 0x1b5e51ee, 0xf65324e6, 0x6afce36c, 0x0316cc04,
0x8644213e, 0xb7dc59d0, 0x7965291f, 0xccd6fd43, 0x41823979, 0x932bcdf6,
0xb657c34d, 0x4edfd282, 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e,
0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2,
);
@Crypt::CAST5_PP::s5 = (
0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5,
0x44dd9d44, 0x1731167f, 0x08fbf1fa, 0xe7f511cc, 0xd2051b00, 0x735aba00,
0x2ab722d8, 0x386381cb, 0xacf6243a, 0x69befd7a, 0xe6a2e77f, 0xf0c720cd,
0xc4494816, 0xccf5c180, 0x38851640, 0x15b0a848, 0xe68b18cb, 0x4caadeff,
0x5f480a01, 0x0412b2aa, 0x259814fc, 0x41d0efe2, 0x4e40b48d, 0x248eb6fb,
0x8dba1cfe, 0x41a99b02, 0x1a550a04, 0xba8f65cb, 0x7251f4e7, 0x95a51725,
0xc106ecd7, 0x97a5980a, 0xc539b9aa, 0x4d79fe6a, 0xf2f3f763, 0x68af8040,
0xed0c9e56, 0x11b4958b, 0xe1eb5a88, 0x8709e6b0, 0xd7e07156, 0x4e29fea7,
0x6366e52d, 0x02d1c000, 0xc4ac8e05, 0x9377f571, 0x0c05372a, 0x578535f2,
0x2261be02, 0xd642a0c9, 0xdf13a280, 0x74b55bd2, 0x682199c0, 0xd421e5ec,
0x53fb3ce8, 0xc8adedb3, 0x28a87fc9, 0x3d959981, 0x5c1ff900, 0xfe38d399,
0x0c4eff0b, 0x062407ea, 0xaa2f4fb1, 0x4fb96976, 0x90c79505, 0xb0a8a774,
0xef55a1ff, 0xe59ca2c2, 0xa6b62d27, 0xe66a4263, 0xdf65001f, 0x0ec50966,
0xdfdd55bc, 0x29de0655, 0x911e739a, 0x17af8975, 0x32c7911c, 0x89f89468,
0x0d01e980, 0x524755f4, 0x03b63cc9, 0x0cc844b2, 0xbcf3f0aa, 0x87ac36e9,
0xe53a7426, 0x01b3d82b, 0x1a9e7449, 0x64ee2d7e, 0xcddbb1da, 0x01c94910,
0xb868bf80, 0x0d26f3fd, 0x9342ede7, 0x04a5c284, 0x636737b6, 0x50f5b616,
0xf24766e3, 0x8eca36c1, 0x136e05db, 0xfef18391, 0xfb887a37, 0xd6e7f7d4,
0xc7fb7dc9, 0x3063fcdf, 0xb6f589de, 0xec2941da, 0x26e46695, 0xb7566419,
0xf654efc5, 0xd08d58b7, 0x48925401, 0xc1bacb7f, 0xe5ff550f, 0xb6083049,
0x5bb5d0e8, 0x87d72e5a, 0xab6a6ee1, 0x223a66ce, 0xc62bf3cd, 0x9e0885f9,
0x68cb3e47, 0x086c010f, 0xa21de820, 0xd18b69de, 0xf3f65777, 0xfa02c3f6,
0x407edac3, 0xcbb3d550, 0x1793084d, 0xb0d70eba, 0x0ab378d5, 0xd951fb0c,
0xded7da56, 0x4124bbe4, 0x94ca0b56, 0x0f5755d1, 0xe0e1e56e, 0x6184b5be,
0x580a249f, 0x94f74bc0, 0xe327888e, 0x9f7b5561, 0xc3dc0280, 0x05687715,
0x646c6bd7, 0x44904db3, 0x66b4f0a3, 0xc0f1648a, 0x697ed5af, 0x49e92ff6,
0x309e374f, 0x2cb6356a, 0x85808573, 0x4991f840, 0x76f0ae02, 0x083be84d,
0x28421c9a, 0x44489406, 0x736e4cb8, 0xc1092910, 0x8bc95fc6, 0x7d869cf4,
0x134f616f, 0x2e77118d, 0xb31b2be1, 0xaa90b472, 0x3ca5d717, 0x7d161bba,
0x9cad9010, 0xaf462ba2, 0x9fe459d2, 0x45d34559, 0xd9f2da13, 0xdbc65487,
0xf3e4f94e, 0x176d486f, 0x097c13ea, 0x631da5c7, 0x445f7382, 0x175683f4,
0xcdc66a97, 0x70be0288, 0xb3cdcf72, 0x6e5dd2f3, 0x20936079, 0x459b80a5,
0xbe60e2db, 0xa9c23101, 0xeba5315c, 0x224e42f2, 0x1c5c1572, 0xf6721b2c,
0x1ad2fff3, 0x8c25404e, 0x324ed72f, 0x4067b7fd, 0x0523138e, 0x5ca3bc78,
0xdc0fd66e, 0x75922283, 0x784d6b17, 0x58ebb16e, 0x44094f85, 0x3f481d87,
0xfcfeae7b, 0x77b5ff76, 0x8c2302bf, 0xaaf47556, 0x5f46b02a, 0x2b092801,
0x3d38f5f7, 0x0ca81f36, 0x52af4a8a, 0x66d5e7c0, 0xdf3b0874, 0x95055110,
0x1b5ad7a8, 0xf61ed5ad, 0x6cf6e479, 0x20758184, 0xd0cefa65, 0x88f7be58,
0x4a046826, 0x0ff6f8f3, 0xa09c7f70, 0x5346aba0, 0x5ce96c28, 0xe176eda3,
0x6bac307f, 0x376829d2, 0x85360fa9, 0x17e3fe2a, 0x24b79767, 0xf5a96b20,
0xd6cd2595, 0x68ff1ebf, 0x7555442c, 0xf19f06be, 0xf9e0659a, 0xeeb9491d,
0x34010718, 0xbb30cab8, 0xe822fe15, 0x88570983, 0x750e6249, 0xda627e55,
0x5e76ffa8, 0xb1534546, 0x6d47de08, 0xefe9e7d4,
);
@Crypt::CAST5_PP::s6 = (
0xf6fa8f9d, 0x2cac6ce1, 0x4ca34867, 0xe2337f7c, 0x95db08e7, 0x016843b4,
0xeced5cbc, 0x325553ac, 0xbf9f0960, 0xdfa1e2ed, 0x83f0579d, 0x63ed86b9,
0x1ab6a6b8, 0xde5ebe39, 0xf38ff732, 0x8989b138, 0x33f14961, 0xc01937bd,
0xf506c6da, 0xe4625e7e, 0xa308ea99, 0x4e23e33c, 0x79cbd7cc, 0x48a14367,
0xa3149619, 0xfec94bd5, 0xa114174a, 0xeaa01866, 0xa084db2d, 0x09a8486f,
0xa888614a, 0x2900af98, 0x01665991, 0xe1992863, 0xc8f30c60, 0x2e78ef3c,
0xd0d51932, 0xcf0fec14, 0xf7ca07d2, 0xd0a82072, 0xfd41197e, 0x9305a6b0,
0xe86be3da, 0x74bed3cd, 0x372da53c, 0x4c7f4448, 0xdab5d440, 0x6dba0ec3,
0x083919a7, 0x9fbaeed9, 0x49dbcfb0, 0x4e670c53, 0x5c3d9c01, 0x64bdb941,
0x2c0e636a, 0xba7dd9cd, 0xea6f7388, 0xe70bc762, 0x35f29adb, 0x5c4cdd8d,
0xf0d48d8c, 0xb88153e2, 0x08a19866, 0x1ae2eac8, 0x284caf89, 0xaa928223,
0x9334be53, 0x3b3a21bf, 0x16434be3, 0x9aea3906, 0xefe8c36e, 0xf890cdd9,
0x80226dae, 0xc340a4a3, 0xdf7e9c09, 0xa694a807, 0x5b7c5ecc, 0x221db3a6,
0x9a69a02f, 0x68818a54, 0xceb2296f, 0x53c0843a, 0xfe893655, 0x25bfe68a,
0xb4628abc, 0xcf222ebf, 0x25ac6f48, 0xa9a99387, 0x53bddb65, 0xe76ffbe7,
0xe967fd78, 0x0ba93563, 0x8e342bc1, 0xe8a11be9, 0x4980740d, 0xc8087dfc,
0x8de4bf99, 0xa11101a0, 0x7fd37975, 0xda5a26c0, 0xe81f994f, 0x9528cd89,
0xfd339fed, 0xb87834bf, 0x5f04456d, 0x22258698, 0xc9c4c83b, 0x2dc156be,
0x4f628daa, 0x57f55ec5, 0xe2220abe, 0xd2916ebf, 0x4ec75b95, 0x24f2c3c0,
0x42d15d99, 0xcd0d7fa0, 0x7b6e27ff, 0xa8dc8af0, 0x7345c106, 0xf41e232f,
0x35162386, 0xe6ea8926, 0x3333b094, 0x157ec6f2, 0x372b74af, 0x692573e4,
0xe9a9d848, 0xf3160289, 0x3a62ef1d, 0xa787e238, 0xf3a5f676, 0x74364853,
0x20951063, 0x4576698d, 0xb6fad407, 0x592af950, 0x36f73523, 0x4cfb6e87,
0x7da4cec0, 0x6c152daa, 0xcb0396a8, 0xc50dfe5d, 0xfcd707ab, 0x0921c42f,
0x89dff0bb, 0x5fe2be78, 0x448f4f33, 0x754613c9, 0x2b05d08d, 0x48b9d585,
0xdc049441, 0xc8098f9b, 0x7dede786, 0xc39a3373, 0x42410005, 0x6a091751,
0x0ef3c8a6, 0x890072d6, 0x28207682, 0xa9a9f7be, 0xbf32679d, 0xd45b5b75,
0xb353fd00, 0xcbb0e358, 0x830f220a, 0x1f8fb214, 0xd372cf08, 0xcc3c4a13,
0x8cf63166, 0x061c87be, 0x88c98f88, 0x6062e397, 0x47cf8e7a, 0xb6c85283,
0x3cc2acfb, 0x3fc06976, 0x4e8f0252, 0x64d8314d, 0xda3870e3, 0x1e665459,
0xc10908f0, 0x513021a5, 0x6c5b68b7, 0x822f8aa0, 0x3007cd3e, 0x74719eef,
0xdc872681, 0x073340d4, 0x7e432fd9, 0x0c5ec241, 0x8809286c, 0xf592d891,
0x08a930f6, 0x957ef305, 0xb7fbffbd, 0xc266e96f, 0x6fe4ac98, 0xb173ecc0,
0xbc60b42a, 0x953498da, 0xfba1ae12, 0x2d4bd736, 0x0f25faab, 0xa4f3fceb,
0xe2969123, 0x257f0c3d, 0x9348af49, 0x361400bc, 0xe8816f4a, 0x3814f200,
0xa3f94043, 0x9c7a54c2, 0xbc704f57, 0xda41e7f9, 0xc25ad33a, 0x54f4a084,
0xb17f5505, 0x59357cbe, 0xedbd15c8, 0x7f97c5ab, 0xba5ac7b5, 0xb6f6deaf,
0x3a479c3a, 0x5302da25, 0x653d7e6a, 0x54268d49, 0x51a477ea, 0x5017d55b,
0xd7d25d88, 0x44136c76, 0x0404a8c8, 0xb8e5a121, 0xb81a928a, 0x60ed5869,
0x97c55b96, 0xeaec991b, 0x29935913, 0x01fdb7f1, 0x088e8dfa, 0x9ab6f6f5,
0x3b4cbf9f, 0x4a5de3ab, 0xe6051d35, 0xa0e1d855, 0xd36b4cf1, 0xf544edeb,
0xb0e93524, 0xbebb8fbd, 0xa2d762cf, 0x49c92f54, 0x38b5f331, 0x7128a454,
0x48392905, 0xa65b1db8, 0x851c97bd, 0xd675cf2f,
);
@Crypt::CAST5_PP::s7 = (
0x85e04019, 0x332bf567, 0x662dbfff, 0xcfc65693, 0x2a8d7f6f, 0xab9bc912,
0xde6008a1, 0x2028da1f, 0x0227bce7, 0x4d642916, 0x18fac300, 0x50f18b82,
0x2cb2cb11, 0xb232e75c, 0x4b3695f2, 0xb28707de, 0xa05fbcf6, 0xcd4181e9,
0xe150210c, 0xe24ef1bd, 0xb168c381, 0xfde4e789, 0x5c79b0d8, 0x1e8bfd43,
0x4d495001, 0x38be4341, 0x913cee1d, 0x92a79c3f, 0x089766be, 0xbaeeadf4,
0x1286becf, 0xb6eacb19, 0x2660c200, 0x7565bde4, 0x64241f7a, 0x8248dca9,
0xc3b3ad66, 0x28136086, 0x0bd8dfa8, 0x356d1cf2, 0x107789be, 0xb3b2e9ce,
0x0502aa8f, 0x0bc0351e, 0x166bf52a, 0xeb12ff82, 0xe3486911, 0xd34d7516,
0x4e7b3aff, 0x5f43671b, 0x9cf6e037, 0x4981ac83, 0x334266ce, 0x8c9341b7,
0xd0d854c0, 0xcb3a6c88, 0x47bc2829, 0x4725ba37, 0xa66ad22b, 0x7ad61f1e,
0x0c5cbafa, 0x4437f107, 0xb6e79962, 0x42d2d816, 0x0a961288, 0xe1a5c06e,
0x13749e67, 0x72fc081a, 0xb1d139f7, 0xf9583745, 0xcf19df58, 0xbec3f756,
0xc06eba30, 0x07211b24, 0x45c28829, 0xc95e317f, 0xbc8ec511, 0x38bc46e9,
0xc6e6fa14, 0xbae8584a, 0xad4ebc46, 0x468f508b, 0x7829435f, 0xf124183b,
0x821dba9f, 0xaff60ff4, 0xea2c4e6d, 0x16e39264, 0x92544a8b, 0x009b4fc3,
0xaba68ced, 0x9ac96f78, 0x06a5b79a, 0xb2856e6e, 0x1aec3ca9, 0xbe838688,
0x0e0804e9, 0x55f1be56, 0xe7e5363b, 0xb3a1f25d, 0xf7debb85, 0x61fe033c,
0x16746233, 0x3c034c28, 0xda6d0c74, 0x79aac56c, 0x3ce4e1ad, 0x51f0c802,
0x98f8f35a, 0x1626a49f, 0xeed82b29, 0x1d382fe3, 0x0c4fb99a, 0xbb325778,
0x3ec6d97b, 0x6e77a6a9, 0xcb658b5c, 0xd45230c7, 0x2bd1408b, 0x60c03eb7,
0xb9068d78, 0xa33754f4, 0xf430c87d, 0xc8a71302, 0xb96d8c32, 0xebd4e7be,
0xbe8b9d2d, 0x7979fb06, 0xe7225308, 0x8b75cf77, 0x11ef8da4, 0xe083c858,
0x8d6b786f, 0x5a6317a6, 0xfa5cf7a0, 0x5dda0033, 0xf28ebfb0, 0xf5b9c310,
0xa0eac280, 0x08b9767a, 0xa3d9d2b0, 0x79d34217, 0x021a718d, 0x9ac6336a,
0x2711fd60, 0x438050e3, 0x069908a8, 0x3d7fedc4, 0x826d2bef, 0x4eeb8476,
0x488dcf25, 0x36c9d566, 0x28e74e41, 0xc2610aca, 0x3d49a9cf, 0xbae3b9df,
0xb65f8de6, 0x92aeaf64, 0x3ac7d5e6, 0x9ea80509, 0xf22b017d, 0xa4173f70,
0xdd1e16c3, 0x15e0d7f9, 0x50b1b887, 0x2b9f4fd5, 0x625aba82, 0x6a017962,
0x2ec01b9c, 0x15488aa9, 0xd716e740, 0x40055a2c, 0x93d29a22, 0xe32dbf9a,
0x058745b9, 0x3453dc1e, 0xd699296e, 0x496cff6f, 0x1c9f4986, 0xdfe2ed07,
0xb87242d1, 0x19de7eae, 0x053e561a, 0x15ad6f8c, 0x66626c1c, 0x7154c24c,
0xea082b2a, 0x93eb2939, 0x17dcb0f0, 0x58d4f2ae, 0x9ea294fb, 0x52cf564c,
0x9883fe66, 0x2ec40581, 0x763953c3, 0x01d6692e, 0xd3a0c108, 0xa1e7160e,
0xe4f2dfa6, 0x693ed285, 0x74904698, 0x4c2b0edd, 0x4f757656, 0x5d393378,
0xa132234f, 0x3d321c5d, 0xc3f5e194, 0x4b269301, 0xc79f022f, 0x3c997e7e,
0x5e4f9504, 0x3ffafbbd, 0x76f7ad0e, 0x296693f4, 0x3d1fce6f, 0xc61e45be,
0xd3b5ab34, 0xf72bf9b7, 0x1b0434c0, 0x4e72b567, 0x5592a33d, 0xb5229301,
0xcfd2a87f, 0x60aeb767, 0x1814386b, 0x30bcc33d, 0x38a0c07d, 0xfd1606f2,
0xc363519b, 0x589dd390, 0x5479f8e6, 0x1cb8d647, 0x97fd61a9, 0xea7759f4,
0x2d57539d, 0x569a58cf, 0xe84e63ad, 0x462e1b78, 0x6580f87e, 0xf3817914,
0x91da55f4, 0x40a230f3, 0xd1988f35, 0xb6e318d2, 0x3ffa50bc, 0x3d40f021,
0xc3c0bdae, 0x4958c24c, 0x518f36b2, 0x84b1d370, 0x0fedce83, 0x878ddada,
0xf2a279c7, 0x94e01be8, 0x90716f4b, 0x954b8aa3,
);
@Crypt::CAST5_PP::s8 = (
0xe216300d, 0xbbddfffc, 0xa7ebdabd, 0x35648095, 0x7789f8b7, 0xe6c1121b,
0x0e241600, 0x052ce8b5, 0x11a9cfb0, 0xe5952f11, 0xece7990a, 0x9386d174,
0x2a42931c, 0x76e38111, 0xb12def3a, 0x37ddddfc, 0xde9adeb1, 0x0a0cc32c,
0xbe197029, 0x84a00940, 0xbb243a0f, 0xb4d137cf, 0xb44e79f0, 0x049eedfd,
0x0b15a15d, 0x480d3168, 0x8bbbde5a, 0x669ded42, 0xc7ece831, 0x3f8f95e7,
0x72df191b, 0x7580330d, 0x94074251, 0x5c7dcdfa, 0xabbe6d63, 0xaa402164,
0xb301d40a, 0x02e7d1ca, 0x53571dae, 0x7a3182a2, 0x12a8ddec, 0xfdaa335d,
0x176f43e8, 0x71fb46d4, 0x38129022, 0xce949ad4, 0xb84769ad, 0x965bd862,
0x82f3d055, 0x66fb9767, 0x15b80b4e, 0x1d5b47a0, 0x4cfde06f, 0xc28ec4b8,
0x57e8726e, 0x647a78fc, 0x99865d44, 0x608bd593, 0x6c200e03, 0x39dc5ff6,
0x5d0b00a3, 0xae63aff2, 0x7e8bd632, 0x70108c0c, 0xbbd35049, 0x2998df04,
0x980cf42a, 0x9b6df491, 0x9e7edd53, 0x06918548, 0x58cb7e07, 0x3b74ef2e,
0x522fffb1, 0xd24708cc, 0x1c7e27cd, 0xa4eb215b, 0x3cf1d2e2, 0x19b47a38,
0x424f7618, 0x35856039, 0x9d17dee7, 0x27eb35e6, 0xc9aff67b, 0x36baf5b8,
0x09c467cd, 0xc18910b1, 0xe11dbf7b, 0x06cd1af8, 0x7170c608, 0x2d5e3354,
0xd4de495a, 0x64c6d006, 0xbcc0c62c, 0x3dd00db3, 0x708f8f34, 0x77d51b42,
0x264f620f, 0x24b8d2bf, 0x15c1b79e, 0x46a52564, 0xf8d7e54e, 0x3e378160,
0x7895cda5, 0x859c15a5, 0xe6459788, 0xc37bc75f, 0xdb07ba0c, 0x0676a3ab,
0x7f229b1e, 0x31842e7b, 0x24259fd7, 0xf8bef472, 0x835ffcb8, 0x6df4c1f2,
0x96f5b195, 0xfd0af0fc, 0xb0fe134c, 0xe2506d3d, 0x4f9b12ea, 0xf215f225,
0xa223736f, 0x9fb4c428, 0x25d04979, 0x34c713f8, 0xc4618187, 0xea7a6e98,
0x7cd16efc, 0x1436876c, 0xf1544107, 0xbedeee14, 0x56e9af27, 0xa04aa441,
0x3cf7c899, 0x92ecbae6, 0xdd67016d, 0x151682eb, 0xa842eedf, 0xfdba60b4,
0xf1907b75, 0x20e3030f, 0x24d8c29e, 0xe139673b, 0xefa63fb8, 0x71873054,
0xb6f2cf3b, 0x9f326442, 0xcb15a4cc, 0xb01a4504, 0xf1e47d8d, 0x844a1be5,
0xbae7dfdc, 0x42cbda70, 0xcd7dae0a, 0x57e85b7a, 0xd53f5af6, 0x20cf4d8c,
0xcea4d428, 0x79d130a4, 0x3486ebfb, 0x33d3cddc, 0x77853b53, 0x37effcb5,
0xc5068778, 0xe580b3e6, 0x4e68b8f4, 0xc5c8b37e, 0x0d809ea2, 0x398feb7c,
0x132a4f94, 0x43b7950e, 0x2fee7d1c, 0x223613bd, 0xdd06caa2, 0x37df932b,
0xc4248289, 0xacf3ebc3, 0x5715f6b7, 0xef3478dd, 0xf267616f, 0xc148cbe4,
0x9052815e, 0x5e410fab, 0xb48a2465, 0x2eda7fa4, 0xe87b40e4, 0xe98ea084,
0x5889e9e1, 0xefd390fc, 0xdd07d35b, 0xdb485694, 0x38d7e5b2, 0x57720101,
0x730edebc, 0x5b643113, 0x94917e4f, 0x503c2fba, 0x646f1282, 0x7523d24a,
0xe0779695, 0xf9c17a8f, 0x7a5b2121, 0xd187b896, 0x29263a4d, 0xba510cdf,
0x81f47c9f, 0xad1163ed, 0xea7b5965, 0x1a00726e, 0x11403092, 0x00da6d77,
0x4a0cdd61, 0xad1f4603, 0x605bdfb0, 0x9eedc364, 0x22ebe6a8, 0xcee7d28a,
0xa0e736a0, 0x5564a6b9, 0x10853209, 0xc7eb8f37, 0x2de705ca, 0x8951570f,
0xdf09822b, 0xbd691a6c, 0xaa12e4f2, 0x87451c0f, 0xe0f6a27a, 0x3ada4819,
0x4cf1764f, 0x0d771c2b, 0x67cdb156, 0x350d8384, 0x5938fa0f, 0x42399ef3,
0x36997b07, 0x0e84093d, 0x4aa93e61, 0x8360d87b, 0x1fa98b0c, 0x1149382c,
0xe97625a5, 0x0614d1b7, 0x0e25244b, 0x0c768347, 0x589e8d82, 0x0d2059d1,
0xa466bb1e, 0xf8da0a82, 0x04f19130, 0xba6e4ec0, 0x99265164, 0x1ee7230d,
0x50b2ad80, 0xeaee6801, 0x8db2a283, 0xea8bf59e,
);
1 # end Tables.pm

1064
database/perl/vendor/lib/Crypt/CBC.pm vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
package Crypt::Checksum;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw/ adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int
crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int /] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
# obsolete since v0.057, only for backwards compatibility
use Crypt::Checksum::CRC32;
use Crypt::Checksum::Adler32;
sub adler32_data { goto \&Crypt::Checksum::Adler32::adler32_data }
sub adler32_data_hex { goto \&Crypt::Checksum::Adler32::adler32_data_hex }
sub adler32_data_int { goto \&Crypt::Checksum::Adler32::adler32_data_int }
sub adler32_file { goto \&Crypt::Checksum::Adler32::adler32_file }
sub adler32_file_hex { goto \&Crypt::Checksum::Adler32::adler32_file_hex }
sub adler32_file_int { goto \&Crypt::Checksum::Adler32::adler32_file_int }
sub crc32_data { goto \&Crypt::Checksum::CRC32::crc32_data }
sub crc32_data_hex { goto \&Crypt::Checksum::CRC32::crc32_data_hex }
sub crc32_data_int { goto \&Crypt::Checksum::CRC32::crc32_data_int }
sub crc32_file { goto \&Crypt::Checksum::CRC32::crc32_file }
sub crc32_file_hex { goto \&Crypt::Checksum::CRC32::crc32_file_hex }
sub crc32_file_int { goto \&Crypt::Checksum::CRC32::crc32_file_int }
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') { #filename
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
binmode($handle);
}
else { #handle
$handle = $file
}
croak "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf)
}
croak "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Checksum - [internal only]
=head1 DESCRIPTION
You are probably looking for L<Crypt::Checksum::CRC32> or L<Crypt::Checksum::Adler32>.
=cut

View File

@@ -0,0 +1,194 @@
package Crypt::Checksum::Adler32;
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Checksum Exporter);
our %EXPORT_TAGS = ( all => [qw( adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub adler32_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->digest }
sub adler32_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->hexdigest }
sub adler32_file_int { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::Adler32->new->addfile(@_)->intdigest }
1;
=pod
=head1 NAME
Crypt::Checksum::Adler32 - Compute Adler32 checksum
=head1 SYNOPSIS
### Functional interface:
use Crypt::Checksum::Adler32 ':all';
# calculate Adler32 checksum from string/buffer
$checksum_raw = adler32_data($data);
$checksum_hex = adler32_data_hex($data);
$checksum_int = adler32_data_int($data);
# calculate Adler32 checksum from file
$checksum_raw = adler32_file('filename.dat');
$checksum_hex = adler32_file_hex('filename.dat');
$checksum_int = adler32_file_int('filename.dat');
# calculate Adler32 checksum from filehandle
$checksum_raw = adler32_file(*FILEHANDLE);
$checksum_hex = adler32_file_hex(*FILEHANDLE);
$checksum_int = adler32_file_int(*FILEHANDLE);
### OO interface:
use Crypt::Checksum::Adler32;
$d = Crypt::Checksum::Adler32->new;
$d->add('any data');
$d->add('another data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$checksum_raw = $d->digest; # raw 4 bytes
$checksum_hex = $d->hexdigest; # hexadecimal form
$checksum_int = $d->intdigest; # 32bit unsigned integer
=head1 DESCRIPTION
Calculating Adler32 checksums.
I<Updated: v0.057>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Checksum::Adler32 qw(adler32_data adler32_data_hex adler32_data_int adler32_file adler32_file_hex adler32_file_int);
Or all of them at once:
use Crypt::Checksum::Adler32 ':all';
=head1 FUNCTIONS
=head2 adler32_data
Returns checksum as raw octects.
$checksum_raw = adler32_data('data string');
#or
$checksum_raw = adler32_data('any data', 'more data', 'even more data');
=head2 adler32_data_hex
Returns checksum as a hexadecimal string.
$checksum_hex = adler32_data_hex('data string');
#or
$checksum_hex = adler32_data_hex('any data', 'more data', 'even more data');
=head2 adler32_data_int
Returns checksum as unsigned 32bit integer.
$checksum_int = adler32_data_int('data string');
#or
$checksum_int = adler32_data_int('any data', 'more data', 'even more data');
=head2 adler32_file
Returns checksum as raw octects.
$checksum_raw = adler32_file('filename.dat');
#or
$checksum_raw = adler32_file(*FILEHANDLE);
=head2 adler32_file_hex
Returns checksum as a hexadecimal string.
$checksum_hex = adler32_file_hex('filename.dat');
#or
$checksum_hex = adler32_file_hex(*FILEHANDLE);
=head2 adler32_file_int
Returns checksum as unsigned 32bit integer.
$checksum_int = adler32_file_int('filename.dat');
#or
$checksum_int = adler32_file_int(*FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the checksum object.
$d = Crypt::Checksum::Adler32->new;
=head2 clone
Creates a copy of the checksum object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the checksum object state and returns a reference to the checksum object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest
Returns the binary checksum (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the checksum encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 intdigest
Returns the checksum encoded as unsigned 32bit integer.
$result_int = $d->intdigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<https://en.wikipedia.org/wiki/Adler-32>
=back
=cut

View File

@@ -0,0 +1,194 @@
package Crypt::Checksum::CRC32;
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Checksum Exporter);
our %EXPORT_TAGS = ( all => [qw( crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub crc32_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->digest }
sub crc32_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->hexdigest }
sub crc32_file_int { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Checksum::CRC32->new->addfile(@_)->intdigest }
1;
=pod
=head1 NAME
Crypt::Checksum::CRC32 - Compute CRC32 checksum
=head1 SYNOPSIS
### Functional interface:
use Crypt::Checksum::CRC32 ':all';
# calculate CRC32 checksum from string/buffer
$checksum_raw = crc32_data($data);
$checksum_hex = crc32_data_hex($data);
$checksum_int = crc32_data_int($data);
# calculate CRC32 checksum from file
$checksum_raw = crc32_file('filename.dat');
$checksum_hex = crc32_file_hex('filename.dat');
$checksum_int = crc32_file_int('filename.dat');
# calculate CRC32 checksum from filehandle
$checksum_raw = crc32_file(*FILEHANDLE);
$checksum_hex = crc32_file_hex(*FILEHANDLE);
$checksum_int = crc32_file_int(*FILEHANDLE);
### OO interface:
use Crypt::Checksum::CRC32;
$d = Crypt::Checksum::CRC32->new;
$d->add('any data');
$d->add('another data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$checksum_raw = $d->digest; # raw 4 bytes
$checksum_hex = $d->hexdigest; # hexadecimal form
$checksum_int = $d->intdigest; # 32bit unsigned integer
=head1 DESCRIPTION
Calculating CRC32 checksums.
I<Updated: v0.057>
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Checksum::CRC32 qw(crc32_data crc32_data_hex crc32_data_int crc32_file crc32_file_hex crc32_file_int);
Or all of them at once:
use Crypt::Checksum::CRC32 ':all';
=head1 FUNCTIONS
=head2 crc32_data
Returns checksum as raw octects.
$checksum_raw = crc32_data('data string');
#or
$checksum_raw = crc32_data('any data', 'more data', 'even more data');
=head2 crc32_data_hex
Returns checksum as a hexadecimal string.
$checksum_hex = crc32_data_hex('data string');
#or
$checksum_hex = crc32_data_hex('any data', 'more data', 'even more data');
=head2 crc32_data_int
Returns checksum as unsigned 32bit integer.
$checksum_int = crc32_data_int('data string');
#or
$checksum_int = crc32_data_int('any data', 'more data', 'even more data');
=head2 crc32_file
Returns checksum as raw octects.
$checksum_raw = crc32_file('filename.dat');
#or
$checksum_raw = crc32_file(*FILEHANDLE);
=head2 crc32_file_hex
Returns checksum as a hexadecimal string.
$checksum_hex = crc32_file_hex('filename.dat');
#or
$checksum_hex = crc32_file_hex(*FILEHANDLE);
=head2 crc32_file_int
Returns checksum as unsigned 32bit integer.
$checksum_int = crc32_file_int('filename.dat');
#or
$checksum_int = crc32_file_int(*FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the checksum object.
$d = Crypt::Checksum::CRC32->new;
=head2 clone
Creates a copy of the checksum object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the checksum object state and returns a reference to the checksum object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate checksum for.
The return value is the checksum object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest
Returns the binary checksum (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the checksum encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 intdigest
Returns the checksum encoded as unsigned 32bit integer.
$result_int = $d->intdigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<https://en.wikipedia.org/wiki/Cyclic_redundancy_check>
=back
=cut

155
database/perl/vendor/lib/Crypt/Cipher.pm vendored Normal file
View File

@@ -0,0 +1,155 @@
package Crypt::Cipher;
use strict;
use warnings;
our $VERSION = '0.069';
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
### the following methods/functions are implemented in XS:
# - new
# - DESTROY
# - blocksize
# - decrypt
# - default_rounds
# - encrypt
# - max_keysize
# - min_keysize
sub keysize { goto \&max_keysize; } # for Crypt::CBC compatibility
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Cipher - Generic interface to cipher functions
=head1 SYNOPSIS
#### example 1 (encrypting single block)
use Crypt::Cipher;
my $key = '...'; # length has to be valid key size for this cipher
my $c = Crypt::Cipher->new('AES', $key);
my $blocksize = $c->blocksize;
my $ciphertext = $c->encrypt('plain text block'); #encrypt 1 block
my $plaintext = $c->decrypt($ciphertext); #decrypt 1 block
### example 2 (using CBC mode)
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('AES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
#### example 3 (compatibility with Crypt::CBC)
use Crypt::CBC;
use Crypt::Cipher;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cipher = Crypt::Cipher('AES', $key);
my $cbc = Crypt::CBC->new( -cipher=>$cipher, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
Provides an interface to various symmetric cipher algorithms.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
Constructor, returns a reference to the cipher object.
## basic scenario
$d = Crypt::Cipher->new($name, $key);
# $name = one of 'AES', 'Anubis', 'Blowfish', 'CAST5', 'Camellia', 'DES', 'DES_EDE',
# 'KASUMI', 'Khazad', 'MULTI2', 'Noekeon', 'RC2', 'RC5', 'RC6',
# 'SAFERP', 'SAFER_K128', 'SAFER_K64', 'SAFER_SK128', 'SAFER_SK64',
# 'SEED', 'Skipjack', 'Twofish', 'XTEA', 'IDEA', 'Serpent'
# simply any <NAME> for which there exists Crypt::Cipher::<NAME>
# $key = binary key (keysize should comply with selected cipher requirements)
## some of the ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds
$d = Crypt::Cipher->new('MULTI2', $key, $rounds);
# $rounds = positive integer (should comply with selected cipher requirements)
=head2 encrypt
Encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of B<blocksize> bytes.
$ciphertext = $d->encrypt($plaintext);
=head2 decrypt
Decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of B<blocksize> bytes.
$plaintext = $d->encrypt($ciphertext);
=head2 keysize
Just an alias for B<max_keysize> (needed for L<Crypt::CBC|Crypt::CBC> compatibility).
=head2 max_keysize
Returns the maximal allowed key size (in bytes) for given cipher.
$d->max_keysize;
#or
Crypt::Cipher->max_keysize('AES');
#or
Crypt::Cipher::max_keysize('AES');
=head2 min_keysize
Returns the minimal allowed key size (in bytes) for given cipher.
$d->min_keysize;
#or
Crypt::Cipher->min_keysize('AES');
#or
Crypt::Cipher::min_keysize('AES');
=head2 blocksize
Returns block size (in bytes) for given cipher.
$d->blocksize;
#or
Crypt::Cipher->blocksize('AES');
#or
Crypt::Cipher::blocksize('AES');
=head2 default_rounds
Returns default number of rounds for given cipher. NOTE: only some ciphers (e.g. MULTI2, RC5, SAFER) allow one to set number of rounds via new().
$d->default_rounds;
#or
Crypt::Cipher->default_rounds('AES');
#or
Crypt::Cipher::default_rounds('AES');
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * Check subclasses like L<Crypt::Cipher::AES|Crypt::Cipher::AES>, L<Crypt::Cipher::Blowfish|Crypt::Cipher::Blowfish>, ...
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::AES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('AES') }
sub keysize { Crypt::Cipher::keysize('AES') }
sub max_keysize { Crypt::Cipher::max_keysize('AES') }
sub min_keysize { Crypt::Cipher::min_keysize('AES') }
sub default_rounds { Crypt::Cipher::default_rounds('AES') }
1;
=pod
=head1 NAME
Crypt::Cipher::AES - Symmetric cipher AES (aka Rijndael), key size: 128/192/256 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('AES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::AES;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::AES', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the AES cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::AES->new($key);
#or
$c = Crypt::Cipher::AES->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::AES->keysize;
#or
Crypt::Cipher::AES::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::AES->blocksize;
#or
Crypt::Cipher::AES::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::AES->max_keysize;
#or
Crypt::Cipher::AES::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::AES->min_keysize;
#or
Crypt::Cipher::AES::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::AES->default_rounds;
#or
Crypt::Cipher::AES::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Advanced_Encryption_Standard>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Anubis;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Anubis') }
sub keysize { Crypt::Cipher::keysize('Anubis') }
sub max_keysize { Crypt::Cipher::max_keysize('Anubis') }
sub min_keysize { Crypt::Cipher::min_keysize('Anubis') }
sub default_rounds { Crypt::Cipher::default_rounds('Anubis') }
1;
=pod
=head1 NAME
Crypt::Cipher::Anubis - Symmetric cipher Anubis, key size: 128-320 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Anubis');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Anubis;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Anubis', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Anubis cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Anubis->new($key);
#or
$c = Crypt::Cipher::Anubis->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Anubis->keysize;
#or
Crypt::Cipher::Anubis::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Anubis->blocksize;
#or
Crypt::Cipher::Anubis::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Anubis->max_keysize;
#or
Crypt::Cipher::Anubis::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Anubis->min_keysize;
#or
Crypt::Cipher::Anubis::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Anubis->default_rounds;
#or
Crypt::Cipher::Anubis::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Anubis_(cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Blowfish;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Blowfish') }
sub keysize { Crypt::Cipher::keysize('Blowfish') }
sub max_keysize { Crypt::Cipher::max_keysize('Blowfish') }
sub min_keysize { Crypt::Cipher::min_keysize('Blowfish') }
sub default_rounds { Crypt::Cipher::default_rounds('Blowfish') }
1;
=pod
=head1 NAME
Crypt::Cipher::Blowfish - Symmetric cipher Blowfish, key size: 64-448 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Blowfish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Blowfish;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Blowfish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Blowfish cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Blowfish->new($key);
#or
$c = Crypt::Cipher::Blowfish->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Blowfish->keysize;
#or
Crypt::Cipher::Blowfish::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Blowfish->blocksize;
#or
Crypt::Cipher::Blowfish::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Blowfish->max_keysize;
#or
Crypt::Cipher::Blowfish::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Blowfish->min_keysize;
#or
Crypt::Cipher::Blowfish::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Blowfish->default_rounds;
#or
Crypt::Cipher::Blowfish::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Blowfish_(cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::CAST5;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('CAST5') }
sub keysize { Crypt::Cipher::keysize('CAST5') }
sub max_keysize { Crypt::Cipher::max_keysize('CAST5') }
sub min_keysize { Crypt::Cipher::min_keysize('CAST5') }
sub default_rounds { Crypt::Cipher::default_rounds('CAST5') }
1;
=pod
=head1 NAME
Crypt::Cipher::CAST5 - Symmetric cipher CAST5 (aka CAST-128), key size: 40-128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('CAST5');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::CAST5;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::CAST5', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the CAST5 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::CAST5->new($key);
#or
$c = Crypt::Cipher::CAST5->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::CAST5->keysize;
#or
Crypt::Cipher::CAST5::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::CAST5->blocksize;
#or
Crypt::Cipher::CAST5::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::CAST5->max_keysize;
#or
Crypt::Cipher::CAST5::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::CAST5->min_keysize;
#or
Crypt::Cipher::CAST5::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::CAST5->default_rounds;
#or
Crypt::Cipher::CAST5::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/CAST-128>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Camellia;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Camellia') }
sub keysize { Crypt::Cipher::keysize('Camellia') }
sub max_keysize { Crypt::Cipher::max_keysize('Camellia') }
sub min_keysize { Crypt::Cipher::min_keysize('Camellia') }
sub default_rounds { Crypt::Cipher::default_rounds('Camellia') }
1;
=pod
=head1 NAME
Crypt::Cipher::Camellia - Symmetric cipher Camellia, key size: 128/192/256 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Camellia');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Camellia;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Camellia', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Camellia cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Camellia->new($key);
#or
$c = Crypt::Cipher::Camellia->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Camellia->keysize;
#or
Crypt::Cipher::Camellia::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Camellia->blocksize;
#or
Crypt::Cipher::Camellia::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Camellia->max_keysize;
#or
Crypt::Cipher::Camellia::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Camellia->min_keysize;
#or
Crypt::Cipher::Camellia::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Camellia->default_rounds;
#or
Crypt::Cipher::Camellia::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Camellia_(cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::DES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('DES') }
sub keysize { Crypt::Cipher::keysize('DES') }
sub max_keysize { Crypt::Cipher::max_keysize('DES') }
sub min_keysize { Crypt::Cipher::min_keysize('DES') }
sub default_rounds { Crypt::Cipher::default_rounds('DES') }
1;
=pod
=head1 NAME
Crypt::Cipher::DES - Symmetric cipher DES, key size: 64[56] bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('DES');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::DES;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::DES', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the DES cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::DES->new($key);
#or
$c = Crypt::Cipher::DES->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::DES->keysize;
#or
Crypt::Cipher::DES::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::DES->blocksize;
#or
Crypt::Cipher::DES::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::DES->max_keysize;
#or
Crypt::Cipher::DES::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::DES->min_keysize;
#or
Crypt::Cipher::DES::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::DES->default_rounds;
#or
Crypt::Cipher::DES::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Data_Encryption_Standard>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::DES_EDE;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('DES_EDE') }
sub keysize { Crypt::Cipher::keysize('DES_EDE') }
sub max_keysize { Crypt::Cipher::max_keysize('DES_EDE') }
sub min_keysize { Crypt::Cipher::min_keysize('DES_EDE') }
sub default_rounds { Crypt::Cipher::default_rounds('DES_EDE') }
1;
=pod
=head1 NAME
Crypt::Cipher::DES_EDE - Symmetric cipher DES_EDE (aka Triple-DES, 3DES), key size: 192[168] bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('DES_EDE');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::DES_EDE;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::DES_EDE', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the DES_EDE cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::DES_EDE->new($key);
#or
$c = Crypt::Cipher::DES_EDE->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::DES_EDE->keysize;
#or
Crypt::Cipher::DES_EDE::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::DES_EDE->blocksize;
#or
Crypt::Cipher::DES_EDE::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::DES_EDE->max_keysize;
#or
Crypt::Cipher::DES_EDE::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::DES_EDE->min_keysize;
#or
Crypt::Cipher::DES_EDE::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::DES_EDE->default_rounds;
#or
Crypt::Cipher::DES_EDE::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Triple_DES>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::IDEA;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('IDEA') }
sub keysize { Crypt::Cipher::keysize('IDEA') }
sub max_keysize { Crypt::Cipher::max_keysize('IDEA') }
sub min_keysize { Crypt::Cipher::min_keysize('IDEA') }
sub default_rounds { Crypt::Cipher::default_rounds('IDEA') }
1;
=pod
=head1 NAME
Crypt::Cipher::IDEA - Symmetric cipher IDEA, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('IDEA');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::IDEA;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::IDEA', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the IDEA cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::IDEA->new($key);
#or
$c = Crypt::Cipher::IDEA->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::IDEA->keysize;
#or
Crypt::Cipher::IDEA::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::IDEA->blocksize;
#or
Crypt::Cipher::IDEA::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::IDEA->max_keysize;
#or
Crypt::Cipher::IDEA::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::IDEA->min_keysize;
#or
Crypt::Cipher::IDEA::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::IDEA->default_rounds;
#or
Crypt::Cipher::IDEA::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::KASUMI;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('KASUMI') }
sub keysize { Crypt::Cipher::keysize('KASUMI') }
sub max_keysize { Crypt::Cipher::max_keysize('KASUMI') }
sub min_keysize { Crypt::Cipher::min_keysize('KASUMI') }
sub default_rounds { Crypt::Cipher::default_rounds('KASUMI') }
1;
=pod
=head1 NAME
Crypt::Cipher::KASUMI - Symmetric cipher KASUMI, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('KASUMI');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::KASUMI;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::KASUMI', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the KASUMI cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::KASUMI->new($key);
#or
$c = Crypt::Cipher::KASUMI->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::KASUMI->keysize;
#or
Crypt::Cipher::KASUMI::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::KASUMI->blocksize;
#or
Crypt::Cipher::KASUMI::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::KASUMI->max_keysize;
#or
Crypt::Cipher::KASUMI::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::KASUMI->min_keysize;
#or
Crypt::Cipher::KASUMI::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::KASUMI->default_rounds;
#or
Crypt::Cipher::KASUMI::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/KASUMI_(block_cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Khazad;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Khazad') }
sub keysize { Crypt::Cipher::keysize('Khazad') }
sub max_keysize { Crypt::Cipher::max_keysize('Khazad') }
sub min_keysize { Crypt::Cipher::min_keysize('Khazad') }
sub default_rounds { Crypt::Cipher::default_rounds('Khazad') }
1;
=pod
=head1 NAME
Crypt::Cipher::Khazad - Symmetric cipher Khazad, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Khazad');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Khazad;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Khazad', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Khazad cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Khazad->new($key);
#or
$c = Crypt::Cipher::Khazad->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Khazad->keysize;
#or
Crypt::Cipher::Khazad::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Khazad->blocksize;
#or
Crypt::Cipher::Khazad::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Khazad->max_keysize;
#or
Crypt::Cipher::Khazad::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Khazad->min_keysize;
#or
Crypt::Cipher::Khazad::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Khazad->default_rounds;
#or
Crypt::Cipher::Khazad::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/KHAZAD>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::MULTI2;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('MULTI2') }
sub keysize { Crypt::Cipher::keysize('MULTI2') }
sub max_keysize { Crypt::Cipher::max_keysize('MULTI2') }
sub min_keysize { Crypt::Cipher::min_keysize('MULTI2') }
sub default_rounds { Crypt::Cipher::default_rounds('MULTI2') }
1;
=pod
=head1 NAME
Crypt::Cipher::MULTI2 - Symmetric cipher MULTI2, key size: 320 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('MULTI2');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::MULTI2;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::MULTI2', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the MULTI2 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::MULTI2->new($key);
#or
$c = Crypt::Cipher::MULTI2->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::MULTI2->keysize;
#or
Crypt::Cipher::MULTI2::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::MULTI2->blocksize;
#or
Crypt::Cipher::MULTI2::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::MULTI2->max_keysize;
#or
Crypt::Cipher::MULTI2::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::MULTI2->min_keysize;
#or
Crypt::Cipher::MULTI2::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::MULTI2->default_rounds;
#or
Crypt::Cipher::MULTI2::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/MULTI2>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Noekeon;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Noekeon') }
sub keysize { Crypt::Cipher::keysize('Noekeon') }
sub max_keysize { Crypt::Cipher::max_keysize('Noekeon') }
sub min_keysize { Crypt::Cipher::min_keysize('Noekeon') }
sub default_rounds { Crypt::Cipher::default_rounds('Noekeon') }
1;
=pod
=head1 NAME
Crypt::Cipher::Noekeon - Symmetric cipher Noekeon, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Noekeon');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Noekeon;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Noekeon', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Noekeon cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Noekeon->new($key);
#or
$c = Crypt::Cipher::Noekeon->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Noekeon->keysize;
#or
Crypt::Cipher::Noekeon::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Noekeon->blocksize;
#or
Crypt::Cipher::Noekeon::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Noekeon->max_keysize;
#or
Crypt::Cipher::Noekeon::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Noekeon->min_keysize;
#or
Crypt::Cipher::Noekeon::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Noekeon->default_rounds;
#or
Crypt::Cipher::Noekeon::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/NOEKEON>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::RC2;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC2') }
sub keysize { Crypt::Cipher::keysize('RC2') }
sub max_keysize { Crypt::Cipher::max_keysize('RC2') }
sub min_keysize { Crypt::Cipher::min_keysize('RC2') }
sub default_rounds { Crypt::Cipher::default_rounds('RC2') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC2 - Symmetric cipher RC2, key size: 40-1024 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC2');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC2;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC2', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC2 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC2->new($key);
#or
$c = Crypt::Cipher::RC2->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC2->keysize;
#or
Crypt::Cipher::RC2::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC2->blocksize;
#or
Crypt::Cipher::RC2::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC2->max_keysize;
#or
Crypt::Cipher::RC2::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC2->min_keysize;
#or
Crypt::Cipher::RC2::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC2->default_rounds;
#or
Crypt::Cipher::RC2::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC2>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::RC5;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC5') }
sub keysize { Crypt::Cipher::keysize('RC5') }
sub max_keysize { Crypt::Cipher::max_keysize('RC5') }
sub min_keysize { Crypt::Cipher::min_keysize('RC5') }
sub default_rounds { Crypt::Cipher::default_rounds('RC5') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC5 - Symmetric cipher RC5, key size: 64-1024 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC5');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC5;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC5', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC5 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC5->new($key);
#or
$c = Crypt::Cipher::RC5->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC5->keysize;
#or
Crypt::Cipher::RC5::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC5->blocksize;
#or
Crypt::Cipher::RC5::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC5->max_keysize;
#or
Crypt::Cipher::RC5::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC5->min_keysize;
#or
Crypt::Cipher::RC5::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC5->default_rounds;
#or
Crypt::Cipher::RC5::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC5>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::RC6;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('RC6') }
sub keysize { Crypt::Cipher::keysize('RC6') }
sub max_keysize { Crypt::Cipher::max_keysize('RC6') }
sub min_keysize { Crypt::Cipher::min_keysize('RC6') }
sub default_rounds { Crypt::Cipher::default_rounds('RC6') }
1;
=pod
=head1 NAME
Crypt::Cipher::RC6 - Symmetric cipher RC6, key size: 64-1024 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('RC6');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::RC6;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::RC6', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the RC6 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::RC6->new($key);
#or
$c = Crypt::Cipher::RC6->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::RC6->keysize;
#or
Crypt::Cipher::RC6::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::RC6->blocksize;
#or
Crypt::Cipher::RC6::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::RC6->max_keysize;
#or
Crypt::Cipher::RC6::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::RC6->min_keysize;
#or
Crypt::Cipher::RC6::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::RC6->default_rounds;
#or
Crypt::Cipher::RC6::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/RC6>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SAFERP;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFERP') }
sub keysize { Crypt::Cipher::keysize('SAFERP') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFERP') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFERP') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFERP') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFERP - Symmetric cipher SAFER+, key size: 128/192/256 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFERP');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFERP;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFERP', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFERP cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFERP->new($key);
#or
$c = Crypt::Cipher::SAFERP->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFERP->keysize;
#or
Crypt::Cipher::SAFERP::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFERP->blocksize;
#or
Crypt::Cipher::SAFERP::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFERP->max_keysize;
#or
Crypt::Cipher::SAFERP::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFERP->min_keysize;
#or
Crypt::Cipher::SAFERP::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFERP->default_rounds;
#or
Crypt::Cipher::SAFERP::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SAFER_K128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_K128') }
sub keysize { Crypt::Cipher::keysize('SAFER_K128') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_K128') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_K128') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_K128') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_K128 - Symmetric cipher SAFER_K128, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_K128');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_K128;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_K128', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_K128 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_K128->new($key);
#or
$c = Crypt::Cipher::SAFER_K128->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_K128->keysize;
#or
Crypt::Cipher::SAFER_K128::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_K128->blocksize;
#or
Crypt::Cipher::SAFER_K128::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_K128->max_keysize;
#or
Crypt::Cipher::SAFER_K128::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_K128->min_keysize;
#or
Crypt::Cipher::SAFER_K128::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_K128->default_rounds;
#or
Crypt::Cipher::SAFER_K128::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SAFER_K64;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_K64') }
sub keysize { Crypt::Cipher::keysize('SAFER_K64') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_K64') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_K64') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_K64') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_K64 - Symmetric cipher SAFER_K64, key size: 64 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_K64');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_K64;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_K64', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_K64 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_K64->new($key);
#or
$c = Crypt::Cipher::SAFER_K64->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_K64->keysize;
#or
Crypt::Cipher::SAFER_K64::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_K64->blocksize;
#or
Crypt::Cipher::SAFER_K64::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_K64->max_keysize;
#or
Crypt::Cipher::SAFER_K64::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_K64->min_keysize;
#or
Crypt::Cipher::SAFER_K64::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_K64->default_rounds;
#or
Crypt::Cipher::SAFER_K64::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SAFER_SK128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_SK128') }
sub keysize { Crypt::Cipher::keysize('SAFER_SK128') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_SK128') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_SK128') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_SK128') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_SK128 - Symmetric cipher SAFER_SK128, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_SK128');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_SK128;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_SK128', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_SK128 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_SK128->new($key);
#or
$c = Crypt::Cipher::SAFER_SK128->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_SK128->keysize;
#or
Crypt::Cipher::SAFER_SK128::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_SK128->blocksize;
#or
Crypt::Cipher::SAFER_SK128::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_SK128->max_keysize;
#or
Crypt::Cipher::SAFER_SK128::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_SK128->min_keysize;
#or
Crypt::Cipher::SAFER_SK128::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_SK128->default_rounds;
#or
Crypt::Cipher::SAFER_SK128::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SAFER_SK64;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SAFER_SK64') }
sub keysize { Crypt::Cipher::keysize('SAFER_SK64') }
sub max_keysize { Crypt::Cipher::max_keysize('SAFER_SK64') }
sub min_keysize { Crypt::Cipher::min_keysize('SAFER_SK64') }
sub default_rounds { Crypt::Cipher::default_rounds('SAFER_SK64') }
1;
=pod
=head1 NAME
Crypt::Cipher::SAFER_SK64 - Symmetric cipher SAFER_SK64, key size: 64 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SAFER_SK64');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SAFER_SK64;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SAFER_SK64', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SAFER_SK64 cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SAFER_SK64->new($key);
#or
$c = Crypt::Cipher::SAFER_SK64->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SAFER_SK64->keysize;
#or
Crypt::Cipher::SAFER_SK64::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SAFER_SK64->blocksize;
#or
Crypt::Cipher::SAFER_SK64::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SAFER_SK64->max_keysize;
#or
Crypt::Cipher::SAFER_SK64::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SAFER_SK64->min_keysize;
#or
Crypt::Cipher::SAFER_SK64::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SAFER_SK64->default_rounds;
#or
Crypt::Cipher::SAFER_SK64::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SAFER>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::SEED;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('SEED') }
sub keysize { Crypt::Cipher::keysize('SEED') }
sub max_keysize { Crypt::Cipher::max_keysize('SEED') }
sub min_keysize { Crypt::Cipher::min_keysize('SEED') }
sub default_rounds { Crypt::Cipher::default_rounds('SEED') }
1;
=pod
=head1 NAME
Crypt::Cipher::SEED - Symmetric cipher SEED, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('SEED');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::SEED;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::SEED', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the SEED cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::SEED->new($key);
#or
$c = Crypt::Cipher::SEED->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::SEED->keysize;
#or
Crypt::Cipher::SEED::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::SEED->blocksize;
#or
Crypt::Cipher::SEED::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::SEED->max_keysize;
#or
Crypt::Cipher::SEED::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::SEED->min_keysize;
#or
Crypt::Cipher::SEED::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::SEED->default_rounds;
#or
Crypt::Cipher::SEED::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/SEED>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Serpent;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Serpent') }
sub keysize { Crypt::Cipher::keysize('Serpent') }
sub max_keysize { Crypt::Cipher::max_keysize('Serpent') }
sub min_keysize { Crypt::Cipher::min_keysize('Serpent') }
sub default_rounds { Crypt::Cipher::default_rounds('Serpent') }
1;
=pod
=head1 NAME
Crypt::Cipher::Serpent - Symmetric cipher Serpent, key size: 128/192/256 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Serpent');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Serpent;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Serpent', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Serpent cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Serpent->new($key);
#or
$c = Crypt::Cipher::Serpent->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Serpent->keysize;
#or
Crypt::Cipher::Serpent::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Serpent->blocksize;
#or
Crypt::Cipher::Serpent::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Serpent->max_keysize;
#or
Crypt::Cipher::Serpent::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Serpent->min_keysize;
#or
Crypt::Cipher::Serpent::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Serpent->default_rounds;
#or
Crypt::Cipher::Serpent::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Serpent_(cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Skipjack;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Skipjack') }
sub keysize { Crypt::Cipher::keysize('Skipjack') }
sub max_keysize { Crypt::Cipher::max_keysize('Skipjack') }
sub min_keysize { Crypt::Cipher::min_keysize('Skipjack') }
sub default_rounds { Crypt::Cipher::default_rounds('Skipjack') }
1;
=pod
=head1 NAME
Crypt::Cipher::Skipjack - Symmetric cipher Skipjack, key size: 80 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Skipjack');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Skipjack;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Skipjack', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Skipjack cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Skipjack->new($key);
#or
$c = Crypt::Cipher::Skipjack->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Skipjack->keysize;
#or
Crypt::Cipher::Skipjack::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Skipjack->blocksize;
#or
Crypt::Cipher::Skipjack::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Skipjack->max_keysize;
#or
Crypt::Cipher::Skipjack::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Skipjack->min_keysize;
#or
Crypt::Cipher::Skipjack::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Skipjack->default_rounds;
#or
Crypt::Cipher::Skipjack::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Skipjack_(cipher)>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::Twofish;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('Twofish') }
sub keysize { Crypt::Cipher::keysize('Twofish') }
sub max_keysize { Crypt::Cipher::max_keysize('Twofish') }
sub min_keysize { Crypt::Cipher::min_keysize('Twofish') }
sub default_rounds { Crypt::Cipher::default_rounds('Twofish') }
1;
=pod
=head1 NAME
Crypt::Cipher::Twofish - Symmetric cipher Twofish, key size: 128/192/256 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('Twofish');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::Twofish;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::Twofish', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the Twofish cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::Twofish->new($key);
#or
$c = Crypt::Cipher::Twofish->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::Twofish->keysize;
#or
Crypt::Cipher::Twofish::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::Twofish->blocksize;
#or
Crypt::Cipher::Twofish::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::Twofish->max_keysize;
#or
Crypt::Cipher::Twofish::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::Twofish->min_keysize;
#or
Crypt::Cipher::Twofish::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::Twofish->default_rounds;
#or
Crypt::Cipher::Twofish::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/Twofish>
=back
=cut

View File

@@ -0,0 +1,118 @@
package Crypt::Cipher::XTEA;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Cipher);
sub blocksize { Crypt::Cipher::blocksize('XTEA') }
sub keysize { Crypt::Cipher::keysize('XTEA') }
sub max_keysize { Crypt::Cipher::max_keysize('XTEA') }
sub min_keysize { Crypt::Cipher::min_keysize('XTEA') }
sub default_rounds { Crypt::Cipher::default_rounds('XTEA') }
1;
=pod
=head1 NAME
Crypt::Cipher::XTEA - Symmetric cipher XTEA, key size: 128 bits
=head1 SYNOPSIS
### example 1
use Crypt::Mode::CBC;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::Mode::CBC->new('XTEA');
my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
### example 2 (slower)
use Crypt::CBC;
use Crypt::Cipher::XTEA;
my $key = '...'; # length has to be valid key size for this cipher
my $iv = '...'; # 16 bytes
my $cbc = Crypt::CBC->new( -cipher=>'Cipher::XTEA', -key=>$key, -iv=>$iv );
my $ciphertext = $cbc->encrypt("secret data");
=head1 DESCRIPTION
This module implements the XTEA cipher. Provided interface is compliant with L<Crypt::CBC|Crypt::CBC> module.
B<BEWARE:> This module implements just elementary "one-block-(en|de)cryption" operation - if you want to
encrypt/decrypt generic data you have to use some of the cipher block modes - check for example
L<Crypt::Mode::CBC|Crypt::Mode::CBC>, L<Crypt::Mode::CTR|Crypt::Mode::CTR> or L<Crypt::CBC|Crypt::CBC> (which will be slower).
=head1 METHODS
=head2 new
$c = Crypt::Cipher::XTEA->new($key);
#or
$c = Crypt::Cipher::XTEA->new($key, $rounds);
=head2 encrypt
$ciphertext = $c->encrypt($plaintext);
=head2 decrypt
$plaintext = $c->decrypt($ciphertext);
=head2 keysize
$c->keysize;
#or
Crypt::Cipher::XTEA->keysize;
#or
Crypt::Cipher::XTEA::keysize;
=head2 blocksize
$c->blocksize;
#or
Crypt::Cipher::XTEA->blocksize;
#or
Crypt::Cipher::XTEA::blocksize;
=head2 max_keysize
$c->max_keysize;
#or
Crypt::Cipher::XTEA->max_keysize;
#or
Crypt::Cipher::XTEA::max_keysize;
=head2 min_keysize
$c->min_keysize;
#or
Crypt::Cipher::XTEA->min_keysize;
#or
Crypt::Cipher::XTEA::min_keysize;
=head2 default_rounds
$c->default_rounds;
#or
Crypt::Cipher::XTEA->default_rounds;
#or
Crypt::Cipher::XTEA::default_rounds;
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Cipher>
=item * L<https://en.wikipedia.org/wiki/XTEA>
=back
=cut

172
database/perl/vendor/lib/Crypt/DES.pm vendored Normal file
View File

@@ -0,0 +1,172 @@
#
# Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
# All rights reserved.
#
# Modifications are Copyright (c) 2000, W3Works, LLC
# All Rights Reserved.
package Crypt::DES;
require Exporter;
require DynaLoader;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default
@EXPORT = qw();
# Other items we are prepared to export if requested
@EXPORT_OK = qw();
$VERSION = '2.07';
bootstrap Crypt::DES $VERSION;
use strict;
use Carp;
sub usage
{
my ($package, $filename, $line, $subr) = caller(1);
$Carp::CarpLevel = 2;
croak "Usage: $subr(@_)";
}
sub blocksize { 8; }
sub keysize { 8; }
sub new
{
usage("new DES key") unless @_ == 2;
my $type = shift;
my $self = {};
bless $self, $type;
$self->{'ks'} = Crypt::DES::expand_key(shift);
return $self;
}
sub encrypt
{
usage("encrypt data[8 bytes]") unless @_ == 2;
my ($self,$data) = @_;
return Crypt::DES::crypt($data, $data, $self->{'ks'}, 1);
}
sub decrypt
{
usage("decrypt data[8 bytes]") unless @_ == 2;
my ($self,$data) = @_;
return Crypt::DES::crypt($data, $data, $self->{'ks'}, 0);
}
1;
__END__
=head1 NAME
Crypt::DES - Perl DES encryption module
=head1 SYNOPSIS
use Crypt::DES;
=head1 DESCRIPTION
The module implements the Crypt::CBC interface,
which has the following methods
=over 4
=item blocksize
=item keysize
=item encrypt
=item decrypt
=back
=head1 FUNCTIONS
=over 4
=item blocksize
Returns the size (in bytes) of the block cipher.
=item keysize
Returns the size (in bytes) of the key. Optimal size is 8 bytes.
=item new
my $cipher = new Crypt::DES $key;
This creates a new Crypt::DES BlockCipher object, using $key,
where $key is a key of C<keysize()> bytes.
=item encrypt
my $cipher = new Crypt::DES $key;
my $ciphertext = $cipher->encrypt($plaintext);
This function encrypts $plaintext and returns the $ciphertext
where $plaintext and $ciphertext should be of C<blocksize()> bytes.
=item decrypt
my $cipher = new Crypt::DES $key;
my $plaintext = $cipher->decrypt($ciphertext);
This function decrypts $ciphertext and returns the $plaintext
where $plaintext and $ciphertext should be of C<blocksize()> bytes.
=back
=head1 EXAMPLE
my $key = pack("H16", "0123456789ABCDEF");
my $cipher = new Crypt::DES $key;
my $ciphertext = $cipher->encrypt("plaintex"); # NB - 8 bytes
print unpack("H16", $ciphertext), "\n";
=head1 NOTES
Do note that DES only uses 8 byte keys and only works on 8 byte data
blocks. If you're intending to encrypt larger blocks or entire files,
please use Crypt::CBC in conjunction with this module. See the
Crypt::CBC documentation for proper syntax and use.
Also note that the DES algorithm is, by today's standard, weak
encryption. Crypt::Blowfish is highly recommended if you're
interested in using strong encryption and a faster algorithm.
=head1 SEE ALSO
Crypt::Blowfish
Crypt::IDEA
Bruce Schneier, I<Applied Cryptography>, 1995, Second Edition,
published by John Wiley & Sons, Inc.
=head1 COPYRIGHT
The implementation of the DES algorithm was developed by,
and is copyright of, Eric Young (eay@mincom.oz.au).
Other parts of the perl extension and module are
copyright of Systemics Ltd ( http://www.systemics.com/ ).
Cross-platform work and packaging for single algorithm
distribution is copyright of W3Works, LLC.
=head1 MAINTAINER
This single-algorithm package and cross-platform code is
maintained by Dave Paris <amused@pobox.com>.
=cut

View File

@@ -0,0 +1,118 @@
# $Id: DES_EDE3.pm,v 1.2 2001/09/15 03:41:09 btrott Exp $
package Crypt::DES_EDE3;
use strict;
use Crypt::DES;
use vars qw( $VERSION );
$VERSION = '0.01';
sub new {
my $class = shift;
my $ede3 = bless {}, $class;
$ede3->init(@_);
}
sub keysize { 24 }
sub blocksize { 8 }
sub init {
my $ede3 = shift;
my($key) = @_;
for my $i (1..3) {
$ede3->{"des$i"} = Crypt::DES->new(substr $key, 8*($i-1), 8);
}
$ede3;
}
sub encrypt {
my($ede3, $block) = @_;
$ede3->{des3}->encrypt(
$ede3->{des2}->decrypt(
$ede3->{des1}->encrypt($block)
)
);
}
sub decrypt {
my($ede3, $block) = @_;
$ede3->{des1}->decrypt(
$ede3->{des2}->encrypt(
$ede3->{des3}->decrypt($block)
)
);
}
1;
__END__
=head1 NAME
Crypt::DES_EDE3 - Triple-DES EDE encryption/decryption
=head1 SYNOPSIS
use Crypt::DES_EDE3;
my $ede3 = Crypt::DES_EDE3->new($key);
$ede3->encrypt($block);
=head1 DESCRIPTION
I<Crypt::DES_EDE3> implements DES-EDE3 encryption. This is triple-DES
encryption where an encrypt operation is encrypt-decrypt-encrypt, and
decrypt is decrypt-encrypt-decrypt. This implementation uses I<Crypt::DES>
to do its dirty DES work, and simply provides a wrapper around that
module: setting up the individual DES ciphers, initializing the keys,
and performing the encryption/decryption steps.
DES-EDE3 encryption requires a key size of 24 bytes.
You're probably best off not using this module directly, as the I<encrypt>
and I<decrypt> methods expect 8-octet blocks. You might want to use the
module in conjunction with I<Crypt::CBC>, for example. This would be
DES-EDE3-CBC, or triple-DES in outer CBC mode.
=head1 USAGE
=head2 $ede3 = Crypt::DES_EDE3->new($key)
Creates a new I<Crypt::DES_EDE3> object (really, a collection of three DES
ciphers), and initializes each cipher with part of I<$key>, which should be
at least 24 bytes. If it's longer than 24 bytes, the extra bytes will be
ignored.
Returns the new object.
=head2 $ede3->encrypt($block)
Encrypts an 8-byte block of data I<$block> using the three DES ciphers in
an encrypt-decrypt-encrypt operation.
Returns the encrypted block.
=head2 $ede3->decrypt($block)
Decrypts an 8-byte block of data I<$block> using the three DES ciphers in
a decrypt-encrypt-decrypt operation.
Returns the decrypted block.
=head2 $ede3->blocksize
Returns the block size (8).
=head2 $ede3->keysize
Returns the key size (24).
=head1 LICENSE
Crypt::DES_EDE3 is free software; you may redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR & COPYRIGHTS
Crypt::DES_EDE3 is Copyright 2001 Benjamin Trott, ben@rhumba.pair.com. All
rights reserved.
=cut

297
database/perl/vendor/lib/Crypt/DSA.pm vendored Normal file
View File

@@ -0,0 +1,297 @@
package Crypt::DSA;
use 5.006;
use strict;
use Digest::SHA1 qw( sha1 );
use Carp qw( croak );
use Crypt::DSA::KeyChain;
use Crypt::DSA::Key;
use Crypt::DSA::Signature;
use Crypt::DSA::Util qw( bitsize bin2mp mod_inverse mod_exp makerandom );
use vars qw( $VERSION );
BEGIN {
$VERSION = '1.17';
}
sub new {
my $class = shift;
my $dsa = bless { @_ }, $class;
$dsa->{_keychain} = Crypt::DSA::KeyChain->new(@_);
$dsa;
}
sub keygen {
my $dsa = shift;
my $key = $dsa->{_keychain}->generate_params(@_);
$dsa->{_keychain}->generate_keys($key);
$key;
}
sub sign {
my $dsa = shift;
my %param = @_;
my($key, $dgst);
croak __PACKAGE__, "->sign: Need a Key" unless $key = $param{Key};
unless ($dgst = $param{Digest}) {
croak __PACKAGE__, "->sign: Need either Message or Digest"
unless $param{Message};
$dgst = sha1($param{Message});
}
my $dlen = length $dgst;
my $i = bitsize($key->q) / 8;
croak "Data too large for key size"
if $dlen > $i || $dlen > 50;
$dsa->_sign_setup($key)
unless $key->kinv && $key->r;
my $m = bin2mp($dgst);
my $xr = ($key->priv_key * $key->r) % $key->q;
my $s = $xr + $m;
$s -= $key->q if $s > $key->q;
$s = ($s * $key->kinv) % $key->q;
my $sig = Crypt::DSA::Signature->new;
$sig->r($key->r);
$sig->s($s);
$sig;
}
sub _sign_setup {
my $dsa = shift;
my $key = shift;
my($k, $r);
{
$k = makerandom(Size => bitsize($key->q));
$k -= $key->q if $k >= $key->q;
redo if $k == 0;
}
$r = mod_exp($key->g, $k, $key->p);
$r %= $key->q;
my $kinv = mod_inverse($k, $key->q);
$key->r($r);
$key->kinv($kinv);
}
sub verify {
my $dsa = shift;
my %param = @_;
my($key, $dgst, $sig);
croak __PACKAGE__, "->verify: Need a Key" unless $key = $param{Key};
unless ($dgst = $param{Digest}) {
croak __PACKAGE__, "->verify: Need either Message or Digest"
unless $param{Message};
$dgst = sha1($param{Message});
}
croak __PACKAGE__, "->verify: Need a Signature"
unless $sig = $param{Signature};
my $u2 = mod_inverse($sig->s, $key->q);
my $u1 = bin2mp($dgst);
$u1 = ($u1 * $u2) % $key->q;
$u2 = ($sig->r * $u2) % $key->q;
my $t1 = mod_exp($key->g, $u1, $key->p);
my $t2 = mod_exp($key->pub_key, $u2, $key->p);
$u1 = ($t1 * $t2) % $key->p;
$u1 %= $key->q;
$u1 == $sig->r;
}
1;
__END__
=pod
=head1 NAME
Crypt::DSA - DSA Signatures and Key Generation
=head1 SYNOPSIS
use Crypt::DSA;
my $dsa = Crypt::DSA->new;
my $key = $dsa->keygen(
Size => 512,
Seed => $seed,
Verbosity => 1
);
my $sig = $dsa->sign(
Message => "foo bar",
Key => $key
);
my $verified = $dsa->verify(
Message => "foo bar",
Signature => $sig,
Key => $key,
);
=head1 DESCRIPTION
I<Crypt::DSA> is an implementation of the DSA (Digital Signature
Algorithm) signature verification system. The implementation
itself is pure Perl, although the heavy-duty mathematics underneath
are provided by the I<Math::Pari> library.
This package provides DSA signing, signature verification, and key
generation.
=head1 USAGE
The I<Crypt::DSA> public interface is similar to that of
I<Crypt::RSA>. This was done intentionally.
=head2 Crypt::DSA->new
Constructs a new I<Crypt::DSA> object. At the moment this isn't
particularly useful in itself, other than being the object you
need to do much else in the system.
Returns the new object.
=head2 $key = $dsa->keygen(%arg)
Generates a new set of DSA keys, including both the public and
private portions of the key.
I<%arg> can contain:
=over 4
=item * Size
The size in bits of the I<p> value to generate. The I<q> and
I<g> values are always 160 bits each.
This argument is mandatory.
=item * Seed
A seed with which I<q> generation will begin. If this seed does
not lead to a suitable prime, it will be discarded, and a new
random seed chosen in its place, until a suitable prime can be
found.
This is entirely optional, and if not provided a random seed will
be generated automatically.
=item * Verbosity
Should be either 0 or 1. A value of 1 will give you a progress
meter during I<p> and I<q> generation--this can be useful, since
the process can be relatively long.
The default is 0.
=back
=head2 $signature = $dsa->sign(%arg)
Signs a message (or the digest of a message) using the private
portion of the DSA key and returns the signature.
The return value--the signature--is a I<Crypt::DSA::Signature>
object.
I<%arg> can include:
=over 4
=item * Digest
A digest to be signed. The digest should be 20 bytes in length
or less.
You must provide either this argument or I<Message> (see below).
=item * Key
The I<Crypt::DSA::Key> object with which the signature will be
generated. Should contain a private key attribute (I<priv_key>).
This argument is required.
=item * Message
A plaintext message to be signed. If you provide this argument,
I<sign> will first produce a SHA1 digest of the plaintext, then
use that as the digest to sign. Thus writing
my $sign = $dsa->sign(Message => $message, ... );
is a shorter way of writing
use Digest::SHA1 qw( sha1 );
my $sig = $dsa->sign(Digest => sha1( $message ), ... );
=back
=head2 $verified = $dsa->verify(%arg)
Verifies a signature generated with I<sign>. Returns a true
value on success and false on failure.
I<%arg> can contain:
=over 4
=item * Key
Key of the signer of the message; a I<Crypt::DSA::Key> object.
The public portion of the key is used to verify the signature.
This argument is required.
=item * Signature
The signature itself. Should be in the same format as returned
from I<sign>, a I<Crypt::DSA::Signature> object.
This argument is required.
=item * Digest
The original signed digest whose length is less than or equal to
20 bytes.
Either this argument or I<Message> (see below) must be present.
=item * Message
As above in I<sign>, the plaintext message that was signed, a
string of arbitrary length. A SHA1 digest of this message will
be created and used in the verification process.
=back
=head1 TODO
Add ability to munge format of keys. For example, read/write keys
from/to key files (SSH key files, etc.), and also write them in
other formats.
=head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA>
For other issues, contact the author.
=head1 AUTHOR
Benjamin Trott E<lt>ben@sixapart.comE<gt>
=head1 COPYRIGHT
Except where otherwise noted,
Crypt::DSA is Copyright 2006 - 2011 Benjamin Trott.
Crypt::DSA is free software; you may redistribute it
and/or modify it under the same terms as Perl itself.
=cut

View File

@@ -0,0 +1,522 @@
package Crypt::DSA::GMP;
use 5.006;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::VERSION = '0.02';
}
use Carp qw( croak );
use Math::BigInt lib => "GMP";
use Digest::SHA qw( sha1 sha256 sha512 );
use Crypt::DSA::GMP::KeyChain;
use Crypt::DSA::GMP::Key;
use Crypt::DSA::GMP::Signature;
use Crypt::DSA::GMP::Util qw( bitsize bin2mp mod_inverse mod_exp makerandomrange );
sub new {
my $class = shift;
my $dsa = bless { @_ }, $class;
$dsa->{_keychain} = Crypt::DSA::GMP::KeyChain->new(@_);
$dsa;
}
sub keygen {
my ($dsa, %params) = @_;
my $key = $dsa->{_keychain}->generate_params(%params);
my $nonblock = $params{NonBlockingKeyGeneration};
$dsa->{_keychain}->generate_keys($key, $nonblock);
croak "Invalid key" unless $key->validate();
$key;
}
sub keyset {
my ($dsa, %param) = @_;
my $key = Crypt::DSA::GMP::Key->new;
croak "Key missing p" unless defined $param{p}; $key->p($param{p});
croak "Key missing q" unless defined $param{q}; $key->q($param{q});
croak "Key missing g" unless defined $param{g}; $key->g($param{g});
$key->priv_key($param{priv_key}) if defined $param{priv_key};
$key->priv_key($param{x} ) if defined $param{x};
$key->pub_key($param{pub_key}) if defined $param{pub_key};
$key->pub_key($param{y} ) if defined $param{y};
$key->pub_key(mod_exp($key->g, $key->priv_key, $key->p))
if !defined $key->pub_key && defined $key->priv_key;
croak "Key missing both private and public keys"
unless defined $key->pub_key || defined $key->priv_key;
croak "Invalid key" unless $key->validate();
$key;
}
sub sign {
my ($dsa, %param) = @_;
my ($key, $dgst) = ($param{Key}, $param{Digest});
croak __PACKAGE__, "->sign: Need a Key" unless defined $key && ref($key);
croak __PACKAGE__, "->sign: Invalid key" unless $key->validate();
my ($p, $q, $g) = ($key->p, $key->q, $key->g);
my $N = bitsize($q);
if (!defined $dgst) {
my $message = $param{Message};
croak __PACKAGE__, "->sign: Need either Message or Digest"
unless defined $message;
# Determine which standard we're following.
$param{Standard} = $dsa->{Standard}
if defined $dsa->{Standard} && !defined $param{Standard};
if (defined $param{Standard} && $param{Standard} =~ /186-[34]/) {
# See NIST SP 800-57 revision 3, section 5.6.1
$dgst = ($N > 256) ? sha512($message) : sha256($message);
} else {
$dgst = sha1($message);
}
}
# FIPS 186-4, section 4.6 "DSA Signature Generation"
# compute z as the leftmost MIN(N, outlen) bits of the digest
my $z = bin2mp($dgst);
$z->brsft(8*length($dgst) - $N) if $N < 8*length($dgst);
# Generate r and s, ensuring neither are zero.
my ($r, $s);
do {
my ($k, $kinv);
do {
# Using FIPS 186-4 B.2.2 approved method
# k is per-message random number 0 < k < q
$k = makerandomrange( Max => $q-2 ) + 1;
$r = mod_exp($g, $k, $p)->bmod($q);
} while $r == 0;
$kinv = mod_inverse($k, $q);
$s = ($kinv * ($z + $key->priv_key * $r)) % $q;
} while $s == 0;
croak "Internal error in signing" if $r == 0 || $s == 0;
my $sig = Crypt::DSA::GMP::Signature->new;
$sig->r($r);
$sig->s($s);
$sig;
}
sub verify {
my ($dsa, %param) = @_;
my ($key, $dgst, $sig) = ($param{Key}, $param{Digest}, $param{Signature});
croak __PACKAGE__, "->verify: Need a Key"
unless defined $key && ref($key);
croak __PACKAGE__, "->verify: Need a Signature"
unless defined $sig && ref($sig);
croak __PACKAGE__, "->verify: Invalid key" unless $key->validate();
my ($p, $q, $g, $r, $s) = ($key->p, $key->q, $key->g, $sig->r, $sig->s);
return 0 unless $r > 0 && $r < $q && $s > 0 && $s < $q;
my $N = bitsize($q);
if (!defined $dgst) {
my $message = $param{Message};
croak __PACKAGE__, "->verify: Need either Message or Digest"
unless defined $message;
# Determine which standard we're following.
$param{Standard} = $dsa->{Standard}
if defined $dsa->{Standard} && !defined $param{Standard};
if (defined $param{Standard} && $param{Standard} =~ /186-[34]/) {
# See NIST SP 800-57 revision 3, section 5.6.1
$dgst = ($N > 256) ? sha512($message) : sha256($message);
} else {
$dgst = sha1($message);
}
}
my $w = mod_inverse($s, $q);
my $z = bin2mp($dgst);
$z->brsft(8*length($dgst) - $N) if $N < 8*length($dgst);
my $u1 = $w->copy->bmul($z)->bmod($q);
my $u2 = $w->copy->bmul($r)->bmod($q);
my $v = mod_exp($g, $u1, $p)
->bmul(mod_exp($key->pub_key, $u2, $p))
->bmod($p)
->bmod($q);
$v == $r;
}
1;
__END__
=pod
=head1 NAME
Crypt::DSA::GMP - DSA Signatures and Key Generation
=head1 SYNOPSIS
use Crypt::DSA::GMP;
my $dsa = Crypt::DSA::GMP->new;
my $key = $dsa->keygen(
Size => 512,
Seed => $seed,
Verbosity => 1
);
my $sig = $dsa->sign(
Message => "foo bar",
Key => $key
);
my $verified = $dsa->verify(
Message => "foo bar",
Signature => $sig,
Key => $key,
);
=head1 DESCRIPTION
L<Crypt::DSA::GMP> is an implementation of the DSA (Digital Signature
Algorithm) signature verification system. The implementation
itself is pure Perl, with mathematics support from
L<Math::BigInt::GMP> and L<Math::Prime::Util::GMP>.
This package provides DSA signing, signature verification, and key
generation.
This module is backwards compatible with L<Crypt::DSA>. It removes
a number of dependencies that were portability concerns.
Importantly, it follows FIPS 186-4 wherever possible, and has
support for the new hash methods.
See L</RECOMMENDED KEY GENERATION PARAMETERS> for recommendations
of key generation parameters.
=head1 USAGE
The public interface is a superset of L<Crypt::DSA>, and is
intentionally very similar to L<Crypt::RSA>.
=head2 new
my $dsa_2 = Crypt::DSA::GMP->new;
my $dsa_4 = Crypt::DSA::GMP->new( Standard => "FIPS 186-4" );
Constructs and returns a new L<Crypt::DSA::GMP> object. This
is the object used to perform other useful actions.
The standard to follow may be given in this call, where it
will be used in all methods unless overridden. Currently
only two standards exist:
FIPS 186-2 (includes FIPS 186-1)
FIPS 186-4 (includes FIPS 186-3)
FIPS 186-2 is used as the default to preserve backwards
compatibility. The primary differences:
- FIPS 186-2:
- Up to 80 bits of security (less with default SHA-1).
- NIST deprecated in 2009.
- Completely backward compatible with Crypt::DSA.
(barring differences caused by Crypt::DSA calling openssl)
- Key generation:
- SHA-1 is used for the CSPRNG.
- QSize (the size of q) must be 160 bits.
- Signing and verification:
- SHA-1 is used to hash Message:
less than 80 bits of security regardless of key sizes.
- No difference if Digest is given directly.
- FIPS 186-4:
- Up to 256 bits of security.
- Key generation:
- SHA-2 256/384/512 is used for the CSPRNG.
- QSize (the size of q) may be any integer from 1 to 512.
- The default QSize is 160 when Size < 2048.
- The default QSize is 256 when Size >= 2048.
- Signing and verification:
- SHA2-256 or SHA2-512 is used to hash Message.
- No difference if Digest is given directly.
=head2 keygen
$key = $dsa->keygen(%arg);
Generates a new of DSA key, including both the public and
private portions of the key.
I<%arg> can contain:
=over 4
=item * Standard
If not provided or contains C<186-1> or C<186-2> then the
backward compatible implementation is used, using SHA-1. If it
is provided and contains C<186-3> or C<186-4> then the newer
and recommended FIPS 186-4 standard is used.
For key generation this means different default and allowed
sizes for I<q>, the use of SHA-256 or SHA-512 during random
prime generation, and the FIPS 186-4 updated prime generation
method.
The FIPS 186-4 recommended primality tests are always used as
they are more stringent than FIPS 186-2.
=item * Size
The size in bits of the I<p> value to generate.
This argument is mandatory, and must be at least 256.
=item * QSize
The size in bits of the I<q> value to generate. This is optional.
If FIPS 186-2 is being used or I<Size> is less than 2048, then
the default value will be 160. If FIPS 186-4 is being used and
I<Size> is 2048 or larger, then the default value is 256.
NIST SP 800-57 describes the cryptographic strengths of different
I<Size> and I<QSize> selections. Their table 2 includes:
Bits L N
----- ----- -----
80 1024 160
112 2048 224 Bits = Bits of security
128 3072 256 L = Size = bit length of p
192 7680 384 N = QSize = bit length of q
256 15360 512
In addition, if SHA-1 is used (the default without FIPS 186-4)
then the bits of security provided is strictly less than 80 bits.
=item * Seed
A seed with which I<q> generation will begin. If this seed does
not lead to a suitable prime, it will be discarded, and a new
random seed chosen in its place, until a suitable prime can be
found.
A seed that is shorter than the size of I<q> will be
immediately discarded.
This is entirely optional, and if not provided a random seed will
be generated automatically.
=item * Verbosity
Should be either 0 or 1. A value of 1 will give you a progress
meter during I<p> and I<q> generation--this can be useful, since
the process can be relatively long.
The default is 0.
=item * Prove
Should be 0, 1, I<P>, or I<Q>. If defined and true, then both
the primes for I<p> and I<q> will have a primality proof
constructed and verified. Setting to I<P> or I<Q> will result
in just that prime being proven. The time for proving I<q>
should be minimal, but proving I<p> when Size is larger than
1024 can be B<very> time consuming.
The default is 0, which means the standard FIPS 186-4 probable
prime tests are done.
=back
=head3 RECOMMENDED KEY GENERATION PARAMETERS
These are recommended parameters for the L</keygen> method.
For strict interoperability with all other DSA software, use:
Size => 1024
For better security and interoperability with anything but the
most pedantic software (FIPS 186-2 had a maximum size of 1024;
FIPS 186-4 strict compliance doesn't support this I<(L,N)> pair):
Size => 2048, QSize => 160, Prove => "Q", Standard => "186-4"
For better security and good interoperability with modern code
(including OpenSSL):
Size => 3072, QSize => 256, Prove => "Q", Standard => "186-4"
Note that signatures should a strong hash (either use the
C<Standard =E<gt> "FIPS 186-4"> option when signing, or hash
the message yourself with something like I<sha256>). Without
this, the FIPS 186-2 default of SHA-1 will be used, and
security strength will be less than 80 bits regardless of the
sizes of I<p> and I<q>.
Using Size larger than 3072 and QSize larger than 256 is possible
and most software will support this. NIST SP 800-57 indicates
the two pairs I<(7680,384)> and I<(15360,512)> as examples of
higher cryptographic strength options with 192 and 256 bits of
security respectively. With either pair, an appropriately strong
hash should be used, e.g. I<sha512>, I<sha3_512>, I<skein_512>,
or I<whirlpool>. The main bottleneck is the time required to
generate the keys, which could be several minutes.
=head2 keyset
my $key = $dsa->keyset(%arg);
Creates a key with given elements, typically read from another
source or via another module. I<p>, I<q>, and I<g> are all
required. One or both of I<priv_key> and I<pub_key> are
required. I<pub_key> will be constructed if it is not supplied
but I<priv_key> is not.
=head2 sign
my $sig = $dsa->sign(Key => $key, Message => $msg);
my $sig = $dsa->sign(Key => $key, Digest => $hash_of_msg);
my $sig = $dsa->sign(%arg);
Signs a message (or the digest of a message) using the private
portion of the DSA key and returns the signature.
The return value (the signature) is a
L<Crypt::DSA::GMP::Signature> object.
I<%arg> can include:
=over 4
=item * Standard
If not provided or contains C<186-1> or C<186-2> then the
backward compatible implementation is used, using SHA-1. If it
is provided and contains C<186-3> or C<186-4> then the newer
and recommended FIPS 186-4 standard is used.
For message signing this means FIPS 186-2 uses SHA-1 for digest
construction and at most 160 bits of the digest is used. With
FIPS 186-4, SHA-256 is used if the bit length of I<q> is 256 or
less and SHA-512 is used otherwise. If the input is a Digest
rather than a Message, then there will be no difference.
=item * Digest
A digest to be signed. If the digest length is larger than
I<N>, the bit length of I<q>, then only the leftmost I<N> bits
will be used (as specified in FIPS 186-4).
You must provide either this argument or I<Message> (see below).
=item * Key
The L<Crypt::DSA::GMP::Key> object with which the signature will be
generated. Should contain a private key attribute (I<priv_key>).
This argument is required.
=item * Message
A plaintext message to be signed. If you provide this argument,
I<sign> will first produce a digest of the plaintext, then
use that as the digest to sign. Thus writing
my $sign = $dsa->sign(Message => $message, ... );
is a shorter way of writing
# FIPS 186-2:
use Digest::SHA qw( sha1 );
my $sig = $dsa->sign(Digest => sha1( $message ), ... );
# FIPS 186-4 with QSize <= 256:
use Digest::SHA qw( sha256 );
my $sig = $dsa->sign(Digest => sha256( $message ), ... );
=back
=head2 verify
my $v = $dsa->verify(Key=>$key, Signature=>$sig, Message=>$msg);
my $v = $dsa->verify(Key=>$key, Signature=>$sig, Digest=>$hash);
my $v = $dsa->verify(%arg);
Verifies a signature generated with L</sign>. Returns a true
value on success and false on failure.
I<%arg> can contain:
=over 4
=item * Standard
If not provided or contains C<186-1> or C<186-2> then the
backward compatible implementation is used, using SHA-1. If it
is provided and contains C<186-3> or C<186-4> then the newer
and recommended FIPS 186-4 standard is used.
For message verification this means FIPS 186-2 uses SHA-1
for digest construction and at most 160 bits of the digest is
used. With FIPS 186-4, SHA-256 is used if the bit length
of I<q> is 256 or less and SHA-512 is used otherwise. If
the input is a Digest rather than a Message, then there will
be no difference.
=item * Key
Key of the signer of the message; a L<Crypt::DSA::GMP::Key> object.
The public portion of the key is used to verify the signature.
This argument is required.
=item * Signature
The signature itself. Should be in the same format as returned
from L</sign>, a L<Crypt::DSA::GMP::Signature> object.
This argument is required.
=item * Digest
The original signed digest. This must be computed using the
same hash that was used to sign the message.
Either this argument or I<Message> (see below) must be present.
=item * Message
As above in I<sign>, the plaintext message that was signed, a
string of arbitrary length. A digest of this message will
be created and used in the verification process.
=back
=head1 SUPPORT
Bugs should be reported via the CPAN bug tracker at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA-GMP>
For other issues, contact the author.
=head1 AUTHORS
Dana Jacobsen E<lt>dana@acm.orgE<gt> wrote the new internals.
Benjamin Trott E<lt>ben@sixapart.comE<gt> wrote L<Crypt::DSA>
which was the basis for this module. The PEM module remains
almost entirely his code.
=head1 COPYRIGHT
Copyright 2013 by Dana Jacobsen E<lt>dana@acm.orgE<gt>.
Portions Copyright 2006-2011 by Benjamin Trott.
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
=cut

View File

@@ -0,0 +1,383 @@
package Crypt::DSA::GMP::Key;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::Key::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::Key::VERSION = '0.01';
}
use Carp qw( croak );
use Math::BigInt lib => "GMP";
use Crypt::DSA::GMP::Util qw( bitsize mod_exp );
use Math::Prime::Util::GMP qw/is_prime/;
sub new {
my ($class, %param) = @_;
my $key = bless { }, $class;
if ($param{Filename} || $param{Content}) {
if ($param{Filename} && $param{Content}) {
croak "Filename and Content are mutually exclusive.";
}
return $key->read(%param);
}
$key->{_validated} = 0;
$key;
}
sub size {
my $key = shift;
return bitsize($key->p);
}
sub sizes {
my $key = shift;
return ( bitsize($key->p), bitsize($key->q) );
}
BEGIN {
no strict 'refs'; ## no critic (ProhibitNoStrict)
for my $meth (qw( p q g pub_key priv_key )) {
# Values are stored as Math::BigInt objects
*$meth = sub {
my($key, $value) = @_;
if (defined $value) {
my $str;
if (ref($value) eq 'Math::BigInt') { $key->{$meth} = $value; }
elsif (ref($value) eq 'Math::Pari') { $str = Math::Pari::pari2pv($value); }
elsif (ref $value) { $str = "$value"; }
elsif ($value =~ /^0x/) { $key->{$meth} = Math::BigInt->new($value); }
else { $str = $value; }
$key->{$meth} = Math::BigInt->new("$str")
if defined $str && $str =~ /^\d+$/;
$key->{_validated} = 0;
} elsif (@_ > 1 && !defined $value) {
delete $key->{$meth};
$key->{_validated} = 0;
}
$key->{$meth};
};
}
}
# Basic mathematic validation of the key parameters.
sub validate {
my $key = shift;
return 0 unless defined $key;
return 1 if $key->{_validated};
my ($p, $q, $g, $x) = ($key->p, $key->q, $key->g, $key->priv_key);
return 0 unless defined $p && defined $q && defined $g;
return 0 unless is_prime($p) && is_prime($q);
return 0 unless ($p-1) % $q == 0;
return 0 unless 1 < $g && $g < $p;
return 0 unless mod_exp($g, $q, $p)->is_one;
if (defined $x) {
return 0 unless 0 < $x && $x < $q;
my $pub = mod_exp($g, $x, $p);
if (!defined $key->pub_key) {
$key->pub_key($pub);
} else {
return 0 unless $key->pub_key == $pub;
}
}
my $y = $key->pub_key;
return 0 unless defined $y;
return 0 unless $y < $p;
$key->{_validated} = 1;
1;
}
# Read and Write turn this base class key into a subclass of the
# appropriate type. However, how do we map their type string into
# the correct module?
# 1. eval "use $class;"
# Crypt::DSA does this. It is really not recommended.
# 2. Use Class::Load
# Correct dynamic way.
# 3. Hard code
# Avoids string evals, best security, but not dynamic.
sub read {
my ($key, %param) = @_;
my $type = $param{Type} or croak "read: Need a key file 'Type'";
$key->_subclass_key($type);
if (my $fname = delete $param{Filename}) {
open(my $fh, "<", $fname) or return;
my $blob = do { local $/; <$fh> };
close $fh or return;
$param{Content} = $blob;
}
$key->deserialize(%param);
}
sub write {
my ($key, %param) = @_;
croak "write: Cannot find public key"
unless defined $key && defined $key->pub_key;
my $type = $param{Type};
if (!defined $type) {
my $pkg = __PACKAGE__;
($type) = ref($key) =~ /^${pkg}::(\w+)$/;
}
croak "write: Need a key file 'Type'"
unless defined $type && $type ne '';
# Subclass key as the requested type.
$key->_subclass_key($type);
# Serialize using the subclass method
my $blob = $key->serialize(%param);
# Write to file if requested
if (my $fname = delete $param{Filename}) {
open(my $fh, ">", $fname) or croak "Can't open $fname: $!";
print $fh $blob;
close $fh or croak "Can't close $fname: $!";
}
# Return the serialized data
return $blob;
}
sub _subclass_key {
my ($key, $type) = @_;
croak "Key type undefined" unless defined $type;
if ($type eq 'PEM') {
require Crypt::DSA::GMP::Key::PEM;
bless $key, 'Crypt::DSA::GMP::Key::PEM';
} elsif ($type eq 'SSH2') {
require Crypt::DSA::GMP::Key::SSH2;
bless $key, 'Crypt::DSA::GMP::Key::SSH2';
} else {
croak "Invalid Key type: '$type'";
}
return $key;
}
1;
__END__
=pod
=for stopwords ssh-dss
=head1 NAME
Crypt::DSA::GMP::Key - DSA key
=head1 SYNOPSIS
use Crypt::DSA::GMP::Key;
my $key = Crypt::DSA::GMP::Key->new;
$key->p($p);
=head1 DESCRIPTION
L<Crypt::DSA::GMP::Key> contains a DSA key, both the public and
private portions. Subclasses of L<Crypt::DSA::GMP::Key> implement
I<read> and I<write> methods, such that you can store DSA
keys on disk, and read them back into your application.
=head1 USAGE
Any of the key attributes can be accessed through combination
get/set methods. The key attributes are: I<p>, I<q>, I<g>,
I<priv_key>, and I<pub_key>. For example:
$key->p($p);
my $p2 = $key->p;
All the attributes are L<Math::BigInt> objects. When setting
with a non-Math::BigInt object, we will attempt conversion from
native integers, numeric strings in base 10 or base 16 (the
latter with a C<0x> prefix), Pari objects, and any object that
support stringification to base 10.
=head2 $key = Crypt::DSA::GMP::Key->new(%arg)
Creates a new (empty) key object. All of the attributes are
initialized to 0.
Alternately, if you provide the I<Filename> parameter (see
below), the key will be read from disk. If you provide
the I<Type> parameter (mandatory if I<Filename> is provided),
be aware that your key will actually be blessed into a subclass
of L<Crypt::DSA::GMP::Key>. Specifically, it will be the class
implementing the specific read functionality for that type,
e.g. L<Crypt::DSA::GMP::Key::PEM>.
Returns the key on success, C<undef> otherwise. (See I<Password>
for one reason why I<new> might return C<undef>).
I<%arg> can contain:
=over 4
=item * Type
The type of file where the key is stored. Currently the only
types supported are I<PEM> and I<SSH2>.
A PEM file is an optionally encrypted, ASN.1-encoded object.
Support for reading/writing PEM files comes from L<Convert::PEM>.
If you don't have this module installed, the I<new> method will die.
An SSH2 file may either be a public key in I<ssh-dss> format, or
a private key using the SSH2 format.
This argument is mandatory, I<if> you're either reading the file from
disk (i.e. you provide a I<Filename> argument) or you've specified the
I<Content> argument.
=item * Filename
The location of the file which contains the key.
Requires a I<Type> argument so the decoder knows what type of file it
is. You can't specify I<Content> and I<Filename> at the same time.
=item * Content
The serialized version of the key. Requires a I<Type> argument so the
decoder knows how to decode it. You can't specify I<Content> and
I<Filename> at the same time.
=item * Password
If your key file is encrypted, you'll need to supply a
passphrase to decrypt it. You can do that here.
If your passphrase is incorrect, I<new> will return C<undef>.
=back
=head2 $key->write(%arg)
Writes a key (optionally) to disk, using a format that you
define with the I<Type> parameter.
If your I<$key> object has a defined I<priv_key> (private key portion),
the key will be written as a DSA private key object; otherwise, it will
be written out as a public key. Note that not all serialization mechanisms
can produce public keys in this version--currently, only PEM public keys
are supported.
I<%arg> can include:
=over 4
=item * Type
The type of file format that you wish to write, e.g. I<PEM>.
This argument is mandatory, I<unless> your I<$key> object is
already blessed into a subclass (e.g. L<Crypt::DSA::GMP::Key::PEM>),
and you wish to write the file using the same subclass.
=item * Filename
The location of the file on disk where you want the key file
to be written.
=item * Password
If you want the key file to be encrypted, provide this
argument, and the ASN.1-encoded string will be encrypted using
the passphrase as a key.
=back
=head2 $key->read(%arg)
Reads a key (optionally) from disk, using a format that you
define with the I<Type> parameter.
I<%arg> can include:
=over 4
=item * Type
The type of file format, e.g. I<PEM>, in which the key is stored.
This argument is mandatory.
=item * Filename
The location of the file on disk where the key file exists.
=item * Password
If the key file is encrypted, this argument must be provided.
=back
=head1 METHODS
=head2 size
Returns the size of the key in bits, which is the size of the
large prime I<p>.
=head2 sizes
Returns a two entry array (L, N) where L is the bit length of
I<p> and N is the bit length of I<q>.
=head2 validate
Does simple validation on the key and returns 1 if it passes,
and 0 otherwise. This includes:
=over 4
=item * existence check on I<p>, I<q>, and I<g>
=item * verify primality of I<p> and I<q>
=item * verify I<q> is a factor of I<p-1>
=item * partial validation of I<g> (FIPS 186-4 A.2.2)
=item * existence check of one of I<priv_key> or I<pub_key>
=item * construction or verification of I<pub_key> if I<priv_key> exists
=back
Using the high level L<Crypt::DSA:::GMP> routines, this method
is called after key generation, before signing, and before
verification. An exception is thrown if the result is not
valid.
=head2 p
The prime modulus I<p>, with bit length L.
=head2 q
A prime divisor of I<p-1>, with bit length N.
=head2 g
A generator of a subgroup of order I<q> in the multiplicative group
of C<GF(p)>. I<g> is in the range [I<2>,I<p-1>].
=head2 priv_key
The private key that must remain secret. It is a randomly
generated integer in the range [I<1>,I<q-1>].
=head2 pub_key
The public key, where I<pub_key> = I<g> ^ I<priv_key> mod I<p>.
=head1 AUTHOR & COPYRIGHTS
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,192 @@
package Crypt::DSA::GMP::Key::PEM;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::Key::PEM::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::Key::PEM::VERSION = '0.01';
}
use base qw( Crypt::DSA::GMP::Key );
use Carp qw( croak );
use Convert::PEM 0.07; # So encode honors the Name parameter
use Crypt::DSA::GMP::Key;
sub deserialize {
my $key = shift;
my %param = @_;
$param{Content} =~ /DSA PRIVATE KEY/ ?
$key->_deserialize_privkey(%param) :
$key->_deserialize_pubkey(%param);
}
sub _deserialize_privkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $pkey = $pem->decode( Content => $param{Content},
Password => $param{Password},
Macro => 'DSAPrivateKey' );
return unless $pkey;
for my $m (qw( p q g pub_key priv_key )) {
$key->$m( $pkey->{$m} );
}
$key;
}
sub _deserialize_pubkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $pkey = $pem->decode( Content => $param{Content},
Password => $param{Password},
Macro => 'DSAPublicKey',
Name => 'PUBLIC KEY' );
return unless $pkey;
my $asn = $pem->asn->find('DSAPubKeyInner');
my $num = $asn->decode($pkey->{pub_key}[0]) or croak $asn->{error};
for my $m (qw( p q g )) {
$key->$m( $pkey->{inner}{DSAParams}{$m} );
}
$key->pub_key($num);
$key;
}
sub serialize {
my $key = shift;
## If this is a private key (has the private key portion), serialize
## it as a private key; otherwise use a public key ASN.1 object.
$key->priv_key ? $key->_serialize_privkey(@_) : $key->_serialize_pubkey(@_);
}
sub _serialize_privkey {
my $key = shift;
my %param = @_;
my $pkey = { version => 0 };
for my $m (qw( p q g pub_key priv_key )) {
$pkey->{$m} = $key->$m();
}
my $pem = $key->_pem;
my $buf = $pem->encode(
Content => $pkey,
Password => $param{Password},
Name => 'DSA PRIVATE KEY',
Macro => 'DSAPrivateKey',
) or croak $pem->errstr;
$buf;
}
sub _serialize_pubkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $asn = $pem->asn->find('DSAPubKeyInner');
## Force stringification.
my $str = $asn->encode($key->pub_key . '') or croak $asn->{error};
my $pkey = {
inner => {
objId => '1.2.840.10040.4.1',
DSAParams => {
p => $key->p,
q => $key->q,
g => $key->g
},
},
pub_key => $str
};
my $buf = $pem->encode(
Content => $pkey,
Password => $param{Password},
Name => 'PUBLIC KEY',
Macro => 'DSAPublicKey',
) or return $key->error($pem->errstr);
$buf;
}
sub _pem {
my $key = shift;
unless (defined $key->{__pem}) {
my $pem = Convert::PEM->new(
Name => "DSA PRIVATE KEY",
ASN => qq(
DSAPrivateKey ::= SEQUENCE {
version INTEGER,
p INTEGER,
q INTEGER,
g INTEGER,
pub_key INTEGER,
priv_key INTEGER
}
DSAPublicKey ::= SEQUENCE {
inner SEQUENCE {
objId OBJECT IDENTIFIER,
DSAParams SEQUENCE {
p INTEGER,
q INTEGER,
g INTEGER
}
}
pub_key BIT STRING
}
DSAPubKeyInner ::= INTEGER
));
$key->{__pem} = $pem;
}
$key->{__pem};
}
1;
__END__
=pod
=head1 NAME
Crypt::DSA::GMP::Key::PEM - Read/write DSA PEM files
=head1 SYNOPSIS
use Crypt::DSA::GMP::Key;
my $key = Crypt::DSA::GMP::Key->new( Type => 'PEM', ...);
$key->write( Type => 'PEM', ...);
=head1 DESCRIPTION
L<Crypt::DSA::GMP::Key::PEM> provides an interface for reading
and writing DSA PEM files, using L<Convert::PEM>. The files are
ASN.1-encoded and optionally encrypted.
You shouldn't use this module directly. As the SYNOPSIS above
suggests, this module should be considered a plugin for
L<Crypt::DSA::GMP::Key>, and all access to PEM files (reading DSA
keys from disk, etc.) should be done through that module.
Read the L<Crypt::DSA::GMP::Key> documentation for more details.
=head1 SUBCLASS METHODS
=head2 serialize
Returns the appropriate serialization blob of the key.
=head2 deserialize
Given an argument hash containing I<Content> and I<Password>, this
unpacks the serialized key into the self object.
=head1 AUTHOR & COPYRIGHTS
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,168 @@
package Crypt::DSA::GMP::Key::SSH2;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::Key::SSH2::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::Key::SSH2::VERSION = '0.01';
}
use base qw( Crypt::DSA::GMP::Key );
use MIME::Base64 qw( decode_base64 );
use Crypt::DSA::GMP::Key;
sub deserialize {
my $key = shift;
my %param = @_;
chomp($param{Content});
my $base64;
if ($param{Content} =~ m:ssh-dss (.+)\s+\S+\s*$:s) {
$base64 = $1;
} elsif ($param{Content} =~ /---- BEGIN/) {
my($head, $object, $content, $tail) = $param{Content} =~
m:(---- BEGIN ([^\n\-]+) ----)\n(.+)(---- END .*? ----)$:s;
my @lines = split /\n/, $content;
my $escaped = 0;
my @real;
for my $l (@lines) {
if (substr($l, -1) eq '\\') {
$escaped++;
next;
}
next if index($l, ':') != -1;
if ($escaped) {
$escaped--;
next;
}
push @real, $l;
}
$base64 = join "\n", @real;
}
return unless defined $base64;
my $content = decode_base64($base64);
my $b = BufferWithInt->new_with_init($content);
if ($b->get_int32 == 7 && $b->get_bytes(7) eq 'ssh-dss') {
# This is the public key format created by OpenSSH
$key->p( $b->get_mp_ssh2b );
$key->q( $b->get_mp_ssh2b );
$key->g( $b->get_mp_ssh2b );
$key->pub_key( $b->get_mp_ssh2b );
$key->priv_key(undef);
return $key;
}
$b->reset_offset;
# This all follows ssh-keygen.c: do_convert_private_ssh2_from_blob
my $magic = $b->get_int32;
return unless $magic == 0x3f6ff9eb; # Private Key MAGIC
my($ignore);
$ignore = $b->get_int32;
my $type = $b->get_str;
my $cipher = $b->get_str;
$ignore = $b->get_int32 for 1..3;
return unless $cipher eq 'none';
$key->p( $b->get_mp_ssh2 );
$key->g( $b->get_mp_ssh2 );
$key->q( $b->get_mp_ssh2 );
$key->pub_key( $b->get_mp_ssh2 );
$key->priv_key( $b->get_mp_ssh2 );
#return unless $b->length == $b->offset;
$key;
}
sub serialize {
my $key = shift;
my %param = @_;
die "serialize is unimplemented";
}
package BufferWithInt;
use strict;
use Data::Buffer;
use Crypt::DSA::GMP::Util qw( bin2mp );
use base qw( Data::Buffer );
sub get_mp_ssh2 {
my $buf = shift;
my $bits = $buf->get_int32;
my $off = $buf->{offset};
my $bytes = int(($bits+7) / 8);
my $int = bin2mp( $buf->bytes($off, $bytes) );
$buf->{offset} += $bytes;
$int;
}
sub get_mp_ssh2b {
my $buf = shift;
my $bytes = $buf->get_int32;
my $off = $buf->{offset};
my $int = bin2mp( $buf->bytes($off, $bytes) );
$buf->{offset} += $bytes;
$int;
}
1;
__END__
=head1 NAME
Crypt::DSA::GMP::Key::SSH2 - Read/write DSA SSH2 files
=head1 SYNOPSIS
use Crypt::DSA::GMP::Key;
my $key = Crypt::DSA::GMP::Key->new( Type => 'SSH2', ...);
$key->write( Type => 'SSH2', ...);
=head1 DESCRIPTION
L<Crypt::DSA::GMP::Key::SSH2> provides an interface for reading
and writing DSA SSH2 files, using L<Data::Buffer>, which provides
functionality for SSH-compatible binary in/out buffers.
Currently encrypted key files are not supported.
You shouldn't use this module directly. As the SYNOPSIS above
suggests, this module should be considered a plugin for
L<Crypt::DSA::GMP::Key>, and all access to SSH2 files (reading DSA
keys from disk, etc.) should be done through that module.
Read the L<Crypt::DSA::GMP::Key> documentation for more details.
=head1 SUBCLASS METHODS
=head2 serialize
Returns the appropriate serialization blob of the key.
=head2 deserialize
Given an argument hash containing I<Content> and I<Password>, this
unpacks the serialized key into the self object.
=head1 TODO
This doesn't handle data produced by OpenSSH. To see the data
from a DSA key in their format:
cat file.dsa | grep -v -- ----- | tr -d '\n' | base64 -d | \
openssl asn1parse -inform DER
So we will need Convert::ASN1 to handle this.
=head1 AUTHOR & COPYRIGHTS
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,395 @@
package Crypt::DSA::GMP::KeyChain;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::KeyChain::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::KeyChain::VERSION = '0.01';
}
use Carp qw( croak );
use Math::BigInt lib => "GMP";
use Math::Prime::Util::GMP qw/is_prob_prime is_provable_prime miller_rabin_random/;
use Digest::SHA qw( sha1 sha1_hex sha256_hex);
use Crypt::DSA::GMP::Key;
use Crypt::DSA::GMP::Util qw( bin2mp bitsize mod_exp makerandomrange randombytes );
sub new {
my ($class, @params) = @_;
return bless { @params }, $class;
}
sub generate_params {
my ($keygen, %param) = @_;
croak "Size parameter missing" unless defined $param{Size};
my $bits = int($param{Size});
my $v = $param{Verbosity};
my $proveq = $param{Prove} && $param{Prove} !~ /^p$/i;
my $provep = $param{Prove} && $param{Prove} !~ /^q$/i;
croak "Number of bits (Size => $bits) is too small (min 256)"
unless $bits >= 256;
# TODO:
# - strict FIPS 186-2 compliance requires L to be a multiple
# of 64 512 <= L <= 1024.
# - strict FIPS 186-3/4 compliance requires L,N to be one of
# the pairs: (1024,160) (2048,224) (2048,256) (3072,256)
# - Can we use new generation method if seed is null?
# OpenSSL was removed:
# 1. It was a portability issue (7 RTs related to it).
# 2. It removes module dependencies.
# 2. Security issues with running a program in the path without
# verifying it is the correct executable.
# 3. We know the code here follows FIPS 186-4. OpenSSL does not.
# 4. The behavior of OpenSSL has changed across different versions.
# 5. This code is faster for key sizes larger than 1024 bits.
# Time for key generations (without proofs, average of 1000)
# 512-bit 47ms Perl 25ms OpenSSL
# 768-bit 78ms Perl 69ms OpenSSL
# 1024-bit 139ms Perl 144ms OpenSSL
# 2048-bit 783ms Perl 1,144ms OpenSSL
# 4096-bit 7,269ms Perl 12,888ms OpenSSL
$param{Standard} = $keygen->{Standard}
if defined $keygen->{Standard} && !defined $param{Standard};
my $standard = (defined $param{Standard} && $param{Standard} =~ /186-[34]/)
? 'FIPS 186-4'
: 'FIPS 186-2';
# $mrseed is just a random number we give to the primality test to give us
# a unique sequence of bases. It's not that important other than (1) we
# don't want the same sequence each call, (2) we don't want to leak any
# information about our state, and (3) we don't want to spend too much
# time/entropy on it. A truncated hash of our seed should work well.
my($counter, $q, $p, $seed, $seedp1, $mrseed);
if ($standard eq 'FIPS 186-2') {
croak "FIPS 186-2 does not support Q sizes other than 160"
if defined $param{QSize} && $param{QSize} != 160;
# See FIPS 186-4 A.1.1.1, non-approved method.
delete $param{Seed} if defined $param{Seed} && length($param{Seed}) != 20;
my $n = int(($bits+159)/160)-1;
my $b = $bits-1-($n*160);
my $p_test = Math::BigInt->new(2)->bpow($bits-1); # 2^(L-1)
do {
## Generate q
while (1) {
print STDERR "." if $v;
$seed = (defined $param{Seed}) ? delete $param{Seed}
: randombytes(20);
$seedp1 = _seed_plus_one($seed);
my $md = sha1($seed) ^ sha1($seedp1);
vec($md, 0, 8) |= 0x80;
vec($md, 19, 8) |= 0x01;
$q = bin2mp($md);
$mrseed = '0x'.substr(sha256_hex($seed),0,16) unless defined $mrseed;
last if ( $proveq && is_provable_prime($q))
|| (!$proveq && is_prob_prime($q)
&& miller_rabin_random($q, 19, $mrseed));
}
print STDERR "*\n" if $v;
## Generate p.
$counter = 0;
my $q2 = Math::BigInt->new(2)->bmul($q);
while ($counter < 4096) {
print STDERR "." if $v;
my $Wstr = '';
for my $j (0 .. $n) {
$seedp1 = _seed_plus_one($seedp1);
$Wstr = sha1_hex($seedp1) . $Wstr;
}
my $W = Math::BigInt->from_hex('0x'.$Wstr)->bmod($p_test);
my $X = $W + $p_test;
$p = $X - ( ($X % $q2) - 1);
if ($p >= $p_test) {
last if ( $provep && is_provable_prime($p))
|| (!$provep && is_prob_prime($p)
&& miller_rabin_random($p, 3, $mrseed));
}
$counter++;
}
} while ($counter >= 4096);
# /\ /\ /\ /\ FIPS 186-2 /\ /\ /\ /\ #
} else {
# \/ \/ \/ \/ FIPS 186-4 \/ \/ \/ \/ #
my $L = $bits;
my $N = (defined $param{QSize}) ? $param{QSize}
: ($bits >= 2048) ? 256 : 160;
croak "Invalid Q size, must be between 1 and 512" if $N < 1 || $N > 512;
croak "Invalid Q size, must be >= Size+8" if $L < $N+8;
# See NIST SP 800-57 rev 3, table 3. sha256 is ok for all sizes
my $outlen = ($N <= 256) ? 256 : ($N <= 384) ? 384 : 512;
my $sha = Digest::SHA->new($outlen);
croak "No digest available for Q size $N" unless defined $sha;
my $n = int(($L+$outlen-1)/$outlen)-1;
my $b = $L-1-($n*$outlen);
my $p_test = Math::BigInt->new(2)->bpow($L-1); # 2^(L-1)
my $q_test = Math::BigInt->new(2)->bpow($N-1); # 2^(N-1)
my $seedlen = int( ($N+7)/8 );
my $nptests = ($L <= 2048) ? 3 : 2; # See FIPS 186-4 table C.1
my $nqtests = ($N <= 160) ? 19 : 27;
delete $param{Seed}
if defined $param{Seed} && length($param{Seed}) < $seedlen;
$param{Seed} = substr($param{Seed}, 0, $seedlen) if defined $param{Seed};
do {
## Generate q
while (1) {
print STDERR "." if $v;
$seed = (defined $param{Seed}) ? delete $param{Seed}
: randombytes($seedlen);
my $digest = $sha->reset->add($seed)->hexdigest;
my $U = Math::BigInt->from_hex('0x'.$digest)->bmod($q_test);
$q = $q_test + $U + 1 - $U->is_odd();
$mrseed = '0x'.substr(sha256_hex($seed),0,16) unless defined $mrseed;
last if ( $proveq && is_provable_prime($q))
|| (!$proveq && is_prob_prime($q)
&& miller_rabin_random($q, $nqtests, $mrseed));
}
print STDERR "*\n" if $v;
$seedp1 = $seed;
## Generate p.
$counter = 0;
my $q2 = Math::BigInt->new(2)->bmul($q);
while ($counter < 4*$L) {
print STDERR "." if $v;
my $Wstr = '';
for my $j (0 .. $n) {
$seedp1 = _seed_plus_one($seedp1);
$Wstr = $sha->reset->add($seedp1)->hexdigest . $Wstr;
}
my $W = Math::BigInt->from_hex('0x'.$Wstr)->bmod($p_test);
my $X = $W + $p_test;
$p = $X - ( ($X % $q2) - 1);
if ($p >= $p_test) {
last if ( $provep && is_provable_prime($p))
|| (!$provep && is_prob_prime($p)
&& miller_rabin_random($p, $nptests, $mrseed));
}
$counter++;
}
} while ($counter >= 4*$L);
}
print STDERR "*" if $v;
my $e = ($p - 1) / $q;
my $h = Math::BigInt->bone;
my $g;
do {
$g = mod_exp(++$h, $e, $p);
} while $g == 1;
print STDERR "\n" if $v;
my $key = Crypt::DSA::GMP::Key->new;
$key->p($p);
$key->q($q);
$key->g($g);
return wantarray ? ($key, $counter, "$h", $seed) : $key;
}
# Using FIPS 186-4 B.1.2 approved method.
sub generate_keys {
my ($keygen, $key, $nonblock) = @_;
my $q = $key->q;
# Generate private key 0 < x < q, using best randomness source.
my $priv_key = makerandomrange( Max => $q-2, KeyGen => !$nonblock ) + 1;
my $pub_key = mod_exp($key->g, $priv_key, $key->p);
$key->priv_key($priv_key);
$key->pub_key($pub_key);
}
sub _seed_plus_one {
my($s) = @_;
for (my $i = length($s)-1; $i >= 0; $i--) {
vec($s, $i, 8)++;
last unless vec($s, $i, 8) == 0;
}
return $s;
}
1;
=pod
=head1 NAME
Crypt::DSA::GMP::KeyChain - DSA key generation system
=head1 SYNOPSIS
use Crypt::DSA::GMP::KeyChain;
my $keychain = Crypt::DSA::GMP::KeyChain->new;
my $key = $keychain->generate_params(
Size => 512,
Seed => $seed,
Verbosity => 1,
);
$keychain->generate_keys($key);
=head1 DESCRIPTION
L<Crypt::DSA::GMP::KeyChain> is a lower-level interface to key
generation than the L<Crypt::DSA::GMP/keygen> method.
It allows you to separately generate the I<p>, I<q>,
and I<g> key parameters, given an optional starting seed, bit
sizes for I<p> and I<q>, and which standard to follow for
construction.
You can then call I<generate_keys> to generate the public and
private portions of the key.
=head1 USAGE
=head2 $keychain = Crypt::DSA::GMP::KeyChain->new
Constructs and returns a new L<Crypt::DSA::GMP::KeyChain>
object. At the moment this isn't particularly useful in
itself, other than being the object you need in order to
call the other methods.
The standard to follow may be given in this call, where it
will be used in all methods unless overridden.
=head2 $key = $keychain->generate_params(%arg)
Generates a set of DSA parameters: the I<p>, I<q>, and I<g>
values of the key. This involves finding primes, and as such
it can be a relatively long process.
When invoked in scalar context, returns a new
I<Crypt::DSA::GMP::Key> object.
In list context, returns the new I<Crypt::DSA::GMP::Key> object
along with: the value of the internal counter when a suitable
prime I<p> was found; the value of I<h> when I<g> was derived;
and the value of the seed (a 20-byte or 32-byte string) when
I<q> was found. These values aren't particularly useful in normal
circumstances, but they could be useful.
I<%arg> can contain:
=over 4
=item * Standard
Indicates which standard is to be followed. By default,
FIPS 186-2 is used, which maintains backward compatibility
with the L<Crypt::DSA> Perl code and old OpenSSL versions. If
C<FIPS 186-3> or C<FIPS 186-4> is given, then the FIPS 186-4
key generation will be used.
The important changes made:
- Using SHA-2 rather than SHA-1 for the CSPRNG. This produces
better quality random data for prime generation.
- Allows I<N> to vary between 1 and 512 rather than fixed at 160.
- The default size for I<N> when not specified is 256 if I<L> is
2048 or larger, 160 otherwise.
- In L<Crypt::DSA::GMP>, the signing and verification will use
SHA-2 256 for signing and verification when I<N> E<lt>= 256,
and SHA-2 512 otherwise. The old standard used SHA-1.
where I<N> is the bit size of I<q>, and I<L> is the bit size of I<p>.
These correspond to the I<QSize> and I<Size> arguments.
The recommended primality tests from FIPS 186-4 are always
performed, since they are more stringent than the older standard
and have no negative impact on the result.
=item * Size
The size in bits of the I<p> value to generate. The minimum
allowable value is 256, and must also be at least 8 bits larger
than the size of I<q> (defaults to 160, see I<QSize>).
For any use where security is a concern, 1024 bits should be
considered a minimum size. NIST SP800-57 (July 2012) considers
1024 bit DSA using SHA-1 to be deprecated, with 2048 or more bits
using SHA-2 to be acceptable.
This argument is mandatory.
=item * QSize
The size in bits of the I<q> value to generate. For the default
FIPS 186-2 standard, this must always be 160. If the FIPS 186-4
standard is used, then this may be in the range 1 to 512 (values
less than 160 are strongly discouraged).
If not specified, I<q> will be 160 bits if either the default
FIPS 186-2 standard is used or if I<Size> is less than 2048.
If FIPS 186-4 is used and I<Size> is 2048 or larger, then I<q>
will be 256.
=item * Seed
A seed with which I<q> generation will begin. If this seed does
not lead to a suitable prime, it will be discarded, and a new
random seed chosen in its place, until a suitable prime can be
found.
A seed that is shorter than the size of I<q> will be
immediately discarded.
This is entirely optional, and if not provided a random seed will
be generated automatically. Do not use this option unless you
have a specific need for a starting seed.
=item * Verbosity
Should be either 0 or 1. A value of 1 will give you a progress
meter during I<p> and I<q> generation -- this can be useful, since
the process can be relatively long.
The default is 0.
=item * Prove
Should be 0, 1, I<P>, or I<Q>. If defined and true, then both
the primes for I<p> and I<q> will be proven primes. Setting to
the string I<P> or I<Q> will result in just that prime being proven.
Using this flag will guarantee the values are prime, which is
valuable if security is extremely important. The current
implementation constructs random primes using the method
A.1.1.1, then ensures they are prime by constructing and
verifying a primality proof, rather than using a constructive
method such as the Maurer or Shawe-Taylor algorithms. The
time for proof will depend on the platform and the Size
parameter. Proving I<q> should take 100 milliseconds or
less, but I<p> can take a very long time if over 1024 bits.
The default is 0, which means the standard FIPS 186-4 probable
prime tests are done.
=back
=head2 $keychain->generate_keys($key)
Generates the public and private portions of the key I<$key>,
a I<Crypt::DSA::GMP::Key> object.
=head1 AUTHOR & COPYRIGHT
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,151 @@
package Crypt::DSA::GMP::Signature;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::Signature::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::Signature::VERSION = '0.01';
}
use Carp qw( croak );
sub new {
my ($class, %param) = @_;
my $sig = bless { }, $class;
if ($param{Content}) {
return $sig->deserialize(%param);
}
return $sig;
}
BEGIN {
no strict 'refs'; ## no critic (ProhibitNoStrict)
for my $meth (qw( r s )) {
# Values are stored as Math::BigInt objects
*$meth = sub {
my($key, $value) = @_;
if (defined $value) {
my $str;
if (ref($value) eq 'Math::BigInt') { $key->{$meth} = $value; }
elsif (ref($value) eq 'Math::Pari') { $str = Math::Pari::pari2pv($value); }
elsif (ref $value) { $str = "$value"; }
elsif ($value =~ /^0x/) { $key->{$meth} = Math::BigInt->new($value); }
else { $str = $value; }
$key->{$meth} = Math::BigInt->new("$str")
if defined $str && $str =~ /^\d+$/;
} elsif (@_ > 1 && !defined $value) {
delete $key->{$meth};
}
$key->{$meth};
};
}
}
sub _asn {
require Convert::ASN1;
my $asn = Convert::ASN1->new;
$asn->prepare('SEQUENCE { r INTEGER, s INTEGER }') or croak $asn->{error};
$asn;
}
sub deserialize {
my ($sig, %param) = @_;
my $asn = __PACKAGE__->_asn;
my $ref = $asn->decode($param{Content});
if (!$ref) {
require MIME::Base64;
my $base64_content = do {
no warnings;
MIME::Base64::decode_base64($param{Content});
};
$ref = $asn->decode($base64_content);
}
croak "Invalid Content" unless $ref;
$sig->s($ref->{s});
$sig->r($ref->{r});
$sig;
}
sub serialize {
my ($sig, %param) = @_;
my $asn = __PACKAGE__->_asn;
my $buf = $asn->encode({ s => $sig->s, r => $sig->r })
or croak $asn->{error};
$buf;
}
1;
__END__
=for stopwords deserialize
=head1 NAME
Crypt::DSA::GMP::Signature - DSA signature object
=head1 SYNOPSIS
use Crypt::DSA::GMP::Signature;
my $sig = Crypt::DSA::GMP::Signature->new;
$sig->r($r);
$sig->s($s);
=head1 DESCRIPTION
L<Crypt::DSA::GMP::Signature> represents a DSA signature. It has two
methods, L</r> and L</s>, which are the L<Math::BigInt> representations
of the two pieces of the DSA signature.
=head1 USAGE
=head2 Crypt::DSA::GMP::Signature->new( %options )
Creates a new signature object, and optionally initializes it with the
information in I<%options>, which can contain:
=over 4
=item * Content
An ASN.1-encoded string representing the DSA signature. In ASN.1 notation,
this looks like:
SEQUENCE {
r INTEGER,
s INTEGER
}
If I<Content> is provided, I<new> will automatically call the L</deserialize>
method to parse the content, and set the L</r> and L</s> methods on the
resulting L<Crypt::DSA::GMP::Signature> object.
=back
=head1 METHODS
=head2 serialize
Serializes the signature object I<$sig> into the format described above:
an ASN.1-encoded representation of the signature, using the ASN.1 syntax
above.
=head2 deserialize
Deserializes the ASN.1-encoded representation into a signature object.
=head2 r
One half of the DSA signature for a message.
This is a L<Math::BigInt> object.
=head2 s
One half of the DSA signature for a message.
This is a L<Math::BigInt> object.
=head1 AUTHOR & COPYRIGHTS
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,187 @@
package Crypt::DSA::GMP::Util;
use strict;
use warnings;
BEGIN {
$Crypt::DSA::GMP::Util::AUTHORITY = 'cpan:DANAJ';
$Crypt::DSA::GMP::Util::VERSION = '0.01';
}
use Carp qw( croak );
use Math::BigInt lib => "GMP";
use Crypt::Random::Seed;
use base qw( Exporter );
our @EXPORT_OK = qw( bitsize bin2mp mp2bin mod_inverse mod_exp randombytes makerandom makerandomrange );
our %EXPORT_TAGS = (all => [ @EXPORT_OK ]);
sub bitsize {
my $n = shift;
$n = Math::BigInt->new("$n") unless ref($n) eq 'Math::BigInt';
length($n->as_bin) - 2;
}
# This is the os2ip function
sub bin2mp {
my $s = shift;
return Math::BigInt->new(0) if !defined $s || $s eq '';
return Math::BigInt->from_hex('0x' . unpack("H*", $s));
}
# This is the i2osp function
sub mp2bin {
my $p = shift;
my $res = '';
if (ref($p) ne 'Math::BigInt' && $p <= ~0) {
do {
$res = chr($p & 0xFF) . $res;
$p >>= 8;
} while $p;
} else {
$p = Math::BigInt->new("$p") unless ref($p) eq 'Math::BigInt';
my $hex = $p->as_hex;
$hex =~ s/^0x0*//;
substr($hex, 0, 0, '0') if length($hex) % 2;
$res = pack("H*", $hex);
}
$res;
}
sub mod_exp {
my($a, $exp, $n) = @_;
$a->copy->bmodpow($exp, $n);
}
sub mod_inverse {
my($a, $n) = @_;
$a->copy->bmodinv($n);
}
{
my ($crs, $crs_best);
sub _setup_rng {
$crs_best = Crypt::Random::Seed->new();
$crs = ($crs_best->is_blocking())
? Crypt::Random::Seed->new(NonBlocking=>1)
: $crs_best;
}
sub randombytes {
my($bytes, $keygen) = @_;
_setup_rng() unless defined $crs;
my $src = ($keygen) ? $crs_best : $crs;
return $src->random_bytes($bytes);
}
}
# Generate uniform random number in range [2^(bits-1),2^bits-1]
sub makerandom {
my %param = @_;
my ($bits, $is_keygen) = ( $param{Size}, $param{KeyGen} );
croak "makerandom must have Size >= 1" unless defined $bits && $bits > 0;
return Math::BigInt->bone if $bits == 1;
my $randbits = $bits - 1;
my $randbytes = int(($randbits+7)/8);
my $randbinary = unpack("B*", randombytes( $randbytes, $is_keygen ));
return Math::BigInt->from_bin( '0b1' . substr($randbinary,0,$randbits) );
}
# Generate uniform random number in range [0, $max]
sub makerandomrange {
my %param = @_;
my ($max, $is_keygen) = ( $param{Max}, $param{KeyGen} );
croak "makerandomrange must have a Max > 0" unless defined $max && $max > 0;
$max = Math::BigInt->new("$max") unless ref($max) eq 'Math::BigInt';
my $range = $max->copy->binc;
my $bits = length($range->as_bin) - 2;
my $bytes = 1 + int(($bits+7)/8);
my $rmax = Math::BigInt->bone->blsft(8*$bytes)->bdec();
my $overflow = $rmax - ($rmax % $range);
my $U;
do {
$U = Math::BigInt->from_hex( '0x' . unpack("H*", randombytes($bytes,$is_keygen)) );
} while $U >= $overflow;
$U->bmod($range); # U is randomly in [0, k*$range-1] for some k.
return $U;
}
1;
__END__
=pod
=for stopwords mod_exp($a makerandom makerandomrange
=head1 NAME
Crypt::DSA::GMP::Util - DSA Utility functions
=head1 SYNOPSIS
use Crypt::DSA::GMP::Util qw( func1 func2 ... );
=head1 DESCRIPTION
L<Crypt::DSA::GMP::Util> contains a set of exportable utility functions
used through the L<Crypt::DSA::GMP> module.
=head2 bitsize($n)
Returns the number of bits in the integer I<$n>.
=head2 bin2mp($string)
Given a string I<$string> of any length, treats the string as a
base-256 representation of an integer, and returns that integer.
=head2 mp2bin($int)
Given an integer I<$int> (maybe a L<Math::BigInt> object),
returns an octet string representation (e.g. a string where
each byte is a base-256 digit of the integer).
=head2 mod_exp($a, $exp, $n)
Computes $a ^ $exp mod $n and returns the value.
=head2 mod_inverse($a, $n)
Computes the multiplicative inverse of $a mod $n and returns the
value.
=head2 randombytes($n)
Returns I<$n> random bytes from the entropy source. The entropy
source is a L<Crypt::Random::Seed> source.
An optional boolean second argument indicates whether the data
is being used for key generation, hence the best possible
randomness is used. If this argument is not present or is false,
then the best non-blocking source will be used.
=head2 makerandom
$n = makerandom(Size => 512);
Takes a I<Size> argument and creates a random L<Math::BigInt>
with exactly that number of bits using data from L</randombytes>.
The high order bit will always be set.
Also takes an optional I<KeyGen> argument that is given to
L</randombytes>.
=head2 makerandomrange
$n = makerandomrange(Max => $max); # 0 <= $n <= $max
Returns a L<Math::BigInt> uniformly randomly selected between
I<0> and I<$max>. Random data is provided by L</randombytes>.
Also takes an optional I<KeyGen> argument that is given to
L</randombytes>.
=head1 AUTHOR & COPYRIGHTS
See L<Crypt::DSA::GMP> for author, copyright, and license information.
=cut

View File

@@ -0,0 +1,230 @@
package Crypt::DSA::Key;
use strict;
use Math::BigInt 1.78 try => 'GMP, Pari';
use Carp qw( croak );
use Crypt::DSA::Util qw( bitsize );
use vars qw{$VERSION};
BEGIN {
$VERSION = '1.17';
}
sub new {
my $class = shift;
my %param = @_;
my $key = bless { }, $class;
if ($param{Filename} || $param{Content}) {
if ($param{Filename} && $param{Content}) {
croak "Filename and Content are mutually exclusive.";
}
return $key->read(%param);
}
$key;
}
sub size { bitsize($_[0]->p) }
BEGIN {
no strict 'refs';
for my $meth (qw( p q g pub_key priv_key r kinv )) {
*$meth = sub {
my($key, $value) = @_;
if (ref $value eq 'Math::Pari') {
$key->{$meth} = Math::Pari::pari2pv($value);
}
elsif (ref $value) {
$key->{$meth} = "$value";
}
elsif ($value) {
if ($value =~ /^0x/) {
$key->{$meth} = Math::BigInt->new($value)->bstr;
}
else {
$key->{$meth} = $value;
}
} elsif (@_ > 1 && !defined $value) {
delete $key->{$meth};
}
my $ret = $key->{$meth} || "";
$ret = Math::BigInt->new("$ret") if $ret =~ /^\d+$/;
$ret;
};
}
}
sub read {
my $key = shift;
my %param = @_;
my $type = $param{Type} or croak "read: Need a key file 'Type'";
my $class = join '::', __PACKAGE__, $type;
eval "use $class;";
croak "Invalid key file type '$type': $@" if $@;
bless $key, $class;
local *FH;
if (my $fname = delete $param{Filename}) {
open FH, $fname or return;
my $blob = do { local $/; <FH> };
close FH;
$param{Content} = $blob;
}
$key->deserialize(%param);
}
sub write {
my $key = shift;
my %param = @_;
my $type;
unless ($type = $param{Type}) {
my $pkg = __PACKAGE__;
($type) = ref($key) =~ /^${pkg}::(\w+)$/;
}
croak "write: Need a key file 'Type'" unless $type;
my $class = join '::', __PACKAGE__, $type;
eval "use $class;";
croak "Invalid key file type '$type': $@" if $@;
bless $key, $class;
my $blob = $key->serialize(%param);
if (my $fname = delete $param{Filename}) {
local *FH;
open FH, ">$fname" or croak "Can't open $fname: $!";
print FH $blob;
close FH;
}
$blob;
}
1;
__END__
=head1 NAME
Crypt::DSA::Key - DSA key
=head1 SYNOPSIS
use Crypt::DSA::Key;
my $key = Crypt::DSA::Key->new;
$key->p($p);
=head1 DESCRIPTION
I<Crypt::DSA::Key> contains a DSA key, both the public and
private portions. Subclasses of I<Crypt::DSA::Key> implement
I<read> and I<write> methods, such that you can store DSA
keys on disk, and read them back into your application.
=head1 USAGE
Any of the key attributes can be accessed through combination
get/set methods. The key attributes are: I<p>, I<q>, I<g>,
I<priv_key>, and I<pub_key>. For example:
$key->p($p);
my $p2 = $key->p;
=head2 $key = Crypt::DSA::Key->new(%arg)
Creates a new (empty) key object. All of the attributes are
initialized to 0.
Alternately, if you provide the I<Filename> parameter (see
below), the key will be read in from disk. If you provide
the I<Type> parameter (mandatory if I<Filename> is provided),
be aware that your key will actually be blessed into a subclass
of I<Crypt::DSA::Key>. Specifically, it will be the class
implementing the specific read functionality for that type,
eg. I<Crypt::DSA::Key::PEM>.
Returns the key on success, C<undef> otherwise. (See I<Password>
for one reason why I<new> might return C<undef>).
I<%arg> can contain:
=over 4
=item * Type
The type of file where the key is stored. Currently the only
option is I<PEM>, which indicates a PEM file (optionally
encrypted, ASN.1-encoded object). Support for reading/writing
PEM files comes from I<Convert::PEM>; if you don't have this
module installed, the I<new> method will die.
This argument is mandatory, I<if> you're either reading the file from
disk (ie. you provide a I<Filename> argument) or you've specified the
I<Content> argument.
=item * Filename
The location of the file from which you'd like to read the key.
Requires a I<Type> argument so the decoder knows what type of file it
is. You can't specify I<Content> and I<Filename> at the same time.
=item * Content
The serialized version of the key. Requires a I<Type> argument so the
decoder knows how to decode it. You can't specify I<Content> and
I<Filename> at the same time.
=item * Password
If your key file is encrypted, you'll need to supply a
passphrase to decrypt it. You can do that here.
If your passphrase is incorrect, I<new> will return C<undef>.
=back
=head2 $key->write(%arg)
Writes a key (optionally) to disk, using a format that you
define with the I<Type> parameter.
If your I<$key> object has a defined I<priv_key> (private key portion),
the key will be written as a DSA private key object; otherwise, it will
be written out as a public key. Note that not all serialization mechanisms
can produce public keys in this version--currently, only PEM public keys
are supported.
I<%arg> can include:
=over 4
=item * Type
The type of file format that you wish to write. I<PEM> is one
example (in fact, currently, it's the only example).
This argument is mandatory, I<unless> your I<$key> object is
already blessed into a subclass (eg. I<Crypt::DSA::Key::PEM>),
and you wish to write the file using the same subclass.
=item * Filename
The location of the file on disk where you want the key file
to be written.
=item * Password
If you want the key file to be encrypted, provide this
argument, and the ASN.1-encoded string will be encrypted using
the passphrase as a key.
=back
=head2 $key->size
Returns the size of the key, in bits. This is actually the
number of bits in the large prime I<p>.
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::DSA manpage for author, copyright,
and license information.
=cut

View File

@@ -0,0 +1,178 @@
package Crypt::DSA::Key::PEM;
use strict;
use Carp qw( croak );
use Convert::PEM;
use Crypt::DSA::Key;
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.17';
@ISA = 'Crypt::DSA::Key';
}
sub deserialize {
my $key = shift;
my %param = @_;
$param{Content} =~ /DSA PRIVATE KEY/ ?
$key->_deserialize_privkey(%param) :
$key->_deserialize_pubkey(%param);
}
sub _deserialize_privkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $pkey = $pem->decode( Content => $param{Content},
Password => $param{Password},
Macro => 'DSAPrivateKey' );
return unless $pkey;
for my $m (qw( p q g pub_key priv_key )) {
$key->$m( $pkey->{$m} );
}
$key;
}
sub _deserialize_pubkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $pkey = $pem->decode( Content => $param{Content},
Password => $param{Password},
Macro => 'DSAPublicKey',
Name => 'PUBLIC KEY' );
return unless $pkey;
my $asn = $pem->asn->find('DSAPubKeyInner');
my $num = $asn->decode($pkey->{pub_key}[0]) or croak $asn->{error};
for my $m (qw( p q g )) {
$key->$m( $pkey->{inner}{DSAParams}{$m} );
}
$key->pub_key($num);
$key;
}
sub serialize {
my $key = shift;
## If this is a private key (has the private key portion), serialize
## it as a private key; otherwise use a public key ASN.1 object.
$key->priv_key ? $key->_serialize_privkey(@_) : $key->_serialize_pubkey(@_);
}
sub _serialize_privkey {
my $key = shift;
my %param = @_;
my $pkey = { version => 0 };
for my $m (qw( p q g pub_key priv_key )) {
$pkey->{$m} = $key->$m();
}
my $pem = $key->_pem;
my $buf = $pem->encode(
Content => $pkey,
Password => $param{Password},
Name => 'DSA PRIVATE KEY',
Macro => 'DSAPrivateKey',
) or croak $pem->errstr;
$buf;
}
sub _serialize_pubkey {
my $key = shift;
my %param = @_;
my $pem = $key->_pem;
my $asn = $pem->asn->find('DSAPubKeyInner');
## Force stringification.
my $str = $asn->encode($key->pub_key . '') or croak $asn->{error};
my $pkey = {
inner => {
objId => '1.2.840.10040.4.1',
DSAParams => {
p => $key->p,
q => $key->q,
g => $key->g
},
},
pub_key => $str
};
my $buf = $pem->encode(
Content => $pkey,
Password => $param{Password},
Name => 'PUBLIC KEY',
Macro => 'DSAPublicKey',
) or return $key->error($pem->errstr);
$buf;
}
sub _pem {
my $key = shift;
unless (defined $key->{__pem}) {
my $pem = Convert::PEM->new(
Name => "DSA PRIVATE KEY",
ASN => qq(
DSAPrivateKey ::= SEQUENCE {
version INTEGER,
p INTEGER,
q INTEGER,
g INTEGER,
pub_key INTEGER,
priv_key INTEGER
}
DSAPublicKey ::= SEQUENCE {
inner SEQUENCE {
objId OBJECT IDENTIFIER,
DSAParams SEQUENCE {
p INTEGER,
q INTEGER,
g INTEGER
}
}
pub_key BIT STRING
}
DSAPubKeyInner ::= INTEGER
));
$key->{__pem} = $pem;
}
$key->{__pem};
}
1;
__END__
=head1 NAME
Crypt::DSA::Key::PEM - Read/write DSA PEM files
=head1 SYNOPSIS
use Crypt::DSA::Key;
my $key = Crypt::DSA::Key->new( Type => 'PEM', ...);
$key->write( Type => 'PEM', ...);
=head1 DESCRIPTION
I<Crypt::DSA::Key::PEM> provides an interface to reading and
writing DSA PEM files, using I<Convert::PEM>. The files are
ASN.1-encoded and optionally encrypted.
You shouldn't use this module directly. As the SYNOPSIS above
suggests, this module should be considered a plugin for
I<Crypt::DSA::Key>, and all access to PEM files (reading DSA
keys from disk, etc.) should be done through that module.
Read the I<Crypt::DSA::Key> documentation for more details.
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::DSA manpage for author, copyright,
and license information.
=cut

View File

@@ -0,0 +1,120 @@
package Crypt::DSA::Key::SSH2;
use strict;
use MIME::Base64 qw( decode_base64 );
use Crypt::DSA::Key;
use vars qw{$VERSION @ISA};
BEGIN {
$VERSION = '1.17';
@ISA = 'Crypt::DSA::Key';
}
use constant PRIVKEY_MAGIC => 0x3f6ff9eb;
sub deserialize {
my $key = shift;
my %param = @_;
chomp($param{Content});
my($head, $object, $content, $tail) = $param{Content} =~
m:(---- BEGIN ([^\n\-]+) ----)\n(.+)(---- END .*? ----)$:s;
my @lines = split /\n/, $content;
my $escaped = 0;
my @real;
for my $l (@lines) {
if (substr($l, -1) eq '\\') {
$escaped++;
next;
}
next if index($l, ':') != -1;
if ($escaped) {
$escaped--;
next;
}
push @real, $l;
}
$content = join "\n", @real;
$content = decode_base64($content);
my $b = BufferWithInt->new;
$b->append($content);
my $magic = $b->get_int32;
return unless $magic == PRIVKEY_MAGIC;
my($ignore);
$ignore = $b->get_int32;
my $type = $b->get_str;
my $cipher = $b->get_str;
$ignore = $b->get_int32 for 1..3;
return unless $cipher eq 'none';
$key->p( $b->get_mp_ssh2 );
$key->g( $b->get_mp_ssh2 );
$key->q( $b->get_mp_ssh2 );
$key->pub_key( $b->get_mp_ssh2 );
$key->priv_key( $b->get_mp_ssh2 );
#return unless $b->length == $b->offset;
$key;
}
sub serialize {
my $key = shift;
my %param = @_;
die "serialize is unimplemented";
}
package BufferWithInt;
use strict;
use Data::Buffer;
use Crypt::DSA::Util qw( bin2mp );
use base qw( Data::Buffer );
sub get_mp_ssh2 {
my $buf = shift;
my $bits = $buf->get_int32;
my $off = $buf->{offset};
my $bytes = int(($bits+7) / 8);
my $int = bin2mp( $buf->bytes($off, $bytes) );
$buf->{offset} += $bytes;
$int;
}
1;
__END__
=head1 NAME
Crypt::DSA::Key::SSH2 - Read/write DSA SSH2 files
=head1 SYNOPSIS
use Crypt::DSA::Key;
my $key = Crypt::DSA::Key->new( Type => 'SSH2', ...);
$key->write( Type => 'SSH2', ...);
=head1 DESCRIPTION
I<Crypt::DSA::Key::SSH2> provides an interface to reading and
writing DSA SSH2 files, using I<Data::Buffer>, which provides
functionality for SSH-compatible binary in/out buffers.
Currently encrypted key files are not supported.
You shouldn't use this module directly. As the SYNOPSIS above
suggests, this module should be considered a plugin for
I<Crypt::DSA::Key>, and all access to SSH2 files (reading DSA
keys from disk, etc.) should be done through that module.
Read the I<Crypt::DSA::Key> documentation for more details.
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::DSA manpage for author, copyright,
and license information.
=cut

View File

@@ -0,0 +1,257 @@
package Crypt::DSA::KeyChain;
use strict;
use Math::BigInt 1.78 try => 'GMP, Pari';
use Digest::SHA1 qw( sha1 );
use Carp qw( croak );
use IPC::Open3;
use File::Spec;
use File::Which ();
use Symbol qw( gensym );
use vars qw{$VERSION};
BEGIN {
$VERSION = '1.17';
}
use Crypt::DSA::Key;
use Crypt::DSA::Util qw( bin2mp bitsize mod_exp makerandom isprime );
sub new {
my $class = shift;
bless { @_ }, $class;
}
sub generate_params {
my $keygen = shift;
my %param = @_;
my $bits = Math::BigInt->new($param{Size});
croak "Number of bits (Size) is too small" unless $bits;
delete $param{Seed} if $param{Seed} && length $param{Seed} != 20;
my $v = $param{Verbosity};
# try to use fast implementations found on the system, if available.
unless ($param{Seed} || wantarray || $param{PurePerl}) {
# OpenSSL support
my $bin = $^O eq 'MSWin32' ? 'openssl.exe' : 'openssl';
my $openssl = File::Which::which($bin);
if ( $openssl ) {
print STDERR "Using openssl\n" if $v;
my $bits_n = int($bits);
open( NULL, ">", File::Spec->devnull );
my $pid = open3( gensym, \*OPENSSL, ">&NULL", "$openssl dsaparam -text -noout $bits_n" );
my @res;
while( <OPENSSL> ) {
push @res, $_;
}
waitpid( $pid, 0 );
close OPENSSL;
close NULL;
my %parts;
my $cur_part;
foreach (@res) {
if (/^\s+(\w):\s*$/) {
$cur_part = lc($1);
next;
}
if (/^\s*((?:[0-9a-f]{2,2}:?)+)\s*$/) {
$parts{$cur_part} .= $1;
}
}
$parts{$_} =~ s/://g for keys %parts;
if (scalar keys %parts == 3) {
my $key = Crypt::DSA::Key->new;
$key->p(Math::BigInt->new("0x" . $parts{p}));
$key->q(Math::BigInt->new("0x" . $parts{q}));
$key->g(Math::BigInt->new("0x" . $parts{g}));
return $key;
}
}
}
# Pure Perl version:
my($counter, $q, $p, $seed, $seedp1) = (0);
## Generate q.
SCOPE: {
print STDERR "." if $v;
$seed = $param{Seed} ? delete $param{Seed} :
join '', map chr rand 256, 1..20;
$seedp1 = _seed_plus_one($seed);
my $md = sha1($seed) ^ sha1($seedp1);
vec($md, 0, 8) |= 0x80;
vec($md, 19, 8) |= 0x01;
$q = bin2mp($md);
redo unless isprime($q);
}
print STDERR "*\n" if $v;
my $n = int(("$bits"-1) / 160);
my $b = ($bits-1)-Math::BigInt->new($n)*160;
my $p_test = Math::BigInt->new(1); $p_test <<= ($bits-1);
## Generate p.
SCOPE: {
print STDERR "." if $v;
my $W = Math::BigInt->new(0);
for my $k (0..$n) {
$seedp1 = _seed_plus_one($seedp1);
my $r0 = bin2mp(sha1($seedp1));
$r0 %= Math::BigInt->new(2) ** $b
if $k == $n;
$W += $r0 << (Math::BigInt->new(160) * $k);
}
my $X = $W + $p_test;
$p = $X - ($X % (2 * $q) - 1);
last if $p >= $p_test && isprime($p);
redo unless ++$counter >= 4096;
}
print STDERR "*" if $v;
my $e = ($p - 1) / $q;
my $h = Math::BigInt->new(2);
my $g;
SCOPE: {
$g = mod_exp($h, $e, $p);
$h++, redo if $g == 1;
}
print STDERR "\n" if $v;
my $key = Crypt::DSA::Key->new;
$key->p($p);
$key->q($q);
$key->g($g);
return wantarray ? ($key, $counter, "$h", $seed) : $key;
}
sub generate_keys {
my $keygen = shift;
my $key = shift;
my($priv_key, $pub_key);
SCOPE: {
my $i = bitsize($key->q);
$priv_key = makerandom(Size => $i);
$priv_key -= $key->q if $priv_key >= $key->q;
redo if $priv_key == 0;
}
$pub_key = mod_exp($key->g, $priv_key, $key->p);
$key->priv_key($priv_key);
$key->pub_key($pub_key);
}
sub _seed_plus_one {
my($s, $i) = ($_[0]);
for ($i=19; $i>=0; $i--) {
vec($s, $i, 8)++;
last unless vec($s, $i, 8) == 0;
}
$s;
}
1;
=pod
=head1 NAME
Crypt::DSA::KeyChain - DSA key generation system
=head1 SYNOPSIS
use Crypt::DSA::KeyChain;
my $keychain = Crypt::DSA::KeyChain->new;
my $key = $keychain->generate_params(
Size => 512,
Seed => $seed,
Verbosity => 1,
);
$keychain->generate_keys($key);
=head1 DESCRIPTION
I<Crypt::DSA::KeyChain> is a lower-level interface to key
generation than the interface in I<Crypt::DSA> (the I<keygen>
method). It allows you to separately generate the I<p>, I<q>,
and I<g> key parameters, given an optional starting seed, and
a mandatory bit size for I<p> (I<q> and I<g> are 160 bits each).
You can then call I<generate_keys> to generate the public and
private portions of the key.
=head1 USAGE
=head2 $keychain = Crypt::DSA::KeyChain->new
Constructs a new I<Crypt::DSA::KeyChain> object. At the moment
this isn't particularly useful in itself, other than being the
object you need in order to call the other methods.
Returns the new object.
=head2 $key = $keychain->generate_params(%arg)
Generates a set of DSA parameters: the I<p>, I<q>, and I<g>
values of the key. This involves finding primes, and as such
it can be a relatively long process.
When invoked in scalar context, returns a new
I<Crypt::DSA::Key> object.
In list context, returns the new I<Crypt::DSA::Key> object,
along with: the value of the internal counter when a suitable
prime I<p> was found; the value of I<h> when I<g> was derived;
and the value of the seed (a 20-byte string) when I<q> was
found. These values aren't particularly useful in normal
circumstances, but they could be useful.
I<%arg> can contain:
=over 4
=item * Size
The size in bits of the I<p> value to generate. The I<q> and
I<g> values are always 160 bits each.
This argument is mandatory.
=item * Seed
A seed with which I<q> generation will begin. If this seed does
not lead to a suitable prime, it will be discarded, and a new
random seed chosen in its place, until a suitable prime can be
found.
This is entirely optional, and if not provided a random seed will
be generated automatically.
=item * Verbosity
Should be either 0 or 1. A value of 1 will give you a progress
meter during I<p> and I<q> generation--this can be useful, since
the process can be relatively long.
The default is 0.
=back
=head2 $keychain->generate_keys($key)
Generates the public and private portions of the key I<$key>,
a I<Crypt::DSA::Key> object.
=head1 AUTHOR & COPYRIGHT
Please see the L<Crypt::DSA> manpage for author, copyright,
and license information.
=cut

View File

@@ -0,0 +1,139 @@
package Crypt::DSA::Signature;
use strict;
use Carp qw( croak );
use vars qw{$VERSION};
BEGIN {
$VERSION = '1.17';
}
sub new {
my $class = shift;
my %param = @_;
my $sig = bless { }, $class;
if ($param{Content}) {
return $sig->deserialize(%param);
}
$sig;
}
BEGIN {
no strict 'refs';
for my $meth (qw( r s )) {
*$meth = sub {
my($key, $value) = @_;
if (ref $value eq 'Math::Pari') {
$key->{$meth} = Math::Pari::pari2pv($value);
}
elsif (ref $value) {
$key->{$meth} = "$value";
}
elsif ($value) {
if ($value =~ /^0x/) {
$key->{$meth} = Math::BigInt->new($value)->bstr;
}
else {
$key->{$meth} = $value;
}
}
my $ret = $key->{$meth} || "";
$ret = Math::BigInt->new("$ret") if $ret =~ /^\d+$/;
$ret;
};
}
}
sub asn {
require Convert::ASN1;
my $asn = Convert::ASN1->new;
$asn->prepare('SEQUENCE { r INTEGER, s INTEGER }') or croak $asn->{error};
$asn;
}
sub deserialize {
my $sig = shift;
my %param = @_;
my $asn = __PACKAGE__->asn;
my $ref;
require MIME::Base64;
## Turn off warnings, because we're attempting to base64-decode content
## that may not be base64-encoded.
local $^W = 0;
for ($param{Content}, MIME::Base64::decode_base64($param{Content})) {
my $out = $asn->decode($_);
$ref = $out, last if $out;
}
croak "Invalid Content" unless $ref;
$sig->s($ref->{s});
$sig->r($ref->{r});
$sig;
}
sub serialize {
my $sig = shift;
my %param = @_;
my $asn = __PACKAGE__->asn;
my $buf = $asn->encode({ s => $sig->s, r => $sig->r })
or croak $asn->{error};
$buf;
}
1;
__END__
=head1 NAME
Crypt::DSA::Signature - DSA signature object
=head1 SYNOPSIS
use Crypt::DSA::Signature;
my $sig = Crypt::DSA::Signature->new;
$sig->r($r);
$sig->s($s);
=head1 DESCRIPTION
I<Crypt::DSA::Signature> represents a DSA signature. It has 2 methods,
I<r> and I<s>, which are the big number representations of the 2 pieces of
the DSA signature.
=head1 USAGE
=head2 Crypt::DSA::Signature->new( %options )
Creates a new signature object, and optionally initializes it with the
information in I<%options>, which can contain:
=over 4
=item * Content
An ASN.1-encoded string representing the DSA signature. In ASN.1 notation,
this looks like:
SEQUENCE {
r INTEGER,
s INTEGER
}
If I<Content> is provided, I<new> will automatically call the I<deserialize>
method to parse the content, and set the I<r> and I<s> methods on the
resulting I<Crypt::DSA::Signature> object.
=back
=head2 $sig->serialize
Serializes the signature object I<$sig> into the format described above:
an ASN.1-encoded representation of the signature, using the ASN.1 syntax
above.
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::DSA manpage for author, copyright,
and license information.
=cut

View File

@@ -0,0 +1,201 @@
package Crypt::DSA::Util;
use strict;
use Math::BigInt 1.78 try => 'GMP, Pari';
use Fcntl;
use Carp qw( croak );
use vars qw( $VERSION @ISA @EXPORT_OK );
use Exporter;
BEGIN {
$VERSION = '1.17';
@ISA = qw( Exporter );
@EXPORT_OK = qw( bitsize bin2mp mp2bin mod_inverse mod_exp makerandom isprime );
}
## Nicked from Crypt::RSA::DataFormat.
## Copyright (c) 2001, Vipul Ved Prakash.
sub bitsize {
length(Math::BigInt->new($_[0])->as_bin) - 2;
}
sub bin2mp {
my $s = shift;
$s eq '' ?
Math::BigInt->new(0) :
Math::BigInt->new("0b" . unpack("B*", $s));
}
sub mp2bin {
my $p = Math::BigInt->new(shift);
my $base = Math::BigInt->new(256);
my $res = '';
while ($p != 0) {
my $r = $p % $base;
$p = ($p-$r) / $base;
$res = chr($r) . $res;
}
$res;
}
sub mod_exp {
my($a, $exp, $n) = @_;
$a->copy->bmodpow($exp, $n);
}
sub mod_inverse {
my($a, $n) = @_;
$a->copy->bmodinv($n);
}
sub makerandom {
my %param = @_;
my $size = $param{Size};
my $bytes = int($size / 8) + 1;
my $r = '';
if ( sysopen my $fh, '/dev/random', O_RDONLY ) {
my $read = 0;
while ($read < $bytes) {
my $got = sysread $fh, my($chunk), $bytes - $read;
next unless $got;
die "Error: $!" if $got == -1;
$r .= $chunk;
$read = length $r;
}
close $fh;
}
elsif ( require Data::Random ) {
$r .= Data::Random::rand_chars( set=>'numeric' ) for 1..$bytes;
}
else {
croak "makerandom requires /dev/random or Data::Random";
}
my $down = $size - 1;
$r = unpack 'H*', pack 'B*', '0' x ( $size % 8 ? 8 - $size % 8 : 0 ) .
'1' . unpack "b$down", $r;
Math::BigInt->new('0x' . $r);
}
# For testing, let us choose our isprime function:
*isprime = \&isprime_algorithms_with_perl;
# from the book "Mastering Algorithms with Perl" by Jon Orwant,
# Jarkko Hietaniemi, and John Macdonald
sub isprime_algorithms_with_perl {
use integer;
my $n = shift;
my $n1 = $n - 1;
my $one = $n - $n1; # not just 1, but a bigint
my $witness = $one * 100;
# find the power of two for the top bit of $n1
my $p2 = $one;
my $p2index = -1;
++$p2index, $p2 *= 2
while $p2 <= $n1;
$p2 /= 2;
# number of interations: 5 for 260-bit numbers, go up to 25 for smaller
my $last_witness = 5;
$last_witness += (260 - $p2index) / 13 if $p2index < 260;
for my $witness_count (1..$last_witness) {
$witness *= 1024;
$witness += int(rand(1024)); # XXXX use good rand
$witness = $witness % $n if $witness > $n;
$witness = $one * 100, redo if $witness == 0;
my $prod = $one;
my $n1bits = $n1;
my $p2next = $p2;
# compute $witness ** ($n - 1)
while (1) {
my $rootone = $prod == 1 || $prod == $n1;
$prod = ($prod * $prod) % $n;
return 0 if $prod == 1 && ! $rootone;
if ($n1bits >= $p2next) {
$prod = ($prod * $witness) % $n;
$n1bits -= $p2next;
}
last if $p2next == 1;
$p2next /= 2;
}
return 0 unless $prod == 1;
}
return 1;
}
sub isprime_gp_pari {
my $n = shift;
my $sn = "$n";
die if $sn =~ /\D/;
my $is_prime = `echo "isprime($sn)" | gp -f -q`;
die "No gp installed?" if $?;
chomp $is_prime;
return $is_prime;
}
sub isprime_paranoid {
my $n = shift;
my $perl = isprime_algorithms_with_perl($n);
my $pari = isprime_gp_pari($n);
die "Perl vs. PARI don't match on '$n'\n" unless $perl == $pari;
return $perl;
}
1;
__END__
=head1 NAME
Crypt::DSA::Util - DSA Utility functions
=head1 SYNOPSIS
use Crypt::DSA::Util qw( func1 func2 ... );
=head1 DESCRIPTION
I<Crypt::DSA::Util> contains a set of exportable utility functions
used through the I<Crypt::DSA> set of libraries.
=head2 bitsize($n)
Returns the number of bits in the I<Math::Pari> integer object
I<$n>.
=head2 bin2mp($string)
Given a string I<$string> of any length, treats the string as a
base-256 representation of an integer, and returns that integer,
a I<Math::Pari> object.
=head2 mp2bin($int)
Given a biginteger I<$int> (a I<Math::Pari> object), linearizes
the integer into an octet string, and returns the octet string.
=head2 mod_exp($a, $exp, $n)
Computes $a ^ $exp mod $n and returns the value. The calculations
are done using I<Math::Pari>, and the return value is a I<Math::Pari>
object.
=head2 mod_inverse($a, $n)
Computes the multiplicative inverse of $a mod $n and returns the
value. The calculations are done using I<Math::Pari>, and the
return value is a I<Math::Pari> object.
=head1 AUTHOR & COPYRIGHTS
Please see the Crypt::DSA manpage for author, copyright,
and license information.
=cut

322
database/perl/vendor/lib/Crypt/Digest.pm vendored Normal file
View File

@@ -0,0 +1,322 @@
package Crypt::Digest;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u digest_file digest_file_hex digest_file_b64 digest_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
### the following methods/functions are implemented in XS:
# - new
# - hashsize
# - clone
# - reset
# - digest
# - hexdigest
# - b64digest
# - add
# - digest_data
# - digest_data_hex
# - digest_data_b64
# - digest_data_b64u
# - DESTROY
### METHODS
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') { #filename
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
binmode($handle);
}
else { #handle
$handle = $file
}
croak "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf)
}
croak "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
### FUNCTIONS
sub digest_file { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->digest }
sub digest_file_hex { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->hexdigest }
sub digest_file_b64 { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->b64digest }
sub digest_file_b64u { local $SIG{__DIE__} = \&CryptX::_croak; Crypt::Digest->new(shift)->addfile(@_)->b64udigest }
1;
=pod
=head1 NAME
Crypt::Digest - Generic interface to hash/digest functions
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u
digest_file digest_file_hex digest_file_b64 digest_file_b64u );
# calculate digest from string/buffer
$digest_raw = digest_data('SHA1', 'data string');
$digest_hex = digest_data_hex('SHA1', 'data string');
$digest_b64 = digest_data_b64('SHA1', 'data string');
$digest_b64u = digest_data_b64u('SHA1', 'data string');
# calculate digest from file
$digest_raw = digest_file('SHA1', 'filename.dat');
$digest_hex = digest_file_hex('SHA1', 'filename.dat');
$digest_b64 = digest_file_b64('SHA1', 'filename.dat');
$digest_b64u = digest_file_b64u('SHA1', 'filename.dat');
# calculate digest from filehandle
$digest_raw = digest_file('SHA1', *FILEHANDLE);
$digest_hex = digest_file_hex('SHA1', *FILEHANDLE);
$digest_b64 = digest_file_b64('SHA1', *FILEHANDLE);
$digest_b64u = digest_file_b64u('SHA1', *FILEHANDLE);
### OO interface:
use Crypt::Digest;
$d = Crypt::Digest->new('SHA1');
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to various hash/digest algorithms.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest qw( digest_data digest_data_hex digest_data_b64 digest_data_b64u
digest_file digest_file_hex digest_file_b64 digest_file_b64u );
Or all of them at once:
use Crypt::Digest ':all';
=head1 FUNCTIONS
Please note that all functions take as its first argument the algorithm name, supported values are:
'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256',
'SHA384', 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool',
'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512',
'BLAKE2b_160', 'BLAKE2b_256', 'BLAKE2b_384', 'BLAKE2b_512',
'BLAKE2s_128', 'BLAKE2s_160', 'BLAKE2s_224', 'BLAKE2s_256'
(simply any <NAME> for which there is Crypt::Digest::<NAME> module)
=head2 digest_data
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a binary string.
$digest_raw = digest_data('SHA1', 'data string');
#or
$digest_raw = digest_data('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_hex
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a hexadecimal string.
$digest_hex = digest_data_hex('SHA1', 'data string');
#or
$digest_hex = digest_data_hex('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_b64
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 string, B<with> trailing '=' padding.
$digest_b64 = digest_data_b64('SHA1', 'data string');
#or
$digest_b64 = digest_data_b64('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_data_b64u
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$digest_b64url = digest_data_b64u('SHA1', 'data string');
#or
$digest_b64url = digest_data_b64u('SHA1', 'any data', 'more data', 'even more data');
=head2 digest_file
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a binary string.
$digest_raw = digest_file('SHA1', 'filename.dat');
#or
$digest_raw = digest_file('SHA1', *FILEHANDLE);
=head2 digest_file_hex
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a hexadecimal string.
$digest_hex = digest_file_hex('SHA1', 'filename.dat');
#or
$digest_hex = digest_file_hex('SHA1', *FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 digest_file_b64
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a Base64 string, B<with> trailing '=' padding.
$digest_b64 = digest_file_b64('SHA1', 'filename.dat');
#or
$digest_b64 = digest_file_b64('SHA1', *FILEHANDLE);
=head2 digest_file_b64u
Reads file (defined by filename or filehandle) content, and returns its digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$digest_b64url = digest_file_b64u('SHA1', 'filename.dat');
#or
$digest_b64url = digest_file_b64u('SHA1', *FILEHANDLE);
=head1 METHODS
=head2 new
Constructor, returns a reference to the digest object.
$d = Crypt::Digest->new($name);
# $name could be: 'CHAES', 'MD2', 'MD4', 'MD5', 'RIPEMD128', 'RIPEMD160',
# 'RIPEMD256', 'RIPEMD320', 'SHA1', 'SHA224', 'SHA256', 'SHA384',
# 'SHA512', 'SHA512_224', 'SHA512_256', 'Tiger192', 'Whirlpool'
#
# simply any <FUNCNAME> for which there is Crypt::Digest::<FUNCNAME> module
=head2 clone
Creates a copy of the digest object state and returns a reference to the copy.
$d->clone();
=head2 reset
Reinitialize the digest object state and returns a reference to the digest object.
$d->reset();
=head2 add
All arguments are appended to the message we calculate digest for.
The return value is the digest object itself.
$d->add('any data');
#or
$d->add('any data', 'more data', 'even more data');
Note that all the following cases are equivalent:
# case 1
$d->add('aa', 'bb', 'cc');
# case 2
$d->add('aa');
$d->add('bb');
$d->add('cc');
# case 3
$d->add('aabbcc');
# case 4
$d->add('aa')->add('bb')->add('cc');
=head2 addfile
The content of the file (or filehandle) is appended to the message we calculate digest for.
The return value is the digest object itself.
$d->addfile('filename.dat');
#or
$d->addfile(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 add_bits
This method is available mostly for compatibility with other Digest::SOMETHING modules on CPAN, you are very unlikely to need it.
The return value is the digest object itself.
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
B<BEWARE:> It is not possible to add bits that are not a multiple of 8.
=head2 hashsize
Returns the length of calculated digest in bytes (e.g. 32 for SHA-256).
$d->hashsize;
#or
Crypt::Digest->hashsize('SHA1');
#or
Crypt::Digest::hashsize('SHA1');
=head2 digest
Returns the binary digest (raw bytes).
$result_raw = $d->digest();
=head2 hexdigest
Returns the digest encoded as a hexadecimal string.
$result_hex = $d->hexdigest();
=head2 b64digest
Returns the digest encoded as a Base64 string, B<with> trailing '=' padding (B<BEWARE:> this padding
style might differ from other Digest::<SOMETHING> modules on CPAN).
$result_b64 = $d->b64digest();
=head2 b64udigest
Returns the digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>
=item * L<Crypt::Digest|Crypt::Digest> tries to be compatible with L<Digest|Digest> interface.
=item * Check subclasses like L<Crypt::Digest::SHA1|Crypt::Digest::SHA1>, L<Crypt::Digest::MD5|Crypt::Digest::MD5>, ...
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2b_160;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_160') }
sub blake2b_160 { Crypt::Digest::digest_data('BLAKE2b_160', @_) }
sub blake2b_160_hex { Crypt::Digest::digest_data_hex('BLAKE2b_160', @_) }
sub blake2b_160_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_160', @_) }
sub blake2b_160_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_160', @_) }
sub blake2b_160_file { Crypt::Digest::digest_file('BLAKE2b_160', @_) }
sub blake2b_160_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_160', @_) }
sub blake2b_160_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_160', @_) }
sub blake2b_160_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_160', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_160 - Hash function BLAKE2b [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_160 qw( blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u
blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u );
# calculate digest from string/buffer
$blake2b_160_raw = blake2b_160('data string');
$blake2b_160_hex = blake2b_160_hex('data string');
$blake2b_160_b64 = blake2b_160_b64('data string');
$blake2b_160_b64u = blake2b_160_b64u('data string');
# calculate digest from file
$blake2b_160_raw = blake2b_160_file('filename.dat');
$blake2b_160_hex = blake2b_160_file_hex('filename.dat');
$blake2b_160_b64 = blake2b_160_file_b64('filename.dat');
$blake2b_160_b64u = blake2b_160_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_160_raw = blake2b_160_file(*FILEHANDLE);
$blake2b_160_hex = blake2b_160_file_hex(*FILEHANDLE);
$blake2b_160_b64 = blake2b_160_file_b64(*FILEHANDLE);
$blake2b_160_b64u = blake2b_160_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_160;
$d = Crypt::Digest::BLAKE2b_160->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_160 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_160 qw(blake2b_160 blake2b_160_hex blake2b_160_b64 blake2b_160_b64u
blake2b_160_file blake2b_160_file_hex blake2b_160_file_b64 blake2b_160_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_160 ':all';
=head1 FUNCTIONS
=head2 blake2b_160
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a binary string.
$blake2b_160_raw = blake2b_160('data string');
#or
$blake2b_160_raw = blake2b_160('any data', 'more data', 'even more data');
=head2 blake2b_160_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a hexadecimal string.
$blake2b_160_hex = blake2b_160_hex('data string');
#or
$blake2b_160_hex = blake2b_160_hex('any data', 'more data', 'even more data');
=head2 blake2b_160_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_160_b64 = blake2b_160_b64('data string');
#or
$blake2b_160_b64 = blake2b_160_b64('any data', 'more data', 'even more data');
=head2 blake2b_160_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_160_b64url = blake2b_160_b64u('data string');
#or
$blake2b_160_b64url = blake2b_160_b64u('any data', 'more data', 'even more data');
=head2 blake2b_160_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a binary string.
$blake2b_160_raw = blake2b_160_file('filename.dat');
#or
$blake2b_160_raw = blake2b_160_file(*FILEHANDLE);
=head2 blake2b_160_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a hexadecimal string.
$blake2b_160_hex = blake2b_160_file_hex('filename.dat');
#or
$blake2b_160_hex = blake2b_160_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_160_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_160_b64 = blake2b_160_file_b64('filename.dat');
#or
$blake2b_160_b64 = blake2b_160_file_b64(*FILEHANDLE);
=head2 blake2b_160_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_160_b64url = blake2b_160_file_b64u('filename.dat');
#or
$blake2b_160_b64url = blake2b_160_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_160->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_160->hashsize();
#or
Crypt::Digest::BLAKE2b_160::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2b_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_256') }
sub blake2b_256 { Crypt::Digest::digest_data('BLAKE2b_256', @_) }
sub blake2b_256_hex { Crypt::Digest::digest_data_hex('BLAKE2b_256', @_) }
sub blake2b_256_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_256', @_) }
sub blake2b_256_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_256', @_) }
sub blake2b_256_file { Crypt::Digest::digest_file('BLAKE2b_256', @_) }
sub blake2b_256_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_256', @_) }
sub blake2b_256_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_256', @_) }
sub blake2b_256_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_256 - Hash function BLAKE2b [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_256 qw( blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u
blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u );
# calculate digest from string/buffer
$blake2b_256_raw = blake2b_256('data string');
$blake2b_256_hex = blake2b_256_hex('data string');
$blake2b_256_b64 = blake2b_256_b64('data string');
$blake2b_256_b64u = blake2b_256_b64u('data string');
# calculate digest from file
$blake2b_256_raw = blake2b_256_file('filename.dat');
$blake2b_256_hex = blake2b_256_file_hex('filename.dat');
$blake2b_256_b64 = blake2b_256_file_b64('filename.dat');
$blake2b_256_b64u = blake2b_256_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_256_raw = blake2b_256_file(*FILEHANDLE);
$blake2b_256_hex = blake2b_256_file_hex(*FILEHANDLE);
$blake2b_256_b64 = blake2b_256_file_b64(*FILEHANDLE);
$blake2b_256_b64u = blake2b_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_256;
$d = Crypt::Digest::BLAKE2b_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_256 qw(blake2b_256 blake2b_256_hex blake2b_256_b64 blake2b_256_b64u
blake2b_256_file blake2b_256_file_hex blake2b_256_file_b64 blake2b_256_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_256 ':all';
=head1 FUNCTIONS
=head2 blake2b_256
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a binary string.
$blake2b_256_raw = blake2b_256('data string');
#or
$blake2b_256_raw = blake2b_256('any data', 'more data', 'even more data');
=head2 blake2b_256_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a hexadecimal string.
$blake2b_256_hex = blake2b_256_hex('data string');
#or
$blake2b_256_hex = blake2b_256_hex('any data', 'more data', 'even more data');
=head2 blake2b_256_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_256_b64 = blake2b_256_b64('data string');
#or
$blake2b_256_b64 = blake2b_256_b64('any data', 'more data', 'even more data');
=head2 blake2b_256_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_256_b64url = blake2b_256_b64u('data string');
#or
$blake2b_256_b64url = blake2b_256_b64u('any data', 'more data', 'even more data');
=head2 blake2b_256_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a binary string.
$blake2b_256_raw = blake2b_256_file('filename.dat');
#or
$blake2b_256_raw = blake2b_256_file(*FILEHANDLE);
=head2 blake2b_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a hexadecimal string.
$blake2b_256_hex = blake2b_256_file_hex('filename.dat');
#or
$blake2b_256_hex = blake2b_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_256_b64 = blake2b_256_file_b64('filename.dat');
#or
$blake2b_256_b64 = blake2b_256_file_b64(*FILEHANDLE);
=head2 blake2b_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_256_b64url = blake2b_256_file_b64u('filename.dat');
#or
$blake2b_256_b64url = blake2b_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_256->hashsize();
#or
Crypt::Digest::BLAKE2b_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2b_384;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_384') }
sub blake2b_384 { Crypt::Digest::digest_data('BLAKE2b_384', @_) }
sub blake2b_384_hex { Crypt::Digest::digest_data_hex('BLAKE2b_384', @_) }
sub blake2b_384_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_384', @_) }
sub blake2b_384_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_384', @_) }
sub blake2b_384_file { Crypt::Digest::digest_file('BLAKE2b_384', @_) }
sub blake2b_384_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_384', @_) }
sub blake2b_384_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_384', @_) }
sub blake2b_384_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_384', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_384 - Hash function BLAKE2b [size: 384 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_384 qw( blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u
blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u );
# calculate digest from string/buffer
$blake2b_384_raw = blake2b_384('data string');
$blake2b_384_hex = blake2b_384_hex('data string');
$blake2b_384_b64 = blake2b_384_b64('data string');
$blake2b_384_b64u = blake2b_384_b64u('data string');
# calculate digest from file
$blake2b_384_raw = blake2b_384_file('filename.dat');
$blake2b_384_hex = blake2b_384_file_hex('filename.dat');
$blake2b_384_b64 = blake2b_384_file_b64('filename.dat');
$blake2b_384_b64u = blake2b_384_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_384_raw = blake2b_384_file(*FILEHANDLE);
$blake2b_384_hex = blake2b_384_file_hex(*FILEHANDLE);
$blake2b_384_b64 = blake2b_384_file_b64(*FILEHANDLE);
$blake2b_384_b64u = blake2b_384_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_384;
$d = Crypt::Digest::BLAKE2b_384->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_384 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_384 qw(blake2b_384 blake2b_384_hex blake2b_384_b64 blake2b_384_b64u
blake2b_384_file blake2b_384_file_hex blake2b_384_file_b64 blake2b_384_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_384 ':all';
=head1 FUNCTIONS
=head2 blake2b_384
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a binary string.
$blake2b_384_raw = blake2b_384('data string');
#or
$blake2b_384_raw = blake2b_384('any data', 'more data', 'even more data');
=head2 blake2b_384_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a hexadecimal string.
$blake2b_384_hex = blake2b_384_hex('data string');
#or
$blake2b_384_hex = blake2b_384_hex('any data', 'more data', 'even more data');
=head2 blake2b_384_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_384_b64 = blake2b_384_b64('data string');
#or
$blake2b_384_b64 = blake2b_384_b64('any data', 'more data', 'even more data');
=head2 blake2b_384_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_384_b64url = blake2b_384_b64u('data string');
#or
$blake2b_384_b64url = blake2b_384_b64u('any data', 'more data', 'even more data');
=head2 blake2b_384_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a binary string.
$blake2b_384_raw = blake2b_384_file('filename.dat');
#or
$blake2b_384_raw = blake2b_384_file(*FILEHANDLE);
=head2 blake2b_384_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a hexadecimal string.
$blake2b_384_hex = blake2b_384_file_hex('filename.dat');
#or
$blake2b_384_hex = blake2b_384_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_384_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_384_b64 = blake2b_384_file_b64('filename.dat');
#or
$blake2b_384_b64 = blake2b_384_file_b64(*FILEHANDLE);
=head2 blake2b_384_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_384_b64url = blake2b_384_file_b64u('filename.dat');
#or
$blake2b_384_b64url = blake2b_384_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_384->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_384->hashsize();
#or
Crypt::Digest::BLAKE2b_384::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2b_512;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2b_512') }
sub blake2b_512 { Crypt::Digest::digest_data('BLAKE2b_512', @_) }
sub blake2b_512_hex { Crypt::Digest::digest_data_hex('BLAKE2b_512', @_) }
sub blake2b_512_b64 { Crypt::Digest::digest_data_b64('BLAKE2b_512', @_) }
sub blake2b_512_b64u { Crypt::Digest::digest_data_b64u('BLAKE2b_512', @_) }
sub blake2b_512_file { Crypt::Digest::digest_file('BLAKE2b_512', @_) }
sub blake2b_512_file_hex { Crypt::Digest::digest_file_hex('BLAKE2b_512', @_) }
sub blake2b_512_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2b_512', @_) }
sub blake2b_512_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2b_512', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2b_512 - Hash function BLAKE2b [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2b_512 qw( blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u
blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u );
# calculate digest from string/buffer
$blake2b_512_raw = blake2b_512('data string');
$blake2b_512_hex = blake2b_512_hex('data string');
$blake2b_512_b64 = blake2b_512_b64('data string');
$blake2b_512_b64u = blake2b_512_b64u('data string');
# calculate digest from file
$blake2b_512_raw = blake2b_512_file('filename.dat');
$blake2b_512_hex = blake2b_512_file_hex('filename.dat');
$blake2b_512_b64 = blake2b_512_file_b64('filename.dat');
$blake2b_512_b64u = blake2b_512_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2b_512_raw = blake2b_512_file(*FILEHANDLE);
$blake2b_512_hex = blake2b_512_file_hex(*FILEHANDLE);
$blake2b_512_b64 = blake2b_512_file_b64(*FILEHANDLE);
$blake2b_512_b64u = blake2b_512_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2b_512;
$d = Crypt::Digest::BLAKE2b_512->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2b_512 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2b_512 qw(blake2b_512 blake2b_512_hex blake2b_512_b64 blake2b_512_b64u
blake2b_512_file blake2b_512_file_hex blake2b_512_file_b64 blake2b_512_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2b_512 ':all';
=head1 FUNCTIONS
=head2 blake2b_512
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a binary string.
$blake2b_512_raw = blake2b_512('data string');
#or
$blake2b_512_raw = blake2b_512('any data', 'more data', 'even more data');
=head2 blake2b_512_hex
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a hexadecimal string.
$blake2b_512_hex = blake2b_512_hex('data string');
#or
$blake2b_512_hex = blake2b_512_hex('any data', 'more data', 'even more data');
=head2 blake2b_512_b64
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_512_b64 = blake2b_512_b64('data string');
#or
$blake2b_512_b64 = blake2b_512_b64('any data', 'more data', 'even more data');
=head2 blake2b_512_b64u
Logically joins all arguments into a single string, and returns its BLAKE2b_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_512_b64url = blake2b_512_b64u('data string');
#or
$blake2b_512_b64url = blake2b_512_b64u('any data', 'more data', 'even more data');
=head2 blake2b_512_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a binary string.
$blake2b_512_raw = blake2b_512_file('filename.dat');
#or
$blake2b_512_raw = blake2b_512_file(*FILEHANDLE);
=head2 blake2b_512_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a hexadecimal string.
$blake2b_512_hex = blake2b_512_file_hex('filename.dat');
#or
$blake2b_512_hex = blake2b_512_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2b_512_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2b_512_b64 = blake2b_512_file_b64('filename.dat');
#or
$blake2b_512_b64 = blake2b_512_file_b64(*FILEHANDLE);
=head2 blake2b_512_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2b_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2b_512_b64url = blake2b_512_file_b64u('filename.dat');
#or
$blake2b_512_b64url = blake2b_512_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2b_512->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2b_512->hashsize();
#or
Crypt::Digest::BLAKE2b_512::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2s_128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_128') }
sub blake2s_128 { Crypt::Digest::digest_data('BLAKE2s_128', @_) }
sub blake2s_128_hex { Crypt::Digest::digest_data_hex('BLAKE2s_128', @_) }
sub blake2s_128_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_128', @_) }
sub blake2s_128_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_128', @_) }
sub blake2s_128_file { Crypt::Digest::digest_file('BLAKE2s_128', @_) }
sub blake2s_128_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_128', @_) }
sub blake2s_128_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_128', @_) }
sub blake2s_128_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_128', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_128 - Hash function BLAKE2s [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_128 qw( blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u
blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u );
# calculate digest from string/buffer
$blake2s_128_raw = blake2s_128('data string');
$blake2s_128_hex = blake2s_128_hex('data string');
$blake2s_128_b64 = blake2s_128_b64('data string');
$blake2s_128_b64u = blake2s_128_b64u('data string');
# calculate digest from file
$blake2s_128_raw = blake2s_128_file('filename.dat');
$blake2s_128_hex = blake2s_128_file_hex('filename.dat');
$blake2s_128_b64 = blake2s_128_file_b64('filename.dat');
$blake2s_128_b64u = blake2s_128_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_128_raw = blake2s_128_file(*FILEHANDLE);
$blake2s_128_hex = blake2s_128_file_hex(*FILEHANDLE);
$blake2s_128_b64 = blake2s_128_file_b64(*FILEHANDLE);
$blake2s_128_b64u = blake2s_128_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_128;
$d = Crypt::Digest::BLAKE2s_128->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_128 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_128 qw(blake2s_128 blake2s_128_hex blake2s_128_b64 blake2s_128_b64u
blake2s_128_file blake2s_128_file_hex blake2s_128_file_b64 blake2s_128_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_128 ':all';
=head1 FUNCTIONS
=head2 blake2s_128
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a binary string.
$blake2s_128_raw = blake2s_128('data string');
#or
$blake2s_128_raw = blake2s_128('any data', 'more data', 'even more data');
=head2 blake2s_128_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a hexadecimal string.
$blake2s_128_hex = blake2s_128_hex('data string');
#or
$blake2s_128_hex = blake2s_128_hex('any data', 'more data', 'even more data');
=head2 blake2s_128_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_128_b64 = blake2s_128_b64('data string');
#or
$blake2s_128_b64 = blake2s_128_b64('any data', 'more data', 'even more data');
=head2 blake2s_128_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_128_b64url = blake2s_128_b64u('data string');
#or
$blake2s_128_b64url = blake2s_128_b64u('any data', 'more data', 'even more data');
=head2 blake2s_128_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a binary string.
$blake2s_128_raw = blake2s_128_file('filename.dat');
#or
$blake2s_128_raw = blake2s_128_file(*FILEHANDLE);
=head2 blake2s_128_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a hexadecimal string.
$blake2s_128_hex = blake2s_128_file_hex('filename.dat');
#or
$blake2s_128_hex = blake2s_128_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_128_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_128_b64 = blake2s_128_file_b64('filename.dat');
#or
$blake2s_128_b64 = blake2s_128_file_b64(*FILEHANDLE);
=head2 blake2s_128_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_128_b64url = blake2s_128_file_b64u('filename.dat');
#or
$blake2s_128_b64url = blake2s_128_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_128->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_128->hashsize();
#or
Crypt::Digest::BLAKE2s_128::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2s_160;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_160') }
sub blake2s_160 { Crypt::Digest::digest_data('BLAKE2s_160', @_) }
sub blake2s_160_hex { Crypt::Digest::digest_data_hex('BLAKE2s_160', @_) }
sub blake2s_160_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_160', @_) }
sub blake2s_160_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_160', @_) }
sub blake2s_160_file { Crypt::Digest::digest_file('BLAKE2s_160', @_) }
sub blake2s_160_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_160', @_) }
sub blake2s_160_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_160', @_) }
sub blake2s_160_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_160', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_160 - Hash function BLAKE2s [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_160 qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u );
# calculate digest from string/buffer
$blake2s_160_raw = blake2s_160('data string');
$blake2s_160_hex = blake2s_160_hex('data string');
$blake2s_160_b64 = blake2s_160_b64('data string');
$blake2s_160_b64u = blake2s_160_b64u('data string');
# calculate digest from file
$blake2s_160_raw = blake2s_160_file('filename.dat');
$blake2s_160_hex = blake2s_160_file_hex('filename.dat');
$blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
$blake2s_160_b64u = blake2s_160_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
$blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
$blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
$blake2s_160_b64u = blake2s_160_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_160;
$d = Crypt::Digest::BLAKE2s_160->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_160 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_160 qw(blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_160 ':all';
=head1 FUNCTIONS
=head2 blake2s_160
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a binary string.
$blake2s_160_raw = blake2s_160('data string');
#or
$blake2s_160_raw = blake2s_160('any data', 'more data', 'even more data');
=head2 blake2s_160_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
$blake2s_160_hex = blake2s_160_hex('data string');
#or
$blake2s_160_hex = blake2s_160_hex('any data', 'more data', 'even more data');
=head2 blake2s_160_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_160_b64 = blake2s_160_b64('data string');
#or
$blake2s_160_b64 = blake2s_160_b64('any data', 'more data', 'even more data');
=head2 blake2s_160_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_160_b64url = blake2s_160_b64u('data string');
#or
$blake2s_160_b64url = blake2s_160_b64u('any data', 'more data', 'even more data');
=head2 blake2s_160_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a binary string.
$blake2s_160_raw = blake2s_160_file('filename.dat');
#or
$blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
=head2 blake2s_160_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a hexadecimal string.
$blake2s_160_hex = blake2s_160_file_hex('filename.dat');
#or
$blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_160_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
#or
$blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
=head2 blake2s_160_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_160_b64url = blake2s_160_file_b64u('filename.dat');
#or
$blake2s_160_b64url = blake2s_160_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_160->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_160->hashsize();
#or
Crypt::Digest::BLAKE2s_160::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2s_224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_224') }
sub blake2s_224 { Crypt::Digest::digest_data('BLAKE2s_224', @_) }
sub blake2s_224_hex { Crypt::Digest::digest_data_hex('BLAKE2s_224', @_) }
sub blake2s_224_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_224', @_) }
sub blake2s_224_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_224', @_) }
sub blake2s_224_file { Crypt::Digest::digest_file('BLAKE2s_224', @_) }
sub blake2s_224_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_224', @_) }
sub blake2s_224_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_224', @_) }
sub blake2s_224_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_224 - Hash function BLAKE2s [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_224 qw( blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u
blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u );
# calculate digest from string/buffer
$blake2s_224_raw = blake2s_224('data string');
$blake2s_224_hex = blake2s_224_hex('data string');
$blake2s_224_b64 = blake2s_224_b64('data string');
$blake2s_224_b64u = blake2s_224_b64u('data string');
# calculate digest from file
$blake2s_224_raw = blake2s_224_file('filename.dat');
$blake2s_224_hex = blake2s_224_file_hex('filename.dat');
$blake2s_224_b64 = blake2s_224_file_b64('filename.dat');
$blake2s_224_b64u = blake2s_224_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_224_raw = blake2s_224_file(*FILEHANDLE);
$blake2s_224_hex = blake2s_224_file_hex(*FILEHANDLE);
$blake2s_224_b64 = blake2s_224_file_b64(*FILEHANDLE);
$blake2s_224_b64u = blake2s_224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_224;
$d = Crypt::Digest::BLAKE2s_224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_224 qw(blake2s_224 blake2s_224_hex blake2s_224_b64 blake2s_224_b64u
blake2s_224_file blake2s_224_file_hex blake2s_224_file_b64 blake2s_224_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_224 ':all';
=head1 FUNCTIONS
=head2 blake2s_224
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a binary string.
$blake2s_224_raw = blake2s_224('data string');
#or
$blake2s_224_raw = blake2s_224('any data', 'more data', 'even more data');
=head2 blake2s_224_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a hexadecimal string.
$blake2s_224_hex = blake2s_224_hex('data string');
#or
$blake2s_224_hex = blake2s_224_hex('any data', 'more data', 'even more data');
=head2 blake2s_224_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_224_b64 = blake2s_224_b64('data string');
#or
$blake2s_224_b64 = blake2s_224_b64('any data', 'more data', 'even more data');
=head2 blake2s_224_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_224_b64url = blake2s_224_b64u('data string');
#or
$blake2s_224_b64url = blake2s_224_b64u('any data', 'more data', 'even more data');
=head2 blake2s_224_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a binary string.
$blake2s_224_raw = blake2s_224_file('filename.dat');
#or
$blake2s_224_raw = blake2s_224_file(*FILEHANDLE);
=head2 blake2s_224_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a hexadecimal string.
$blake2s_224_hex = blake2s_224_file_hex('filename.dat');
#or
$blake2s_224_hex = blake2s_224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_224_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_224_b64 = blake2s_224_file_b64('filename.dat');
#or
$blake2s_224_b64 = blake2s_224_file_b64(*FILEHANDLE);
=head2 blake2s_224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_224_b64url = blake2s_224_file_b64u('filename.dat');
#or
$blake2s_224_b64url = blake2s_224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_224->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_224->hashsize();
#or
Crypt::Digest::BLAKE2s_224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,225 @@
package Crypt::Digest::BLAKE2s_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('BLAKE2s_256') }
sub blake2s_256 { Crypt::Digest::digest_data('BLAKE2s_256', @_) }
sub blake2s_256_hex { Crypt::Digest::digest_data_hex('BLAKE2s_256', @_) }
sub blake2s_256_b64 { Crypt::Digest::digest_data_b64('BLAKE2s_256', @_) }
sub blake2s_256_b64u { Crypt::Digest::digest_data_b64u('BLAKE2s_256', @_) }
sub blake2s_256_file { Crypt::Digest::digest_file('BLAKE2s_256', @_) }
sub blake2s_256_file_hex { Crypt::Digest::digest_file_hex('BLAKE2s_256', @_) }
sub blake2s_256_file_b64 { Crypt::Digest::digest_file_b64('BLAKE2s_256', @_) }
sub blake2s_256_file_b64u { Crypt::Digest::digest_file_b64u('BLAKE2s_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::BLAKE2s_256 - Hash function BLAKE2s [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::BLAKE2s_256 qw( blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u
blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u );
# calculate digest from string/buffer
$blake2s_256_raw = blake2s_256('data string');
$blake2s_256_hex = blake2s_256_hex('data string');
$blake2s_256_b64 = blake2s_256_b64('data string');
$blake2s_256_b64u = blake2s_256_b64u('data string');
# calculate digest from file
$blake2s_256_raw = blake2s_256_file('filename.dat');
$blake2s_256_hex = blake2s_256_file_hex('filename.dat');
$blake2s_256_b64 = blake2s_256_file_b64('filename.dat');
$blake2s_256_b64u = blake2s_256_file_b64u('filename.dat');
# calculate digest from filehandle
$blake2s_256_raw = blake2s_256_file(*FILEHANDLE);
$blake2s_256_hex = blake2s_256_file_hex(*FILEHANDLE);
$blake2s_256_b64 = blake2s_256_file_b64(*FILEHANDLE);
$blake2s_256_b64u = blake2s_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::BLAKE2s_256;
$d = Crypt::Digest::BLAKE2s_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the BLAKE2s_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::BLAKE2s_256 qw(blake2s_256 blake2s_256_hex blake2s_256_b64 blake2s_256_b64u
blake2s_256_file blake2s_256_file_hex blake2s_256_file_b64 blake2s_256_file_b64u);
Or all of them at once:
use Crypt::Digest::BLAKE2s_256 ':all';
=head1 FUNCTIONS
=head2 blake2s_256
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a binary string.
$blake2s_256_raw = blake2s_256('data string');
#or
$blake2s_256_raw = blake2s_256('any data', 'more data', 'even more data');
=head2 blake2s_256_hex
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a hexadecimal string.
$blake2s_256_hex = blake2s_256_hex('data string');
#or
$blake2s_256_hex = blake2s_256_hex('any data', 'more data', 'even more data');
=head2 blake2s_256_b64
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_256_b64 = blake2s_256_b64('data string');
#or
$blake2s_256_b64 = blake2s_256_b64('any data', 'more data', 'even more data');
=head2 blake2s_256_b64u
Logically joins all arguments into a single string, and returns its BLAKE2s_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_256_b64url = blake2s_256_b64u('data string');
#or
$blake2s_256_b64url = blake2s_256_b64u('any data', 'more data', 'even more data');
=head2 blake2s_256_file
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a binary string.
$blake2s_256_raw = blake2s_256_file('filename.dat');
#or
$blake2s_256_raw = blake2s_256_file(*FILEHANDLE);
=head2 blake2s_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a hexadecimal string.
$blake2s_256_hex = blake2s_256_file_hex('filename.dat');
#or
$blake2s_256_hex = blake2s_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 blake2s_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$blake2s_256_b64 = blake2s_256_file_b64('filename.dat');
#or
$blake2s_256_b64 = blake2s_256_file_b64(*FILEHANDLE);
=head2 blake2s_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its BLAKE2s_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$blake2s_256_b64url = blake2s_256_file_b64u('filename.dat');
#or
$blake2s_256_b64url = blake2s_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::BLAKE2s_256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::BLAKE2s_256->hashsize();
#or
Crypt::Digest::BLAKE2s_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://blake2.net/>
=item * L<https://tools.ietf.org/html/rfc7693>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::CHAES;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( chaes chaes_hex chaes_b64 chaes_b64u chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('CHAES') }
sub chaes { Crypt::Digest::digest_data('CHAES', @_) }
sub chaes_hex { Crypt::Digest::digest_data_hex('CHAES', @_) }
sub chaes_b64 { Crypt::Digest::digest_data_b64('CHAES', @_) }
sub chaes_b64u { Crypt::Digest::digest_data_b64u('CHAES', @_) }
sub chaes_file { Crypt::Digest::digest_file('CHAES', @_) }
sub chaes_file_hex { Crypt::Digest::digest_file_hex('CHAES', @_) }
sub chaes_file_b64 { Crypt::Digest::digest_file_b64('CHAES', @_) }
sub chaes_file_b64u { Crypt::Digest::digest_file_b64u('CHAES', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::CHAES - Hash function - CipherHash based on AES [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::CHAES qw( chaes chaes_hex chaes_b64 chaes_b64u
chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u );
# calculate digest from string/buffer
$chaes_raw = chaes('data string');
$chaes_hex = chaes_hex('data string');
$chaes_b64 = chaes_b64('data string');
$chaes_b64u = chaes_b64u('data string');
# calculate digest from file
$chaes_raw = chaes_file('filename.dat');
$chaes_hex = chaes_file_hex('filename.dat');
$chaes_b64 = chaes_file_b64('filename.dat');
$chaes_b64u = chaes_file_b64u('filename.dat');
# calculate digest from filehandle
$chaes_raw = chaes_file(*FILEHANDLE);
$chaes_hex = chaes_file_hex(*FILEHANDLE);
$chaes_b64 = chaes_file_b64(*FILEHANDLE);
$chaes_b64u = chaes_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::CHAES;
$d = Crypt::Digest::CHAES->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the CHAES digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::CHAES qw(chaes chaes_hex chaes_b64 chaes_b64u
chaes_file chaes_file_hex chaes_file_b64 chaes_file_b64u);
Or all of them at once:
use Crypt::Digest::CHAES ':all';
=head1 FUNCTIONS
=head2 chaes
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a binary string.
$chaes_raw = chaes('data string');
#or
$chaes_raw = chaes('any data', 'more data', 'even more data');
=head2 chaes_hex
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a hexadecimal string.
$chaes_hex = chaes_hex('data string');
#or
$chaes_hex = chaes_hex('any data', 'more data', 'even more data');
=head2 chaes_b64
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a Base64 string, B<with> trailing '=' padding.
$chaes_b64 = chaes_b64('data string');
#or
$chaes_b64 = chaes_b64('any data', 'more data', 'even more data');
=head2 chaes_b64u
Logically joins all arguments into a single string, and returns its CHAES digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$chaes_b64url = chaes_b64u('data string');
#or
$chaes_b64url = chaes_b64u('any data', 'more data', 'even more data');
=head2 chaes_file
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a binary string.
$chaes_raw = chaes_file('filename.dat');
#or
$chaes_raw = chaes_file(*FILEHANDLE);
=head2 chaes_file_hex
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a hexadecimal string.
$chaes_hex = chaes_file_hex('filename.dat');
#or
$chaes_hex = chaes_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 chaes_file_b64
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a Base64 string, B<with> trailing '=' padding.
$chaes_b64 = chaes_file_b64('filename.dat');
#or
$chaes_b64 = chaes_file_b64(*FILEHANDLE);
=head2 chaes_file_b64u
Reads file (defined by filename or filehandle) content, and returns its CHAES digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$chaes_b64url = chaes_file_b64u('filename.dat');
#or
$chaes_b64url = chaes_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::CHAES->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::CHAES->hashsize();
#or
Crypt::Digest::CHAES::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/Cryptographic_hash_function#Hash_functions_based_on_block_ciphers>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Keccak224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak224') }
sub keccak224 { Crypt::Digest::digest_data('Keccak224', @_) }
sub keccak224_hex { Crypt::Digest::digest_data_hex('Keccak224', @_) }
sub keccak224_b64 { Crypt::Digest::digest_data_b64('Keccak224', @_) }
sub keccak224_b64u { Crypt::Digest::digest_data_b64u('Keccak224', @_) }
sub keccak224_file { Crypt::Digest::digest_file('Keccak224', @_) }
sub keccak224_file_hex { Crypt::Digest::digest_file_hex('Keccak224', @_) }
sub keccak224_file_b64 { Crypt::Digest::digest_file_b64('Keccak224', @_) }
sub keccak224_file_b64u { Crypt::Digest::digest_file_b64u('Keccak224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak224 - Hash function Keccak-224 [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak224 qw( keccak224 keccak224_hex keccak224_b64 keccak224_b64u
keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u );
# calculate digest from string/buffer
$keccak224_raw = keccak224('data string');
$keccak224_hex = keccak224_hex('data string');
$keccak224_b64 = keccak224_b64('data string');
$keccak224_b64u = keccak224_b64u('data string');
# calculate digest from file
$keccak224_raw = keccak224_file('filename.dat');
$keccak224_hex = keccak224_file_hex('filename.dat');
$keccak224_b64 = keccak224_file_b64('filename.dat');
$keccak224_b64u = keccak224_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak224_raw = keccak224_file(*FILEHANDLE);
$keccak224_hex = keccak224_file_hex(*FILEHANDLE);
$keccak224_b64 = keccak224_file_b64(*FILEHANDLE);
$keccak224_b64u = keccak224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak224;
$d = Crypt::Digest::Keccak224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak224 qw(keccak224 keccak224_hex keccak224_b64 keccak224_b64u
keccak224_file keccak224_file_hex keccak224_file_b64 keccak224_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak224 ':all';
=head1 FUNCTIONS
=head2 keccak224
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a binary string.
$keccak224_raw = keccak224('data string');
#or
$keccak224_raw = keccak224('any data', 'more data', 'even more data');
=head2 keccak224_hex
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a hexadecimal string.
$keccak224_hex = keccak224_hex('data string');
#or
$keccak224_hex = keccak224_hex('any data', 'more data', 'even more data');
=head2 keccak224_b64
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak224_b64 = keccak224_b64('data string');
#or
$keccak224_b64 = keccak224_b64('any data', 'more data', 'even more data');
=head2 keccak224_b64u
Logically joins all arguments into a single string, and returns its Keccak224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak224_b64url = keccak224_b64u('data string');
#or
$keccak224_b64url = keccak224_b64u('any data', 'more data', 'even more data');
=head2 keccak224_file
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a binary string.
$keccak224_raw = keccak224_file('filename.dat');
#or
$keccak224_raw = keccak224_file(*FILEHANDLE);
=head2 keccak224_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a hexadecimal string.
$keccak224_hex = keccak224_file_hex('filename.dat');
#or
$keccak224_hex = keccak224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak224_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak224_b64 = keccak224_file_b64('filename.dat');
#or
$keccak224_b64 = keccak224_file_b64(*FILEHANDLE);
=head2 keccak224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak224_b64url = keccak224_file_b64u('filename.dat');
#or
$keccak224_b64url = keccak224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak224->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak224->hashsize();
#or
Crypt::Digest::Keccak224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Keccak256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak256') }
sub keccak256 { Crypt::Digest::digest_data('Keccak256', @_) }
sub keccak256_hex { Crypt::Digest::digest_data_hex('Keccak256', @_) }
sub keccak256_b64 { Crypt::Digest::digest_data_b64('Keccak256', @_) }
sub keccak256_b64u { Crypt::Digest::digest_data_b64u('Keccak256', @_) }
sub keccak256_file { Crypt::Digest::digest_file('Keccak256', @_) }
sub keccak256_file_hex { Crypt::Digest::digest_file_hex('Keccak256', @_) }
sub keccak256_file_b64 { Crypt::Digest::digest_file_b64('Keccak256', @_) }
sub keccak256_file_b64u { Crypt::Digest::digest_file_b64u('Keccak256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak256 - Hash function Keccak-256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak256 qw( keccak256 keccak256_hex keccak256_b64 keccak256_b64u
keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u );
# calculate digest from string/buffer
$keccak256_raw = keccak256('data string');
$keccak256_hex = keccak256_hex('data string');
$keccak256_b64 = keccak256_b64('data string');
$keccak256_b64u = keccak256_b64u('data string');
# calculate digest from file
$keccak256_raw = keccak256_file('filename.dat');
$keccak256_hex = keccak256_file_hex('filename.dat');
$keccak256_b64 = keccak256_file_b64('filename.dat');
$keccak256_b64u = keccak256_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak256_raw = keccak256_file(*FILEHANDLE);
$keccak256_hex = keccak256_file_hex(*FILEHANDLE);
$keccak256_b64 = keccak256_file_b64(*FILEHANDLE);
$keccak256_b64u = keccak256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak256;
$d = Crypt::Digest::Keccak256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak256 qw(keccak256 keccak256_hex keccak256_b64 keccak256_b64u
keccak256_file keccak256_file_hex keccak256_file_b64 keccak256_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak256 ':all';
=head1 FUNCTIONS
=head2 keccak256
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a binary string.
$keccak256_raw = keccak256('data string');
#or
$keccak256_raw = keccak256('any data', 'more data', 'even more data');
=head2 keccak256_hex
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a hexadecimal string.
$keccak256_hex = keccak256_hex('data string');
#or
$keccak256_hex = keccak256_hex('any data', 'more data', 'even more data');
=head2 keccak256_b64
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak256_b64 = keccak256_b64('data string');
#or
$keccak256_b64 = keccak256_b64('any data', 'more data', 'even more data');
=head2 keccak256_b64u
Logically joins all arguments into a single string, and returns its Keccak256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak256_b64url = keccak256_b64u('data string');
#or
$keccak256_b64url = keccak256_b64u('any data', 'more data', 'even more data');
=head2 keccak256_file
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a binary string.
$keccak256_raw = keccak256_file('filename.dat');
#or
$keccak256_raw = keccak256_file(*FILEHANDLE);
=head2 keccak256_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a hexadecimal string.
$keccak256_hex = keccak256_file_hex('filename.dat');
#or
$keccak256_hex = keccak256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak256_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak256_b64 = keccak256_file_b64('filename.dat');
#or
$keccak256_b64 = keccak256_file_b64(*FILEHANDLE);
=head2 keccak256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak256_b64url = keccak256_file_b64u('filename.dat');
#or
$keccak256_b64url = keccak256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak256->hashsize();
#or
Crypt::Digest::Keccak256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Keccak384;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak384') }
sub keccak384 { Crypt::Digest::digest_data('Keccak384', @_) }
sub keccak384_hex { Crypt::Digest::digest_data_hex('Keccak384', @_) }
sub keccak384_b64 { Crypt::Digest::digest_data_b64('Keccak384', @_) }
sub keccak384_b64u { Crypt::Digest::digest_data_b64u('Keccak384', @_) }
sub keccak384_file { Crypt::Digest::digest_file('Keccak384', @_) }
sub keccak384_file_hex { Crypt::Digest::digest_file_hex('Keccak384', @_) }
sub keccak384_file_b64 { Crypt::Digest::digest_file_b64('Keccak384', @_) }
sub keccak384_file_b64u { Crypt::Digest::digest_file_b64u('Keccak384', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak384 - Hash function Keccak-384 [size: 384 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak384 qw( keccak384 keccak384_hex keccak384_b64 keccak384_b64u
keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u );
# calculate digest from string/buffer
$keccak384_raw = keccak384('data string');
$keccak384_hex = keccak384_hex('data string');
$keccak384_b64 = keccak384_b64('data string');
$keccak384_b64u = keccak384_b64u('data string');
# calculate digest from file
$keccak384_raw = keccak384_file('filename.dat');
$keccak384_hex = keccak384_file_hex('filename.dat');
$keccak384_b64 = keccak384_file_b64('filename.dat');
$keccak384_b64u = keccak384_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak384_raw = keccak384_file(*FILEHANDLE);
$keccak384_hex = keccak384_file_hex(*FILEHANDLE);
$keccak384_b64 = keccak384_file_b64(*FILEHANDLE);
$keccak384_b64u = keccak384_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak384;
$d = Crypt::Digest::Keccak384->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak384 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak384 qw(keccak384 keccak384_hex keccak384_b64 keccak384_b64u
keccak384_file keccak384_file_hex keccak384_file_b64 keccak384_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak384 ':all';
=head1 FUNCTIONS
=head2 keccak384
Logically joins all arguments into a single string, and returns its Keccak384 digest encoded as a binary string.
$keccak384_raw = keccak384('data string');
#or
$keccak384_raw = keccak384('any data', 'more data', 'even more data');
=head2 keccak384_hex
Logically joins all arguments into a single string, and returns its Keccak384 digest encoded as a hexadecimal string.
$keccak384_hex = keccak384_hex('data string');
#or
$keccak384_hex = keccak384_hex('any data', 'more data', 'even more data');
=head2 keccak384_b64
Logically joins all arguments into a single string, and returns its Keccak384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak384_b64 = keccak384_b64('data string');
#or
$keccak384_b64 = keccak384_b64('any data', 'more data', 'even more data');
=head2 keccak384_b64u
Logically joins all arguments into a single string, and returns its Keccak384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak384_b64url = keccak384_b64u('data string');
#or
$keccak384_b64url = keccak384_b64u('any data', 'more data', 'even more data');
=head2 keccak384_file
Reads file (defined by filename or filehandle) content, and returns its Keccak384 digest encoded as a binary string.
$keccak384_raw = keccak384_file('filename.dat');
#or
$keccak384_raw = keccak384_file(*FILEHANDLE);
=head2 keccak384_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak384 digest encoded as a hexadecimal string.
$keccak384_hex = keccak384_file_hex('filename.dat');
#or
$keccak384_hex = keccak384_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak384_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak384_b64 = keccak384_file_b64('filename.dat');
#or
$keccak384_b64 = keccak384_file_b64(*FILEHANDLE);
=head2 keccak384_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak384_b64url = keccak384_file_b64u('filename.dat');
#or
$keccak384_b64url = keccak384_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak384->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak384->hashsize();
#or
Crypt::Digest::Keccak384::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Keccak512;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Keccak512') }
sub keccak512 { Crypt::Digest::digest_data('Keccak512', @_) }
sub keccak512_hex { Crypt::Digest::digest_data_hex('Keccak512', @_) }
sub keccak512_b64 { Crypt::Digest::digest_data_b64('Keccak512', @_) }
sub keccak512_b64u { Crypt::Digest::digest_data_b64u('Keccak512', @_) }
sub keccak512_file { Crypt::Digest::digest_file('Keccak512', @_) }
sub keccak512_file_hex { Crypt::Digest::digest_file_hex('Keccak512', @_) }
sub keccak512_file_b64 { Crypt::Digest::digest_file_b64('Keccak512', @_) }
sub keccak512_file_b64u { Crypt::Digest::digest_file_b64u('Keccak512', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Keccak512 - Hash function Keccak-512 [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Keccak512 qw( keccak512 keccak512_hex keccak512_b64 keccak512_b64u
keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u );
# calculate digest from string/buffer
$keccak512_raw = keccak512('data string');
$keccak512_hex = keccak512_hex('data string');
$keccak512_b64 = keccak512_b64('data string');
$keccak512_b64u = keccak512_b64u('data string');
# calculate digest from file
$keccak512_raw = keccak512_file('filename.dat');
$keccak512_hex = keccak512_file_hex('filename.dat');
$keccak512_b64 = keccak512_file_b64('filename.dat');
$keccak512_b64u = keccak512_file_b64u('filename.dat');
# calculate digest from filehandle
$keccak512_raw = keccak512_file(*FILEHANDLE);
$keccak512_hex = keccak512_file_hex(*FILEHANDLE);
$keccak512_b64 = keccak512_file_b64(*FILEHANDLE);
$keccak512_b64u = keccak512_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Keccak512;
$d = Crypt::Digest::Keccak512->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Keccak512 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Keccak512 qw(keccak512 keccak512_hex keccak512_b64 keccak512_b64u
keccak512_file keccak512_file_hex keccak512_file_b64 keccak512_file_b64u);
Or all of them at once:
use Crypt::Digest::Keccak512 ':all';
=head1 FUNCTIONS
=head2 keccak512
Logically joins all arguments into a single string, and returns its Keccak512 digest encoded as a binary string.
$keccak512_raw = keccak512('data string');
#or
$keccak512_raw = keccak512('any data', 'more data', 'even more data');
=head2 keccak512_hex
Logically joins all arguments into a single string, and returns its Keccak512 digest encoded as a hexadecimal string.
$keccak512_hex = keccak512_hex('data string');
#or
$keccak512_hex = keccak512_hex('any data', 'more data', 'even more data');
=head2 keccak512_b64
Logically joins all arguments into a single string, and returns its Keccak512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak512_b64 = keccak512_b64('data string');
#or
$keccak512_b64 = keccak512_b64('any data', 'more data', 'even more data');
=head2 keccak512_b64u
Logically joins all arguments into a single string, and returns its Keccak512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak512_b64url = keccak512_b64u('data string');
#or
$keccak512_b64url = keccak512_b64u('any data', 'more data', 'even more data');
=head2 keccak512_file
Reads file (defined by filename or filehandle) content, and returns its Keccak512 digest encoded as a binary string.
$keccak512_raw = keccak512_file('filename.dat');
#or
$keccak512_raw = keccak512_file(*FILEHANDLE);
=head2 keccak512_file_hex
Reads file (defined by filename or filehandle) content, and returns its Keccak512 digest encoded as a hexadecimal string.
$keccak512_hex = keccak512_file_hex('filename.dat');
#or
$keccak512_hex = keccak512_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 keccak512_file_b64
Reads file (defined by filename or filehandle) content, and returns its Keccak512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$keccak512_b64 = keccak512_file_b64('filename.dat');
#or
$keccak512_b64 = keccak512_file_b64(*FILEHANDLE);
=head2 keccak512_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Keccak512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$keccak512_b64url = keccak512_file_b64u('filename.dat');
#or
$keccak512_b64url = keccak512_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Keccak512->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Keccak512->hashsize();
#or
Crypt::Digest::Keccak512::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://keccak.team/index.html>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::MD2;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( md2 md2_hex md2_b64 md2_b64u md2_file md2_file_hex md2_file_b64 md2_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('MD2') }
sub md2 { Crypt::Digest::digest_data('MD2', @_) }
sub md2_hex { Crypt::Digest::digest_data_hex('MD2', @_) }
sub md2_b64 { Crypt::Digest::digest_data_b64('MD2', @_) }
sub md2_b64u { Crypt::Digest::digest_data_b64u('MD2', @_) }
sub md2_file { Crypt::Digest::digest_file('MD2', @_) }
sub md2_file_hex { Crypt::Digest::digest_file_hex('MD2', @_) }
sub md2_file_b64 { Crypt::Digest::digest_file_b64('MD2', @_) }
sub md2_file_b64u { Crypt::Digest::digest_file_b64u('MD2', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::MD2 - Hash function MD2 [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::MD2 qw( md2 md2_hex md2_b64 md2_b64u
md2_file md2_file_hex md2_file_b64 md2_file_b64u );
# calculate digest from string/buffer
$md2_raw = md2('data string');
$md2_hex = md2_hex('data string');
$md2_b64 = md2_b64('data string');
$md2_b64u = md2_b64u('data string');
# calculate digest from file
$md2_raw = md2_file('filename.dat');
$md2_hex = md2_file_hex('filename.dat');
$md2_b64 = md2_file_b64('filename.dat');
$md2_b64u = md2_file_b64u('filename.dat');
# calculate digest from filehandle
$md2_raw = md2_file(*FILEHANDLE);
$md2_hex = md2_file_hex(*FILEHANDLE);
$md2_b64 = md2_file_b64(*FILEHANDLE);
$md2_b64u = md2_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::MD2;
$d = Crypt::Digest::MD2->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the MD2 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::MD2 qw(md2 md2_hex md2_b64 md2_b64u
md2_file md2_file_hex md2_file_b64 md2_file_b64u);
Or all of them at once:
use Crypt::Digest::MD2 ':all';
=head1 FUNCTIONS
=head2 md2
Logically joins all arguments into a single string, and returns its MD2 digest encoded as a binary string.
$md2_raw = md2('data string');
#or
$md2_raw = md2('any data', 'more data', 'even more data');
=head2 md2_hex
Logically joins all arguments into a single string, and returns its MD2 digest encoded as a hexadecimal string.
$md2_hex = md2_hex('data string');
#or
$md2_hex = md2_hex('any data', 'more data', 'even more data');
=head2 md2_b64
Logically joins all arguments into a single string, and returns its MD2 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md2_b64 = md2_b64('data string');
#or
$md2_b64 = md2_b64('any data', 'more data', 'even more data');
=head2 md2_b64u
Logically joins all arguments into a single string, and returns its MD2 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md2_b64url = md2_b64u('data string');
#or
$md2_b64url = md2_b64u('any data', 'more data', 'even more data');
=head2 md2_file
Reads file (defined by filename or filehandle) content, and returns its MD2 digest encoded as a binary string.
$md2_raw = md2_file('filename.dat');
#or
$md2_raw = md2_file(*FILEHANDLE);
=head2 md2_file_hex
Reads file (defined by filename or filehandle) content, and returns its MD2 digest encoded as a hexadecimal string.
$md2_hex = md2_file_hex('filename.dat');
#or
$md2_hex = md2_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 md2_file_b64
Reads file (defined by filename or filehandle) content, and returns its MD2 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md2_b64 = md2_file_b64('filename.dat');
#or
$md2_b64 = md2_file_b64(*FILEHANDLE);
=head2 md2_file_b64u
Reads file (defined by filename or filehandle) content, and returns its MD2 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md2_b64url = md2_file_b64u('filename.dat');
#or
$md2_b64url = md2_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::MD2->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::MD2->hashsize();
#or
Crypt::Digest::MD2::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/MD2_(cryptography)>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::MD4;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( md4 md4_hex md4_b64 md4_b64u md4_file md4_file_hex md4_file_b64 md4_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('MD4') }
sub md4 { Crypt::Digest::digest_data('MD4', @_) }
sub md4_hex { Crypt::Digest::digest_data_hex('MD4', @_) }
sub md4_b64 { Crypt::Digest::digest_data_b64('MD4', @_) }
sub md4_b64u { Crypt::Digest::digest_data_b64u('MD4', @_) }
sub md4_file { Crypt::Digest::digest_file('MD4', @_) }
sub md4_file_hex { Crypt::Digest::digest_file_hex('MD4', @_) }
sub md4_file_b64 { Crypt::Digest::digest_file_b64('MD4', @_) }
sub md4_file_b64u { Crypt::Digest::digest_file_b64u('MD4', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::MD4 - Hash function MD4 [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::MD4 qw( md4 md4_hex md4_b64 md4_b64u
md4_file md4_file_hex md4_file_b64 md4_file_b64u );
# calculate digest from string/buffer
$md4_raw = md4('data string');
$md4_hex = md4_hex('data string');
$md4_b64 = md4_b64('data string');
$md4_b64u = md4_b64u('data string');
# calculate digest from file
$md4_raw = md4_file('filename.dat');
$md4_hex = md4_file_hex('filename.dat');
$md4_b64 = md4_file_b64('filename.dat');
$md4_b64u = md4_file_b64u('filename.dat');
# calculate digest from filehandle
$md4_raw = md4_file(*FILEHANDLE);
$md4_hex = md4_file_hex(*FILEHANDLE);
$md4_b64 = md4_file_b64(*FILEHANDLE);
$md4_b64u = md4_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::MD4;
$d = Crypt::Digest::MD4->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the MD4 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::MD4 qw(md4 md4_hex md4_b64 md4_b64u
md4_file md4_file_hex md4_file_b64 md4_file_b64u);
Or all of them at once:
use Crypt::Digest::MD4 ':all';
=head1 FUNCTIONS
=head2 md4
Logically joins all arguments into a single string, and returns its MD4 digest encoded as a binary string.
$md4_raw = md4('data string');
#or
$md4_raw = md4('any data', 'more data', 'even more data');
=head2 md4_hex
Logically joins all arguments into a single string, and returns its MD4 digest encoded as a hexadecimal string.
$md4_hex = md4_hex('data string');
#or
$md4_hex = md4_hex('any data', 'more data', 'even more data');
=head2 md4_b64
Logically joins all arguments into a single string, and returns its MD4 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md4_b64 = md4_b64('data string');
#or
$md4_b64 = md4_b64('any data', 'more data', 'even more data');
=head2 md4_b64u
Logically joins all arguments into a single string, and returns its MD4 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md4_b64url = md4_b64u('data string');
#or
$md4_b64url = md4_b64u('any data', 'more data', 'even more data');
=head2 md4_file
Reads file (defined by filename or filehandle) content, and returns its MD4 digest encoded as a binary string.
$md4_raw = md4_file('filename.dat');
#or
$md4_raw = md4_file(*FILEHANDLE);
=head2 md4_file_hex
Reads file (defined by filename or filehandle) content, and returns its MD4 digest encoded as a hexadecimal string.
$md4_hex = md4_file_hex('filename.dat');
#or
$md4_hex = md4_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 md4_file_b64
Reads file (defined by filename or filehandle) content, and returns its MD4 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md4_b64 = md4_file_b64('filename.dat');
#or
$md4_b64 = md4_file_b64(*FILEHANDLE);
=head2 md4_file_b64u
Reads file (defined by filename or filehandle) content, and returns its MD4 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md4_b64url = md4_file_b64u('filename.dat');
#or
$md4_b64url = md4_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::MD4->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::MD4->hashsize();
#or
Crypt::Digest::MD4::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/MD4>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::MD5;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( md5 md5_hex md5_b64 md5_b64u md5_file md5_file_hex md5_file_b64 md5_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('MD5') }
sub md5 { Crypt::Digest::digest_data('MD5', @_) }
sub md5_hex { Crypt::Digest::digest_data_hex('MD5', @_) }
sub md5_b64 { Crypt::Digest::digest_data_b64('MD5', @_) }
sub md5_b64u { Crypt::Digest::digest_data_b64u('MD5', @_) }
sub md5_file { Crypt::Digest::digest_file('MD5', @_) }
sub md5_file_hex { Crypt::Digest::digest_file_hex('MD5', @_) }
sub md5_file_b64 { Crypt::Digest::digest_file_b64('MD5', @_) }
sub md5_file_b64u { Crypt::Digest::digest_file_b64u('MD5', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::MD5 - Hash function MD5 [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::MD5 qw( md5 md5_hex md5_b64 md5_b64u
md5_file md5_file_hex md5_file_b64 md5_file_b64u );
# calculate digest from string/buffer
$md5_raw = md5('data string');
$md5_hex = md5_hex('data string');
$md5_b64 = md5_b64('data string');
$md5_b64u = md5_b64u('data string');
# calculate digest from file
$md5_raw = md5_file('filename.dat');
$md5_hex = md5_file_hex('filename.dat');
$md5_b64 = md5_file_b64('filename.dat');
$md5_b64u = md5_file_b64u('filename.dat');
# calculate digest from filehandle
$md5_raw = md5_file(*FILEHANDLE);
$md5_hex = md5_file_hex(*FILEHANDLE);
$md5_b64 = md5_file_b64(*FILEHANDLE);
$md5_b64u = md5_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::MD5;
$d = Crypt::Digest::MD5->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the MD5 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::MD5 qw(md5 md5_hex md5_b64 md5_b64u
md5_file md5_file_hex md5_file_b64 md5_file_b64u);
Or all of them at once:
use Crypt::Digest::MD5 ':all';
=head1 FUNCTIONS
=head2 md5
Logically joins all arguments into a single string, and returns its MD5 digest encoded as a binary string.
$md5_raw = md5('data string');
#or
$md5_raw = md5('any data', 'more data', 'even more data');
=head2 md5_hex
Logically joins all arguments into a single string, and returns its MD5 digest encoded as a hexadecimal string.
$md5_hex = md5_hex('data string');
#or
$md5_hex = md5_hex('any data', 'more data', 'even more data');
=head2 md5_b64
Logically joins all arguments into a single string, and returns its MD5 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md5_b64 = md5_b64('data string');
#or
$md5_b64 = md5_b64('any data', 'more data', 'even more data');
=head2 md5_b64u
Logically joins all arguments into a single string, and returns its MD5 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md5_b64url = md5_b64u('data string');
#or
$md5_b64url = md5_b64u('any data', 'more data', 'even more data');
=head2 md5_file
Reads file (defined by filename or filehandle) content, and returns its MD5 digest encoded as a binary string.
$md5_raw = md5_file('filename.dat');
#or
$md5_raw = md5_file(*FILEHANDLE);
=head2 md5_file_hex
Reads file (defined by filename or filehandle) content, and returns its MD5 digest encoded as a hexadecimal string.
$md5_hex = md5_file_hex('filename.dat');
#or
$md5_hex = md5_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 md5_file_b64
Reads file (defined by filename or filehandle) content, and returns its MD5 digest encoded as a Base64 string, B<with> trailing '=' padding.
$md5_b64 = md5_file_b64('filename.dat');
#or
$md5_b64 = md5_file_b64(*FILEHANDLE);
=head2 md5_file_b64u
Reads file (defined by filename or filehandle) content, and returns its MD5 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$md5_b64url = md5_file_b64u('filename.dat');
#or
$md5_b64url = md5_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::MD5->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::MD5->hashsize();
#or
Crypt::Digest::MD5::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/MD5>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::RIPEMD128;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('RIPEMD128') }
sub ripemd128 { Crypt::Digest::digest_data('RIPEMD128', @_) }
sub ripemd128_hex { Crypt::Digest::digest_data_hex('RIPEMD128', @_) }
sub ripemd128_b64 { Crypt::Digest::digest_data_b64('RIPEMD128', @_) }
sub ripemd128_b64u { Crypt::Digest::digest_data_b64u('RIPEMD128', @_) }
sub ripemd128_file { Crypt::Digest::digest_file('RIPEMD128', @_) }
sub ripemd128_file_hex { Crypt::Digest::digest_file_hex('RIPEMD128', @_) }
sub ripemd128_file_b64 { Crypt::Digest::digest_file_b64('RIPEMD128', @_) }
sub ripemd128_file_b64u { Crypt::Digest::digest_file_b64u('RIPEMD128', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::RIPEMD128 - Hash function RIPEMD-128 [size: 128 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::RIPEMD128 qw( ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u
ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u );
# calculate digest from string/buffer
$ripemd128_raw = ripemd128('data string');
$ripemd128_hex = ripemd128_hex('data string');
$ripemd128_b64 = ripemd128_b64('data string');
$ripemd128_b64u = ripemd128_b64u('data string');
# calculate digest from file
$ripemd128_raw = ripemd128_file('filename.dat');
$ripemd128_hex = ripemd128_file_hex('filename.dat');
$ripemd128_b64 = ripemd128_file_b64('filename.dat');
$ripemd128_b64u = ripemd128_file_b64u('filename.dat');
# calculate digest from filehandle
$ripemd128_raw = ripemd128_file(*FILEHANDLE);
$ripemd128_hex = ripemd128_file_hex(*FILEHANDLE);
$ripemd128_b64 = ripemd128_file_b64(*FILEHANDLE);
$ripemd128_b64u = ripemd128_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::RIPEMD128;
$d = Crypt::Digest::RIPEMD128->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the RIPEMD128 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::RIPEMD128 qw(ripemd128 ripemd128_hex ripemd128_b64 ripemd128_b64u
ripemd128_file ripemd128_file_hex ripemd128_file_b64 ripemd128_file_b64u);
Or all of them at once:
use Crypt::Digest::RIPEMD128 ':all';
=head1 FUNCTIONS
=head2 ripemd128
Logically joins all arguments into a single string, and returns its RIPEMD128 digest encoded as a binary string.
$ripemd128_raw = ripemd128('data string');
#or
$ripemd128_raw = ripemd128('any data', 'more data', 'even more data');
=head2 ripemd128_hex
Logically joins all arguments into a single string, and returns its RIPEMD128 digest encoded as a hexadecimal string.
$ripemd128_hex = ripemd128_hex('data string');
#or
$ripemd128_hex = ripemd128_hex('any data', 'more data', 'even more data');
=head2 ripemd128_b64
Logically joins all arguments into a single string, and returns its RIPEMD128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd128_b64 = ripemd128_b64('data string');
#or
$ripemd128_b64 = ripemd128_b64('any data', 'more data', 'even more data');
=head2 ripemd128_b64u
Logically joins all arguments into a single string, and returns its RIPEMD128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd128_b64url = ripemd128_b64u('data string');
#or
$ripemd128_b64url = ripemd128_b64u('any data', 'more data', 'even more data');
=head2 ripemd128_file
Reads file (defined by filename or filehandle) content, and returns its RIPEMD128 digest encoded as a binary string.
$ripemd128_raw = ripemd128_file('filename.dat');
#or
$ripemd128_raw = ripemd128_file(*FILEHANDLE);
=head2 ripemd128_file_hex
Reads file (defined by filename or filehandle) content, and returns its RIPEMD128 digest encoded as a hexadecimal string.
$ripemd128_hex = ripemd128_file_hex('filename.dat');
#or
$ripemd128_hex = ripemd128_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 ripemd128_file_b64
Reads file (defined by filename or filehandle) content, and returns its RIPEMD128 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd128_b64 = ripemd128_file_b64('filename.dat');
#or
$ripemd128_b64 = ripemd128_file_b64(*FILEHANDLE);
=head2 ripemd128_file_b64u
Reads file (defined by filename or filehandle) content, and returns its RIPEMD128 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd128_b64url = ripemd128_file_b64u('filename.dat');
#or
$ripemd128_b64url = ripemd128_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::RIPEMD128->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::RIPEMD128->hashsize();
#or
Crypt::Digest::RIPEMD128::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/RIPEMD>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::RIPEMD160;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('RIPEMD160') }
sub ripemd160 { Crypt::Digest::digest_data('RIPEMD160', @_) }
sub ripemd160_hex { Crypt::Digest::digest_data_hex('RIPEMD160', @_) }
sub ripemd160_b64 { Crypt::Digest::digest_data_b64('RIPEMD160', @_) }
sub ripemd160_b64u { Crypt::Digest::digest_data_b64u('RIPEMD160', @_) }
sub ripemd160_file { Crypt::Digest::digest_file('RIPEMD160', @_) }
sub ripemd160_file_hex { Crypt::Digest::digest_file_hex('RIPEMD160', @_) }
sub ripemd160_file_b64 { Crypt::Digest::digest_file_b64('RIPEMD160', @_) }
sub ripemd160_file_b64u { Crypt::Digest::digest_file_b64u('RIPEMD160', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::RIPEMD160 - Hash function RIPEMD-160 [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::RIPEMD160 qw( ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u
ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u );
# calculate digest from string/buffer
$ripemd160_raw = ripemd160('data string');
$ripemd160_hex = ripemd160_hex('data string');
$ripemd160_b64 = ripemd160_b64('data string');
$ripemd160_b64u = ripemd160_b64u('data string');
# calculate digest from file
$ripemd160_raw = ripemd160_file('filename.dat');
$ripemd160_hex = ripemd160_file_hex('filename.dat');
$ripemd160_b64 = ripemd160_file_b64('filename.dat');
$ripemd160_b64u = ripemd160_file_b64u('filename.dat');
# calculate digest from filehandle
$ripemd160_raw = ripemd160_file(*FILEHANDLE);
$ripemd160_hex = ripemd160_file_hex(*FILEHANDLE);
$ripemd160_b64 = ripemd160_file_b64(*FILEHANDLE);
$ripemd160_b64u = ripemd160_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::RIPEMD160;
$d = Crypt::Digest::RIPEMD160->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the RIPEMD160 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::RIPEMD160 qw(ripemd160 ripemd160_hex ripemd160_b64 ripemd160_b64u
ripemd160_file ripemd160_file_hex ripemd160_file_b64 ripemd160_file_b64u);
Or all of them at once:
use Crypt::Digest::RIPEMD160 ':all';
=head1 FUNCTIONS
=head2 ripemd160
Logically joins all arguments into a single string, and returns its RIPEMD160 digest encoded as a binary string.
$ripemd160_raw = ripemd160('data string');
#or
$ripemd160_raw = ripemd160('any data', 'more data', 'even more data');
=head2 ripemd160_hex
Logically joins all arguments into a single string, and returns its RIPEMD160 digest encoded as a hexadecimal string.
$ripemd160_hex = ripemd160_hex('data string');
#or
$ripemd160_hex = ripemd160_hex('any data', 'more data', 'even more data');
=head2 ripemd160_b64
Logically joins all arguments into a single string, and returns its RIPEMD160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd160_b64 = ripemd160_b64('data string');
#or
$ripemd160_b64 = ripemd160_b64('any data', 'more data', 'even more data');
=head2 ripemd160_b64u
Logically joins all arguments into a single string, and returns its RIPEMD160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd160_b64url = ripemd160_b64u('data string');
#or
$ripemd160_b64url = ripemd160_b64u('any data', 'more data', 'even more data');
=head2 ripemd160_file
Reads file (defined by filename or filehandle) content, and returns its RIPEMD160 digest encoded as a binary string.
$ripemd160_raw = ripemd160_file('filename.dat');
#or
$ripemd160_raw = ripemd160_file(*FILEHANDLE);
=head2 ripemd160_file_hex
Reads file (defined by filename or filehandle) content, and returns its RIPEMD160 digest encoded as a hexadecimal string.
$ripemd160_hex = ripemd160_file_hex('filename.dat');
#or
$ripemd160_hex = ripemd160_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 ripemd160_file_b64
Reads file (defined by filename or filehandle) content, and returns its RIPEMD160 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd160_b64 = ripemd160_file_b64('filename.dat');
#or
$ripemd160_b64 = ripemd160_file_b64(*FILEHANDLE);
=head2 ripemd160_file_b64u
Reads file (defined by filename or filehandle) content, and returns its RIPEMD160 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd160_b64url = ripemd160_file_b64u('filename.dat');
#or
$ripemd160_b64url = ripemd160_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::RIPEMD160->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::RIPEMD160->hashsize();
#or
Crypt::Digest::RIPEMD160::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/RIPEMD>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::RIPEMD256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('RIPEMD256') }
sub ripemd256 { Crypt::Digest::digest_data('RIPEMD256', @_) }
sub ripemd256_hex { Crypt::Digest::digest_data_hex('RIPEMD256', @_) }
sub ripemd256_b64 { Crypt::Digest::digest_data_b64('RIPEMD256', @_) }
sub ripemd256_b64u { Crypt::Digest::digest_data_b64u('RIPEMD256', @_) }
sub ripemd256_file { Crypt::Digest::digest_file('RIPEMD256', @_) }
sub ripemd256_file_hex { Crypt::Digest::digest_file_hex('RIPEMD256', @_) }
sub ripemd256_file_b64 { Crypt::Digest::digest_file_b64('RIPEMD256', @_) }
sub ripemd256_file_b64u { Crypt::Digest::digest_file_b64u('RIPEMD256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::RIPEMD256 - Hash function RIPEMD-256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::RIPEMD256 qw( ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u
ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u );
# calculate digest from string/buffer
$ripemd256_raw = ripemd256('data string');
$ripemd256_hex = ripemd256_hex('data string');
$ripemd256_b64 = ripemd256_b64('data string');
$ripemd256_b64u = ripemd256_b64u('data string');
# calculate digest from file
$ripemd256_raw = ripemd256_file('filename.dat');
$ripemd256_hex = ripemd256_file_hex('filename.dat');
$ripemd256_b64 = ripemd256_file_b64('filename.dat');
$ripemd256_b64u = ripemd256_file_b64u('filename.dat');
# calculate digest from filehandle
$ripemd256_raw = ripemd256_file(*FILEHANDLE);
$ripemd256_hex = ripemd256_file_hex(*FILEHANDLE);
$ripemd256_b64 = ripemd256_file_b64(*FILEHANDLE);
$ripemd256_b64u = ripemd256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::RIPEMD256;
$d = Crypt::Digest::RIPEMD256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the RIPEMD256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::RIPEMD256 qw(ripemd256 ripemd256_hex ripemd256_b64 ripemd256_b64u
ripemd256_file ripemd256_file_hex ripemd256_file_b64 ripemd256_file_b64u);
Or all of them at once:
use Crypt::Digest::RIPEMD256 ':all';
=head1 FUNCTIONS
=head2 ripemd256
Logically joins all arguments into a single string, and returns its RIPEMD256 digest encoded as a binary string.
$ripemd256_raw = ripemd256('data string');
#or
$ripemd256_raw = ripemd256('any data', 'more data', 'even more data');
=head2 ripemd256_hex
Logically joins all arguments into a single string, and returns its RIPEMD256 digest encoded as a hexadecimal string.
$ripemd256_hex = ripemd256_hex('data string');
#or
$ripemd256_hex = ripemd256_hex('any data', 'more data', 'even more data');
=head2 ripemd256_b64
Logically joins all arguments into a single string, and returns its RIPEMD256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd256_b64 = ripemd256_b64('data string');
#or
$ripemd256_b64 = ripemd256_b64('any data', 'more data', 'even more data');
=head2 ripemd256_b64u
Logically joins all arguments into a single string, and returns its RIPEMD256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd256_b64url = ripemd256_b64u('data string');
#or
$ripemd256_b64url = ripemd256_b64u('any data', 'more data', 'even more data');
=head2 ripemd256_file
Reads file (defined by filename or filehandle) content, and returns its RIPEMD256 digest encoded as a binary string.
$ripemd256_raw = ripemd256_file('filename.dat');
#or
$ripemd256_raw = ripemd256_file(*FILEHANDLE);
=head2 ripemd256_file_hex
Reads file (defined by filename or filehandle) content, and returns its RIPEMD256 digest encoded as a hexadecimal string.
$ripemd256_hex = ripemd256_file_hex('filename.dat');
#or
$ripemd256_hex = ripemd256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 ripemd256_file_b64
Reads file (defined by filename or filehandle) content, and returns its RIPEMD256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd256_b64 = ripemd256_file_b64('filename.dat');
#or
$ripemd256_b64 = ripemd256_file_b64(*FILEHANDLE);
=head2 ripemd256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its RIPEMD256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd256_b64url = ripemd256_file_b64u('filename.dat');
#or
$ripemd256_b64url = ripemd256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::RIPEMD256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::RIPEMD256->hashsize();
#or
Crypt::Digest::RIPEMD256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/RIPEMD>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::RIPEMD320;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('RIPEMD320') }
sub ripemd320 { Crypt::Digest::digest_data('RIPEMD320', @_) }
sub ripemd320_hex { Crypt::Digest::digest_data_hex('RIPEMD320', @_) }
sub ripemd320_b64 { Crypt::Digest::digest_data_b64('RIPEMD320', @_) }
sub ripemd320_b64u { Crypt::Digest::digest_data_b64u('RIPEMD320', @_) }
sub ripemd320_file { Crypt::Digest::digest_file('RIPEMD320', @_) }
sub ripemd320_file_hex { Crypt::Digest::digest_file_hex('RIPEMD320', @_) }
sub ripemd320_file_b64 { Crypt::Digest::digest_file_b64('RIPEMD320', @_) }
sub ripemd320_file_b64u { Crypt::Digest::digest_file_b64u('RIPEMD320', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::RIPEMD320 - Hash function RIPEMD-320 [size: 320 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::RIPEMD320 qw( ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u
ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u );
# calculate digest from string/buffer
$ripemd320_raw = ripemd320('data string');
$ripemd320_hex = ripemd320_hex('data string');
$ripemd320_b64 = ripemd320_b64('data string');
$ripemd320_b64u = ripemd320_b64u('data string');
# calculate digest from file
$ripemd320_raw = ripemd320_file('filename.dat');
$ripemd320_hex = ripemd320_file_hex('filename.dat');
$ripemd320_b64 = ripemd320_file_b64('filename.dat');
$ripemd320_b64u = ripemd320_file_b64u('filename.dat');
# calculate digest from filehandle
$ripemd320_raw = ripemd320_file(*FILEHANDLE);
$ripemd320_hex = ripemd320_file_hex(*FILEHANDLE);
$ripemd320_b64 = ripemd320_file_b64(*FILEHANDLE);
$ripemd320_b64u = ripemd320_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::RIPEMD320;
$d = Crypt::Digest::RIPEMD320->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the RIPEMD320 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::RIPEMD320 qw(ripemd320 ripemd320_hex ripemd320_b64 ripemd320_b64u
ripemd320_file ripemd320_file_hex ripemd320_file_b64 ripemd320_file_b64u);
Or all of them at once:
use Crypt::Digest::RIPEMD320 ':all';
=head1 FUNCTIONS
=head2 ripemd320
Logically joins all arguments into a single string, and returns its RIPEMD320 digest encoded as a binary string.
$ripemd320_raw = ripemd320('data string');
#or
$ripemd320_raw = ripemd320('any data', 'more data', 'even more data');
=head2 ripemd320_hex
Logically joins all arguments into a single string, and returns its RIPEMD320 digest encoded as a hexadecimal string.
$ripemd320_hex = ripemd320_hex('data string');
#or
$ripemd320_hex = ripemd320_hex('any data', 'more data', 'even more data');
=head2 ripemd320_b64
Logically joins all arguments into a single string, and returns its RIPEMD320 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd320_b64 = ripemd320_b64('data string');
#or
$ripemd320_b64 = ripemd320_b64('any data', 'more data', 'even more data');
=head2 ripemd320_b64u
Logically joins all arguments into a single string, and returns its RIPEMD320 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd320_b64url = ripemd320_b64u('data string');
#or
$ripemd320_b64url = ripemd320_b64u('any data', 'more data', 'even more data');
=head2 ripemd320_file
Reads file (defined by filename or filehandle) content, and returns its RIPEMD320 digest encoded as a binary string.
$ripemd320_raw = ripemd320_file('filename.dat');
#or
$ripemd320_raw = ripemd320_file(*FILEHANDLE);
=head2 ripemd320_file_hex
Reads file (defined by filename or filehandle) content, and returns its RIPEMD320 digest encoded as a hexadecimal string.
$ripemd320_hex = ripemd320_file_hex('filename.dat');
#or
$ripemd320_hex = ripemd320_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 ripemd320_file_b64
Reads file (defined by filename or filehandle) content, and returns its RIPEMD320 digest encoded as a Base64 string, B<with> trailing '=' padding.
$ripemd320_b64 = ripemd320_file_b64('filename.dat');
#or
$ripemd320_b64 = ripemd320_file_b64(*FILEHANDLE);
=head2 ripemd320_file_b64u
Reads file (defined by filename or filehandle) content, and returns its RIPEMD320 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$ripemd320_b64url = ripemd320_file_b64u('filename.dat');
#or
$ripemd320_b64url = ripemd320_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::RIPEMD320->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::RIPEMD320->hashsize();
#or
Crypt::Digest::RIPEMD320::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/RIPEMD>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA1;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha1 sha1_hex sha1_b64 sha1_b64u sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA1') }
sub sha1 { Crypt::Digest::digest_data('SHA1', @_) }
sub sha1_hex { Crypt::Digest::digest_data_hex('SHA1', @_) }
sub sha1_b64 { Crypt::Digest::digest_data_b64('SHA1', @_) }
sub sha1_b64u { Crypt::Digest::digest_data_b64u('SHA1', @_) }
sub sha1_file { Crypt::Digest::digest_file('SHA1', @_) }
sub sha1_file_hex { Crypt::Digest::digest_file_hex('SHA1', @_) }
sub sha1_file_b64 { Crypt::Digest::digest_file_b64('SHA1', @_) }
sub sha1_file_b64u { Crypt::Digest::digest_file_b64u('SHA1', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA1 - Hash function SHA-1 [size: 160 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA1 qw( sha1 sha1_hex sha1_b64 sha1_b64u
sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u );
# calculate digest from string/buffer
$sha1_raw = sha1('data string');
$sha1_hex = sha1_hex('data string');
$sha1_b64 = sha1_b64('data string');
$sha1_b64u = sha1_b64u('data string');
# calculate digest from file
$sha1_raw = sha1_file('filename.dat');
$sha1_hex = sha1_file_hex('filename.dat');
$sha1_b64 = sha1_file_b64('filename.dat');
$sha1_b64u = sha1_file_b64u('filename.dat');
# calculate digest from filehandle
$sha1_raw = sha1_file(*FILEHANDLE);
$sha1_hex = sha1_file_hex(*FILEHANDLE);
$sha1_b64 = sha1_file_b64(*FILEHANDLE);
$sha1_b64u = sha1_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA1;
$d = Crypt::Digest::SHA1->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA1 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA1 qw(sha1 sha1_hex sha1_b64 sha1_b64u
sha1_file sha1_file_hex sha1_file_b64 sha1_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA1 ':all';
=head1 FUNCTIONS
=head2 sha1
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a binary string.
$sha1_raw = sha1('data string');
#or
$sha1_raw = sha1('any data', 'more data', 'even more data');
=head2 sha1_hex
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a hexadecimal string.
$sha1_hex = sha1_hex('data string');
#or
$sha1_hex = sha1_hex('any data', 'more data', 'even more data');
=head2 sha1_b64
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha1_b64 = sha1_b64('data string');
#or
$sha1_b64 = sha1_b64('any data', 'more data', 'even more data');
=head2 sha1_b64u
Logically joins all arguments into a single string, and returns its SHA1 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha1_b64url = sha1_b64u('data string');
#or
$sha1_b64url = sha1_b64u('any data', 'more data', 'even more data');
=head2 sha1_file
Reads file (defined by filename or filehandle) content, and returns its SHA1 digest encoded as a binary string.
$sha1_raw = sha1_file('filename.dat');
#or
$sha1_raw = sha1_file(*FILEHANDLE);
=head2 sha1_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA1 digest encoded as a hexadecimal string.
$sha1_hex = sha1_file_hex('filename.dat');
#or
$sha1_hex = sha1_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha1_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA1 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha1_b64 = sha1_file_b64('filename.dat');
#or
$sha1_b64 = sha1_file_b64(*FILEHANDLE);
=head2 sha1_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA1 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha1_b64url = sha1_file_b64u('filename.dat');
#or
$sha1_b64url = sha1_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA1->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA1->hashsize();
#or
Crypt::Digest::SHA1::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-1>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha224 sha224_hex sha224_b64 sha224_b64u sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA224') }
sub sha224 { Crypt::Digest::digest_data('SHA224', @_) }
sub sha224_hex { Crypt::Digest::digest_data_hex('SHA224', @_) }
sub sha224_b64 { Crypt::Digest::digest_data_b64('SHA224', @_) }
sub sha224_b64u { Crypt::Digest::digest_data_b64u('SHA224', @_) }
sub sha224_file { Crypt::Digest::digest_file('SHA224', @_) }
sub sha224_file_hex { Crypt::Digest::digest_file_hex('SHA224', @_) }
sub sha224_file_b64 { Crypt::Digest::digest_file_b64('SHA224', @_) }
sub sha224_file_b64u { Crypt::Digest::digest_file_b64u('SHA224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA224 - Hash function SHA-224 [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA224 qw( sha224 sha224_hex sha224_b64 sha224_b64u
sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u );
# calculate digest from string/buffer
$sha224_raw = sha224('data string');
$sha224_hex = sha224_hex('data string');
$sha224_b64 = sha224_b64('data string');
$sha224_b64u = sha224_b64u('data string');
# calculate digest from file
$sha224_raw = sha224_file('filename.dat');
$sha224_hex = sha224_file_hex('filename.dat');
$sha224_b64 = sha224_file_b64('filename.dat');
$sha224_b64u = sha224_file_b64u('filename.dat');
# calculate digest from filehandle
$sha224_raw = sha224_file(*FILEHANDLE);
$sha224_hex = sha224_file_hex(*FILEHANDLE);
$sha224_b64 = sha224_file_b64(*FILEHANDLE);
$sha224_b64u = sha224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA224;
$d = Crypt::Digest::SHA224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA224 qw(sha224 sha224_hex sha224_b64 sha224_b64u
sha224_file sha224_file_hex sha224_file_b64 sha224_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA224 ':all';
=head1 FUNCTIONS
=head2 sha224
Logically joins all arguments into a single string, and returns its SHA224 digest encoded as a binary string.
$sha224_raw = sha224('data string');
#or
$sha224_raw = sha224('any data', 'more data', 'even more data');
=head2 sha224_hex
Logically joins all arguments into a single string, and returns its SHA224 digest encoded as a hexadecimal string.
$sha224_hex = sha224_hex('data string');
#or
$sha224_hex = sha224_hex('any data', 'more data', 'even more data');
=head2 sha224_b64
Logically joins all arguments into a single string, and returns its SHA224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha224_b64 = sha224_b64('data string');
#or
$sha224_b64 = sha224_b64('any data', 'more data', 'even more data');
=head2 sha224_b64u
Logically joins all arguments into a single string, and returns its SHA224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha224_b64url = sha224_b64u('data string');
#or
$sha224_b64url = sha224_b64u('any data', 'more data', 'even more data');
=head2 sha224_file
Reads file (defined by filename or filehandle) content, and returns its SHA224 digest encoded as a binary string.
$sha224_raw = sha224_file('filename.dat');
#or
$sha224_raw = sha224_file(*FILEHANDLE);
=head2 sha224_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA224 digest encoded as a hexadecimal string.
$sha224_hex = sha224_file_hex('filename.dat');
#or
$sha224_hex = sha224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha224_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha224_b64 = sha224_file_b64('filename.dat');
#or
$sha224_b64 = sha224_file_b64(*FILEHANDLE);
=head2 sha224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha224_b64url = sha224_file_b64u('filename.dat');
#or
$sha224_b64url = sha224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA224->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA224->hashsize();
#or
Crypt::Digest::SHA224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha256 sha256_hex sha256_b64 sha256_b64u sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA256') }
sub sha256 { Crypt::Digest::digest_data('SHA256', @_) }
sub sha256_hex { Crypt::Digest::digest_data_hex('SHA256', @_) }
sub sha256_b64 { Crypt::Digest::digest_data_b64('SHA256', @_) }
sub sha256_b64u { Crypt::Digest::digest_data_b64u('SHA256', @_) }
sub sha256_file { Crypt::Digest::digest_file('SHA256', @_) }
sub sha256_file_hex { Crypt::Digest::digest_file_hex('SHA256', @_) }
sub sha256_file_b64 { Crypt::Digest::digest_file_b64('SHA256', @_) }
sub sha256_file_b64u { Crypt::Digest::digest_file_b64u('SHA256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA256 - Hash function SHA-256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA256 qw( sha256 sha256_hex sha256_b64 sha256_b64u
sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u );
# calculate digest from string/buffer
$sha256_raw = sha256('data string');
$sha256_hex = sha256_hex('data string');
$sha256_b64 = sha256_b64('data string');
$sha256_b64u = sha256_b64u('data string');
# calculate digest from file
$sha256_raw = sha256_file('filename.dat');
$sha256_hex = sha256_file_hex('filename.dat');
$sha256_b64 = sha256_file_b64('filename.dat');
$sha256_b64u = sha256_file_b64u('filename.dat');
# calculate digest from filehandle
$sha256_raw = sha256_file(*FILEHANDLE);
$sha256_hex = sha256_file_hex(*FILEHANDLE);
$sha256_b64 = sha256_file_b64(*FILEHANDLE);
$sha256_b64u = sha256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA256;
$d = Crypt::Digest::SHA256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA256 qw(sha256 sha256_hex sha256_b64 sha256_b64u
sha256_file sha256_file_hex sha256_file_b64 sha256_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA256 ':all';
=head1 FUNCTIONS
=head2 sha256
Logically joins all arguments into a single string, and returns its SHA256 digest encoded as a binary string.
$sha256_raw = sha256('data string');
#or
$sha256_raw = sha256('any data', 'more data', 'even more data');
=head2 sha256_hex
Logically joins all arguments into a single string, and returns its SHA256 digest encoded as a hexadecimal string.
$sha256_hex = sha256_hex('data string');
#or
$sha256_hex = sha256_hex('any data', 'more data', 'even more data');
=head2 sha256_b64
Logically joins all arguments into a single string, and returns its SHA256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha256_b64 = sha256_b64('data string');
#or
$sha256_b64 = sha256_b64('any data', 'more data', 'even more data');
=head2 sha256_b64u
Logically joins all arguments into a single string, and returns its SHA256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha256_b64url = sha256_b64u('data string');
#or
$sha256_b64url = sha256_b64u('any data', 'more data', 'even more data');
=head2 sha256_file
Reads file (defined by filename or filehandle) content, and returns its SHA256 digest encoded as a binary string.
$sha256_raw = sha256_file('filename.dat');
#or
$sha256_raw = sha256_file(*FILEHANDLE);
=head2 sha256_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA256 digest encoded as a hexadecimal string.
$sha256_hex = sha256_file_hex('filename.dat');
#or
$sha256_hex = sha256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha256_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha256_b64 = sha256_file_b64('filename.dat');
#or
$sha256_b64 = sha256_file_b64(*FILEHANDLE);
=head2 sha256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha256_b64url = sha256_file_b64u('filename.dat');
#or
$sha256_b64url = sha256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA256->hashsize();
#or
Crypt::Digest::SHA256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA384;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha384 sha384_hex sha384_b64 sha384_b64u sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA384') }
sub sha384 { Crypt::Digest::digest_data('SHA384', @_) }
sub sha384_hex { Crypt::Digest::digest_data_hex('SHA384', @_) }
sub sha384_b64 { Crypt::Digest::digest_data_b64('SHA384', @_) }
sub sha384_b64u { Crypt::Digest::digest_data_b64u('SHA384', @_) }
sub sha384_file { Crypt::Digest::digest_file('SHA384', @_) }
sub sha384_file_hex { Crypt::Digest::digest_file_hex('SHA384', @_) }
sub sha384_file_b64 { Crypt::Digest::digest_file_b64('SHA384', @_) }
sub sha384_file_b64u { Crypt::Digest::digest_file_b64u('SHA384', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA384 - Hash function SHA-384 [size: 384 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA384 qw( sha384 sha384_hex sha384_b64 sha384_b64u
sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u );
# calculate digest from string/buffer
$sha384_raw = sha384('data string');
$sha384_hex = sha384_hex('data string');
$sha384_b64 = sha384_b64('data string');
$sha384_b64u = sha384_b64u('data string');
# calculate digest from file
$sha384_raw = sha384_file('filename.dat');
$sha384_hex = sha384_file_hex('filename.dat');
$sha384_b64 = sha384_file_b64('filename.dat');
$sha384_b64u = sha384_file_b64u('filename.dat');
# calculate digest from filehandle
$sha384_raw = sha384_file(*FILEHANDLE);
$sha384_hex = sha384_file_hex(*FILEHANDLE);
$sha384_b64 = sha384_file_b64(*FILEHANDLE);
$sha384_b64u = sha384_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA384;
$d = Crypt::Digest::SHA384->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA384 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA384 qw(sha384 sha384_hex sha384_b64 sha384_b64u
sha384_file sha384_file_hex sha384_file_b64 sha384_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA384 ':all';
=head1 FUNCTIONS
=head2 sha384
Logically joins all arguments into a single string, and returns its SHA384 digest encoded as a binary string.
$sha384_raw = sha384('data string');
#or
$sha384_raw = sha384('any data', 'more data', 'even more data');
=head2 sha384_hex
Logically joins all arguments into a single string, and returns its SHA384 digest encoded as a hexadecimal string.
$sha384_hex = sha384_hex('data string');
#or
$sha384_hex = sha384_hex('any data', 'more data', 'even more data');
=head2 sha384_b64
Logically joins all arguments into a single string, and returns its SHA384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha384_b64 = sha384_b64('data string');
#or
$sha384_b64 = sha384_b64('any data', 'more data', 'even more data');
=head2 sha384_b64u
Logically joins all arguments into a single string, and returns its SHA384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha384_b64url = sha384_b64u('data string');
#or
$sha384_b64url = sha384_b64u('any data', 'more data', 'even more data');
=head2 sha384_file
Reads file (defined by filename or filehandle) content, and returns its SHA384 digest encoded as a binary string.
$sha384_raw = sha384_file('filename.dat');
#or
$sha384_raw = sha384_file(*FILEHANDLE);
=head2 sha384_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA384 digest encoded as a hexadecimal string.
$sha384_hex = sha384_file_hex('filename.dat');
#or
$sha384_hex = sha384_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha384_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha384_b64 = sha384_file_b64('filename.dat');
#or
$sha384_b64 = sha384_file_b64(*FILEHANDLE);
=head2 sha384_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha384_b64url = sha384_file_b64u('filename.dat');
#or
$sha384_b64url = sha384_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA384->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA384->hashsize();
#or
Crypt::Digest::SHA384::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA3_224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA3_224') }
sub sha3_224 { Crypt::Digest::digest_data('SHA3_224', @_) }
sub sha3_224_hex { Crypt::Digest::digest_data_hex('SHA3_224', @_) }
sub sha3_224_b64 { Crypt::Digest::digest_data_b64('SHA3_224', @_) }
sub sha3_224_b64u { Crypt::Digest::digest_data_b64u('SHA3_224', @_) }
sub sha3_224_file { Crypt::Digest::digest_file('SHA3_224', @_) }
sub sha3_224_file_hex { Crypt::Digest::digest_file_hex('SHA3_224', @_) }
sub sha3_224_file_b64 { Crypt::Digest::digest_file_b64('SHA3_224', @_) }
sub sha3_224_file_b64u { Crypt::Digest::digest_file_b64u('SHA3_224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA3_224 - Hash function SHA3-224 [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA3_224 qw( sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u );
# calculate digest from string/buffer
$sha3_224_raw = sha3_224('data string');
$sha3_224_hex = sha3_224_hex('data string');
$sha3_224_b64 = sha3_224_b64('data string');
$sha3_224_b64u = sha3_224_b64u('data string');
# calculate digest from file
$sha3_224_raw = sha3_224_file('filename.dat');
$sha3_224_hex = sha3_224_file_hex('filename.dat');
$sha3_224_b64 = sha3_224_file_b64('filename.dat');
$sha3_224_b64u = sha3_224_file_b64u('filename.dat');
# calculate digest from filehandle
$sha3_224_raw = sha3_224_file(*FILEHANDLE);
$sha3_224_hex = sha3_224_file_hex(*FILEHANDLE);
$sha3_224_b64 = sha3_224_file_b64(*FILEHANDLE);
$sha3_224_b64u = sha3_224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA3_224;
$d = Crypt::Digest::SHA3_224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA3_224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA3_224 qw(sha3_224 sha3_224_hex sha3_224_b64 sha3_224_b64u
sha3_224_file sha3_224_file_hex sha3_224_file_b64 sha3_224_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA3_224 ':all';
=head1 FUNCTIONS
=head2 sha3_224
Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a binary string.
$sha3_224_raw = sha3_224('data string');
#or
$sha3_224_raw = sha3_224('any data', 'more data', 'even more data');
=head2 sha3_224_hex
Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a hexadecimal string.
$sha3_224_hex = sha3_224_hex('data string');
#or
$sha3_224_hex = sha3_224_hex('any data', 'more data', 'even more data');
=head2 sha3_224_b64
Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_224_b64 = sha3_224_b64('data string');
#or
$sha3_224_b64 = sha3_224_b64('any data', 'more data', 'even more data');
=head2 sha3_224_b64u
Logically joins all arguments into a single string, and returns its SHA3_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_224_b64url = sha3_224_b64u('data string');
#or
$sha3_224_b64url = sha3_224_b64u('any data', 'more data', 'even more data');
=head2 sha3_224_file
Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a binary string.
$sha3_224_raw = sha3_224_file('filename.dat');
#or
$sha3_224_raw = sha3_224_file(*FILEHANDLE);
=head2 sha3_224_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a hexadecimal string.
$sha3_224_hex = sha3_224_file_hex('filename.dat');
#or
$sha3_224_hex = sha3_224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha3_224_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_224_b64 = sha3_224_file_b64('filename.dat');
#or
$sha3_224_b64 = sha3_224_file_b64(*FILEHANDLE);
=head2 sha3_224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA3_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_224_b64url = sha3_224_file_b64u('filename.dat');
#or
$sha3_224_b64url = sha3_224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA3_224->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA3_224->hashsize();
#or
Crypt::Digest::SHA3_224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-3>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA3_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA3_256') }
sub sha3_256 { Crypt::Digest::digest_data('SHA3_256', @_) }
sub sha3_256_hex { Crypt::Digest::digest_data_hex('SHA3_256', @_) }
sub sha3_256_b64 { Crypt::Digest::digest_data_b64('SHA3_256', @_) }
sub sha3_256_b64u { Crypt::Digest::digest_data_b64u('SHA3_256', @_) }
sub sha3_256_file { Crypt::Digest::digest_file('SHA3_256', @_) }
sub sha3_256_file_hex { Crypt::Digest::digest_file_hex('SHA3_256', @_) }
sub sha3_256_file_b64 { Crypt::Digest::digest_file_b64('SHA3_256', @_) }
sub sha3_256_file_b64u { Crypt::Digest::digest_file_b64u('SHA3_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA3_256 - Hash function SHA3-256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA3_256 qw( sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u
sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u );
# calculate digest from string/buffer
$sha3_256_raw = sha3_256('data string');
$sha3_256_hex = sha3_256_hex('data string');
$sha3_256_b64 = sha3_256_b64('data string');
$sha3_256_b64u = sha3_256_b64u('data string');
# calculate digest from file
$sha3_256_raw = sha3_256_file('filename.dat');
$sha3_256_hex = sha3_256_file_hex('filename.dat');
$sha3_256_b64 = sha3_256_file_b64('filename.dat');
$sha3_256_b64u = sha3_256_file_b64u('filename.dat');
# calculate digest from filehandle
$sha3_256_raw = sha3_256_file(*FILEHANDLE);
$sha3_256_hex = sha3_256_file_hex(*FILEHANDLE);
$sha3_256_b64 = sha3_256_file_b64(*FILEHANDLE);
$sha3_256_b64u = sha3_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA3_256;
$d = Crypt::Digest::SHA3_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA3_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA3_256 qw(sha3_256 sha3_256_hex sha3_256_b64 sha3_256_b64u
sha3_256_file sha3_256_file_hex sha3_256_file_b64 sha3_256_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA3_256 ':all';
=head1 FUNCTIONS
=head2 sha3_256
Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a binary string.
$sha3_256_raw = sha3_256('data string');
#or
$sha3_256_raw = sha3_256('any data', 'more data', 'even more data');
=head2 sha3_256_hex
Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a hexadecimal string.
$sha3_256_hex = sha3_256_hex('data string');
#or
$sha3_256_hex = sha3_256_hex('any data', 'more data', 'even more data');
=head2 sha3_256_b64
Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_256_b64 = sha3_256_b64('data string');
#or
$sha3_256_b64 = sha3_256_b64('any data', 'more data', 'even more data');
=head2 sha3_256_b64u
Logically joins all arguments into a single string, and returns its SHA3_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_256_b64url = sha3_256_b64u('data string');
#or
$sha3_256_b64url = sha3_256_b64u('any data', 'more data', 'even more data');
=head2 sha3_256_file
Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a binary string.
$sha3_256_raw = sha3_256_file('filename.dat');
#or
$sha3_256_raw = sha3_256_file(*FILEHANDLE);
=head2 sha3_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a hexadecimal string.
$sha3_256_hex = sha3_256_file_hex('filename.dat');
#or
$sha3_256_hex = sha3_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha3_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_256_b64 = sha3_256_file_b64('filename.dat');
#or
$sha3_256_b64 = sha3_256_file_b64(*FILEHANDLE);
=head2 sha3_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA3_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_256_b64url = sha3_256_file_b64u('filename.dat');
#or
$sha3_256_b64url = sha3_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA3_256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA3_256->hashsize();
#or
Crypt::Digest::SHA3_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-3>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA3_384;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA3_384') }
sub sha3_384 { Crypt::Digest::digest_data('SHA3_384', @_) }
sub sha3_384_hex { Crypt::Digest::digest_data_hex('SHA3_384', @_) }
sub sha3_384_b64 { Crypt::Digest::digest_data_b64('SHA3_384', @_) }
sub sha3_384_b64u { Crypt::Digest::digest_data_b64u('SHA3_384', @_) }
sub sha3_384_file { Crypt::Digest::digest_file('SHA3_384', @_) }
sub sha3_384_file_hex { Crypt::Digest::digest_file_hex('SHA3_384', @_) }
sub sha3_384_file_b64 { Crypt::Digest::digest_file_b64('SHA3_384', @_) }
sub sha3_384_file_b64u { Crypt::Digest::digest_file_b64u('SHA3_384', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA3_384 - Hash function SHA3-384 [size: 384 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA3_384 qw( sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u
sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u );
# calculate digest from string/buffer
$sha3_384_raw = sha3_384('data string');
$sha3_384_hex = sha3_384_hex('data string');
$sha3_384_b64 = sha3_384_b64('data string');
$sha3_384_b64u = sha3_384_b64u('data string');
# calculate digest from file
$sha3_384_raw = sha3_384_file('filename.dat');
$sha3_384_hex = sha3_384_file_hex('filename.dat');
$sha3_384_b64 = sha3_384_file_b64('filename.dat');
$sha3_384_b64u = sha3_384_file_b64u('filename.dat');
# calculate digest from filehandle
$sha3_384_raw = sha3_384_file(*FILEHANDLE);
$sha3_384_hex = sha3_384_file_hex(*FILEHANDLE);
$sha3_384_b64 = sha3_384_file_b64(*FILEHANDLE);
$sha3_384_b64u = sha3_384_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA3_384;
$d = Crypt::Digest::SHA3_384->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA3_384 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA3_384 qw(sha3_384 sha3_384_hex sha3_384_b64 sha3_384_b64u
sha3_384_file sha3_384_file_hex sha3_384_file_b64 sha3_384_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA3_384 ':all';
=head1 FUNCTIONS
=head2 sha3_384
Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a binary string.
$sha3_384_raw = sha3_384('data string');
#or
$sha3_384_raw = sha3_384('any data', 'more data', 'even more data');
=head2 sha3_384_hex
Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a hexadecimal string.
$sha3_384_hex = sha3_384_hex('data string');
#or
$sha3_384_hex = sha3_384_hex('any data', 'more data', 'even more data');
=head2 sha3_384_b64
Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_384_b64 = sha3_384_b64('data string');
#or
$sha3_384_b64 = sha3_384_b64('any data', 'more data', 'even more data');
=head2 sha3_384_b64u
Logically joins all arguments into a single string, and returns its SHA3_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_384_b64url = sha3_384_b64u('data string');
#or
$sha3_384_b64url = sha3_384_b64u('any data', 'more data', 'even more data');
=head2 sha3_384_file
Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a binary string.
$sha3_384_raw = sha3_384_file('filename.dat');
#or
$sha3_384_raw = sha3_384_file(*FILEHANDLE);
=head2 sha3_384_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a hexadecimal string.
$sha3_384_hex = sha3_384_file_hex('filename.dat');
#or
$sha3_384_hex = sha3_384_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha3_384_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_384_b64 = sha3_384_file_b64('filename.dat');
#or
$sha3_384_b64 = sha3_384_file_b64(*FILEHANDLE);
=head2 sha3_384_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA3_384 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_384_b64url = sha3_384_file_b64u('filename.dat');
#or
$sha3_384_b64url = sha3_384_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA3_384->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA3_384->hashsize();
#or
Crypt::Digest::SHA3_384::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-3>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA3_512;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA3_512') }
sub sha3_512 { Crypt::Digest::digest_data('SHA3_512', @_) }
sub sha3_512_hex { Crypt::Digest::digest_data_hex('SHA3_512', @_) }
sub sha3_512_b64 { Crypt::Digest::digest_data_b64('SHA3_512', @_) }
sub sha3_512_b64u { Crypt::Digest::digest_data_b64u('SHA3_512', @_) }
sub sha3_512_file { Crypt::Digest::digest_file('SHA3_512', @_) }
sub sha3_512_file_hex { Crypt::Digest::digest_file_hex('SHA3_512', @_) }
sub sha3_512_file_b64 { Crypt::Digest::digest_file_b64('SHA3_512', @_) }
sub sha3_512_file_b64u { Crypt::Digest::digest_file_b64u('SHA3_512', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA3_512 - Hash function SHA3-512 [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA3_512 qw( sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u
sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u );
# calculate digest from string/buffer
$sha3_512_raw = sha3_512('data string');
$sha3_512_hex = sha3_512_hex('data string');
$sha3_512_b64 = sha3_512_b64('data string');
$sha3_512_b64u = sha3_512_b64u('data string');
# calculate digest from file
$sha3_512_raw = sha3_512_file('filename.dat');
$sha3_512_hex = sha3_512_file_hex('filename.dat');
$sha3_512_b64 = sha3_512_file_b64('filename.dat');
$sha3_512_b64u = sha3_512_file_b64u('filename.dat');
# calculate digest from filehandle
$sha3_512_raw = sha3_512_file(*FILEHANDLE);
$sha3_512_hex = sha3_512_file_hex(*FILEHANDLE);
$sha3_512_b64 = sha3_512_file_b64(*FILEHANDLE);
$sha3_512_b64u = sha3_512_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA3_512;
$d = Crypt::Digest::SHA3_512->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA3_512 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA3_512 qw(sha3_512 sha3_512_hex sha3_512_b64 sha3_512_b64u
sha3_512_file sha3_512_file_hex sha3_512_file_b64 sha3_512_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA3_512 ':all';
=head1 FUNCTIONS
=head2 sha3_512
Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a binary string.
$sha3_512_raw = sha3_512('data string');
#or
$sha3_512_raw = sha3_512('any data', 'more data', 'even more data');
=head2 sha3_512_hex
Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a hexadecimal string.
$sha3_512_hex = sha3_512_hex('data string');
#or
$sha3_512_hex = sha3_512_hex('any data', 'more data', 'even more data');
=head2 sha3_512_b64
Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_512_b64 = sha3_512_b64('data string');
#or
$sha3_512_b64 = sha3_512_b64('any data', 'more data', 'even more data');
=head2 sha3_512_b64u
Logically joins all arguments into a single string, and returns its SHA3_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_512_b64url = sha3_512_b64u('data string');
#or
$sha3_512_b64url = sha3_512_b64u('any data', 'more data', 'even more data');
=head2 sha3_512_file
Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a binary string.
$sha3_512_raw = sha3_512_file('filename.dat');
#or
$sha3_512_raw = sha3_512_file(*FILEHANDLE);
=head2 sha3_512_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a hexadecimal string.
$sha3_512_hex = sha3_512_file_hex('filename.dat');
#or
$sha3_512_hex = sha3_512_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha3_512_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha3_512_b64 = sha3_512_file_b64('filename.dat');
#or
$sha3_512_b64 = sha3_512_file_b64(*FILEHANDLE);
=head2 sha3_512_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA3_512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha3_512_b64url = sha3_512_file_b64u('filename.dat');
#or
$sha3_512_b64url = sha3_512_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA3_512->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA3_512->hashsize();
#or
Crypt::Digest::SHA3_512::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-3>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA512;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha512 sha512_hex sha512_b64 sha512_b64u sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA512') }
sub sha512 { Crypt::Digest::digest_data('SHA512', @_) }
sub sha512_hex { Crypt::Digest::digest_data_hex('SHA512', @_) }
sub sha512_b64 { Crypt::Digest::digest_data_b64('SHA512', @_) }
sub sha512_b64u { Crypt::Digest::digest_data_b64u('SHA512', @_) }
sub sha512_file { Crypt::Digest::digest_file('SHA512', @_) }
sub sha512_file_hex { Crypt::Digest::digest_file_hex('SHA512', @_) }
sub sha512_file_b64 { Crypt::Digest::digest_file_b64('SHA512', @_) }
sub sha512_file_b64u { Crypt::Digest::digest_file_b64u('SHA512', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA512 - Hash function SHA-512 [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA512 qw( sha512 sha512_hex sha512_b64 sha512_b64u
sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u );
# calculate digest from string/buffer
$sha512_raw = sha512('data string');
$sha512_hex = sha512_hex('data string');
$sha512_b64 = sha512_b64('data string');
$sha512_b64u = sha512_b64u('data string');
# calculate digest from file
$sha512_raw = sha512_file('filename.dat');
$sha512_hex = sha512_file_hex('filename.dat');
$sha512_b64 = sha512_file_b64('filename.dat');
$sha512_b64u = sha512_file_b64u('filename.dat');
# calculate digest from filehandle
$sha512_raw = sha512_file(*FILEHANDLE);
$sha512_hex = sha512_file_hex(*FILEHANDLE);
$sha512_b64 = sha512_file_b64(*FILEHANDLE);
$sha512_b64u = sha512_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA512;
$d = Crypt::Digest::SHA512->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA512 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA512 qw(sha512 sha512_hex sha512_b64 sha512_b64u
sha512_file sha512_file_hex sha512_file_b64 sha512_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA512 ':all';
=head1 FUNCTIONS
=head2 sha512
Logically joins all arguments into a single string, and returns its SHA512 digest encoded as a binary string.
$sha512_raw = sha512('data string');
#or
$sha512_raw = sha512('any data', 'more data', 'even more data');
=head2 sha512_hex
Logically joins all arguments into a single string, and returns its SHA512 digest encoded as a hexadecimal string.
$sha512_hex = sha512_hex('data string');
#or
$sha512_hex = sha512_hex('any data', 'more data', 'even more data');
=head2 sha512_b64
Logically joins all arguments into a single string, and returns its SHA512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_b64 = sha512_b64('data string');
#or
$sha512_b64 = sha512_b64('any data', 'more data', 'even more data');
=head2 sha512_b64u
Logically joins all arguments into a single string, and returns its SHA512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_b64url = sha512_b64u('data string');
#or
$sha512_b64url = sha512_b64u('any data', 'more data', 'even more data');
=head2 sha512_file
Reads file (defined by filename or filehandle) content, and returns its SHA512 digest encoded as a binary string.
$sha512_raw = sha512_file('filename.dat');
#or
$sha512_raw = sha512_file(*FILEHANDLE);
=head2 sha512_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA512 digest encoded as a hexadecimal string.
$sha512_hex = sha512_file_hex('filename.dat');
#or
$sha512_hex = sha512_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha512_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA512 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_b64 = sha512_file_b64('filename.dat');
#or
$sha512_b64 = sha512_file_b64(*FILEHANDLE);
=head2 sha512_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA512 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_b64url = sha512_file_b64u('filename.dat');
#or
$sha512_b64url = sha512_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA512->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA512->hashsize();
#or
Crypt::Digest::SHA512::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA512_224;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA512_224') }
sub sha512_224 { Crypt::Digest::digest_data('SHA512_224', @_) }
sub sha512_224_hex { Crypt::Digest::digest_data_hex('SHA512_224', @_) }
sub sha512_224_b64 { Crypt::Digest::digest_data_b64('SHA512_224', @_) }
sub sha512_224_b64u { Crypt::Digest::digest_data_b64u('SHA512_224', @_) }
sub sha512_224_file { Crypt::Digest::digest_file('SHA512_224', @_) }
sub sha512_224_file_hex { Crypt::Digest::digest_file_hex('SHA512_224', @_) }
sub sha512_224_file_b64 { Crypt::Digest::digest_file_b64('SHA512_224', @_) }
sub sha512_224_file_b64u { Crypt::Digest::digest_file_b64u('SHA512_224', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA512_224 - Hash function SHA-512/224 [size: 224 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA512_224 qw( sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u
sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u );
# calculate digest from string/buffer
$sha512_224_raw = sha512_224('data string');
$sha512_224_hex = sha512_224_hex('data string');
$sha512_224_b64 = sha512_224_b64('data string');
$sha512_224_b64u = sha512_224_b64u('data string');
# calculate digest from file
$sha512_224_raw = sha512_224_file('filename.dat');
$sha512_224_hex = sha512_224_file_hex('filename.dat');
$sha512_224_b64 = sha512_224_file_b64('filename.dat');
$sha512_224_b64u = sha512_224_file_b64u('filename.dat');
# calculate digest from filehandle
$sha512_224_raw = sha512_224_file(*FILEHANDLE);
$sha512_224_hex = sha512_224_file_hex(*FILEHANDLE);
$sha512_224_b64 = sha512_224_file_b64(*FILEHANDLE);
$sha512_224_b64u = sha512_224_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA512_224;
$d = Crypt::Digest::SHA512_224->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA512_224 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA512_224 qw(sha512_224 sha512_224_hex sha512_224_b64 sha512_224_b64u
sha512_224_file sha512_224_file_hex sha512_224_file_b64 sha512_224_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA512_224 ':all';
=head1 FUNCTIONS
=head2 sha512_224
Logically joins all arguments into a single string, and returns its SHA512_224 digest encoded as a binary string.
$sha512_224_raw = sha512_224('data string');
#or
$sha512_224_raw = sha512_224('any data', 'more data', 'even more data');
=head2 sha512_224_hex
Logically joins all arguments into a single string, and returns its SHA512_224 digest encoded as a hexadecimal string.
$sha512_224_hex = sha512_224_hex('data string');
#or
$sha512_224_hex = sha512_224_hex('any data', 'more data', 'even more data');
=head2 sha512_224_b64
Logically joins all arguments into a single string, and returns its SHA512_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_224_b64 = sha512_224_b64('data string');
#or
$sha512_224_b64 = sha512_224_b64('any data', 'more data', 'even more data');
=head2 sha512_224_b64u
Logically joins all arguments into a single string, and returns its SHA512_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_224_b64url = sha512_224_b64u('data string');
#or
$sha512_224_b64url = sha512_224_b64u('any data', 'more data', 'even more data');
=head2 sha512_224_file
Reads file (defined by filename or filehandle) content, and returns its SHA512_224 digest encoded as a binary string.
$sha512_224_raw = sha512_224_file('filename.dat');
#or
$sha512_224_raw = sha512_224_file(*FILEHANDLE);
=head2 sha512_224_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA512_224 digest encoded as a hexadecimal string.
$sha512_224_hex = sha512_224_file_hex('filename.dat');
#or
$sha512_224_hex = sha512_224_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha512_224_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA512_224 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_224_b64 = sha512_224_file_b64('filename.dat');
#or
$sha512_224_b64 = sha512_224_file_b64(*FILEHANDLE);
=head2 sha512_224_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA512_224 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_224_b64url = sha512_224_file_b64u('filename.dat');
#or
$sha512_224_b64url = sha512_224_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA512_224->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA512_224->hashsize();
#or
Crypt::Digest::SHA512_224::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::SHA512_256;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('SHA512_256') }
sub sha512_256 { Crypt::Digest::digest_data('SHA512_256', @_) }
sub sha512_256_hex { Crypt::Digest::digest_data_hex('SHA512_256', @_) }
sub sha512_256_b64 { Crypt::Digest::digest_data_b64('SHA512_256', @_) }
sub sha512_256_b64u { Crypt::Digest::digest_data_b64u('SHA512_256', @_) }
sub sha512_256_file { Crypt::Digest::digest_file('SHA512_256', @_) }
sub sha512_256_file_hex { Crypt::Digest::digest_file_hex('SHA512_256', @_) }
sub sha512_256_file_b64 { Crypt::Digest::digest_file_b64('SHA512_256', @_) }
sub sha512_256_file_b64u { Crypt::Digest::digest_file_b64u('SHA512_256', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::SHA512_256 - Hash function SHA-512/256 [size: 256 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::SHA512_256 qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u
sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u );
# calculate digest from string/buffer
$sha512_256_raw = sha512_256('data string');
$sha512_256_hex = sha512_256_hex('data string');
$sha512_256_b64 = sha512_256_b64('data string');
$sha512_256_b64u = sha512_256_b64u('data string');
# calculate digest from file
$sha512_256_raw = sha512_256_file('filename.dat');
$sha512_256_hex = sha512_256_file_hex('filename.dat');
$sha512_256_b64 = sha512_256_file_b64('filename.dat');
$sha512_256_b64u = sha512_256_file_b64u('filename.dat');
# calculate digest from filehandle
$sha512_256_raw = sha512_256_file(*FILEHANDLE);
$sha512_256_hex = sha512_256_file_hex(*FILEHANDLE);
$sha512_256_b64 = sha512_256_file_b64(*FILEHANDLE);
$sha512_256_b64u = sha512_256_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::SHA512_256;
$d = Crypt::Digest::SHA512_256->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the SHA512_256 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::SHA512_256 qw(sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u
sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u);
Or all of them at once:
use Crypt::Digest::SHA512_256 ':all';
=head1 FUNCTIONS
=head2 sha512_256
Logically joins all arguments into a single string, and returns its SHA512_256 digest encoded as a binary string.
$sha512_256_raw = sha512_256('data string');
#or
$sha512_256_raw = sha512_256('any data', 'more data', 'even more data');
=head2 sha512_256_hex
Logically joins all arguments into a single string, and returns its SHA512_256 digest encoded as a hexadecimal string.
$sha512_256_hex = sha512_256_hex('data string');
#or
$sha512_256_hex = sha512_256_hex('any data', 'more data', 'even more data');
=head2 sha512_256_b64
Logically joins all arguments into a single string, and returns its SHA512_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_256_b64 = sha512_256_b64('data string');
#or
$sha512_256_b64 = sha512_256_b64('any data', 'more data', 'even more data');
=head2 sha512_256_b64u
Logically joins all arguments into a single string, and returns its SHA512_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_256_b64url = sha512_256_b64u('data string');
#or
$sha512_256_b64url = sha512_256_b64u('any data', 'more data', 'even more data');
=head2 sha512_256_file
Reads file (defined by filename or filehandle) content, and returns its SHA512_256 digest encoded as a binary string.
$sha512_256_raw = sha512_256_file('filename.dat');
#or
$sha512_256_raw = sha512_256_file(*FILEHANDLE);
=head2 sha512_256_file_hex
Reads file (defined by filename or filehandle) content, and returns its SHA512_256 digest encoded as a hexadecimal string.
$sha512_256_hex = sha512_256_file_hex('filename.dat');
#or
$sha512_256_hex = sha512_256_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 sha512_256_file_b64
Reads file (defined by filename or filehandle) content, and returns its SHA512_256 digest encoded as a Base64 string, B<with> trailing '=' padding.
$sha512_256_b64 = sha512_256_file_b64('filename.dat');
#or
$sha512_256_b64 = sha512_256_file_b64(*FILEHANDLE);
=head2 sha512_256_file_b64u
Reads file (defined by filename or filehandle) content, and returns its SHA512_256 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$sha512_256_b64url = sha512_256_file_b64u('filename.dat');
#or
$sha512_256_b64url = sha512_256_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::SHA512_256->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::SHA512_256->hashsize();
#or
Crypt::Digest::SHA512_256::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/SHA-2>
=back
=cut

View File

@@ -0,0 +1,102 @@
package Crypt::Digest::SHAKE;
use strict;
use warnings;
our $VERSION = '0.069';
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') { #filename
open($handle, "<", $file) || croak "FATAL: cannot open '$file': $!";
binmode($handle);
}
else { #handle
$handle = $file
}
croak "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf)
}
croak "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Digest::SHAKE - Hash functions SHAKE128, SHAKE256 from SHA3 family
=head1 SYNOPSIS
use Crypt::Digest::SHAKE
$d = Crypt::Digest::SHAKE->new(128);
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$part1 = $d->done(100); # 100 raw bytes
$part2 = $d->done(100); # another 100 raw bytes
#...
=head1 DESCRIPTION
Provides an interface to the SHA3's sponge function SHAKE.
=head1 METHODS
=head2 new
$d = Crypt::Digest::SHA3-SHAKE->new($num);
# $num ... 128 or 256
=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 done
$result_raw = $d->done($len);
# can be called multiple times
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest|Crypt::Digest>
=item * L<http://en.wikipedia.org/wiki/SHA-3|http://en.wikipedia.org/wiki/SHA-3>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Tiger192;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Tiger192') }
sub tiger192 { Crypt::Digest::digest_data('Tiger192', @_) }
sub tiger192_hex { Crypt::Digest::digest_data_hex('Tiger192', @_) }
sub tiger192_b64 { Crypt::Digest::digest_data_b64('Tiger192', @_) }
sub tiger192_b64u { Crypt::Digest::digest_data_b64u('Tiger192', @_) }
sub tiger192_file { Crypt::Digest::digest_file('Tiger192', @_) }
sub tiger192_file_hex { Crypt::Digest::digest_file_hex('Tiger192', @_) }
sub tiger192_file_b64 { Crypt::Digest::digest_file_b64('Tiger192', @_) }
sub tiger192_file_b64u { Crypt::Digest::digest_file_b64u('Tiger192', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Tiger192 - Hash function Tiger-192 [size: 192 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Tiger192 qw( tiger192 tiger192_hex tiger192_b64 tiger192_b64u
tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u );
# calculate digest from string/buffer
$tiger192_raw = tiger192('data string');
$tiger192_hex = tiger192_hex('data string');
$tiger192_b64 = tiger192_b64('data string');
$tiger192_b64u = tiger192_b64u('data string');
# calculate digest from file
$tiger192_raw = tiger192_file('filename.dat');
$tiger192_hex = tiger192_file_hex('filename.dat');
$tiger192_b64 = tiger192_file_b64('filename.dat');
$tiger192_b64u = tiger192_file_b64u('filename.dat');
# calculate digest from filehandle
$tiger192_raw = tiger192_file(*FILEHANDLE);
$tiger192_hex = tiger192_file_hex(*FILEHANDLE);
$tiger192_b64 = tiger192_file_b64(*FILEHANDLE);
$tiger192_b64u = tiger192_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Tiger192;
$d = Crypt::Digest::Tiger192->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Tiger192 digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Tiger192 qw(tiger192 tiger192_hex tiger192_b64 tiger192_b64u
tiger192_file tiger192_file_hex tiger192_file_b64 tiger192_file_b64u);
Or all of them at once:
use Crypt::Digest::Tiger192 ':all';
=head1 FUNCTIONS
=head2 tiger192
Logically joins all arguments into a single string, and returns its Tiger192 digest encoded as a binary string.
$tiger192_raw = tiger192('data string');
#or
$tiger192_raw = tiger192('any data', 'more data', 'even more data');
=head2 tiger192_hex
Logically joins all arguments into a single string, and returns its Tiger192 digest encoded as a hexadecimal string.
$tiger192_hex = tiger192_hex('data string');
#or
$tiger192_hex = tiger192_hex('any data', 'more data', 'even more data');
=head2 tiger192_b64
Logically joins all arguments into a single string, and returns its Tiger192 digest encoded as a Base64 string, B<with> trailing '=' padding.
$tiger192_b64 = tiger192_b64('data string');
#or
$tiger192_b64 = tiger192_b64('any data', 'more data', 'even more data');
=head2 tiger192_b64u
Logically joins all arguments into a single string, and returns its Tiger192 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$tiger192_b64url = tiger192_b64u('data string');
#or
$tiger192_b64url = tiger192_b64u('any data', 'more data', 'even more data');
=head2 tiger192_file
Reads file (defined by filename or filehandle) content, and returns its Tiger192 digest encoded as a binary string.
$tiger192_raw = tiger192_file('filename.dat');
#or
$tiger192_raw = tiger192_file(*FILEHANDLE);
=head2 tiger192_file_hex
Reads file (defined by filename or filehandle) content, and returns its Tiger192 digest encoded as a hexadecimal string.
$tiger192_hex = tiger192_file_hex('filename.dat');
#or
$tiger192_hex = tiger192_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 tiger192_file_b64
Reads file (defined by filename or filehandle) content, and returns its Tiger192 digest encoded as a Base64 string, B<with> trailing '=' padding.
$tiger192_b64 = tiger192_file_b64('filename.dat');
#or
$tiger192_b64 = tiger192_file_b64(*FILEHANDLE);
=head2 tiger192_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Tiger192 digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$tiger192_b64url = tiger192_file_b64u('filename.dat');
#or
$tiger192_b64url = tiger192_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Tiger192->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Tiger192->hashsize();
#or
Crypt::Digest::Tiger192::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/Tiger_(cryptography)>
=back
=cut

View File

@@ -0,0 +1,223 @@
package Crypt::Digest::Whirlpool;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
use base qw(Crypt::Digest Exporter);
our %EXPORT_TAGS = ( all => [qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u )] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use Crypt::Digest;
sub hashsize { Crypt::Digest::hashsize('Whirlpool') }
sub whirlpool { Crypt::Digest::digest_data('Whirlpool', @_) }
sub whirlpool_hex { Crypt::Digest::digest_data_hex('Whirlpool', @_) }
sub whirlpool_b64 { Crypt::Digest::digest_data_b64('Whirlpool', @_) }
sub whirlpool_b64u { Crypt::Digest::digest_data_b64u('Whirlpool', @_) }
sub whirlpool_file { Crypt::Digest::digest_file('Whirlpool', @_) }
sub whirlpool_file_hex { Crypt::Digest::digest_file_hex('Whirlpool', @_) }
sub whirlpool_file_b64 { Crypt::Digest::digest_file_b64('Whirlpool', @_) }
sub whirlpool_file_b64u { Crypt::Digest::digest_file_b64u('Whirlpool', @_) }
1;
=pod
=head1 NAME
Crypt::Digest::Whirlpool - Hash function Whirlpool [size: 512 bits]
=head1 SYNOPSIS
### Functional interface:
use Crypt::Digest::Whirlpool qw( whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u
whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u );
# calculate digest from string/buffer
$whirlpool_raw = whirlpool('data string');
$whirlpool_hex = whirlpool_hex('data string');
$whirlpool_b64 = whirlpool_b64('data string');
$whirlpool_b64u = whirlpool_b64u('data string');
# calculate digest from file
$whirlpool_raw = whirlpool_file('filename.dat');
$whirlpool_hex = whirlpool_file_hex('filename.dat');
$whirlpool_b64 = whirlpool_file_b64('filename.dat');
$whirlpool_b64u = whirlpool_file_b64u('filename.dat');
# calculate digest from filehandle
$whirlpool_raw = whirlpool_file(*FILEHANDLE);
$whirlpool_hex = whirlpool_file_hex(*FILEHANDLE);
$whirlpool_b64 = whirlpool_file_b64(*FILEHANDLE);
$whirlpool_b64u = whirlpool_file_b64u(*FILEHANDLE);
### OO interface:
use Crypt::Digest::Whirlpool;
$d = Crypt::Digest::Whirlpool->new;
$d->add('any data');
$d->addfile('filename.dat');
$d->addfile(*FILEHANDLE);
$result_raw = $d->digest; # raw bytes
$result_hex = $d->hexdigest; # hexadecimal form
$result_b64 = $d->b64digest; # Base64 form
$result_b64u = $d->b64udigest; # Base64 URL Safe form
=head1 DESCRIPTION
Provides an interface to the Whirlpool digest algorithm.
=head1 EXPORT
Nothing is exported by default.
You can export selected functions:
use Crypt::Digest::Whirlpool qw(whirlpool whirlpool_hex whirlpool_b64 whirlpool_b64u
whirlpool_file whirlpool_file_hex whirlpool_file_b64 whirlpool_file_b64u);
Or all of them at once:
use Crypt::Digest::Whirlpool ':all';
=head1 FUNCTIONS
=head2 whirlpool
Logically joins all arguments into a single string, and returns its Whirlpool digest encoded as a binary string.
$whirlpool_raw = whirlpool('data string');
#or
$whirlpool_raw = whirlpool('any data', 'more data', 'even more data');
=head2 whirlpool_hex
Logically joins all arguments into a single string, and returns its Whirlpool digest encoded as a hexadecimal string.
$whirlpool_hex = whirlpool_hex('data string');
#or
$whirlpool_hex = whirlpool_hex('any data', 'more data', 'even more data');
=head2 whirlpool_b64
Logically joins all arguments into a single string, and returns its Whirlpool digest encoded as a Base64 string, B<with> trailing '=' padding.
$whirlpool_b64 = whirlpool_b64('data string');
#or
$whirlpool_b64 = whirlpool_b64('any data', 'more data', 'even more data');
=head2 whirlpool_b64u
Logically joins all arguments into a single string, and returns its Whirlpool digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$whirlpool_b64url = whirlpool_b64u('data string');
#or
$whirlpool_b64url = whirlpool_b64u('any data', 'more data', 'even more data');
=head2 whirlpool_file
Reads file (defined by filename or filehandle) content, and returns its Whirlpool digest encoded as a binary string.
$whirlpool_raw = whirlpool_file('filename.dat');
#or
$whirlpool_raw = whirlpool_file(*FILEHANDLE);
=head2 whirlpool_file_hex
Reads file (defined by filename or filehandle) content, and returns its Whirlpool digest encoded as a hexadecimal string.
$whirlpool_hex = whirlpool_file_hex('filename.dat');
#or
$whirlpool_hex = whirlpool_file_hex(*FILEHANDLE);
B<BEWARE:> You have to make sure that the filehandle is in binary mode before you pass it as argument to the addfile() method.
=head2 whirlpool_file_b64
Reads file (defined by filename or filehandle) content, and returns its Whirlpool digest encoded as a Base64 string, B<with> trailing '=' padding.
$whirlpool_b64 = whirlpool_file_b64('filename.dat');
#or
$whirlpool_b64 = whirlpool_file_b64(*FILEHANDLE);
=head2 whirlpool_file_b64u
Reads file (defined by filename or filehandle) content, and returns its Whirlpool digest encoded as a Base64 URL Safe string (see RFC 4648 section 5).
$whirlpool_b64url = whirlpool_file_b64u('filename.dat');
#or
$whirlpool_b64url = whirlpool_file_b64u(*FILEHANDLE);
=head1 METHODS
The OO interface provides the same set of functions as L<Crypt::Digest>.
=head2 new
$d = Crypt::Digest::Whirlpool->new();
=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 add_bits
$d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
#or
$d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
=head2 hashsize
$d->hashsize;
#or
Crypt::Digest::Whirlpool->hashsize();
#or
Crypt::Digest::Whirlpool::hashsize();
=head2 digest
$result_raw = $d->digest();
=head2 hexdigest
$result_hex = $d->hexdigest();
=head2 b64digest
$result_b64 = $d->b64digest();
=head2 b64udigest
$result_b64url = $d->b64udigest();
=head1 SEE ALSO
=over
=item * L<CryptX|CryptX>, L<Crypt::Digest>
=item * L<https://en.wikipedia.org/wiki/Whirlpool_(cryptography)>
=back
=cut

88
database/perl/vendor/lib/Crypt/IDEA.pm vendored Normal file
View File

@@ -0,0 +1,88 @@
#! /usr/local/bin/perl -w
#
# Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
# All rights reserved.
#
package Crypt::IDEA;
$VERSION="1.10";
require Exporter;
require DynaLoader;
@ISA = (Exporter, DynaLoader);
# Items to export into callers namespace by default
@EXPORT = qw();
# Other items we are prepared to export if requested
@EXPORT_OK = qw();
bootstrap Crypt::IDEA;
$VERSION="1.10";
package IDEA;
$VERSION="1.10";
use strict;
use Carp;
sub usage
{
my ($mess, $package, $filename, $line, $subr);
($mess) = @_;
($package, $filename, $line, $subr) = caller(1);
$Carp::CarpLevel = 2;
croak "Usage: $package\::$subr - $mess";
}
sub blocksize { 8; }
sub keysize { 16; }
sub new
{
usage("new IDEA key") unless @_ == 2;
my $type = shift; my $self = {}; bless $self, $type;
$self->{'ks'} = Crypt::IDEA::expand_key(shift);
$self;
}
sub encrypt
{
usage("encrypt data[8 bytes]") unless @_ == 2;
my $self = shift;
my $data = shift;
Crypt::IDEA::crypt($data, $data, $self->{'ks'});
$data;
}
sub decrypt
{
usage("decrypt data[8 bytes]") unless @_ == 2;
my $self = shift;
my $data = shift;
#
# Cache Decrypt key schedule
#
$self->{'dks'} = Crypt::IDEA::invert_key($self->{'ks'})
unless exists $self->{'dks'};
Crypt::IDEA::crypt($data, $data, $self->{'dks'});
$data;
}
1;

87
database/perl/vendor/lib/Crypt/IDEA.pod vendored Normal file
View File

@@ -0,0 +1,87 @@
=head1 NAME
IDEA - Perl interface to IDEA block cipher
=head1 SYNOPSIS
use Crypt::IDEA;
=head1 DESCRIPTION
This perl extension is an implementation of the IDEA block cipher algorithm.
The module implements the Crypt::BlockCipher interface,
which has the following methods
=over 4
=item blocksize
=item keysize
=item encrypt
=item decrypt
=back
=head1 FUNCTIONS
=over 4
=item blocksize
Returns the size (in bytes) of the block cipher.
=item keysize
Returns the size (in bytes) of the key.
=item new
my $cipher = new IDEA $key;
This creates a new IDEA BlockCipher object, using $key,
where $key is a key of C<keysize()> bytes.
=item encrypt
my $cipher = new IDEA $key;
my $ciphertext = $cipher->encrypt($plaintext);
This function encrypts $plaintext and returns the $ciphertext
where $plaintext and $ciphertext should be of C<blocksize()> bytes.
=item decrypt
my $cipher = new IDEA $key;
my $plaintext = $cipher->decrypt($ciphertext);
This function decrypts $ciphertext and returns the $plaintext
where $plaintext and $ciphertext should be of C<blocksize()> bytes.
=back
=head1 EXAMPLE
my $key = pack("H32", "0123456789ABCDEF0123456789ABCDEF");
my $cipher = new IDEA $key;
my $ciphertext = $cipher->encrypt("plaintex"); # NB - 8 bytes
print unpack("H16", $ciphertext), "\n";
=head1 SEE ALSO
Crypt::CBD, Crypt::DES, Crypt::Blowfish
Bruce Schneier, I<Applied Cryptography>, 1995, Second Edition,
published by John Wiley & Sons, Inc.
=head1 COPYRIGHT
This implementation is copyright Systemics Ltd ( http://www.systemics.com/ ).
The IDEA algorithm is patented in Europe and the United States
by Ascom-Tech AG.
Module altered between 1999 and 2005 to allow added functionality with perl -MCPAN,
Changes by Dave Paris (edited lib paths, endian issues, new tests).
Thank you to contributors for endian patches and new test suite!

View File

@@ -0,0 +1,127 @@
package Crypt::KeyDerivation;
use strict;
use warnings;
our $VERSION = '0.069';
require Exporter; our @ISA = qw(Exporter); ### use Exporter 5.57 'import';
our %EXPORT_TAGS = ( all => [qw(pbkdf1 pbkdf2 hkdf hkdf_expand hkdf_extract)] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
1;
=pod
=head1 NAME
Crypt::KeyDerivation - PBKDF1, PBKDF2 and HKDF key derivation functions
=head1 SYNOPSIS
use Crypt::KeyDerivation ':all';
### PBKDF1/2
$derived_key1 = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
$derived_key2 = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
### HKDF & co.
$derived_key3 = hkdf($keying_material, $salt, $hash_name, $len, $info);
$prk = hkdf_extract($keying_material, $salt, $hash_name);
$okm1 = hkdf_expand($prk, $hash_name, $len, $info);
=head1 DESCRIPTION
Provides an interface to Key derivation functions:
=over
=item * PBKDF1 and PBKDF according to PKCS#5 v2.0 L<https://tools.ietf.org/html/rfc2898|https://tools.ietf.org/html/rfc2898>
=item * HKDF (+ related) according to L<https://tools.ietf.org/html/rfc5869|https://tools.ietf.org/html/rfc5869>
=back
=head1 FUNCTIONS
=head2 pbkdf1
B<BEWARE:> if you are not sure, do not use C<pbkdf1> but rather choose C<pbkdf2>.
$derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name, $len);
#or
$derived_key = pbkdf1($password, $salt, $iteration_count, $hash_name);
#or
$derived_key = pbkdf1($password, $salt, $iteration_count);
#or
$derived_key = pbkdf1($password, $salt);
# $password ......... input keying material (password)
# $salt ............. salt/nonce (expected length: 8)
# $iteration_count .. optional, DEFAULT: 5000
# $hash_name ........ optional, DEFAULT: 'SHA256'
# $len .............. optional, derived key len, DEFAULT: 32
=head2 pbkdf2
$derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name, $len);
#or
$derived_key = pbkdf2($password, $salt, $iteration_count, $hash_name);
#or
$derived_key = pbkdf2($password, $salt, $iteration_count);
#or
$derived_key = pbkdf2($password, $salt);
# $password ......... input keying material (password)
# $salt ............. salt/nonce
# $iteration_count .. optional, DEFAULT: 5000
# $hash_name ........ optional, DEFAULT: 'SHA256'
# $len .............. optional, derived key len, DEFAULT: 32
=head2 hkdf
$okm2 = hkdf($password, $salt, $hash_name, $len, $info);
#or
$okm2 = hkdf($password, $salt, $hash_name, $len);
#or
$okm2 = hkdf($password, $salt, $hash_name);
#or
$okm2 = hkdf($password, $salt);
# $password ... input keying material (password)
# $salt ....... salt/nonce, if undef defaults to HashLen zero octets
# $hash_name .. optional, DEFAULT: 'SHA256'
# $len ........ optional, derived key len, DEFAULT: 32
# $info ....... optional context and application specific information, DEFAULT: ''
=head2 hkdf_extract
$prk = hkdf_extract($password, $salt, $hash_name);
#or
$prk = hkdf_extract($password, $salt, $hash_name);
# $password ... input keying material (password)
# $salt ....... salt/nonce, if undef defaults to HashLen zero octets
# $hash_name .. optional, DEFAULT: 'SHA256'
=head2 hkdf_expand
$okm = hkdf_expand($pseudokey, $hash_name, $len, $info);
#or
$okm = hkdf_expand($pseudokey, $hash_name, $len);
#or
$okm = hkdf_expand($pseudokey, $hash_name);
#or
$okm = hkdf_expand($pseudokey);
# $pseudokey .. input keying material
# $hash_name .. optional, DEFAULT: 'SHA256'
# $len ........ optional, derived key len, DEFAULT: 32
# $info ....... optional context and application specific information, DEFAULT: ''
=cut

45
database/perl/vendor/lib/Crypt/Mac.pm vendored Normal file
View File

@@ -0,0 +1,45 @@
package Crypt::Mac;
use strict;
use warnings;
our $VERSION = '0.069';
use Carp;
$Carp::Internal{(__PACKAGE__)}++;
use CryptX;
sub addfile {
my ($self, $file) = @_;
my $handle;
if (ref(\$file) eq 'SCALAR') {
open($handle, "<", $file) || die "FATAL: cannot open '$file': $!";
binmode($handle);
}
else {
$handle = $file
}
die "FATAL: invalid handle" unless defined $handle;
my $n;
my $buf = "";
local $SIG{__DIE__} = \&CryptX::_croak;
while (($n = read($handle, $buf, 32*1024))) {
$self->add($buf);
}
die "FATAL: read failed: $!" unless defined $n;
return $self;
}
sub CLONE_SKIP { 1 } # prevent cloning
1;
=pod
=head1 NAME
Crypt::Mac - [internal only]
=cut

View File

@@ -0,0 +1,147 @@
package Crypt::Mac::BLAKE2b;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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>
=back
=cut

View File

@@ -0,0 +1,147 @@
package Crypt::Mac::BLAKE2s;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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>
=back
=cut

145
database/perl/vendor/lib/Crypt/Mac/F9.pm vendored Normal file
View File

@@ -0,0 +1,145 @@
package Crypt::Mac::F9;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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

View File

@@ -0,0 +1,164 @@
package Crypt::Mac::HMAC;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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');
# $hash_name ... any <NAME> for which there exists Crypt::Digest::<NAME>
# $key ......... the key (octets/bytes)
=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');
# $hash_name ... any <NAME> for which there exists Crypt::Digest::<NAME>
# $key ......... the key (octets/bytes, not hex!)
=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');
# $hash_name ... any <NAME> for which there exists Crypt::Digest::<NAME>
# $key ......... the key (octets/bytes, not Base64!)
=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');
# $hash_name ... any <NAME> for which there exists Crypt::Digest::<NAME>
# $key ......... the key (octets/bytes, not Base64url!)
=head1 METHODS
=head2 new
$d = Crypt::Mac::HMAC->new($hash_name, $key);
# $hash_name ... any <NAME> for which there exists Crypt::Digest::<NAME>
# $key ......... the key (octets/bytes)
=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>
=item * L<https://tools.ietf.org/html/rfc2104>
=back
=cut

View File

@@ -0,0 +1,147 @@
package Crypt::Mac::OMAC;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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>
=back
=cut

View File

@@ -0,0 +1,147 @@
package Crypt::Mac::PMAC;
### BEWARE - GENERATED FILE, DO NOT EDIT MANUALLY!
use strict;
use warnings;
our $VERSION = '0.069';
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();
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>
=back
=cut

Some files were not shown because too many files have changed in this diff Show More