1CAST5_PP(3)           User Contributed Perl Documentation          CAST5_PP(3)
2
3
4

NAME

6       Crypt::CAST5_PP - CAST5 block cipher in pure Perl
7

SYNOPSIS

9           use Crypt::CBC;
10
11           my $crypt = Crypt::CBC->new({
12               key    => "secret key",
13               cipher => "CAST5_PP",
14           });
15
16           my $message = "All mimsy were the borogoves";
17           my $ciphertext = $crypt->encrypt($message);
18           print unpack("H*", $ciphertext), "\n";
19
20           my $plaintext = $crypt->decrypt($ciphertext);
21           print $plaintext, "\n";
22

DESCRIPTION

24       This module provides a pure Perl implementation of the CAST5 block
25       cipher.  CAST5 is also known as CAST-128. It is a product of the CAST
26       design procedure developed by C. Adams and S. Tavares.
27
28       The CAST5 cipher is available royalty-free.
29

FUNCTIONS

31   blocksize
32       Returns the CAST5 block size, which is 8 bytes. This function exists so
33       that Crypt::CAST5_PP can work with Crypt::CBC.
34
35   keysize
36       Returns the maximum CAST5 key size, 16 bytes.
37
38   new
39           $cast5 = Crypt::CAST5_PP->new($key);
40
41       Create a new encryption object. If the optional key parameter is given,
42       it will be passed to the init() function.
43
44   init
45           $cast5->init($key);
46
47       Set or change the encryption key to be used. The key must be from 40
48       bits (5 bytes) to 128 bits (16 bytes) in length. Note that if the key
49       used is 80 bits or less, encryption and decryption will be somewhat
50       faster.
51
52       It is best for the key to be random binary data, not something
53       printable like a password. A message digest function may be useful for
54       converting a password to an encryption key; see Digest::SHA1 or
55       Digest::MD5.  Note that Crypt::CBC runs the given "key" through MD5 to
56       get the actual encryption key.
57
58   encrypt
59           $ciphertext = $cast5->encrypt($plaintext);
60
61       Encrypt a block of plaintext using the current encryption key, and
62       return the corresponding ciphertext. The input must be 8 bytes long,
63       and the output has the same length. Note that the encryption is in ECB
64       mode, which means that it encrypts each block independently. That can
65       leave you vulnerable to dictionary attacks, so it is generally best to
66       use some form of chaining between blocks; see Crypt::CBC.
67
68   decrypt
69           $plaintext = $cast5->decrypt($ciphertext);
70
71       Decrypt the ciphertext and return the corresponding plaintext.
72

LIMITATIONS

74       Always produces untainted output, even if the input is tainted, because
75       that's what perl's pack() function does.
76

SEE ALSO

78       RFC 2144, "The CAST-128 Encryption Algorithm", C. Adams, May 1997
79
80       Crypt::CBC
81

AUTHOR

83       Bob Mathews, <bobmathews@alumni.calpoly.edu>
84
86       Copyright (c) 2006 Bob Mathews. All rights reserved.  This program is
87       free software; you can redistribute it and/or modify it under the same
88       terms as Perl itself.
89
90
91
92perl v5.28.1                      2006-07-01                       CAST5_PP(3)
Impressum