SlideShare a Scribd company logo
1 of 31
Download to read offline
Understanding Cryptography – A Textbook for
Students and Practitioners
by Christof Paar and JanPelzl
www.crypto-textbook.com
Chapter 2 – Stream Ciphers
ver. October 29, 2009
These slides were prepared by Thomas Eisenbarth, Christof Paar and JanPelzl
Modified by Sam Bowne
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl2
Some legal stuff (sorry): Terms of Use
• The slides can used free of charge. All copyrights for the slides remain with
the authors.
• The title of the accompanying book “Understanding Cryptography” by
Springer and the author’s names must remain on eachslide.
• If the slides are modified, appropriate credits to the book authorsand the
book title must remain within the slides.
• It is not permitted to reproduce parts or all of the slides in printedform
whatsoever without written consent by the authors.
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl3
Contents of this Chapter
• Intro to stream ciphers
• Random number generators (RNGs)
• One-Time Pad (OTP)
• Linear feedback shift registers (LFSRs)
• Trivium: a modern stream cipher
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl4
Intro to Stream Ciphers
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Stream Ciphers in the Field of Cryptology
Cryptology
Cryptography Cryptanalysis
Symmetric Ciphers Asymmetric Ciphers Protocols
Block Ciphers Stream Ciphers
Stream Ciphers were invented in 1917 by Gilbert Vernam
5
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Stream Cipher
6
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Block Cipher
7
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Stream Cipher vs. Block Cipher
• Stream Ciphers
• Encrypt bits individually
• Usually small and fast
• Common in embedded devices (e.g., A5/1 for GSM phones)
• Block Ciphers:
• Always encrypt a full block (several bits)
• Are common for Internet applications
8
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
• Encryption and decryption are simple additions modulo 2 (aka XOR)
• Encryption and decryption are the same functions
xi , yi , si ∈ {0,1}• Encryption: yi = esi(xi ) = xi + si mod 2
• Decryption: xi = esi(yi ) = yi + si mod 2
■ Encryption and Decryption with Stream Ciphers
Plaintext xi, ciphertext yi and key stream si consist of individual bits
9
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Synchronous vs. Asynchronous Stream Cipher
• Security of stream cipher depends entirely on the key stream si :
• Should be random , i.e., Pr(si = 0) = Pr(si = 1) = 0.5
• Must be reproducible by sender and receiver
• Synchronous Stream Cipher
• Key stream depend only on the key (and possibly an initialization vector IV)
• Asynchronous Stream Ciphers
• Key stream depends also on the ciphertext (dotted feedback enabled)
10
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Why is Modulo 2 Addition a Good Encryption Function?
• Modulo 2 addition is equivalent to XOR operation
• For perfectly random key stream si , each ciphertext output bit
has a 50% chance to be 0 or 1
Good statistic property forciphertext
• Inverting XOR is simple, since it is the same XOR operation
xi si yi
0 0 0
0 1 1
1 0 1
1 1 0
11
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl12
■ Stream Cipher: Throughput
Performance comparison of symmetric ciphers(Pentium4):
Cipher Key length Mbit/s
DES 56 36.95
3DES 112 13.32
AES 128 51.19
RC4 (stream cipher) (choosable) 211.34
Source: Zhao et al., Anatomy and Performance of SSL Processing, ISPASS 2005
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl14
Random Number Generators (RNGs)
■ Random number generators (RNGs)
RNG
Cryptographically
Secure RNG
Pseudorandom NGTrue RNG
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl15
■ True Random Number Generators (TRNGs)
• Based on physical random processes: coin flipping, dice rolling, semiconductor
noise, radioactive decay, mouse movement, clock jitter of digital circuits
• Output stream si should have good statistical properties:
Pr(si = 0) = Pr(si = 1) = 50% (often achieved bypost-processing)
• Output can neither be predicted nor be reproduced
Typically used for generation of keys, nonces (used only-once values) and for
many other purposes
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl16
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl17
■ Pseudorandom Number Generator (PRNG)
•Generate sequences from initial seed value
•Typically, output stream has good statistical properties
•Output can be reproduced and can be predicted
•Often computed in a recursive way:
Example: rand() function in ANSIC:
Most PRNGs have bad cryptographic properties!
■ Cryptanalyzing a Simple PRNG
Simple PRNG: Linear Congruential Generator
S0 = seed
Si+1 = A Si + B mod m, i = 0, 1, 2, ...
Assume
• unknown A, B and S0 as key
• Size of A, B and Si to be 100 bit
• 300 bits of output are known, i.e. S1, S2 and S3
Solving
…directly reveals A and B. All Si can be computed easily!
Bad cryptographic properties due to the linearity of most PRNGs
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl18
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl19
■ Cryptographically Secure
Pseudorandom Number Generator
(CSPRNG)
• Special PRNG with additional property:
• Output must be unpredictable
More precisely: Given n consecutive bits of output si , the
following output bits sn+1
cannot be predicted (in polynomial time).
• Needed in cryptography, in particular for stream ciphers
• Remark: There are almost no other applications that need
unpredictability, whereas many, many (technical) systems
need PRNGs.
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl20
One-Time Pad (OTP)
■ One-Time Pad (OTP)
Unconditionally secure cryptosystem:
• A cryptosystem is unconditionally secure if it cannot be broken even with
infinite computational resources
One-Time Pad
• A cryptosystem developed by Mauborgne that is based on Vernam’s stream
cipher:
• Properties:
Let the plaintext, ciphertext and key consist of individual bits
xi, yi, ki ∈ {0,1}.
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl21
Encryption:
Decryption:
eki
(xi) = xi ⊕ ki.
dki
(yi) = yi ⊕ ki
OTP is unconditionally secure if and only if the key ki. is used once!
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl22
■ One-Time Pad (OTP)
Unconditionally secure cryptosystem:
Every equation is a linear equation with two unknowns
for every yi are xi = 0 and xi = 1 equiprobable!
This is true iff k0, k1, ... are independent, i.e., all ki have to be
generated truly random
It can be shown that this systems can provably not be solved.
Disadvantage: For almost all applications the OTP is impractical
since the key must be as long as the message! (Imagine you
have to encrypt a 1GByte email attachment.)
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl23
Linear Feedback Shift Registers (LFSRs)
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Linear Feedback Shift Registers (LFSRs)
• Concatenated flip-flops (FF), i.e., a shift register together with a feedback path
• Feedback computes fresh input by XOR of certain state bits
• Degree m given by number of storage elements
• If pi = 1, the feedback connection is present (“closed switch), otherwise there is
not feedback from this flip-flop (“open switch”)
• Output sequence repeats periodically
• Maximum output length: 2m-1
24
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Linear Feedback Shift Registers (LFSRs): Example with m=3
clk FF2 FF1 FF0=si
0 1 0 0
1 0 1 0
2 1 0 1
3 1 1 0
4 1 1 1
5 0 1 1
6 0 0 1
7 1 0 0
8 0 1 0
25
• LFSR output described by 

