Download presentation

Presentation is loading. Please wait.

Published byNico Raef Modified about 1 year ago

1
1 Cryptography, Attacks and Countermeasures Lecture 3 - Stream Ciphers John A Clark and Susan Stepney Dept. of Computer Science University of York, UK

2
2 Stream Ciphers Part I: Pseudo-random number generators. Lots of Bad Ways Part II: Divide and conquer attacks.

3
3 Stream Ciphers - Vernam Vernam Cipher works by generating a random bit stream and then XORing that stream on a bit by bit basis with the plaintext. BiBi PiPi CiCi BiBi PiPi Random Stream B i Random Stream B i Key K Both sender and receiver can generate key stream Bi. Receiver XORs the ciphertext stream with the key stream to recover the plaintext stream. We will use this cipher to illustrate several concepts.

4
4 Linear Feedback Shift Registers L ij At each iteration there is a right shift, a bit falls off the end, and the leftmost bit is set according to the linear feedback function. Here 0+0+1=

5
5 Periodicity We would like the stream to be ‘random-looking’. One feature should be that the stream should not repeat itself too quickly. Note that this is in effect a finite state machine and so must repeat itself eventually. The maximal period for an n-bit register is 2 n -1. Why not 2 n ?

6
6 Maximal Period m-sequences The tap sequence defines the linear feedback function and is often regarded as a finite field polynomial. You have to choose the tap sequence very carefully. Some choices provide a maximal length period. These are primitive polynomials

7
7 Primitive Polynomials Give m-sequences 0011 tD3D3 D2D2 D1D1 D0D tD3D3 D2D2 D1D1 D0D Common to denote the above by the polynomial C(D)=1+D+D 4. Note we are back to where we started.

8
8 Some Polynomials Don’t 0011 tD3D3 D2D2 D1D1 D0D tD3D3 D2D2 D1D1 D0D The polynomial C(D)=1+D+D 3 does not give a maximal period sequence.

9
9 Not good for PRNG Consider a 64 bit register. Can this be used as a key stream generator? No. Once you know a very small amount of plaintext (e.g. 32 consecutive bits) then you can calculate the corresponding key stream and so you know the rightmost 32 bits in the register. You can now try in turn all other 2 32 combinations for the rest. When you get the right one, you are able to generate the whole key stream And so plaintext should make sense. This is just too easy to break. But LFSRs are very easy to implement; and execute quickly. Can we fix matters? How about a less primitive way of extracting the key stream. How about combining several streams to achieve any better security?

10
10 Very Simple Model LFSR 1 ZjZj f Use some function f to operate on some subset of the LFSR register components

11
11 Boolean Functions – Algebraic Normal Form (ANF) A Boolean function on n-inputs can be represented in minimal sum (XOR +) of products (AND.) form: This is the algebraic normal form of the function. The algebraic degree of the function is the size of the largest subset of inputs (i.e. the number of x j in it) associated with a non-zero co- efficient. 1 is a constant function (as is 0) x 1 +x 3 +x 5 is a linear function x 1.x 3 +x 5 is a quadratic function x 1.x 3.x 5 +x 4 x 5 +x 2 is a cubic function f(x 1,…,x n )=a 0 +a 1. x 1 +…+a n. x n + a 1,2.x 1.x 2 +…+ a n-1,n.x n-1.x n +… …+a 1,2,..,n x 1.x 2...x n

12
12 Very Simple Model LSFR 1 ZjZj f What about a linear function f?

13
13 Very Simple Model This would be pretty awful. Suppose we know a sequence of keystream bits z 0, z 1, z 2, z 2,…=1, 1, 1, 1,… Essentially every key stream output can be expressed as a linear function of the elements of the initial state. We can derive a number of these equations and then solve them by standard linear algebra techniques. 0011

14
14 Very Simple Model z 0 = s 0 +s 2 s3s3 s2s2 s1s1 s0s0 s 0 +s 3 s3s3 s2s2 s1s1 s 0 +s 1 +s 3 s 0 +s 3 s3s3 s2s2 s 0 +s 1 +s 2 +s 3 s 0 +s 1 +s 3 s 0 +s 3 s3s3 s 0 +s 1 +s 2 s 0 +s 1 +s 2 +s 3 s 0 +s 1 +s 3 s 0 +s 3 z 1 = s 1 +s 3 z 2 = s 2 +s 0 +s 3 z 3 = s 3 +s 0 +s 1 +s 3 = s 0 +s 1 XORed to give feedback

15
15 Very Simple Model z 0 = s 0 +s 2 z 1 = s 1 +s 3 z 2 = s 2 +s 0 +s 3 z 3 = s 3 +s 0 +s 1 +s 3 = s 0 +s 1 We can apply linear algebra equation solving techniques and solve for the s i s0s1s2s3s0s1s2s z0z1z2z3z0z1z2z3 This has solution s0s1s2s3s0s1s2s

16
16 Harder Model LSFR 1 ZjZj f What about a non- linear function f This is better but it is still possible to attack such systems if f is approximated by a linear function. We will talk about approximations later.

17
17 Classical Stream Cipher Model Plaintext Stream P j Keystream Z j Cipherstream C j LSFR 1 LSFR 2 LSFR n ZjZj L 1j L 2j L nj Combining Boolean function f. Receiver can generate key stream and recover plaintext N- Bit registers Initial register values form the ‘key’ Choose f very carefully f PjPj CjCj

