This page lists commonly used cryptographic algorithms and methods, and tries to give references to implementations and textbooks. Where available, comments are also made about the usefulness or other aspects of the algorithms. The comments should be interpreted as the author's subjective opinion and should not be considered authoritative in any way.
Public key algorithms use a different key for encryption and decryption, and the decryption key cannot (practically) be derived from the encryption key. Public key methods are important because they can be used to transmit encryption keys or other data securely even when the parties have no opportunity to agree on a secret key in private. All known methods are quite slow, and they are usually only used to encrypt session keys (randomly generated "normal" keys), that are then used to encrypt the bulk of the data using a symmetric cipher (see below).
For information on the recommended key lengths for RSA, see the article by Bruce Schneier. At present, 512 bit keys are considered weak, 1024 bit keys are probably secure enough for most purposes, and 2048 bit keys are likely to remain secure for decades.
One should know that RSA is very vulnerable to chosen plaintext attacks. There is also a new timing attack that can be used to break many implementations of RSA. The RSA algorithm is believed to be safe when used properly, but one must be very careful when using it to avoid these attacks.
Many implementations of RSA are freely available. See e.g. RSAREF , RSAEURO, SSLeay, PGP source code, Ssh source code, and the Crypto++ library. See also ftp.funet.fi:/pub/crypt/cryptography/asymmetric/rsa.
For more information, see e.g.
Diffie-Hellman is sensitive to the choice of the strong prime and the generator. One possible prime/generator pair is suggested in the Photuris draft. The size of the secret exponent is also important for its security. Conservative advice is to make the random exponent twice as long as the intended session key.
One should note the results presented in Brian A. LaMacchia and Andrew M. Odlyzko, Computation of Discrete Logarithms in Prime Fields, Designs, Codes and Cryptography 1 (1991), 47-62. Basically, they conclude that by doing precomputations, it is possible to compute discrete logarithms relative to a particular prime efficiently. The work needed for the precomputation is approximately equal or slightly higher than the work needed for factoring a composite number of the same size. In practice this means that if the same prime is used for a large number of exchanges, it should be larger than 512 bits in size, preferably 1024 bits.
There is also a new timing attack that can be used to break many implementations of Diffie-Hellman.
Many implementations of Diffie-Hellman are freely available. See e.g. RSAREF, RSAEURO, SSLeay, alodes, or Crypto++.
For further information, see e.g.
Elliptic curve public key cryptosystems is an emerging field. They have been slow to execute, but have become feasible with modern computers. They are considered to be fairly secure, but haven't yet undergone the same scrutiny as for example RSA.
For further information, see e.g.
Several public domain implementations are available. See e.g. the eliptic package.
There should be no reason whatsoever to use DSS for anything (with the potential exclusion of US government contracts) since better methods are widely available. DSS source code is included in in the Crypto++ library.
Source code can be found in ftp.funet.fi:/pub/crypt/cryptography/asymmetric/luc and is included in the Crypto++ library.
Secret key algorithms use a the same key for both encryption and decryption (or the other is easily derivable from the other).
DES is a block cipher with 64-bit block size. It uses 56-bit keys. This makes it fairly easy to break with modern computers or special-purpose hardware. DES is still strong enough to keep most random hackers and individuals out, but it is easily breakable with special hardware by government, criminal organizations, or major corporations. In large volumes, the cost of beaking DES keys is on the order of tens of dollars. DES is getting too weak, and should not be used in new designs.
A variant of DES, Triple-DES or 3DES is based on using DES three times (normally in an encrypt-decrypt-encrypt sequence with three different, unrelated keys). Many people consider Triple-DES to be much safer than plain DES.
Implementations of DES can be found e.g. in the libdes, alodes, SSLeay, Crypto++, descore, chalmers-des, and destoo libraries.
Blowfish is used in a number of popular software packages, including Nautilus and PGPfone. Implementations of Blowfish can be found e.g. in the Crypto++ library, and here.
IDEA is patented in the United States and in most of the European countries. The patent is held by Ascom-Tech. Non-commercial use of IDEA is free. Commercial licenses can be obtained by contacting idea@ascom.ch.
Several implementations of IDEA are freely available. See e.g. SSLeay, PGP source code, and Ssh source code, idea86, Crypto++.
Source code and information about RC4 can be found here and in many cryptographic libraries, e.g. SSLeay, Crypto++, and Ssh source code.
The United States government routinely approves RC4 with 40 bit keys for export. Keys that are this small can be easily broken by governments, criminals, and amateurs.
It is interesting to know that the exportable version of SSL (Netscape's Secure Socket Layer), which uses RC4-40, was recently broken by at least two independent groups. Breaking it took about eight days; in many major universities (or companies) the corresponding amount of computing power is available to any computer science major. More information about the incident can be found on Damien Doligez's SSL cracking page , and a collection of various articles is in a local file.
An analysis of SAFER-K64 was presented in Crypto'95 and is in the proceedings.
An example of a hash-based cipher is MDC/SHA; code can be found e.g. in the Crypto++ library.
These and a number of other ciphers are available from ftp.funet.fi:/pub/crypt/cryptography/symmetric .
Many commonly used ciphers (e.g., IDEA, DES, BLOWFISH) are block ciphers. This means that they take a fixed-size block of data (usually 64 bits), an transform it to another 64 bit block using a function selected by the key. The cipher basically defines a one-to-one mapping from 64-bit integers to another permutation of 64-bit integers.
If the same block is encrypted twice with the same key, the resulting ciphertext blocks are the same (this method of encryption is called Electronic Code Book mode, or ECB). This information could be useful for an attacker.
In practical applications, it is desirable to make identical plaintext blocks encrypt to different ciphertext blocks. Two methods are commonly used for this:
The previous ciphertext block is usually stored in an Initialization Vector (IV). An initialization vector of zero is commonly used for the first block, though other arrangements are also in use.
More information on cipher modes can be found e.g. in Bruce Schneier: Applied Cryptography, John Wiley & Sons, 1994.
However, some people have reported potential weaknesses in it, and "keyed MD5" (typically used for authentication by having a shared secret, and computing an authentication value by hashing first the secret (as a key), and then the data to be hashed) has been reported to be broken. It is also reported that one could build a special-purpose machine costing a few million dollars to find a plaintext matching given hash value in a few weeks.
MD5 is available from ftp.funet.fi:/pub/crypt/hash/mds/md5 . It is also included in PGP source code, SSLeay, RSAREF, Crypto++, and Ssh source code. MD5 is described e.g. in Bruce Schneier: Applied Cryptography, John Wiley & Sons, 1994.
SHA is available from ftp.funet.fi:/pub/crypt/hash/sha, and is included in many cryptographic libraries, such as Crypto++.
Cryptographic systems need cryptographically strong random numbers that cannot be guessed by an attacker. Random numbers are typically used to generate session keys, and their quality is critical for the quality of the resulting systems. The random number generator is easily overlooked, and becomes the weakest point of the system.
Some machines may have special purpose hardware noise generators. Noise from the leak current of a diode or transistor, least significant bits of audio inputs, times between interrupts, etc. are all good sources of randomness when processed with a suitable hash function. It is a good idea to acquire true environmental noise whenever possible.
Examples of cryptographic random number generators can be found e.g. in PGP source code, Noiz, and Ssh source code.
Disclaimer: Any opinions and evaluations presented here are speculative, and the author cannot be held responsible for their correctness.