|
Module Cryptokit.Ciphermodule Cipher:
The
Cipher module implements the AES, DES, Triple-DES and ARCfour
symmetric ciphers. Symmetric ciphers are presented as transforms
parameterized by a secret key and a ``direction'' indicating
whether encryption or decryption is to be performed.
The same secret key is used for encryption and for decryption.type direction =
type chaining_mode =
val aes :
AES is the Advanced Encryption Standard, also known as Rijndael.
This is a modern block cipher, recently standardized.
It processes data by blocks of 128 bits (16 bytes),
and supports keys of 128, 192 or 256 bits.
The string argument is the key; it must have length 16, 24 or 32.
The direction argument specifies whether encryption or decryption
is to be performed.
The optional
The optional
The optional
The val des :
DES is the Data Encryption Standard. Probably still the
most widely used cipher today, although it can be broken
relatively easily by brute force, due to its small key size (56 bits).
It should therefore be considered as weak encryption.
Its block size is 64 bits (8 bytes).
The arguments to the
des function have the same meaning as
for the Cryptokit.Cipher.aes function. The key argument is
a string of length 8 (64 bits); the least significant bit of
each key byte is ignored.val triple_des :
Triple DES with two or three DES keys.
This is a popular variant of DES
where each block is encrypted with a 56-bit key
k1 ,
decrypted with another 56-bit key k2 , then re-encrypted with
either k1 or a third 56-bit key k3 .
This results in a 112-bit or 168-bit key length that resists
brute-force attacks. However, the three encryptions required
on each block make this cipher quite slow (4 times slower than
AES). The arguments to the triple_des function have the
same meaning as for the Cryptokit.Cipher.aes function. The
key argument is a string of length 16 or 24, representing the
concatenation of the key parts k1 , k2 , and optionally
k3 . The least significant bit of each key byte is
ignored.val arcfour :
ARCfour (``alleged RC4'') is a fast stream cipher
that appears to produce equivalent results with the commercial
RC4 cipher from RSA Data Security Inc. This company holds the
RC4 trademark, and sells the real RC4 cipher. So, it is prudent
not to use ARCfour in a commercial product.
ARCfour is popular for its speed: approximately 2 times faster than AES. It accepts any key length up to 2048 bits. The ARCfour cipher is a stream cipher, not a block cipher. Hence, its natural block size is 1, and no padding is required. Chaining modes do not apply. A feature of stream ciphers is that the xor of two ciphertexts obtained with the same key is the xor of the corresponding plaintexts, which allows various attacks. Hence, the same key must never be reused.
The string argument is the key; its length must be between
1 and 256 inclusive. The direction argument is present for
consistency with the other ciphers only, and is actually
ignored: for all stream ciphers, decryption is the same
function as encryption. |