equations:
• Maximum output length (of 23-1=7) achieved only for certain
feedback configurations, .e.g., the one shown here.
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
*See Chapter 2 of Understanding Cryptography for furtherdetails.
■ Security of LFSRs
LFSRs typically described bypolynomials:
• Single LFSRs generate highly predictable output
• If 2m output bits of an LFSR of degree m are known, the feedback
coefficients pi of the LFSR can be found by solving a system of linear
equations*
• Because of this many stream ciphers use combinations of LFSRs
26
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl27
Trivium: a modern stream cipher
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ A Modern Stream Cipher - Trivium
• Three nonlinear LFSRs (NLFSR) of length 93, 84, 111
• XOR-Sum of all three NLFSR outputs generates key stream si
• Small in Hardware:
• Total register count: 288
• Non-linearity: 3 AND-Gates
• 7 XOR-Gates (4 with three inputs)
28
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl
■ Trivium
Initialization:
• Load 80-bit IV intoA
• Load 80-bit key into B
• Set c109 , c110 , c111 =1, all other bits 0
Warm-Up:
• Clock cipher 4 x 288 = 1152 times without generating output
Encryption:
• XOR-Sum of all three NLFSR outputs generates key stream si
Design can be parallelized to produce up to 64 bits of output per clock cycle
Register length Feedback bit Feedforward bit AND inputs
A 93 69 66 91, 92
B 84 78 69 82, 83
C 111 87 66 109, 110
29
Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl30
■ Lessons Learned
• Stream ciphers are less popular than block ciphers in most domains such as Internet
security. There are exceptions, for instance, the popular stream cipher RC4.
• Stream ciphers sometimes require fewer resources, e.g., code size or chip area, for
implementation than block ciphers, and they are attractive for use in constrained
environments such as cell phones.
• The requirements for a cryptographically secure pseudorandom number generator are far
more demanding than the requirements for pseudorandom number generators used in other
applications such as testing or simulation
• The One-Time Pad is a provable secure symmetric cipher. However, it is highly impractical
for most applications because the key length has to equal the messagelength.
• Single LFSRs make poor stream ciphers despite their good statistical properties.However,
careful combinations of several LFSR can yield strong ciphers.
2. Stream Ciphers

