1package Crypt::Shark; 2 3use strict; 4use warnings; 5require Exporter; 6 7our @EXPORT_OK = qw(keysize blocksize new encrypt decrypt); 8our $VERSION = '1.0.1'; 9our @ISA = qw(Exporter); 10 11require XSLoader; 12XSLoader::load('Crypt::Shark', $VERSION); 13 14# Preloaded methods go here. 15 161; 17 18__END__ 19 20=head1 NAME 21 22Crypt::Shark - Crypt::CBC compliant block cipher 23 24=head1 ABSTRACT 25 26Shark is 64-bit block cipher that accepts a 128-bit key. 27 28=head1 SYNOPSIS 29 30 use Crypt::Shark; 31 32 $cipher = new Crypt::Shark $key; 33 $ciphertext = $cipher->encrypt($plaintext); 34 $plaintext = $cipher->decrypt($ciphertext); 35 36=head1 DESCRIPTION 37 38Shark is 64-bit block cipher that accepts a 128-bit key. It was 39designed by Vincent Rijmen, Joan Daemen, Bart Preneel, Antoon 40Bosselaers, and Erik De Win. 41 42This module supports the Crypt::CBC interface, with the following 43functions. 44 45=head2 Functions 46 47=over 48 49=item B<blocksize> 50 51Returns the size (in bytes) of the block (8, in this case). 52 53=item B<keysize> 54 55Returns the size (in bytes) of the key (16, in this case). 56 57=item B<encrypt($data)> 58 59Encrypts 8 bytes of $data and returns the corresponding ciphertext. 60 61=item B<decrypt($data)> 62 63Decrypts 8 bytes of $data and returns the corresponding plaintext. 64 65=back 66 67=head1 EXAMPLE 1 68 69 #!/usr/local/bin/perl 70 71 use diagnostics; 72 use strict; 73 use warnings; 74 use Crypt::Shark; 75 76 # key must be 16 bytes long 77 my $key = "0123456789abcdef"; 78 79 my $cipher = new Crypt::Shark $key; 80 81 print "blocksize = ", $cipher->blocksize, " bytes \n"; 82 print "keysize = ", $cipher->keysize, " bytes \n"; 83 84 # block must be 8 bytes long 85 my $plaintext1 = "01234567"; 86 87 my $ciphertext = $cipher->encrypt($plaintext1); 88 my $plaintext2 = $cipher->decrypt($ciphertext); 89 90 print "Decryption OK\n" if ($plaintext1 eq $plaintext2); 91 92=head1 EXAMPLE 2 93 94 #!/usr/local/bin/perl 95 96 use diagnostics; 97 use strict; 98 use warnings; 99 use Crypt::CBC; # CBC automatically loads Shark for us 100 101 # when using Crypt::CBC, key may be of ANY length 102 my $key = "0123456789abcdef"; 103 104 # IV must be exactly 16 bytes long 105 my $IV = pack "H16", 0; 106 107 my $cipher = Crypt::CBC->new({'key' => $key, 108 'cipher' => 'Shark', 109 'iv' => $IV, 110 'regenerate_key' => 1, 111 'padding' => 'standard', 112 'prepend_iv' => 0 113 }); 114 115 # when using Crypt::CBC, plaintext may be of ANY length 116 my $plaintext1 = "This is a test"; 117 118 my $ciphertext = $cipher->encrypt($plaintext1); 119 my $plaintext2 = $cipher->decrypt($ciphertext); 120 121 print "Decryption OK\n" if ($plaintext1 eq $plaintext2); 122 123=head1 MORE EXAMPLES 124 125See B<Crypt::CBC> for more examples using CBC mode. See also the 126"examples" and "t" directories for some more examples. 127 128=head1 SEE ALSO 129 130B<Crypt::Khazad>, B<Crypt::Misty1>, B<Crypt::Anubis>, 131B<Crypt::Noekeon>, B<Crypt::Skipjack>, B<Crypt::Camellia>, 132B<Crypt::Square>, and B<Crypt::Rainbow>. 133 134=head1 COPYRIGHT AND LICENSE 135 136Copyright 2003 by Julius C. Duque. Please read B<contact.html> that 137comes with this distribution for details on how to contact the author. 138 139This library is free software; you can redistribute it and/or modify 140it under the same terms as the GNU General Public License. 141 142=cut 143 144