18
18 Periodicity The LFSRs need not all be the same length. The LFSRs will give a vector input which has period that is the product of the least common multiple of the periods of each of the LFSRs. E.g. if period LFSR1=3,LFSR2=7 then overall period is 21

19
19 Awful Choice for f LSFR 1 LSFR 2 ZjZj x 1j x 2j 32- Bit registers Initial register values form the ‘key’ Zj=f(x 1j, x 2j )= x 1j f PjPj CjCj This is a truly awful choice. The key is intended to be 2 x 32 = 64 bits. You have completely ignored LFSR 2. Key size = 32 bits only

20
20 Better but Still Awful Choice for f LSFR 1 LSFR 2 ZjZj x 1j x 2j 32- Bit registers Initial register values form the ‘key’ f PjPj CjCj Congratulations! You have not ignored LFSR 2! Key size = 64 bits? Zj=f(x 1j, x 2j ) = x 1j x 2j +

21
21 Better but Still Awful Choice for f Well not quite such a good choice. Suppose you know 32 consecutive bits of plaintext (or can guess them correctly). Calculate the 32 bits of key stream. But if stream bit is 0 then there are only 2 possible pairs. Similarly, if stream value is 1. Effective key size = 2 32 x32x31x30x2x1 y32y31y30y2y ===== xk yk 0 + = = = or

22
22 First Bit of Bad Linearity The combination function here is a linear function of the inputs: f(x1,x2)=x1 f(x1,x2)=x2 f(x1,x2)=x1+x2 The following are quadratic functions: f(x1,x2)=x1.x2 + x1 f(x1,x2)= x1.x2 + x2 f(x1,x2)= x1.x2 + x1+x2 Extreme examples given but beware linearity - even a hint of it can spell trouble. linear functions are so called because they can cause some cryptosystems to be broken straight away??

23
23 Divide and Conquer Attacks Exploiting simple correlations in the combining function

24
24 Geffe Generator LSFR 1 LSFR 2 LSFR 3 ZjZj a 1j b 2j c 3j 2x1 Multiplexor select Z=(a & b) + (not(a) & c)

25
25 Geffe Generator – DIVIDE AND CONQUER Looking at the table it is clear that the output z agrees with b 75% of the time. Also agrees with c 75% of the time. abcz abcz

26
26 Geffe Generator – DIVIDE AND CONQUER So consider each possible initial state s of register LFSR2. Determine the LFSR2 stream that s produces. Check the degree of agreement of this stream with the actual key stream. Turns out: if state s is correct you will get roughly the right amount of agreement. if state s is incorrect you will get roughly random (50%) agreement. Thus we have targeted LFSR2 and can easily break it. Now can target LFSR3 in exactly the same way. So we can get LFSR2 and LFSR3. Now we can derive the selection LFSR1 state very straightforwardly: try every possible state. The correct one should allow you to simulate the whole sequence. Other ways too.

27
27 Divide and Conquer Divide and conquer attacks were suggested by Siegenthaler as a means of exploiting approximate linear relationships between function inputs and its output. This led to new criteria being developed as countermeasures to these correlation attacks. We will consider an extremely simple example.

28
28 Divide and Conquer Consider the following combining function f(x1,x2)=x1.x2+x1 Clearly not linear. But… f(x1,x2) agrees with x1 75% of the time here. Consider each possible initial state of LFSR1 and determine the degree of agreement with the actual key stream. The correct initial state will give approximately 75% agreement and the rest will give fairly random agreement. It’s also obvious that if we know f(x1,x2)=1 then we know both x1 and x2 => this is simply due to the incredibly small nature of the example. x1x2f(x1,x2)

29
29 Divide and Conquer Consider two functions f(x1,x2) and g(x1,x2) We say that f(x1,x2) is approximated by g(x1,x2) if the percentage of pairs (x1,x2) which given the same values for f and g differs from 50%. If they agree precisely half the time we say that they are uncorrelated. Note: if the percentage of agreement is less than 50% we can always find a function that has positive agreement, namely g(x1,x2)+true.

30
30 Ideas Generalise We can consider similar ideas for n-input functions: f(x1,x2,…,xn); and g(x1,x2,…,xn) Degree of approximation with linear functions may be slight. The smaller the degree of approximation the more data you need to have to break the system.

31
31 And then what? The idea of multiple LFSRs is that the size of the keyspace should be the product of the keyspace sizes for each register. Divide and conquer reduces this to a sum of key sizes and you attack each in turn. Note what happens when you crack one LFSR. The complexity of the remaining task is reduced: f(x1,x2)=x1.x2+x1 Once you know x1 then the task for x2 is simpler – whenever you know x1=1 you know what x2 is.

32
32 All Fall Down In a similar vein, suppose: There is a small exploitable correlation with input x1. There is a small correlation with x1+x2. If LFSR 1 can be broken to reveal x1 then we have now have a straightforward correlation with x2 to exploit.

33
33 Don’t tell them But what if you don’t publicise the taps sequence – keep the feedback polynomial secret (as part of the key). Makes things harder but there are in fact some further attacks here too.

34
34 Summary Have presented some very simple stream cipher models. Divide and conquer attacks. Dangers of linearity and hints of it. Next lecture: What do we do about the dangers? Boolean function criteria. High non-linearity. High algebraic degree. Correlation immunity. Tradeoffs between them.

35
35

36
36

37
37 Lectures begin at

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google