More Related Content

What's hot

Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash functionMijanur Rahman Milon
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographySeema Goel
 
Cryptography and network security
Cryptography and network securityCryptography and network security
Cryptography and network securitypatisa
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption StandardPrince Rachit
 
CRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYCRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYKathirvel Ayyaswamy
 
Data Encryption Standard (DES)
Data Encryption Standard (DES)Data Encryption Standard (DES)
Data Encryption Standard (DES)Haris Ahmed
 
Cryptography and Information Security
Cryptography and Information SecurityCryptography and Information Security
Cryptography and Information SecurityDr Naim R Kidwai
 
Advanced encryption standard (aes)
Advanced encryption standard (aes)Advanced encryption standard (aes)
Advanced encryption standard (aes)farazvirk554
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithmsRashmi Burugupalli
 
Topic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxTopic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxUrjaDhabarde
 
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere CipherCaesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere CipherMona Rajput
 
2. public key cryptography and RSA
2. public key cryptography and RSA2. public key cryptography and RSA
2. public key cryptography and RSADr.Florence Dayana
 
Message Authentication Code & HMAC
Message Authentication Code & HMACMessage Authentication Code & HMAC
Message Authentication Code & HMACKrishna Gehlot
 

What's hot (20)

Network security cryptographic hash function
Network security  cryptographic hash functionNetwork security  cryptographic hash function
Network security cryptographic hash function
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Cryptography and network security
Cryptography and network securityCryptography and network security
Cryptography and network security
 
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITYCS6701 CRYPTOGRAPHY AND NETWORK SECURITY
CS6701 CRYPTOGRAPHY AND NETWORK SECURITY
 
AES-Advanced Encryption Standard
AES-Advanced Encryption StandardAES-Advanced Encryption Standard
AES-Advanced Encryption Standard
 
CRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITYCRYPTOGRAPHY AND NETWORK SECURITY
CRYPTOGRAPHY AND NETWORK SECURITY
 
Cryptography
CryptographyCryptography
Cryptography
 
Symmetric and asymmetric key
Symmetric and asymmetric keySymmetric and asymmetric key
Symmetric and asymmetric key
 
Data Encryption Standard (DES)
Data Encryption Standard (DES)Data Encryption Standard (DES)
Data Encryption Standard (DES)
 
Cryptography and Information Security
Cryptography and Information SecurityCryptography and Information Security
Cryptography and Information Security
 
Advanced encryption standard (aes)
Advanced encryption standard (aes)Advanced encryption standard (aes)
Advanced encryption standard (aes)
 
Block Cipher
Block CipherBlock Cipher
Block Cipher
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
 
