Lecture#3
Lecture#3
Thanks to PK, Kohno, Kurose, Ross and others for sample slides and materials
Cryptography
1
Classical ciphers
Mono-alphabetic: Letters of the plaintext alphabet are
mapped into other unique letters
Poly-alphabetic: Letters of the plaintext alphabet are
mapped into letters of the ciphertext space depending
on their positions in the text
Substitution
5
a b c d e f g h i j k l m n o p q r s t u v w x y z
q e r y u i o p a s d f g w h j k l z x c v b n m t
Plaintext: under attack we need help
Ciphertext: cwyul qxxqrd bu wuuy pufj
[from Stallings, Cryptography & Network Security]
6
Transposition
7
Plain text: I a t t a c k
Key: 2342342 (key is “234”)
Cipher text: K d x v d g m
Problem of Vigenere Cipher
7-9
Hash Functions
No keys
Symmetric Key Cryptography
11
Blocks of
plaintext
Padding
16
DES operation
initial permutation
16 identical “rounds” of
function application,
each using different 48
bits of key
final permutation
The Advanced Encryption Standard (AES)
19
In 1997, the U.S. National Institute for Standards and Technology (NIST)
put out a public call for a replacement to DES.
It narrowed down the list of submissions to five finalists, and ultimately
chose an algorithm that is now known as the Advanced Encryption
Standard (AES).
AES is a block cipher that operates on 128-bit blocks. It is designed to
be used with keys that are 128, 192, or 256 bits long, yielding ciphers
known as AES-128, AES-192, and AES-256.
20
Weakness:
Strengths:
Documents and images are not
Is very simple suitable for ECB encryption since
Allows for parallel patters in the plaintext are
encryptions of the blocks repeated in the ciphertext:
of a plaintext
Can tolerate the loss or
damage of a block
Cipher Block Chaining (CBC) Mode
24
In Cipher Block Chaining (CBC) Mode
The previous ciphertext block is combined with the
current plaintext block C[i] = EK (C[i −1] P[i])
C[−1] = V, a random block separately transmitted
encrypted (known as the initialization vector)
Decryption: P[i] = C[i −1] DK (C[i])
CBC Encryption: CBC Decryption:
P[0] P[1] P[2] P[3] P[0] P[1] P[2] P[3]
V
V
EK EK EK EK DK DK DK DK
Strengths: Weaknesses:
Doesn’t show patterns in CBC requires the reliable
the plaintext transmission of all the
Is the most common mode
blocks sequentially
Is fast and relatively
CBC is not suitable for
simple
applications that allow
packet losses (e.g., music
and video streaming)
Stream Cipher
26
Key stream
Pseudo-random sequence of bits S = S[0], S[1], S[2], …
Can be generated on-line one bit (or byte) at the time
Stream cipher
XOR the plaintext with the key stream C[i] = S[i] P[i]
Suitable for plaintext of arbitrary length generated on the fly, e.g., media
stream
Synchronous stream cipher
Key stream obtained only from the secret key K
◼ Independent with plaintext and ciphertext
Works for high-error channels if plaintext has packets with sequence numbers
Sender and receiver must synchronize in using key stream
If a digit is corrupted in transmission, only a single digit in the plaintext is
affected and the error does not propagate to other parts of the message.
Stream Cipher
27
RC4
Designed in 1987 by Ron Rivest for RSA Security
Trade secret until 1994
Uses keys with up to 2,048 bits
Simple algorithm
Block cipher in counter mode (CTR)
Use a block cipher with block size b
The secret key is a pair (K,t), where K is key and t (counter) is a b-
bit value
The key stream is the concatenation of ciphertexts
EK (t), EK (t + 1), EK (t + 2), …
Can use a shorter counter concatenated with a random value
Synchronous stream cipher
Hash Functions
29
IV || || || || digest
SHA-1
Hashing Time MD5
0.06
0.05
0.04
msec
0.03
0.02
0.01
0
0 100 200 300 400 500 600 700 800 900 1000
Input Size (Bytes)
Cryptographic Hash Lifecycle
35
http://valerieaurora.org/hash.html
[via http://www.schneier.com/blog/archives/2011/06/the_life_cycle.html]
Birthday Attack
36
The brute-force birthday attack aims at finding a collision for a hash function h
Randomly generate a sequence of plaintexts X1, X2, X3,…
For each Xi compute yi = h(Xi) and test whether yi = yj for some j < i
Stop as soon as a collision has been found
If there are m possible hash values, the probability that the i-th plaintext does not collide
with any of the previous i −1 plaintexts is 1 − (i − 1)/m
The probability Fk that the attack fails (no collisions) after k plaintexts is
Fk = (1 − 1/m) (1 − 2/m) (1 − 3/m) … (1 − (k − 1)/m)
Using the standard approximation 1 − x e−x
Fk e−(1/m + 2/m + 3/m + … + (k−1)/m) = e−k(k−1)/2m
The attack succeeds/fails with probability ½ when Fk = ½ , that is,
e−k(k−1)/2m = ½
k 1.17 m½
We conclude that a hash function with b-bit values provides about b/2 bits of security
Public Key Cryptography
37
+ Bob’s public
K
B key
- Bob’s private
K
B key
Prime number p:
p is an integer
p2
The only divisors of p are 1 and p
Examples
2, 7, 19 are primes
−3, 0, 1, 6 are not primes
Prime decomposition of a positive integer n:
n = p1e1 … pkek
Example:
200 = 23 52
Fundamental Theorem of Arithmetic
The prime decomposition of a positive integer is unique
Greatest Common Divisor
40
Magic d
m = (m e mod n) mod n
happens!
c
RSA example:
45
letter m me c = me mod n
encrypt:
l 12 1524832 17
d
decrypt:
c c m = cd mod n letter
17 481968572106750915091411825223071697 12 l
Computational extensive
RSA: Why is that m = (m e mod n)
d
mod n
e
(m mod n) d mod n = medmod n
ed mod (p-1)(q-1)
= m mod n
(using number theory result above)
1
= m mod n
(since we chose ed to be divisible by
(p-1)(q-1) with remainder 1 )
= m
RSA: another important property
7-47
Setup: Example
n = pq, with p and q primes ◼ Setup:
e relatively prime to p = 7, q = 17
(n) = (p − 1) (q − 1) n = 717 = 119
d inverse of e in Z(n) (n) = 616 = 96
◼ ed mod z = 1 e=5
Keys: d = 77
Public key: KE = (n, e) ◼ Keys:
Private key: KD = d public key: (119, 5)
private key: 77
Encryption:
◼ Encryption:
Plaintext M in Zn
M = 19
C = Me mod n C = 195 mod 119 = 66
Decryption: ◼ Decryption:
M = Cd mod n C = 6677 mod 119 = 19
Digital Signatures
49
Asymmetry:
Signature can only be generated by owner/knower of private key
Signature can be verified by anyone via public key
Non-repudiation:
Sender cannot prove message (signature) was not sent
Key may have been stolen
Public Key Distribution and Authentication
50
Efficiency
Publickey cryptographic algorithms are orders of magnitude
slower than symmetric key algorithms
Hybrid model
Public
key used to establish temporary shared key
Symmetric key used for remainder of communication
Computational Security
52
⚫ What to hide
⚫ Texts
⚫ Images
⚫ Sound
⚫ ……
⚫ How to hide
– embed text in text/images/audio/video files
– embed image in text/images/audio/video files
– embed sound in text/images/audio/video files
A Real Steganographic Example
59
During WWI the following cipher message was
actually sent by a German spy
“Apparently neutral’s protest is thoroughly discounted
and ignored. Isman hard hit. Blockade issue affects
pretext for embargo on by-products, ejecting suets and
vegetable oils”
Hidden Message
“Pershingsails from NY June 1”
How to extract the hidden message from the sent
message?
A Steganographic System
60