CHAPTER 6: Other cryptosystems , pseudo-random numbers generators and hash functions A large number of interesting and important cryptosystems have already been designed. In this chapter we present some of them in order to illustrate principles and techniques that can be used to design cryptosystems. At first, we present several cryptosystems security of which is based on the fact that computation of discrete logarithms is infeasible in some groups. Secondly, we discuss pseudo-random number generators and hash functions – other very important concepts of modern cryptography. Finally, we discuss one of the fundamental questions of modern cryptography: when can a cryptosystem be considered as (computationally) perfectly secure? In order to do that we will: • discuss the role randomness play in the cryptography; • introduce the very fundamental definitions of perfect security of cryptosystem • present some examples of perfectly secure cryptosystems. Rabin cryptosystem Primes p, q of the form 4k + 3 are kept secret, n = pq is the public key. Encryption: of a plaintext w < n c = w^2 mod n Generalized Rabin cryptosystem Public key: n, B (0 £ B £ n -1) Trapdoor: primes p, q (n = pq) of the form 4k+3 Encryption: e(x) = x (x + B) mod n Decryption: It is easy to verify that if is a nontrivial square root of 1 modulo n, then there are four decryptions of e(x): Security of Rabin cryptosystem We show that any hypothetical decryption algorithm A for Rabin cryptosystem, can be used, as an oracle, in the following Las Vegas algorithm, to factor an integer n. Algorithm: • Choose a random r , 1 £ r £ n -1; • Compute y = (r^2 - B^2/4) mod n; {y = e[k](r – B/2)}. • Call A(y), to obtain a decryption • Compute x[1] = x + B/2; {x[1]^2 º r^2 mod n} • if x[1] = ± r then quit (failure) else gcd(x[1] + r, n) = p or q ElGamal cryptosystem Design: choose a large prime p – (with at least 150 digits). choose two random integers 1 £ q, x < p - where q is a primitive element of Z*[p][] calculate y = q^x mod p. Shanks’ algorithm for discrete logarithm Let m = [sqrt(p - 1)]. The following algorithm computes lg[q]y in Z*[p]. • Compute q^mj^ mod p, 0 £ j £ m - 1. • Create list L[1] of m pairs (j, q^mj^ mod p), sorted by the second item. • Compute yq ^-i mod p, 0 £ i £ m - 1. • Create list L[2] of pairs (i, yq ^-i mod p) sorted by the second item. [• ] Find two pairs, one (j, z) Î L[1] and second (i, z) Î L[2] Bit security of discrete logarithm Let us consider problem to compute L[i](y) = i-th least significant bit of lg[q]y in Z*[p]. Result 1 L[1](y) can be computed efficiently. To show that we use the fact that the set QR(p) has (p -1)/2 elements. Let q be a primitive element of Z*[p]. Clearly, q^a ÎQR(p) if a is even. Since the elements q^0 mod p, q^2 mod p, …, q ^p-3 mod p are all distinct, we have that QR(p) = {q ^2i mod p | 0 £ i £ (p - 3)/2} Consequence: y is a quadratic residue iff lg[q]y is even, that is iff L[1](y) = 0. By Euler's criterion y is a quadratic residue if y^(p-1)/2^ º 1 mod p L[1](y) can therefore be computed as follows: L[1](y) = 0 if y^(p-1)/2^ º 1 mod p; L[1](y) = 1 otherwise Williams cryptosystem - basics Similar to RSA, but number operations are performed in a quadratic field. Cryptoanalysis of Williams cryptosystem is equivalent to factoring. Consider numbers of the form where a, b, c are integers. If c remains fixed a can be viewed as a pair (a, b). a[1][ ]+ a [2] = (a [1], b [1]) + (a [2],b [2]) = (a [1] + a [2], b [1] + b[2]) a [1]a [2] = (a [1], b [1]) · (a [2],b [2]) = (a [1]a [2] + c b [1]b [2], a [1]b [2] + b[1]a [2]) The conjugate a of a is defined by Williams cryptosystem - efficient exponentiation Assume now a ^2^ - cb ^2 = 1 Then aa = 1 and consequently X[I ]^2 - cY[I]^2 = 1 Moreover, for j ³ i X[I+J] = 2X[I] X[J] – X[J – I] Y[I+J] = 2Y[I] X[J] – Y[J – I] From these and following equations: X[I+J] = 2X[I] X[J] + cY[I] Y[J] [] Y[I+J] = 2Y[I] X[J] + X[I ]Y[J] we get the recursive formulas: X [2i] = X [i]^2 + cY [i ]^2 = 2X [i ]^2 - 1 Y [2i] = 2X [i]Y [i] X [2i][+1] = 2X [i]Y [i+1] – X [1] Y [2i][+1] = 2X [i]Y [i+1] – Y [1][] Consequences: 1. X [i] and Y [i] can be, given i, computed fast. Remark Since X [0] = 1, X [1] = a, X [i] does not depend on b. WHEN is a CRYPTOSYSTEM (perfectly) SECURE? First question:. Is it enough for perfect security of a cryptosystem that one cannot get a plaintext from a cryptotext? NO, NO, NO WHY? For many applications it is crucial that no information about the plaintext could be obtained. • Intuitively, a cryptosystem is (perfectly) secure if one cannot get any (new) information about the corresponding plaintext from any cryptotext. • It is very nontrivial to define correctly when a cryptosystem is (computationally) perfectly secure. • It has been shown that perfectly secure cryptosystems have to use randomized encryptions. Cryptography and Randomness Randomness and cryptography are deeply related. 1. Prime goal of any good encryption method is to transform even a highly nonrandom plaintext into a highly random cryptotext. (Avalanche effect.) Example Let e[k] be an encryption algorithm, x[0] be a plaintext. And x[ i] = e[k][ ](x [i-1]), i ³ 1. It is intuitive clear that if encryption e[k] is “cryptographically secure'', then it is very, very likely that the sequence x[ ][0][ ]x[ ][1][ ]x[ ][2][ ]x[ ][3] is (quite) random. Perfect encryption can therefore produce (quite) perfect (pseudo)randomness. Secure encryptions - basic concepts I We now start to discuss a very nontrivial question: when is an encryption scheme computationally perfectly SECURE? First ,some very basic technical concepts: Definition A function f:N ® R is a negligible function if for any polynomial p (n) it holds, for almost all n: Secure encryptions - pseudorandom generators In cryptography random sequences can be usually fully replaced by pseudorandom sequences generated by (cryptographically perfect) pseudorandom generators. Definition - pseudorandom generator. Let l (n):N ® N be such that l(n) > n for all n. A (computationally indistinguishable) pseudorandom generator with stretch function l, is an efficient deterministic algorithm which on input of a random n-bit seed outputs a l(n)-bit sequence which is computationally indistinguishable from a random l(n)-bit sequence. Cryptographically strong pseudo-random generators Fundamental question: when is a pseudo-random generator good enough for cryptographical purposes? Basic concept: A pseudo-random generator is called cryptographically strong if the sequence of bits it produces, from a short random seed, is so good for using with ONE-TIME PAD cryptosystem, that no polynomial time algorithm allows a cryptanalyst to learn any information about the plaintext from the cryptotext. A cryptographically strong pseudo-random generator would therefore provide sufficient security in a secret-key cryptosystem if both parties agree on some short seed and never use it twice. As discussed later: Cryptographically strong pseudo-random generators could provide perfect secrecy also for public-key cryptography. Problem: Do cryptographically strong pseudo-random generators exist? Candidates for cryptographically strong pseudo-random generators So far there are only candidates for cryptographically strong pseudo-random generators. For example, cryptographically strong are all pseudo-random generators that are unpredictable to the left in the sense that a cryptanalyst that knows the generator and sees the whole generated sequence except its first bit has no better way to find out this first bit than to toss the coin. It has been shown that if integer factoring is intractable, then the so-called BBS pseudo-random generator, discussed below, is unpredictable to the left. (We make use of the fact that if factoring is unfeasible, then for almost all quadratic residues x mod n, coin-tossing is the best possible way to estimate the least significant bit of x after seeing x^2 mod n.) Let n be a Blum integer. Choose a random quadratic residue x[0] (modulo n). For i ³ 0 let x [i+][1] = x [i]^2^ mod n, b [i ]= the least significant bit of x [I] For each integer i, let BBS [n,][ i ](x[0]) = b[0]…b [i-1] be the first i bits of the pseudo-random sequence generated from the seed x[0] by the BBS pseudo-random generator. BBS pseudo-random generator - analysis Choose random x, relatively prime to n, compute x[0][ ]= x ^2^ mod n x [i+][1] = x [i]^2^ mod n, b [i ]= the least significant bit of x [I] BBS [n,][ i ](x[0]) = b[0]…b [i-1] Randomized encryptions From security point of view, public-key cryptography with deterministic encryptions has the following serious drawback: A cryptoanalyst who knows the public encryption function e [k] and a cryptotext c can try to guess a plaintext w, compute e [k][ ](w) and compare it with c. The purpose of randomized encryptions is to encrypt messages, using randomized algorithms, in such a way that one can prove that no feasible computation on the cryptotext can provide any information whatsoever about the corresponding plaintext (except with a negligible probability). Secure encryption - First definition Definition - semantic security of encryption A cryptographic system is semantically secure if for every feasible algorithm A, there exists a feasible algorithm B so that for every two functions f, h: {0,1}* ® {0,1} ^n^ ^ and all probability ensembles {X [n]} [n][Î][N], where X [n] ranges over {0,1} ^n^ where is a negligible function. Secure encryptions - Second definition Definition A randomized-encryption cryptosystem is polynomial time secure if, for any cÎN and sufficiently large sÎN (security parameter), any randomized polynomial time algorithms that takes as input s (in unary) and the public key, cannot distinguish between randomized encryptions, by that key, of two given messages of length c, with the probability larger than 1/2 +1/s^c. Both definitions are equivalent. HASH FUNCTIONS Another very simple, fundamental and important cryptographic concept is that of hash functions. Hash functions h:{0,1}* → {0,1}^m ; h:{0,1}^n → {0,1}^m, n>>m map (very) long messages w into short ones, called usually message digest or hash or fingerprints of w, in a way that has important cryptographic properties. ^ Digital signatures are one of important applications of hash functions. In most of the digital signature schemes, to be discussed in the next chapter, the length of a signature is at least as long as of the message being signed. This is clearly a big disadvantage. To remedy this situation, signing procedure is applied to a hash of the message, rather than to the message itself. This is OK provided the hash function has good cryptographic properties, discussed next. HASH FUNCTIONS & DIGITAL SIGNATURE Basic use of hash functions for digital signatures: If Alice wants to sign a message w, she first creates hash z=h(w), then computes signature s of the hash z, using a signing algorithm sig and a key k: s=sig[k](z) and transmits the pair (w,s). To verify a signature, a verification algorithm ver and the key k are used. At first z=h(w) is computed and then it is verified that ver[k](z,s)=true. PROPERTIES HASH FUNCTIONS SHOULD HAVE I. We now derive basic properties cryptographically good hash functions should have by analysing several possible attacks on their use. Attack 1 If Eve gets a valid signature (w,y), where y=sig[k](h(w)) and she would be able to find w’ such that h(w’)=h(w), then also (w’,y), a forgery, would be a valid signature. Cryptographically good hash function should therefore have the following weak collision-free property Definition 1.Let w be a message. A hash function h is weakly collision-free for w, if it is computationally infeasible to find a w’ such that h(w)=h(w’). PROPERTIES HASH FUNCTIONS SHOULD HAVE II. Attack 2 If Eve finds two w and w’ such that h(w’)=h(w), she can ask Alice to sign h(w) to get signature s and then Eve can create a forgery (w’,s). Cryptographically good hash function should therefore have the following strong collision-free property Definition 2. A hash function h is strongly collision-free if it is computationally infeasible to find two elements w≠w’ such that h(w)=h(w’). PROPERTIES HASH FUNCTIONS SHOULD HAVE III. Attack 3 If Eve can compute signature s of a random z, and then she can find w such that z=h(w), then Eve can create forgery (w,s). To exclude such an attack, hash functions should have the following one-wayness property. Definition 3. A hash function h is one-way if it is computationally infeasible to find, given z, an w such that h(w)=z. One can show that if a hash function has strongly collision-free property, then it has one-wayness property. Hash functions and integrity of data An important use of hash functions is to protect integrity of data in the following way: The problem of protecting data of arbitrary length is reduced, using hash functions, to the problem to protect integrity of the data of fixed (and small) length fingerprints. In addition, to send reliably a message w through an unreliable (and cheap) channel, one sends also its (small) hash h(w) through a very secure (and therefore expensive) channel. The receiver, familiar also with the hash function h that is being used, can then verify the integrity of the message w’ he receives by computing h(w’) and comparing h(w) and h(w’) . EXAMPLES Example 1 For a vector a=(a[1],…, a[k ]) of integers let where n is a product of two large integers. This hash functions does not meet any of the three properties mentioned on the last slide. Hash functions and commitments A commitment to a data w, without revealing w, using a hash function h, can be done as follows: Commitment phase: To commit to a w choose a random r and make public h(wr). Opening phase: reveal r and w. For this application the hash function h has to be one-way: from h(wr) it should be unfeasible to determine wr FINDING COLLISIONS with INVERSION ALGORITHM Theorem Let h:X→Z be a hash function where X and Z are finite and |X| ≥ 2|Z|. If there is an inversion algorithm A for h, then there exists randomized algorithm to find collisions. VARIATION on BIRTHDAY PARADOX It is well know that if there are 23 (39) [40] people in one room, then the probability that two of them have the same birthday is more than 50% (70%)[89%] – this is called a Birthday paradox. Birthday Paradox attack on digital signatures Similarly, Fred makes 2^30 changes of the fraudulent document. Considering birthday problem with n = 2^50, r = 2^30 we get that r = , with = 2^10 and therefore with probability 1- e^-1024 1 there is a version of the good document that has the same hash as a version of the fraudulent document. Finding a match, Fred can ask Alice to sign a good version and then append the signature to the fraudulent contract. HASH FUNCTION DOMAIN LOWER BOUND Birthday paradox imposes a lower bound on the sizes of message digests (fingerprints) For example a 40-bit message would be insecure because a collision could be found with probability 0.5 with just over 20^20 random hashes. Minimum acceptable size of message digest seems to be 128 and therefore 160 are used in such important systems as DSS – Digital Signature Schemes (standard). AN ALMOST GOOD HASH FUNCTION We show an example of the hash function (so called Discrete Log Hash Function) that seems to have as the only drawback that it is too slow to be used in practice: Let p be a large prime such that q = (p -1)/2 is also prime and let α, β be two primitive roots modulo p. Denote a = log[α ]β (that is β = α^a). h will map two integers smaller than q to an integer smaller than p, for m = x[0 ]+[ ]x[1]q, 0 £ x[0],[ ]x[1 ]£ q –1 as follows, h(x[0],[ ]x[1]) = h(m) = (mod p). EXTENDING HASH FUNCTIONS Let h :{0, 1}^m ® {0, 1}^t be a strongly collision-free hash function, where m > t +1. We design now a strongly collision-free hash function h* : Let a bit string x, |x| = n > m, has decomposition x = x[1 ]|| x[2 ]. . . || x[k ], where |x[i]| = m – t – 1 if i < k and |x[k]| = m – t – 1 – d for some d. (Hence k = én / (m – t – 1)ù.) h* will be computed as follows: • for i=1 to k-1 do y[i ]:= x[i ]; • y[k ]:= x[k][ ]|| 0^d ; y[k+1 ]:= binary representation of d ; • g[1 ]:= h(0^t+1 || y[1]) ; • for i=1 to k do g[i+1 ]:= h(g[i ]||1^ || y[i+1]) ; • h*(x) := g[k+1]. HASH FUNCTIONS from CRYPTOSYSTEMS Let us have computationally secure cryptosystem with plaintexts, keys and cryptotexts being binary strings of a fixed length n and with encryption function e[k ]. If x=x[1 ]|| x[2 ]|| … [ ]|| x[k] is decomposition of x into substrings of length n, g[0- ]is a random string, and g[i ]= f(x[i ], g[i-1]) for i=1,..,k, where f is a function that “incorporates” encryption function e[k ]of the cryptosystem, then h(x)= g[k ]. For example such good properties have these two functions: [ ] PRACTICALLY USED HASH FUNCTIONS A variety of hash functions has been constructed. Very often used hash functions are MD4, MD5 (created by Rivest in 1990 and 1991 and producing 128 bit message digest). NIST even published, as a standard, in 1993, SHA (Secure Hash Algorithm) – producing 160 bit message digest – based on similar ideas as MD4 and MD5. A hash function is called secure if it is strongly collision-free. One of the most important cryptographic results of the last years was due to the Chinese Wang who has shown that MD4 is not cryptographically secure. Randomized version of RSA-like cryptosystems The scheme works for any trapdoor function (as in case of RSA), for any pseudorandom generator G: {0,1} ^k ® {0,1} ^l, k << l and any hash function h: {0,1}^ ^l ® {0,1} ^k, where n = l + k. Given a random seed s Î {0,1} ^k as input, G generates a pseudorandom bit-sequence of length l. Bloom-Goldwasser cryptosystem once more Private key: Blum primes p and q. Global goals of cryptography Cryptosystems and encryption/decryption techniques are only one part of modern cryptography. General goal of modern cryptography is construction of schemes which are robust against malicious attempts to make these schemes to deviate from their prescribed functionality. The fact that an adversary can design its attacks after the cryptographic scheme has been specified, makes design of such cryptographic schemes very difficult - schemes should be secure under all possible attacks. In the next chapters several of such most important basic functionalities and design of secure systems for them will be considered. For example: digital signatures, user and message authentication,.... Moreover, also such basic primitives as zero-knowledge proofs, needed to deal with general cryptography problems will be presented and discussed. We will also discuss cryptographic protocols for a variety of important applications. For example for voting, digital cash,....