Topic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptxTopic20 The RC4 Algorithm.pptx
Topic20 The RC4 Algorithm.pptx
 
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere CipherCaesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
Caesar Cipher , Substitution Cipher, PlayFair and Vigenere Cipher
 
2. public key cryptography and RSA
2. public key cryptography and RSA2. public key cryptography and RSA
2. public key cryptography and RSA
 
Encryption algorithms
Encryption algorithmsEncryption algorithms
Encryption algorithms
 
Message Authentication Code & HMAC
Message Authentication Code & HMACMessage Authentication Code & HMAC
Message Authentication Code & HMAC
 
Cryptography.ppt
Cryptography.pptCryptography.ppt
Cryptography.ppt
 
Cryptography
CryptographyCryptography
Cryptography
 

Similar to 2. Stream Ciphers

3. The Data Encryption Standard (DES) and Alternatives
3. The Data Encryption Standard (DES) and Alternatives3. The Data Encryption Standard (DES) and Alternatives
3. The Data Encryption Standard (DES) and AlternativesSam Bowne
 
ChapterTwoCryptoTheStreamCipherFHSU.pptx
ChapterTwoCryptoTheStreamCipherFHSU.pptxChapterTwoCryptoTheStreamCipherFHSU.pptx
ChapterTwoCryptoTheStreamCipherFHSU.pptxssuser0a47f0
 
Introduction to Cryptography Parts II and III
Introduction to Cryptography Parts II and IIIIntroduction to Cryptography Parts II and III
Introduction to Cryptography Parts II and IIIMaksim Djackov
 
CRYPTO Module 05.in.pdf
CRYPTO Module 05.in.pdfCRYPTO Module 05.in.pdf
CRYPTO Module 05.in.pdfAnushaS405812
 
Introduction to Cryptography Part I
Introduction to Cryptography Part IIntroduction to Cryptography Part I
Introduction to Cryptography Part IMaksim Djackov
 
What is Cryptography?
What is Cryptography?What is Cryptography?
What is Cryptography?Pratik Poddar
 
SymmetricCryptography-Part3 - Tagged.pdf
SymmetricCryptography-Part3 - Tagged.pdfSymmetricCryptography-Part3 - Tagged.pdf
SymmetricCryptography-Part3 - Tagged.pdfMohammedMorhafJaely
 
1 Cryptography Introduction_shared.ppt
1 Cryptography Introduction_shared.ppt1 Cryptography Introduction_shared.ppt
1 Cryptography Introduction_shared.pptssuser0cd7c9
 
Stream ciphers presentation
Stream ciphers presentationStream ciphers presentation
Stream ciphers presentationdegarden
 
Lecture intro to_wcdma
Lecture intro to_wcdmaLecture intro to_wcdma
Lecture intro to_wcdmaGurpreet Singh
 
CNIT 141 5. Stream Ciphers
CNIT 141 5. Stream CiphersCNIT 141 5. Stream Ciphers
CNIT 141 5. Stream CiphersSam Bowne
 
CNIT 141: 2. Randomness
CNIT 141: 2. RandomnessCNIT 141: 2. Randomness
CNIT 141: 2. RandomnessSam Bowne
 
Cryptography and network security Nit701
Cryptography and network security Nit701Cryptography and network security Nit701
Cryptography and network security Nit701Amit Pathak
 
Detailed cryptographic analysis of contact tracing protocols
Detailed cryptographic analysis of contact tracing protocolsDetailed cryptographic analysis of contact tracing protocols
Detailed cryptographic analysis of contact tracing protocolsChristian Spolaore
 

Similar to 2. Stream Ciphers (20)

3. The Data Encryption Standard (DES) and Alternatives
3. The Data Encryption Standard (DES) and Alternatives3. The Data Encryption Standard (DES) and Alternatives
3. The Data Encryption Standard (DES) and Alternatives
 
ChapterTwoCryptoTheStreamCipherFHSU.pptx
ChapterTwoCryptoTheStreamCipherFHSU.pptxChapterTwoCryptoTheStreamCipherFHSU.pptx
ChapterTwoCryptoTheStreamCipherFHSU.pptx
 
