BA Chapter2 Symmetric Encryption
BA Chapter2 Symmetric Encryption
plaintext to Bob
● Alice and Bob share a secret key
Secret Key
Insecure channel
● In a symmetric encryption scheme the encryption and decryption keys are the same
● Note that this definition does not cover any notion of security yet
● In contrast:
● The cipher
Plaintext A B C D E F G H I J K L M
Ciphertext E F G H I J K L M N O P Q
Plaintext N O P Q R S T U V W X Y Z
● Security of the Caesar cipher Ciphertext R S T U V W X Y Z A B C D
► Assume a message has been encrypted letter by letter using the Cesar cipher
► Try out each of the 25 keys and check if the resulting plaintext makes sense
§ Requires recognizable plaintext
► The key space is too small!
Plaintext A B C D E F G H I J K L M
Ciphertext E F G H I J K L M N O P Q
Plaintext N O P Q R S T U V W X Y Z
Ciphertext R S T U V W X Y Z A B C D
● Idea
► Replace each plaintext letter with one specific other letter according to a substitution table
► Plaintext space = ciphertext space = {A,…Z}
► Key space = all permutations of the letters A,…, Z
► Size of the key space: |𝒦| = 26! = 4.0329146 · 1026
● Example
Plaintext A B C D E F G H I J K L M
Ciphertext D H C E Z W V S J M L O Q
Plaintext N O P Q R S T U V W X Y Z
Ciphertext P A F K G N B R T Y I X U
► That is 10 4 4.0329146 · 1026 ms = 4.0329146 · 1027 ms = 4.0329146 · 1024 s = 6.7215243 4 1022 min
= 1.2788288 · 1017 years
● Let’s assume we
► Can decrypt 500 000 characters per ms and still need to decrypt 100 characters in order to be sure
𝟏 𝟏𝟎𝟎 𝟏 𝟏
● Then we will on average need ( ( |𝒦|= ( ( |𝒦|ms to find the right key
𝟐 𝟓𝟎𝟎 𝟎𝟎𝟎 𝟐 𝟓 𝟎𝟎𝟎
► That is 10-4 4 4.0329146 · 1026 ms = 4.0329146 · 1022 ms = 4.0329146 · 1019 s = 6.7215243 4 1017 min
= 1.2788288 · 1012 years
● For any given language and text basis one can determine the relative letter frequencies
Top 5
● Ciphertext C
E
► JW XAR DGZ FDGDPAJE XAR HZOJZTZ BSDB D TZGX ZTJO DBBDCLZG JN ARB BA VZB XAR
T
► JW XAR DGZ FDGDPAJE XAR HZOJZTZ BSDB D TZGX ZTJO DBBDCLZG JN ARB BA VZB XAR
A
► I? ?O? A?E ?A?A?OI? ?O? ?E?IE?E T?AT A ?E?? E?I? ATTA??E? I? O?T TO ?ET ?O?
O
I
Letter in C Z B D A J G C L X R W F P E D T O N V H
Frequency 8 7 7 6 5
Replace E T A O I R C K Y U F P N D H V L S G B
with
► I? ?O? ARE ?ARA?OI? ?O? ?E?IE?E T?AT A ?ER? E?I? ATTACKER I? O?T TO ?ET ?O?
► I? YOU ARE ?ARA?OI? YOU ?E?IE?E T?AT A ?ERY E?I? ATTACKER I? OUT TO ?ET YOU
► IF YOU ARE PARANOID YOU BELIEVE THAT A VERY EVIL ATTACKER IS OUT TO GET YOU
● Gives us 20 letters for which the mapping is known, i.e. 76,9% of the key
● Idea of Shanon
► A ciphertext should not reveal any new information on the plaintext Whether or not C is
observed, P is as
Definition: likely as its
occurrence in the
An encryption scheme is said to provide perfect secrecy if plaintext space
Given a probability distribution Pr on 𝒫, and Pr(𝑃) > 0 for all plaintexts 𝑃
For each 𝑃 ∈ 𝒫, 𝐶 ∈ 𝒞 and 𝐾 ∈ 𝒦 chosen uniformly at random Pr(𝑷|𝑪) = Pr(𝑷)
● This implies: |𝒦| ≥ |𝒞| ≥ |𝒫| for a perfectly secure encryption scheme
► |𝒞| ≥ |𝒫| holds for any encryption scheme as the encryption functions need to be injective
► If |𝒦| < |𝒞| would hold, then for any 𝑃 ∈ 𝒫, { 𝐸" (𝑃) | 𝑘 ∈ 𝒦} ≠ 𝒞, i.e., there is a 𝐶
∈ 𝒞 that does not occur as ciphertext of 𝑃 such that Pr(𝑃|𝐶) = 0 for this 𝐶
► As we assume Pr(𝑃) > 0, this contradict the perfect forward secrecy
Definition:
Given a probability distribution Pr on 𝒫, and Pr(𝑃) > 0 for all plaintexts 𝑃
An encryption scheme is said to provide perfect secrecy if
For each 𝑃 ∈ 𝒫, 𝐶 ∈ 𝒞 and 𝐾 ∈ 𝒦 chosen uniformly at random
Pr(𝑷|𝑪) = Pr(𝑷) Equivalent
1. Pr(C|P) = Pr(C)
2. Pr(C|P1) = Pr(C|P2)
Proof of 1.:
"# 𝐶𝑃 "#(%)
“⇐ ”: Assume Pr(𝐶|𝑃) = Pr(𝐶), then = Pr(P)
"#(')
Definition: Equivalent
Given a probability distribution Pr on 𝒫, and Pr(𝑃) > 0 for all plaintexts 𝑃 1. Pr(C|P) = Pr(C)
2. Pr(C|P1) = Pr(C|P2)
An encryption scheme is said to provide perfect secrecy if
For each 𝑃 ∈ 𝒫, 𝐶 ∈ 𝒞 and 𝐾 ∈ 𝒦 chosen uniformly at random
Pr(𝑷|𝑪) = Pr(𝑷)
Shannon’s Theorem:
Let | 𝒫| = |𝒞| = | 𝒦|, and Pr(𝑃) > 0 for all plaintexts 𝑃.
Then an encryption scheme provides perfect secrecy ⇔
1. K chosen uniformly at random for each plaintext to encrypt and
2. for each 𝑷 ∈ 𝒫 and 𝑪 ∈ 𝒞 there is exactly one 𝑲 ∈ 𝒦 with 𝑬𝑲(𝑷) = 𝑪
Proof
“⟹ “Assume encryption scheme is perfectly secure “⟸” Assume each key is equally likely and for each 𝑃,
► Let 𝑃 ∈ 𝒫 and assume there is a 𝐶 ∈ 𝒞 such that there 𝐶 and there is exactly one 𝐾 such that 𝐸𝐾 (𝑃) = 𝐶.
is no 𝐾 with 𝐸𝐾 (𝑃) = 𝐶, &
► Then, Pr(𝐶|𝑃) = |𝒦|
such that for any 𝐶 and 𝑃1, 𝑃2 it
► then Pr(𝑃|𝐶) = 0 and thus Pr(𝑃) ≠ Pr(𝑃|𝐶) which
&
contradicts the perfect secrecy. holds that Pr(𝐶|𝑃1) = Pr(𝐶|𝑃2) = |𝒦| , such that the
► Consequently, there must be at least one 𝐾 such that
second equivalent definition of perfect secrecy holds
𝐸𝐾 (𝑃) = 𝐶. As there are as many keys as ciphertexts,
there must be exactly one such 𝐾 for each 𝑃 and 𝐶.
► If 𝐾 was not chosen uniformly, then given 𝐶, there
would be some plaintexts that is more likely, than
others. This again contradicts the perfect secrecy.
=
𝐶 ⊕ 𝐾 = 𝑃 ⊕ 𝐾 ⊕ 𝐾 = 𝑃 𝐶 = 10001111
𝐶 = 10001111
⊕
𝐾 = 00110010
=
𝑃 = 10111101
Theorem:
The One-Time-Pad provides perfect secrecy
Proof:
► Follows directly from Shannon’s Theorem:
§ As | 𝒫| = |𝒞| = | 𝒦| per definition of the OTP, we can apply Shannon’s
Theorem
§ Key is selected uniformly at random in one-time pad ⟹ each key is
equally likely
§ Given any pair 𝐶, 𝑃 of ciphertext and plaintext there is a key K that
encrypts 𝑃 to 𝐶, namely 𝐾 = 𝑃 ⨁ 𝐶:
𝐸𝐾 (𝑃) = 𝑃 ⨁ 𝐾 = 𝑃 ⨁ (𝑃 ⨁ 𝐶) = 𝐶
Advantages Disadvantages
● Easy to compute ● Key must be as long as plaintext
► Encryption and decryption are the same ► Impractical in most realistic scenarios
► Still used for diplomatic and intelligence traffic
operation
● Does not guarantee integrity
► Bitwise XOR is very cheap to compute
► One-time pad only guarantees confidentiality
● As secure as theoretically possible
► Attacker cannot recover plaintext, but can easily
► Given a ciphertext, all plaintexts are equally change it to something else without being detected
likely ● Insecure if keys are reused
► Security independent on the attacker’s ► Attacker can obtain XOR of plaintexts
computational resources ● Obviously not practical for all applications
► Stream ciphers try to simulate the OTP based on a small random seed
► Block cipher encrypt complete blocks of plaintexts instead of single bits
● When do we call such encryption schemes secure?
Computational Security
An encryption scheme is called computationally secure if
► All known attacks against the cipher are computationally infeasible
► I.e., theoretically possible but would take too much time to be practical for any
(reasonable) amount of resources
● How can we attack encryption schemes
ciphertext
● Thus, he can collect ciphertext(s) and try to
?
3
Encryption
Decryption
● Attacker observes ciphertext and has access to one or more pair of plaintext and ciphertext
Example: ? 3
?
a known plaintext attack
Encryption
► One pair of plaintext / ciphertext Decryption
key
► Ciphertext-only setting
§ Try out each key to decrypt the ciphertext and check if resulting plaintext “makes sense”
§ Only works if valid plaintexts are recognizable for the attacker
► Known-plaintext setting
§ Try out each key to decrypt the ciphertext
§ Check if it decrypts to the known plaintext
|𝒦|
► On average attacker will have to try out keys
*
● As, e.g., been used to attack the security architecture WPA2 for WLAN
► RC4 ► SNOW 3G
§ Before its break used in WLAN, TLS, … § Supported by 3G/LTE/5G networks
● Any cipher that only provides computational security can break at any point in time
► We need to be prepared and always ensure that we can easily switch from one cipher to another
► DES ► KASUMI
§ Before its break used in IPSec, TLS, … § Supported by 3G/LTE/5G networks
► IDEA ► AES
§ Supported by TLS, IPSec,…
► … ► Camellia
§ Supported by TLS
► …
► We need to be prepared and always ensure that we can easily switch from one cipher to another
Plaintext Ciphertext
DESK
(64 bit) (64 bit)
● January 13th, 1999: DES key broken within 22 hours and 15 minutes
● Variants
§ Regardless of the key length § Broken shortly afterwards (or during presentation)
– DEAL, Frog, HPC, Loki97, Magenta
► Aug. 1999 finalists announced
§ MARS, RC6, Rijndael, Serpent, Twofish
Plaintext Ciphertext ► Oct. 2000 Rijndael selected as AES
AESK
(128 bit) (128 bit) ► Nov. 2001 AES standardized in FIPS 197
S ⊕ 𝐴·
Substitute Byte (SB) Round Key Addition (KA) Shift Row (SR) Mix Column (MC)
► 57 = 01010111 ⋍ 𝑥6 + 𝑥4 + 𝑥2 + 𝑥 + 1
► 83 = 10000011 ⋍ 𝑥7 + 𝑥 + 1
► (𝑥6 + 𝑥4 + 𝑥2 + 𝑥 + 1) (𝑥7 + 𝑥 + 1) = 𝑥13 + 𝑥11 + 𝑥9 + 𝑥8 + 𝑥7 + 𝑥7 + 𝑥5 + 𝑥3 + 𝑥2 + 𝑥 + x6 + x4 +
x2 + x + 1 = 𝑥13 + 𝑥11 + 𝑥9 + 𝑥8 + 𝑥6 + 𝑥5 + 𝑥4 + 𝑥3 + 1
Column 3
38 replaced with byte in S in
column 𝑏0𝑏1𝑏2𝑏3 and row 𝑏4𝑏5𝑏6𝑏7
35
Row 2
11000100
S-Box
lowest order bit here!
plaintext
KA SB SR MC* KA
next round
ciphertext
● The round key is always 128 bit key MC*: no mix column operation in the last round
► Different for each round, generated from the secret key
● Number of rounds depends on the key size
► 128 bit key: 10 rounds 192 bit key: 12 rounds 256 bit key: 14 rounds
𝐶1 𝐶2 𝐶3 𝐶4 … 𝐶
● Problem 𝑛
𝐶1 𝐶2 𝐶3 𝐶4 … 𝐶𝑛
● Standard Documents