Documente Academic
Documente Profesional
Documente Cultură
* Key space Effective key space Classical cryptosystems Caesar Affine cipher Vigenre system One time pad (Vernam) Attacks: * Brute force attack * frequency analysis * dictionary attack
Key space
Key space = the set of all possible encryption keys In best encryption algorithms the most effective attack is the Brute Force attack, where the enemy performs a complete search through all possible keys of the key space to find the right one. In 2006 a secure size for a key space is considered to be > 80 bits The standard block cipher DES had only 64 ( effectively only 56). That is why DES is no more safe (if it ever has been that.) Even though the key size is 128 bits, the effective key space can be much less, if the encryption algorithm is not well planned ( = for a given cipher text, not all keys are equally probable). In less successful encryption algorithms, output of the algorithm is not random enough. ( f.e there are more ones than zeros, there can be runs of ones.)
Randomness cont
1001101011100100001011001010101001
P = 1 / 16 P = 1/ 4 P=1/8
P = 1/2
In addition to the randomness of the cipher bits a property of a good algorithm is that changing one of the message bits should cause lots of changes ( 50 %) in the output sequence.
There is an attack called differential cryptoanalysis, which tries to analyze how different bits affect the output. If only a few bits would be changed, then the algorithm could be vulnerable.
DES
DES block cipher was created by IBM in cooperation with NSA 1977 for purposes of US administration and business. It was the world standard from 1977 to 2001 (and is still used). Good in DES Its output sequence satisfies excellently the randomness postulates of Golomb => It can be used for creating hash values of passwords ( Unix passwd). It can also be used as a pseudorandom generator. Faults of DES: * too short key (effective key space 56 bits) * the leaking of the code made every cryptoanalyst in the world try breaking it
Exercise: Calculate the effective key space size A password is 8 characters long and it contains only English letters (26).
Assuming that a password can contain English letters + numbers 0 -9, how long it must at least be to be safe ( safety limit is 80 bits)
Hackers use very often the dictionary attack, which is based on lists of most common passwords. Unfortunately the key space of a company network too often consists of the names of the family members or petty animals of the users.
Classical cryptosystems
1. 2. 3. 4. 5. Caesar cipher Caesar affine cipher Random substitution Vigenre cipher One Time Pad (the only unbreakable cipher, Vernam 1919)
1. Caesar cipher
Cipher is based on a rotation of alphabet by k , which is the key The Romans used for encryption a substitution table: alphabet in the first row and shifted alphabet on the second row substitution table for k = 7 a b c d e f g h i j k l m n o p q r s t u v w x y z h i j k l m nopq r s t u v w xy z a bc d e f g
The key space size is 25 Decryption algorithm is the same, but with key k = - 7
Modern computer version encodes first characters into numbers and performs rotation using modular arithmetic.
message
rovaniemi
17 14 21 0 13 8 4 12 8
+ 7 mod 26
24 21 2 7 20 15 11 19 15
cipher
yvchupltp
Decryption: 1. Map the cipher characters to numbers : a = 0, , z = 25 2. Decrypt the number sequence c using m = a-1*c +a-1*b mod 26 where a-1 is the multiplicative inverse of a mod 26 3. Map the numbers back to characters
message
rovaniemi
17 14 21 0 13 8 4 12 8 c = 7 m + 3 mod 26 0 23 20 3 16 7 5 9 7
Example: encryption of letter o O encodes to 14 7*14 + 3 mod 26 = 101 mod 26 = 23 which decodes to x
cipher
axudqhf jh
8x, 1, 25<D
When x has value 15, we have 7*x = 1 => number 15 is the inverse.
3. Random substitution
We can use also a random permutation of alphabet for encryption. Decryption is made with the same table using the inverse permutation
Out[28]//MatrixForm=
a b c d e f g h i j k l m n o p q r s t u v w x y z N y g k n c q o u x z l r a f t m e p i s b w d h j v
Now the key space is n ! , where n is the size of the alphabet. F.E if n = 26, the key space is 4 *1026, which is bigger than 80 bits.
However each character always maps into the same image character, and the cipher is easy to break with frequency analysis.
4. Vigenre cipher
Blaise de Vigenre (April 5, 1523 - 1596) was a French diplomat and cryptographer.
Vigenre Algorithm (modern version to be used with computers): 1. Encode the message into a number sequence (of numbers 0 25) 2. Repeat the keyword to produce a string of length of the message. Encode the string into a number sequence 3. Add sequences using vector addition mod 26. 4. Decode the sum vector into characters to obtain the cipher
Decryption is done similarly. Only difference is that in decryption the key sequence is subtracted from the cipher.
message
rovaniemi
key
oulu
17 14 21 0 13 8 4 12 8 14 20 11 20 14 20 11 20 14 Addition mod 26 5 8 6 20 1 2 15 6 22
14 20 11 20
cipher
Vigenres cipher was considered unbreakable until 1863, when a Prussian officer Friedrich Kasiski found a test, which helped to determine the length of the key word.
Kasiski test needs a lot of ciphertexts encrypted with the same password.
If in the ciphertexts appears the same character or the same group of characters in several positions with distances D, it is very likely that D is a multiple of the key word length. ( see Wikipedia: Vigenere, Kasiski )
If we manage to find the key word length n, then it is not very difficult to break the cipher, because the cryptoanalysis is then equivalent with the cryptoanalysis of n Caesar ciphers. Breaking can be done with frequency analysis.
m = c + k mod 2
( m = ck )
If the key k is a completely random bit string of the same length as the message, and each key is used only once, we have a provably 100% secure encryption system. This system is called One Time Pad. It was used between Moscow and Washington during the cold war.
The security of One Time Pad is obvious, because For any binary cipher text c and every possible binary message m there is a binary key string k with property c=mk
* Searching all possible key strings we obtain the set of all possible meaningful and meaningless messages and there is no way of determining which one is right. But if we use same key twice, the Brute Force attack works and the key can be revealed.
1 1 0
0 0 0
0 1 1
1 1 0
1 0 1
0 1 1
1 0 1
0 0 0
0 0 0
0 1 1
1 0 1
1 1 0
0 1 1
1 0 1
1 1 0
0 0 0
cipher
10
yvchupltp
Method: Try all possible keys 1 25 . The key that gives a meaningful message is right.
In[40]:=
Out[40]=
, rovaniemi , , , <
The string number 7 - rovaniemi - is the only sensible word => The message is rovaniemi and key = 7.
Examples of cryptoanalysis:
Hypothesis: Character e maps to p => The key k = 11 Trial of decryption of the ciphertext with key 11 gives:
11
Computer exercises
1. Implement with Mathematica a) Caesar encryption and decryption b) Affine encryption and decryption c) Vigenere encryption and decryption algorithm d) One Time Pad with binary messages
lbokusxqmvkccsmkvoxmbizdsyxcicdowcsc wybookcidrkdlbokusxqwynobxmszrobc
12