Cryptography: Michigan State University Computer Science and Engineering
Cryptography: Michigan State University Computer Science and Engineering
CSE 825
Cryptography, as covered in the text, seems worth spending some class time on
Given a sufficiently large encoded message, it can readily be "cracked" by comparing the frequency of letter occurrences in the coded message with the frequency of letter occurrences in the language used for the message. Graph of letter frequencies the English language
0.140 0.120
0.082 0.127 0.091
0.075
0.070
0.067
0.063
0.061
0.028
0.028
0.024
0.023
0.022
0.020
0.020
0.019
0.015
0.010
0.008
0.002
0.001
0.001
0.001
Improvements
Stream cipher:
encryption rule depends on the plaintext symbols position in the stream of plaintext symbols
Block cipher:
encrypt several plaintext symbols at once in a block
Stream
As the name implies, you generate a long stream of ciphertext from a shorter key.
Method 1 Using key LUCKY to encode first two letters CO 1. Select rows LU 2. Select cols CO 3. Result is NI
Method 2 Use key LUCKY to select rows in order Then use only those rows for the table (next slide)
Method 2 (cont) Key LUCKY is in the repeated rows Use plaintext for column and then use rows one at a time (next slide)
Michigan State University Computer Science and Engineering
To encode the first letter C we use the row of the code indicated by the arrow and the column indicated by the arrow; Hence the letter N is substituted for C.
The next letter to be encoded is O. We now use the second shifted alphabet from the code table and the column headed by the letter O.
Note that the letter I in the message corresponds to four different letters in the encoded message (i.e. a stream cipher). Also in the encoded message the letter E was substituted for two different letters of the original message. Such many-to-one substitutions make letter frequency counting much more difficult.
The text describes the same process mathematically and much more simply:
C = P + K mod 26
Where
P = alphabetic position of plaintext character K = alphabetic position of key character C = alphabetic position of cipher character
One-Time Pad
Since repetition is a weakness, one solution is for the key sequence to be as long as the plaintext and to never repeat. The one-time pad (WWI) can provide that. Encryption/Decryption is simply an XOR of the plaintext stream with the keystream.
Perfect Secrecy
A cipher has perfect secrecy if and only if there are as many possible keys as possible plaintexts, and if every key is equally likely. The one-time pad is the only one which provides perfect secrecy (Shannon).
Michigan State University Computer Science and Engineering
Expansion
Key distribution is expensive for one-time pads so it is more common for stream ciphers to use a suitable pseudorandom number generator to expand a short key into a long keystream.
Michigan State University Computer Science and Engineering
Text Themes
Repetition is bad: any repetition provides sufficient clues for cracking. Also, how you use a cipher is as important as the quality of the cipher itself, e.g. if you use it in a way that allows repetition, you lose.
Michigan State University Computer Science and Engineering
Block Cipher
Divide input bit stream into n-bit sections, encrypt only that section, no dependency/history between sections
In a good block cipher, each output bit is a function of all n input bits and all k key bits
Michigan State University Computer Science and Engineering
Stream Cipher
Stream ciphers
Rather than divide bit stream into discrete blocks, as block ciphers do, XOR each bit of your plaintext continuous stream with a bit from a pseudo-random sequence At receiver, use same symmetric key, XOR again to extract plaintext Michigan State University
Computer Science and Engineering
Vigenres allowed letter frequency analysis Block ciphers flatten that distribution
Playfair
(simple block cipher) Block: 5x5 grid of letters without J Algorithm If two letters are in the same row or column, replace by succeeding letters. Otherwise, the two letters stand at two of the corners of a rectangle; replace with letters at other two corners
Playfair
Invented around 1854 by Sir Charles Wheatstone Keyword: playfair Plaintext: meet at the schoolhouse Plaintext1: me et at th es ch ox ol ho us ex Ciphertext: eg mn fq qm kn bk sv vr gq xn ku P I E N U L R G O V A B H Q W Y C K S X F D M T Z
Analysis
Playfair allows one character change in input to change one character in output. We want small changes in input to diffuse completely through the output. Playfair has a block length of two. DES, a modern block cipher, has a block length of 64; DESs replacement, AES, has a block length of 128.
Birthday Theorem
How many people do you invite to your party so that two will have the same birthday (with high probability)? 365 You need N to have a high probability of a collision.
Birthday Attack
A birthday attack is a name used to refer to a class of brute-force attacks.
birthday paradox : the probability that two or more people in a group of 23 share the same birthday is greater than
General formulation
function f() whose output is uniformly distributed over domain On repeated random inputs n = { n1, n2, , .., nk }
Pr(ni = nj) = 1.2k1/2, for some 1 <= i, j <= k, 1 <= j < k, i != j E.g., 1.2(3651/2) = 23
Michigan State University Computer Science and Engineering
Feistel Cipher
1950s IBM On team that developed DES He used multiple rounds of permutation blocks which were reversible. Notation: (f1 , f2 , f3 ) represents three Feistel cipher rounds
Luby-Rackoff
(proof of Felstel Ciphers)
If fi were random functions, then (f1 , f2 , f3 ) was indistinguishable from a random permutation under chosen plain text attack.
(chosen plain text attack: opponent chooses some number of plain text inputs and sees the corresponding ciphertext outputs.)
Michigan State University Computer Science and Engineering
Luby-Rackoff
(proof of Felstel Ciphers)
If fi were random functions, (f1 , f2 , f3 , f4 ) was indistinguishable under chosen plaintext/ciphertext attack, i.e. it was a pseudorandom permutation That is, four rounds of Feistel are enough
(chosen plaintext/ciphertext attack: can choose either plaintext or ciphertext and see corresponding result.)
Michigan State University Computer Science and Engineering
DES was the most widely-used block cipher in the 80s and 90s. (e.g. Funds transfer security in banks)
DES
Consists of several phases
An initial permutation (IP) Key transformation 16 rounds of:
Expansion permutation of input(Avalanche Effect) Expands 32 bits to 48 bits, thus a single bit affects 2 substitutions. Dependency of output bits on input bits spread faster S-box substitution (confusion) P-box permutation (diffusion)
Michigan State University Computer Science and Engineering
DES Algorithm
PeDEStrian attacks
56 keys Obvious attack: guess the key. 2 Complementation Property: 255 keys 1 million per second: 1100 years Store EK(P1) for all K: 512 petabytes
DEStroying Security
Differential Cryptanalysis (1990) (in text): Say you know plaintext, ciphertext pairs Difference dP = P1 P2, dC = C1 C2 Distribution of dCs given dP may reveal key Need lots of pairs to get lots of good dPs Look at pairs, build up key in pieces Could find some bits, brute-force for rest Michigan State University
Computer Science and Engineering
DEServing of Praise
Against 8-round DES, attack requires:
214 = 16,384 chosen plaintexts, or 238 known plaintext-ciphertext pairs
DESperate measures
Linear cryptanalysis (in text):
Look at algorithm structure: find places where, if you XOR plaintext and ciphertext bits together, you get key bits S-boxes not linear, but can approximate
43 known pairs; best known attack Need 2 DES apparently not optimized against this Still, not an easy-to-mount attack
Michigan State University Computer Science and Engineering
Characteristics of DES
Dependence: All output bits depend on all input bits. Avalanche effect: a small alternation of the plaintext results in a large change of the ciphertext. A small change in the key results in a large change in the ciphertext. Small space (4) of weak keys. A pair of keys is weak if after two subsequent encipherments with the keys, we get the original plaintext. 12 semi-weak keys (the inverse of the key is another key). Complimentarity: DESk(P)=C DESco(k)(co(P))=co(C)
Cracking DES
In the summer of 1998, the Electronic Frontier Foundation (EFF) built a DES cracker machine at a cost of $250,000 It had 1536 chips, worked at a rate of 88 billion keys per second, and was able to break a DES encrypted message in 56 hours One year later, with the cracker working in tandem with 100,000 PCs over the Internet, a DES encrypted message was cracked in only 22 hours. They were testing 245 billion keys per second.
DES Problem
Key is too short (56 bits). 42 known texts A linear attack requiring 2 exists, but from a practical standpoint even 240 known texts is impractical.
3DES
One common way to make DES more secure today is to encrypt three times using DES.
triple-DES (3DES). 3DES is extremely slow, so a better algorithm was needed. Provides us with a key space of 2112 keys
AES Requirements
Motivation To replace DES with a single block encryption algorithm with a strength equal to or better than 3DES and with significantly improved efficiency Minimum Acceptability Requirements implement symmetric (private) key cryptography be a block cipher work on 128-bit blocks with three key sizes : 128, 192, 256 bits
Michigan State University Computer Science and Engineering
Cost
Licensing Requirements available on a worldwide, nonexclusive, royalty-free basis Computational Efficiency applicable to both hardware & software implementations; speed of algos under specified platforms Memory Requirements applicable to both hardware and software implementations; factors e.g. gate counts, code size, RAM requirements
-- array of 4 words(each 32 bits) of a block -- 10 rounds for key-block combination of 128-128 bits -- consists of XOR of keywords(each 3bits), S-box lookups, intra-word byte rotation -- bitwise-XOR with keywords for whitening -- similar to Round except without MixColumn
Michigan State University Computer Science and Engineering
S-box
b i,j
ByteSub acts on individual bytes of the State. Purpose (high) non-linearity Note : only 1 S-box (8 bits x 8 bits) ByteSub is a non-linear byte substitution constructed by the composition of two transformations : Take multiplicative inverse in GF(28) (00 mapped to itself) Apply an affine ( over GF(2) ) transformation: 8F a i,j A6
Michigan State University Computer Science and Engineering
c(x)
The columns of the State are considered as polynomials over GF(28) and multiplied module x4+1 with a fixed polynomial c(x) : c(x) = 03x3 + 01x2 + 01x + 02 MixColumn is implemented using operations of XOR, conditional bitshifts. Purpose inter-byte diffusion within columns (based on ECC theory) Together with ShiftRow, it ensures that after a few rounds,all output bits depend on all input bits. Coefficients of the matrix were also chosen for efficient implementation. Michigan State University
Computer Science and Engineering
In AddRoundKey, the Round Key is bitwise XORed to the State. Purpose makes round function key-dependent Key-XORing with plaintext or ciphertext is sometimes called whitening. This is a cheap way of adding to the security of the cipher by preventing the collection of plaintext-ciphertext pairs.
Michigan State University Computer Science and Engineering
Suitable for smart cards Flexible in dedicated hardware -- Daemen & Rijmen Michigan State University
Computer Science and Engineering
IETF protocols
most that use encryption are naturally AES ready AES phased in over next 2 or 3 years from year 2000 DES will remain for backwards compatibility till ~ 2003
Michigan State University Computer Science and Engineering
Finally
a standard for cryptographic algorithms to protect international commerce and communications Everything in the cipher world from now on will be measured, quantified, and compared to AES. Be it speed, strength, block size, key size, number of rounds, and so on it will be relative to the AES. It is the yardstick! --Raif S. Naffah, senior software engineer, Forge Research openness about the design strong endorsement of the public-sector cryptographic expertise
Levels of security
An encryption scheme is unconditionally secure if the ciphertext generated by the scheme does not contain enough information to determine uniquely the corresponding plaintext. An encryption scheme is computationally secure if the cost of breaking the cipher exceeds the value of the encrypted information or the time requited to break the cipher exceeds the lifetime of the information.
Michigan State University Computer Science and Engineering
RSA Encryption/Decryption
Public key k+ is {e,n} and private key k- is {d, n} Encryption and Decryption +,P) : ciphertext = plaintexte mod n E(k D(k-,C) : plaintext = ciphertextd mod n Example
Public key (7,33), Private Key (3,33) Data 4 (encoding of actual data) E({7,33},4) = 47 mod 33 = 16384 mod 33 = 16 D({3,33},16) = Michiganmod 33 = 4096 mod 33 = 4 163 State University
Computer Science and Engineering
E.g.,
E({3,45},4) = 43 mod 33 = 64 mod 33 = 31 D({7,45},19) = 317 mod 33 = 27,512,614,111 mod 33 = 4