The document discusses stream ciphers, which encrypt plaintext one byte at a time using a pseudorandom bit generator and the XOR operation. It highlights the properties and design considerations for stream ciphers, emphasizing the importance of key length and randomness for security. RC4, a widely used stream cipher, is detailed, including its key scheduling and pseudorandom generation algorithms.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
13 views22 pages
Chapter 5
The document discusses stream ciphers, which encrypt plaintext one byte at a time using a pseudorandom bit generator and the XOR operation. It highlights the properties and design considerations for stream ciphers, emphasizing the importance of key length and randomness for security. RC4, a widely used stream cipher, is detailed, including its key scheduling and pseudorandom generation algorithms.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22
Stream Cipher Structure
Dr. Benita Jaison , St. Francis College
Random and Pseudorandom
1. Truly random - is defined as exhibiting ``true''
randomness. 2. Pseudorandom - is defined as having the appearance of randomness, but nevertheless exhibiting a specific, repeatable pattern. 3. Numbers calculated by a computer through a deterministic process, cannot, by definition, be random
Dr. Benita Jaison , St. Francis College
Stream Cipher • A typical stream cipher encrypts plaintext one byte at a time. • A stream cipher processes the input elements continuously producing output one element at a time . • A key is input to a pseudorandom bit generator that produces a random stream bit numbers. • The keystream output of the generator, is combined one byte at a time with the plaintext stream using the bitwise exclusive-OR (XOR) operation. • The primary advantage of a stream cipher is that stream ciphers are almost always faster and use far less code than do block ciphers.
Dr. Benita Jaison , St. Francis College
Stream Cipher Properties The following important design considerations for a stream cipher: • The encryption key sequence should have a large period, the longer the period of repeat the more difficult it will be to do cryptanalysis. • The keystream should approximate the properties of a true random number stream as close as possible, the more random- appearing the keystream is, the more randomized the ciphertext is, making cryptanalysis more difficult. • To guard against brute-force attacks, the key needs to be sufficiently long.Thus, with current technology, a key length of at least 128 bits is desirable. • With a properly designed pseudorandom number generator, a stream cipher can be as secure as block cipher of comparable key length. The primary advantage of a stream cipher is that stream ciphers are almost always faster and use far less code than do block ciphers. A stream cipher can be constructed with any cryptographically strong PRNG. Dr. Benita Jaison , St. Francis College Encryption Speed
Dr. Benita Jaison , St. Francis College
RC4 • RC4 is a stream cipher designed in 1987 by Ron Rivest for RSA Security. • It is a variable key-size stream cipher with byte- oriented operations. • The algorithm is based on the use of a random permutation. • The period of the cipher is greater than 10^100. • Eight to sixteen machine operations are required per output byte, and the cipher can be expected to run very quickly in software. • RC4 is the most widely used stream cipher. • It is used in the SSL/TLS secure web protocol, & in the WEP & WPA wireless LAN security protocols. Dr. Benita Jaison , St. Francis College RC 4 Algorithm • Designed by Ron Rivest for RSA Security • Variable key-size from 1 to 256 bytes. • S[255] is a state vector S, which contains a 8 bit number or a byte. • Key is used to initialise the state vector S. • T is a temporary vector of length 256 bytes. • K is repeatedly copied in to vector T, to fill out T. Dr. Benita Jaison , St. Francis College RC 4 Algorithm • Key Scheduling • Pseudo - Random Generation Algorithm (Stream Generation)
• CT = PT xor KeyStream • PT = CT xor KeyStream
Dr. Benita Jaison , St. Francis College
KEY SCHEDULING ALGORITHM j=0 for i = 0 to 255 do j = j + S[i] + K[i] mod 256 swap S[i] and S[j] end for
Dr. Benita Jaison , St. Francis College
KEY SCHEDULING • Uses an S Array of length 256 • where S[0] = 0 to S[255] = 255 • Suppose the key is K={"I AM THE KEY“}; • Key encoding using ASCII gives K={ 73, 32, 65, 77, 32, 84, 72, 69, 32, 75, 69, 89} • Key Array, K is of length 256, K[0] to K[255] • Element of the key array is repeated copied to vector T. • T[0] = 73,T[1] = 32, T[2] = 65, T[3] = 77, T[4] = 32, T[5] =84,……. ,T[11] = 89, T[12] = 73, T[13] = 32,…. T[255] = ? Dr. Benita Jaison , St. Francis College PSEUDO- RANDOM GENERATION ALGORITHM set i=0 and j= 0 for i = i + 1 j = j + S[i] mod 256 swap S[i] and S[j] t = S[i] + S[j] mod 256 KeyStream = S[t] end for
Dr. Benita Jaison , St. Francis College
KEY SCHEDULING • Suppose the S-Array is of length 8 • [S0, S1, S2, S3, S4, S5, S6, S7] = [0, 1, 2, 3, 4, 5, 6, 7] • Let the key be K = [3 1 4 1 5] • The T array thus is • [T0, T1, T2, T3, T4, T5, T6, T7] = [3, 1, 4, 1, 5, 3, 1,4]
Dr. Benita Jaison , St. Francis College
Initialisation • S is initialised from 0 to 255 in ascending order s[0]=0,s[1]=1,s[2]=2,s[3]=3,…..s[255]=255. • Key value K is transferred to T. If keylen is lesser than 256 bytes then K is repeatedly copied to T ,to fill out T. /* Initialisation */ • for i=0 to 255 • S[i]=i; (S[0]=0,S[1]=1,S[2]=2,…..S[255]=255) • T[i]=k[i mod keylen];
• → T[0]=k[0 mod 256] =k[0]
Dr. Benita Jaison , St. Francis College Initial permutation of S • S[0],S[1],….S[255] is having values in ascending order from 0 to 255. Using permutation, S values are swapped with one another. /* Initial Permutation */ j=0; for i=0 to 255 do j=(j + S[i]+T[i]) mod 256; Swap(S[i],S[j]);
Dr. Benita Jaison , St. Francis College
Stream Generation • The key K is only used for the initialisation of S vector. The key stream is generated using the S values. Stream generation involves cycling through all the elements of S[i] and for each S[i],swapping S[i] with another byte in S, once it reaches till S[255],it again starts from S[0].
/* Stream generation */
i=0,j=0; While (true) for i=0 to 255) j=(j+S[i])mod 256; Swap(S[i],S[j]); t=(S[i] + S[j]) mod 256; k=S[t];
Dr. Benita Jaison , St. Francis College
• k=S[t].
• To encrypt, XOR the value k with the next byte
of plaintext. • To decrypt ,XOR the value k with the next byte of cipher text.
Dr. Benita Jaison , St. Francis College
Example • Let K be of keylen 8 byte.(K can vary from 1 to 256 bytes). • Let S be the State vector and T be the temporary vector.
Dr. Benita Jaison , St. Francis College
Initialisation S[0]=0,S[1]=1,S[2]=2,…..S[255]=255
T[0]=k[0 mod 256] =k[0]
T[1]=k[1 mod 256] =k[1] T[2]=k[2 mod 256] =k[2] T[3]=k[3 mod 256] =k[3] T[4]=k[4 mod 256] =k[4] T[5]=k[5 mod 256] =k[5] T[6]=k[6 mod 256] =k[6] T[7]=k[7 mod 256] =k[7] T[8]=k[0 mod 256] =k[0] T[9]=k[1 mod 256] =k[1] T[10]=k[2 mod 256] =k[2] T[11]=k[3 mod 256] =k[3] T[12]=k[4 mod 256] =k[4] T[13]=k[5 mod 256] =k[5] T[14]=k[6 mod 256] =k[6] T[15]=k[7 mod 256] =k[7] T[16]=k[0 mod 256] =k[0] Dr. Benita Jaison , St. Francis College Initial permutation of S