Introduction to Cryptography Parts II and III
Introduction to Cryptography Parts II and IIIIntroduction to Cryptography Parts II and III
Introduction to Cryptography Parts II and III
 
Symmetric
SymmetricSymmetric
Symmetric
 
CRYPTO Module 05.in.pdf
CRYPTO Module 05.in.pdfCRYPTO Module 05.in.pdf
CRYPTO Module 05.in.pdf
 
Introduction to Cryptography Part I
Introduction to Cryptography Part IIntroduction to Cryptography Part I
Introduction to Cryptography Part I
 
What is Cryptography?
What is Cryptography?What is Cryptography?
What is Cryptography?
 
SymmetricCryptography-Part3 - Tagged.pdf
SymmetricCryptography-Part3 - Tagged.pdfSymmetricCryptography-Part3 - Tagged.pdf
SymmetricCryptography-Part3 - Tagged.pdf
 
1 Cryptography Introduction_shared.ppt
1 Cryptography Introduction_shared.ppt1 Cryptography Introduction_shared.ppt
1 Cryptography Introduction_shared.ppt
 
Cryptography-101
Cryptography-101Cryptography-101
Cryptography-101
 
Cryptography - 101
Cryptography - 101Cryptography - 101
Cryptography - 101
 
Stream ciphers presentation
Stream ciphers presentationStream ciphers presentation
Stream ciphers presentation
 
Lecture intro to_wcdma
Lecture intro to_wcdmaLecture intro to_wcdma
Lecture intro to_wcdma
 
Iss lecture 2
Iss lecture 2Iss lecture 2
Iss lecture 2
 
CNIT 141 5. Stream Ciphers
CNIT 141 5. Stream CiphersCNIT 141 5. Stream Ciphers
CNIT 141 5. Stream Ciphers
 
Modern Cryptography
Modern CryptographyModern Cryptography
Modern Cryptography
 
Edward Schaefer
Edward SchaeferEdward Schaefer
Edward Schaefer
 
CNIT 141: 2. Randomness
CNIT 141: 2. RandomnessCNIT 141: 2. Randomness
CNIT 141: 2. Randomness
 
Cryptography and network security Nit701
Cryptography and network security Nit701Cryptography and network security Nit701
Cryptography and network security Nit701
 
Detailed cryptographic analysis of contact tracing protocols
Detailed cryptographic analysis of contact tracing protocolsDetailed cryptographic analysis of contact tracing protocols
Detailed cryptographic analysis of contact tracing protocols
 

More from Sam Bowne

3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 

More from Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 

