Methods for Symmetric Key Cryptography and Cryptanalysis EWM Phd Summer School, Turku, June 2009
Total Page:16
File Type:pdf, Size:1020Kb
Methods for Symmetric Key Cryptography and Cryptanalysis EWM PhD Summer School, Turku, June 2009 Kaisa Nyberg [email protected] Department of Information and Computer Science Helsinki University of Technology and Nokia, Finland Methods for Symmetric Key Cryptography and Cryptanalysis – 1/32 This lecture is dedicated to the memory of Professor Susanne Dierolf a dear and supporting friend, a highly respected colleague, and a great European Woman in Mathematics, who passed away in May 2009 at the age of 64 in Trier, Germany. Methods for Symmetric Key Cryptography and Cryptanalysis – 2/32 Outline 1. Boolean function Linear approximation of Boolean function Related probability distribution 2. Cryptographic encryption primitives Linear approximation of block cipher Linear approximation of stream cipher 3. Cryptanalysis and attack scenarios Key information deduction on block cipher Distinguishing attack on stream cipher Initial state recovery of stream cipher 4. Conclusions Methods for Symmetric Key Cryptography and Cryptanalysis – 3/32 Boolean Functions Methods for Symmetric Key Cryptography and Cryptanalysis – 4/32 Binary vector space n Z 2 the space of n-dimensional binary vectors ¨ sum modulo 2 Given two vectors 1 n 1 n n a = ´a ; : : : ; a µ; b = ´b ; : : : ; b µ ¾ Z 2 the inner product (dot product) is defined as 1 1 n n a ¡ b = a b ¨ ¡ ¡ ¡ ¨ a b : Then a is called the linear mask of b. Methods for Symmetric Key Cryptography and Cryptanalysis – 5/32 Boolean function n f : Z 2 Z 2 Boolean function. Linear Boolean function is of the form f ´x µ = u ¡ x for some n fixed linear mask u ¾ Z 2. n m f : Z 2 Z 2 with f = ´ f1 ; : : : ; fm µ; where fi are Boolean functions, is called a vector Boolean function of dimension m. n m A linear vector Boolean function from Z 2 to Z 2 is represented by an m ¢ n binary matrix U. The m rows of U are denoted by u1 ; : : : ; um, where each ui is a linear mask. Methods for Symmetric Key Cryptography and Cryptanalysis – 6/32 Correlation n The correlation between two Boolean functions f : Z 2 Z 2 n and g : Z 2 Z 2 is defined as n n n c´ f ; gµ = 2 ´ #x ¾ Z 2 f ´x µ = g´x µ #x ¾ Z 2 f ´x µ = g´x µµ Correlation c´ f ; 0µ is called the correlation (sometimes aka bias) of f . Linear cryptanalysis makes use of large correlations of Boolean functions in cipher constructions. Methods for Symmetric Key Cryptography and Cryptanalysis – 7/32 Random variable related to Boolean function n X discrete random variable taking on values in Z 2 = ´ η µ n If p p η¾Z is the probability distribution (p.d.) of X, 2 ηµ where pη = Pr´X = , we denote X p. n θ Z Let denote the uniform distribution on 2. n m θ: Let f : Z 2 Z 2 be a Boolean function and X Then the p.d. of f ´X µ is called the p.d. of f . Methods for Symmetric Key Cryptography and Cryptanalysis – 8/32 Walsh-Hadamard Transform Walsh-Hadamard transform is a type of discrete Fourier-transform. n φ Z Ê Let : 2 be a real-valued function. The Walsh-Hadamard transform bφ of φ is defined as x¡u n b φ φ´ µ = ´ µ´ µ ; ¾ Z : u ∑ x 1 u 2 n x¾Z 2 Then b n n b φ ¾ Z ; φ´ µ; ´x µ = 2 x x 2 using the inverse of Walsh-Hadamard transform. Methods for Symmetric Key Cryptography and Cryptanalysis – 9/32 Convolution n n φ Z Ê ψ Z Ê The convolution of two functions : 2 and : 2 is defined as n φ £ ψµ´ µ = ´ µψ´ · µ; ¾ Z : ´ φ y ∑ x x y y 2 n x¾Z 2 Then \ n b b φ £ ψµ´ µ = φ´ µψ ´ µ; ¾ Z : ´ u u u u 2 Methods for Symmetric Key Cryptography and Cryptanalysis – 10/32 Correlation and probability distribution The correlations of masked Boolean function can be computed as Walsh-Hadamard transform of the distribution of the function: η n a¡ f ´xµ a¡ b c´a ¡ f µ = 2 ∑ ´ 1µ = ∑ ´ 1µ pη = p´aµ: n m η¾Z x¾Z 2 2 n m Theorem 1 Let f : Z 2 Z 2 be a Boolean function with p.d. p and m one-dimensional correlations c´a ¡ f µ; a ¾ Z 2 . Then η m a¡ pη = 2 ∑ ´ 1µ c´a ¡ f µ m a¾Z 2 m η ¾ Z for all 2 . Methods for Symmetric Key Cryptography and Cryptanalysis – 11/32 Cryptographic Encryption Primitives Methods for Symmetric Key Cryptography and Cryptanalysis – 12/32 Symmetric-key encryption K ¾ K the key x ¾ P the plaintext y ¾ C the ciphertext Encryption method is a family EK of transformations EK : P C , parametrised using the key K such that for each encryption transfor- mation EK there is a decryption transformation DK : C P , such that DK ´EK ´x µµµ = x, for all x ¾ P . Methods for Symmetric Key Cryptography and Cryptanalysis – 13/32 Block cipher The data to be encrypted is split into blocks xi, i = 1; : : : ; N of fixed length n. A typical value of n is 128. n ` P = C = Z 2, K = Z 2 Block cipher seen as a vector Boolean function n ` n n ` f : Z 2 ¢ Z 2 Z 2 ¢ Z 2 ¢ Z 2 f ´x ; K µ = ´x ; EK ´x µ; K µ Linear approximation of a block cipher u ¡ x ¨ w ¡ EK ´x µ ¨ v ¡ K θ where x and K is fixed. Methods for Symmetric Key Cryptography and Cryptanalysis – 14/32 Stream cipher Data to be encrypted is split into blocks xi ; i = 1; : : : ; N of fixed length n. Now typical values of n are n = 1; 8; or 32. ` K = Z 2 The key K ¾ K determines the initial state of a keystream generator which produces a new fresh key Ki, i = 1; : : : ; N, for each data block. n N P = C = ´Z 2 µ where N can be any positive integer less than the period of the keystream generator. EK ´x1 ; : : : ; xN µ = K1 ¨ x1 ; : : : ; KN ¨ xN Methods for Symmetric Key Cryptography and Cryptanalysis – 15/32 Linear approximation of stream cipher Key stream generator seen as Boolean functions ` ` n fi : Z 2 Z 2 ¢ Z 2 ; fi ´K µ = ´K ; Ki µ Linear approximations of key stream generator ui ¡ K ¨ w ¡ Ki Methods for Symmetric Key Cryptography and Cryptanalysis – 16/32 Cryptanalysis Methods for Symmetric Key Cryptography and Cryptanalysis – 17/32 Attack scenarios Assumptions about data available to attacker Ciphertext only (Shannon’s model) Known plaintext-ciphertext pairs Chosen (by attacker) plaintext and corresponding ciphertext Methods for Symmetric Key Cryptography and Cryptanalysis – 18/32 Breaks This classification is hierarchial. An attack is successful if its complexity is less than the complexity of exhaustive key search. Total break: attacker gets the key Instance deduction: attacker gets a clone of DK Key information deduction: attacker gets partial information about the key Distinguishing: attacker can distinguish the cipher from a purely random function Distinguishing leads sometimes to information deduction. Methods for Symmetric Key Cryptography and Cryptanalysis – 19/32 Linear cryptanalysis Linear cryptanalysis is a known plaintext-ciphertext attack Linear cryptanalysis makes use of linear approximations of the cipher. Linear cryptanalysis can be used in distinguishing attacks or in key information deduction. Methods for Symmetric Key Cryptography and Cryptanalysis – 20/32 Key information recovery on block cipher Linear approximation of a block cipher u ¡ x ¨ w ¡ EK ´x µ ¨ v ¡ K θ where x and K is fixed. The correlation c of this Boolean function is assumed to be known or a sufficiently accurate estimate is available. Observe a number N of known plaintext-ciphertext pairs ´x ; EK ´x µµ and calculate the observed correlation c˜ of u ¡ x ¨ w ¡ EK ´x µ. Determine v ¡ K = 0, if cc˜ > 0, and v ¡ K = 1, otherwise. Methods for Symmetric Key Cryptography and Cryptanalysis – 21/32 The probability of success Consider the case c > 0 and v ¡ K = 0. Other cases are similar. Let N0 be the observed number of plaintexts x such that u ¡ x ¨ w ¡ EK ´x µ = 0. Then N0 is binomially distributed with expected value N p and variance N p´1 pµ, c·1 where p = 2 . Then N0 N p Ô Z = N ´0; 1µ N p´1 pµ where N ´0; 1µ is the standard normal distribution. Then the bit v ¡ K is correctly determined if the observed correlation c˜ is positive, which happens if and only if Ô N0 > N =2, or equivalently, Z > c N. Hence the probability of success can be estimated as Ô Φ´ µ 1 c N where Φ is the cumulative density function of N ´0; 1µ. The probability is 0.921 for 2 N = 1=c . This gives an estimate of the number N of plaintext-ciphertext pairs for successful cryptanalysis. Methods for Symmetric Key Cryptography and Cryptanalysis – 22/32 Linear attacks on stream cipher i Let fi : K Ki be of the form g Æ f , where f is a (linear) state transition function and g is a nonlinear state output function, aka filter function. Assume that we have a strong linear approximation of g, that is u ¡ x ¨ w ¡ g´x µ with correlation c. Now two types of linear attacks can be launched: distinguishing attacks initial state information deduction attacks. Methods for Symmetric Key Cryptography and Cryptanalysis – 23/32 Additive synchronous stream cipher Methods for Symmetric Key Cryptography and Cryptanalysis – 24/32 Distinguishing attack on stream cipher From the linear approximation we get u ¡ si ¨ w ¡ g´si µ = u ¡ si ¨ w ¡ Ki i with correlation c, where si = f ´K µ is the state at time i, i = 1; : : : ; N.