1package Crypt::CAST5;
2
3require 5.004;
4use strict;
5use DynaLoader;
6
7use vars qw( $VERSION @ISA );
8
9$VERSION = "0.05";
10@ISA = qw( DynaLoader );
11
12bootstrap Crypt::CAST5 $VERSION;
13
141 # end Crypt::CAST5
15__END__
16
17=head1 NAME
18
19Crypt::CAST5 - CAST5 block cipher
20
21=head1 SYNOPSIS
22
23    use Crypt::CBC;
24
25    my $crypt = Crypt::CBC->new({
26        key    => "secret key",
27        cipher => "CAST5",
28    });
29
30    my $message = "All mimsy were the borogoves";
31    my $ciphertext = $crypt->encrypt($message);
32    print unpack("H*", $ciphertext), "\n";
33
34    my $plaintext = $crypt->decrypt($ciphertext);
35    print $plaintext, "\n";
36
37=head1 DESCRIPTION
38
39This module provides an implementation of the CAST5 block cipher using
40compiled C code for increased speed. CAST5 is also known as CAST-128. It
41is a product of the CAST design procedure developed by C. Adams and
42S. Tavares.
43
44The CAST5 cipher is available royalty-free.
45
46=head1 FUNCTIONS
47
48=head2 blocksize
49
50Returns the CAST5 block size, which is 8 bytes. This function exists
51so that Crypt::CAST5 can work with Crypt::CBC.
52
53=head2 keysize
54
55Returns the maximum CAST5 key size, 16 bytes.
56
57=head2 new
58
59    $cast5 = Crypt::CAST5->new($key);
60
61Create a new encryption object. If the optional key parameter is given,
62it will be passed to the init() function.
63
64=head2 init
65
66    $cast5->init($key);
67
68Set or change the encryption key to be used. The key must be from 40 bits
69(5 bytes) to 128 bits (16 bytes) in length. Note that if the key used is
7080 bits or less, encryption and decryption will be somewhat faster.
71
72It is best for the key to be random binary data, not something printable
73like a password. A message digest function may be useful for converting
74a password to an encryption key; see L<Digest::SHA1> or L<Digest::MD5>.
75Note that Crypt::CBC runs the given "key" through MD5 to get the actual
76encryption key.
77
78=head2 encrypt
79
80    $ciphertext = $cast5->encrypt($plaintext);
81
82Encrypt a block of plaintext using the current encryption key, and return
83the corresponding ciphertext. The input must be 8 bytes long, and the output
84has the same length. Note that the encryption is in ECB mode, which means
85that it encrypts each block independently. That can leave you vulnerable
86to dictionary attacks, so it is generally best to use some form of chaining
87between blocks; see L<Crypt::CBC>.
88
89=head2 decrypt
90
91    $plaintext = $cast5->decrypt($ciphertext);
92
93Decrypt the ciphertext and return the corresponding plaintext.
94
95=head1 SEE ALSO
96
97RFC 2144, "The CAST-128 Encryption Algorithm", C. Adams, May 1997
98
99L<Crypt::CBC>
100
101=head1 AUTHOR
102
103Bob Mathews, E<lt>bobmathews@alumni.calpoly.eduE<gt>
104
105=head1 COPYRIGHT AND LICENSE
106
107Copyright (C) 2002-2006 Bob Mathews
108
109This library is free software; you can redistribute it and/or modify
110it under the same terms as Perl itself.
111
112=cut
113
114