2. Stream Ciphers

  • 1. Understanding Cryptography – A Textbook for Students and Practitioners by Christof Paar and JanPelzl www.crypto-textbook.com Chapter 2 – Stream Ciphers ver. October 29, 2009 These slides were prepared by Thomas Eisenbarth, Christof Paar and JanPelzl Modified by Sam Bowne
  • 2. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl2 Some legal stuff (sorry): Terms of Use • The slides can used free of charge. All copyrights for the slides remain with the authors. • The title of the accompanying book “Understanding Cryptography” by Springer and the author’s names must remain on eachslide. • If the slides are modified, appropriate credits to the book authorsand the book title must remain within the slides. • It is not permitted to reproduce parts or all of the slides in printedform whatsoever without written consent by the authors.
  • 3. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl3 Contents of this Chapter • Intro to stream ciphers • Random number generators (RNGs) • One-Time Pad (OTP) • Linear feedback shift registers (LFSRs) • Trivium: a modern stream cipher
  • 4. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl4 Intro to Stream Ciphers
  • 5. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Stream Ciphers in the Field of Cryptology Cryptology Cryptography Cryptanalysis Symmetric Ciphers Asymmetric Ciphers Protocols Block Ciphers Stream Ciphers Stream Ciphers were invented in 1917 by Gilbert Vernam 5
  • 6. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Stream Cipher 6
  • 7. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Block Cipher 7
  • 8. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Stream Cipher vs. Block Cipher • Stream Ciphers • Encrypt bits individually • Usually small and fast • Common in embedded devices (e.g., A5/1 for GSM phones) • Block Ciphers: • Always encrypt a full block (several bits) • Are common for Internet applications 8
  • 9. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl • Encryption and decryption are simple additions modulo 2 (aka XOR) • Encryption and decryption are the same functions xi , yi , si ∈ {0,1}• Encryption: yi = esi(xi ) = xi + si mod 2 • Decryption: xi = esi(yi ) = yi + si mod 2 ■ Encryption and Decryption with Stream Ciphers Plaintext xi, ciphertext yi and key stream si consist of individual bits 9
  • 10. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Synchronous vs. Asynchronous Stream Cipher • Security of stream cipher depends entirely on the key stream si : • Should be random , i.e., Pr(si = 0) = Pr(si = 1) = 0.5 • Must be reproducible by sender and receiver • Synchronous Stream Cipher • Key stream depend only on the key (and possibly an initialization vector IV) • Asynchronous Stream Ciphers • Key stream depends also on the ciphertext (dotted feedback enabled) 10
  • 11. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Why is Modulo 2 Addition a Good Encryption Function? • Modulo 2 addition is equivalent to XOR operation • For perfectly random key stream si , each ciphertext output bit has a 50% chance to be 0 or 1 Good statistic property forciphertext • Inverting XOR is simple, since it is the same XOR operation xi si yi 0 0 0 0 1 1 1 0 1 1 1 0 11
  • 12. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl12 ■ Stream Cipher: Throughput Performance comparison of symmetric ciphers(Pentium4): Cipher Key length Mbit/s DES 56 36.95 3DES 112 13.32 AES 128 51.19 RC4 (stream cipher) (choosable) 211.34 Source: Zhao et al., Anatomy and Performance of SSL Processing, ISPASS 2005
  • 13.
  • 14. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl14 Random Number Generators (RNGs)
  • 15. ■ Random number generators (RNGs) RNG Cryptographically Secure RNG Pseudorandom NGTrue RNG Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl15
  • 16. ■ True Random Number Generators (TRNGs) • Based on physical random processes: coin flipping, dice rolling, semiconductor noise, radioactive decay, mouse movement, clock jitter of digital circuits • Output stream si should have good statistical properties: Pr(si = 0) = Pr(si = 1) = 50% (often achieved bypost-processing) • Output can neither be predicted nor be reproduced Typically used for generation of keys, nonces (used only-once values) and for many other purposes Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl16
  • 17. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl17 ■ Pseudorandom Number Generator (PRNG) •Generate sequences from initial seed value •Typically, output stream has good statistical properties •Output can be reproduced and can be predicted •Often computed in a recursive way: Example: rand() function in ANSIC: Most PRNGs have bad cryptographic properties!
  • 18. ■ Cryptanalyzing a Simple PRNG Simple PRNG: Linear Congruential Generator S0 = seed Si+1 = A Si + B mod m, i = 0, 1, 2, ... Assume • unknown A, B and S0 as key • Size of A, B and Si to be 100 bit • 300 bits of output are known, i.e. S1, S2 and S3 Solving …directly reveals A and B. All Si can be computed easily! Bad cryptographic properties due to the linearity of most PRNGs Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl18
  • 19. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl19 ■ Cryptographically Secure Pseudorandom Number Generator (CSPRNG) • Special PRNG with additional property: • Output must be unpredictable More precisely: Given n consecutive bits of output si , the following output bits sn+1 cannot be predicted (in polynomial time). • Needed in cryptography, in particular for stream ciphers • Remark: There are almost no other applications that need unpredictability, whereas many, many (technical) systems need PRNGs.
  • 20. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl20 One-Time Pad (OTP)
  • 21. ■ One-Time Pad (OTP) Unconditionally secure cryptosystem: • A cryptosystem is unconditionally secure if it cannot be broken even with infinite computational resources One-Time Pad • A cryptosystem developed by Mauborgne that is based on Vernam’s stream cipher: • Properties: Let the plaintext, ciphertext and key consist of individual bits xi, yi, ki ∈ {0,1}. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl21 Encryption: Decryption: eki (xi) = xi ⊕ ki. dki (yi) = yi ⊕ ki OTP is unconditionally secure if and only if the key ki. is used once!
  • 22. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl22 ■ One-Time Pad (OTP) Unconditionally secure cryptosystem: Every equation is a linear equation with two unknowns for every yi are xi = 0 and xi = 1 equiprobable! This is true iff k0, k1, ... are independent, i.e., all ki have to be generated truly random It can be shown that this systems can provably not be solved. Disadvantage: For almost all applications the OTP is impractical since the key must be as long as the message! (Imagine you have to encrypt a 1GByte email attachment.)
  • 23. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl23 Linear Feedback Shift Registers (LFSRs)
  • 24. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Linear Feedback Shift Registers (LFSRs) • Concatenated flip-flops (FF), i.e., a shift register together with a feedback path • Feedback computes fresh input by XOR of certain state bits • Degree m given by number of storage elements • If pi = 1, the feedback connection is present (“closed switch), otherwise there is not feedback from this flip-flop (“open switch”) • Output sequence repeats periodically • Maximum output length: 2m-1 24
  • 25. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Linear Feedback Shift Registers (LFSRs): Example with m=3 clk FF2 FF1 FF0=si 0 1 0 0 1 0 1 0 2 1 0 1 3 1 1 0 4 1 1 1 5 0 1 1 6 0 0 1 7 1 0 0 8 0 1 0 25 • LFSR output described by 
 equations: • Maximum output length (of 23-1=7) achieved only for certain feedback configurations, .e.g., the one shown here.
  • 26. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl *See Chapter 2 of Understanding Cryptography for furtherdetails. ■ Security of LFSRs LFSRs typically described bypolynomials: • Single LFSRs generate highly predictable output • If 2m output bits of an LFSR of degree m are known, the feedback coefficients pi of the LFSR can be found by solving a system of linear equations* • Because of this many stream ciphers use combinations of LFSRs 26
  • 27. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl27 Trivium: a modern stream cipher
  • 28. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ A Modern Stream Cipher - Trivium • Three nonlinear LFSRs (NLFSR) of length 93, 84, 111 • XOR-Sum of all three NLFSR outputs generates key stream si • Small in Hardware: • Total register count: 288 • Non-linearity: 3 AND-Gates • 7 XOR-Gates (4 with three inputs) 28
  • 29. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl ■ Trivium Initialization: • Load 80-bit IV intoA • Load 80-bit key into B • Set c109 , c110 , c111 =1, all other bits 0 Warm-Up: • Clock cipher 4 x 288 = 1152 times without generating output Encryption: • XOR-Sum of all three NLFSR outputs generates key stream si Design can be parallelized to produce up to 64 bits of output per clock cycle Register length Feedback bit Feedforward bit AND inputs A 93 69 66 91, 92 B 84 78 69 82, 83 C 111 87 66 109, 110 29
  • 30. Chapter 2 of Understanding Cryptography by Christof Paar and Jan Pelzl30 ■ Lessons Learned • Stream ciphers are less popular than block ciphers in most domains such as Internet security. There are exceptions, for instance, the popular stream cipher RC4. • Stream ciphers sometimes require fewer resources, e.g., code size or chip area, for implementation than block ciphers, and they are attractive for use in constrained environments such as cell phones. • The requirements for a cryptographically secure pseudorandom number generator are far more demanding than the requirements for pseudorandom number generators used in other applications such as testing or simulation • The One-Time Pad is a provable secure symmetric cipher. However, it is highly impractical for most applications because the key length has to equal the messagelength. • Single LFSRs make poor stream ciphers despite their good statistical properties.However, careful combinations of several LFSR can yield strong ciphers.