Jul 19, 2008

Affine Cipher

The Affine cipher is a special case of the more general monoalphabetic substitution cipher. In affine ciphers the encryption function for a letter is e(x) = (ax + b)(mod m) where,
• a and m are coprime (otherwise a would have no multiplicative inverse modulo m).
• m is the size of the alphabet.
The decryption function is d(x) = a − 1(e(x) − b)(mod m) where a − 1 is the multiplicative inverse of a in the group
Considering the specific case of encrypting messages in English (i.e. m = 26), there are a total of 286 non-trivial affine ciphers, not counting the trivial Caesar ciphers obtained when a = 1. This lack of variety renders the system as highly insecure when considered in light of Kerckhoffs' Principle. Even without foreknowledge that a text were enciphered with an affine cipher, the ciphertext would have all of the vulnerabilities of ordinary monoalphabetic substitution ciphers.
The cipher's primary weakness comes from the fact that if the cryptanalyst can discover (by means of frequency analysis, brute force, guessing or otherwise) the plaintext of two ciphertext characters then the key can be obtained by solving a simultaneous equation. Since we know a and m are relatively prime this can be used to rapidly discard many "false" keys in an automated system.
The same type of transformation used in affine ciphers is used in linear congruential generators, a type of pseudorandom number generator. This generator is not a cryptographically secure pseudorandom number generator for the same reason that the affine cipher is not secure.

No comments: