Debian Codegraph @

Doc/src/cipher/cast.rst

raw
1 CAST-128
2 ========
3
4 .. warning::
5 Use :doc:`aes`. This module is provided only for legacy purposes.
6
7 CAST-128_ (or CAST5) is a symmetric block cipher specified in RFC2144_.
8
9 It has a fixed data block size of 8 bytes. Its key can vary in length
10 from 40 to 128 bits.
11
12 CAST is deemed to be cryptographically secure, but its usage is not widespread.
13 Keys of sufficient length should be used to prevent brute force attacks
14 (128 bits are recommended).
15
16 As an example, encryption can be done as follows:
17
18 >>> from Crypto.Cipher import CAST
19 >>>
20 >>> key = b'Sixteen byte key'
21 >>> cipher = CAST.new(key, CAST.MODE_OPENPGP)
22 >>> plaintext = b'sona si latine loqueris '
23 >>> msg = cipher.encrypt(plaintext)
24 >>>
25 ...
26 >>> eiv = msg[:CAST.block_size+2]
27 >>> ciphertext = msg[CAST.block_size+2:]
28 >>> cipher = CAST.new(key, CAST.MODE_OPENPGP, eiv)
29 >>> print cipher.decrypt(ciphertext)
30
31 .. _CAST-128: http://en.wikipedia.org/wiki/CAST-128
32 .. _RFC2144: http://tools.ietf.org/html/rfc2144
33
34 .. automodule:: Crypto.Cipher.CAST
35 :members: