Network Security: CS 6823 - Lecture 5 Cryptography
Network Security: CS 6823 - Lecture 5 Cryptography
Network Security: CS 6823 - Lecture 5 Cryptography
CS 6823 Lecture 5
Cryptography
Phillip Mak
[email protected]
Cryptography
Overview
Symmetric Key Cryptography
Public Key Cryptography
Message integrity and digital signatures
Cryptography basics
Cryptography is the process of converting plaintext into ciphertext.
Plaintext Readable text
Ciphertext Unreadable or encrypted text
History of Cryptography
Substitution Cipher
Replaces one letter with another letter based
on some key
Example: Julius Caesars Cipher
Key value of right shift 3
ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
World War I
Zimmerman Telegram
Encrypted telegram from
foreign secretary of the
German empire to German
ambassador in Mexico
Intercepted and decrypted
by the British
Indicated that unrestricted
sub warfare would
commence. Proposed an
alliance with Mexico to
reclaim lost land to US.
Pivotal in US entering WWI
Courtesy: Wikipedia
6
World War II
Enigma
Used by the
Germans
Replaced letters as
they were typed
Substitutions were
computed using a
key and a set of
switches and rotors.
Cryptography Issues
Confidentiality: only sender, intended receiver should understand
message contents:
sender encrypts message
receiver decrypts message
m plaintext message
KA(m) is ciphertext, encrypted with key KA
m = KB(KA(m))
11
M,
3
Cycling pattern:
e.g. n=4, M , M , M , M , M , M , M , M ,
1
13
14
Chosen-plaintext attack:
Eve can get the ciphertext from some chosen plaintext
15
Rainbow Tables
Rainbow Table
Pre-computes commonly used passwords
Time/Memory Tradeoff
Used to recover the plaintext from a given HASH value.
Commonly used to attack HASHed password
Types of Cryptography
Crypto often uses keys:
Algorithm is typically known to everyone
Only keys are secret Kerckhoffs Principle Can be extended to
security systems design in general
Hash functions
Involves the use of no keys
Nothing secret: How can this be useful?
18
20
21
22
Block Ciphers
Break plaintext message into equal-size blocks
Encrypt each block as a unit
23
Stream Ciphers:
Even easier
Attacker obtains two
ciphertexts, c and c,
generating with same key
sequence
c c = m m
There are well known
methods for decrypting two
plaintexts given their XOR
Integrity problem too
suppose attacker knows c
and m (eg, plaintext
attack);
wants to change m to m
calculates c = c (m
m)
25
26
Block Ciphers
Message to be encrypted is processed in blocks of k
bits (e.g., 64-bit blocks).
1-to-1 mapping is used to map k-bit block of plaintext
to k-bit block of ciphertext
Example with k=3
inputoutput
000110
001111
010101
011100
inputoutput
100011
101010
110000
111001
Block Ciphers
How many possible mappings are there for k=3?
How many 3-bit inputs?
How many permutations of the 3-bit inputs?
Answer: 23! = 40,320 ; not very many!
Prototype Function
64-bit input
8bits
8bits
8bits
8bits
8bits
8bits
8bits
8bits
S1
S2
S3
S4
S5
S6
S7
S8
8 bits
8 bits
8 bits
8 bits
8 bits
8 bits
8 bits
8 bits
Substitution
table
64-bit intermediate
Loop for
n rounds
64-bit output
29
From
Kaufman
et al
How about:
Generate random 64-bit number r(i) for each plaintext
block m(i)
Calculate c(i) = KS( m(i) r(i) )
Transmit c(i), r(i), i=1,2,
At receiver: m(i) = KS(c(i)) r(i)
Problem: inefficient, need to send c(i) and r(i)
31
33
35
37
Public Key
Cryptography
(Asymmetric)
radically different
approach [DiffieHellman76, RSA78]
sender, receiver do
not share secret key
public encryption key
known to all
private decryption key
known only to receiver
38
39
- +
K (K (m)) = m
B B
+
https://www.khanacademy.org/math/appl
iedmath/cryptography/modarithmetic/a/fast
-modular-exponentiation
41
KB
KB
43
mod n
44
RSA Example
Bob chooses p=5, q=7. Then n=35, =24.
e=5 (so e, relatively prime).
d=29 (so ed-1 exactly divisible by ).
decrypt:
bit pattern
e
m
0000lI00
12
248832
c
17
481968572106750915091411825223071697
e
c = m mod n
17
d
m = c mod n
12
45
K (K (m))
B B
+ = m= K (K (m))
B B
48
Session Keys
Exponentiation is computationally intensive
DES is at least 100 times faster than RSA
Session key, KS
Bob and Alice use RSA to exchange a symmetric
key KS
Once both have KS, they use symmetric key
cryptography
49
Diffie-Hellman
Allows two entities to agree on shared key.
But does not provide encryption
A=g mod
n a
K=B mod
n
b
g, n, A
B
B=g mod
n
b
K=A mod
n
50
Diffie-Hellman (cont)
Alice and Bob agree to use a prime number n=23 and
base g=5.
Alice chooses a secret integer a=6, then sends Bob A =
ga mod n
A = 56 mod 23 = 8.
52
Message Integrity
Allows communicating parties to verify that
received messages are authentic.
Content of message has not been altered
Source of message is who/what you think it is
Message has not been artificially delayed
(playback attack)
Sequence of messages is maintained
Encryption( )
Message
CipherText
o
r
Decryption( )
Encryption keeps
communications private
Encryption and decryption
can
use same or different keys
Achieved by various
algorithms,
e.g. DES, CAST
Need key management
Hash
Message Digest
Message Digests
Function H( ) that takes as input
an arbitrary length message and
outputs a fixed-length string:
message signature
Note that H( ) is a many-to-1
function
Desirable properties:
H( ) is often called a hash
Easy to calculate
function
Irreversibility
Collision resistance:
Computationally difficult
to produce m and m
such that H(m) = H(m)
Seemingly random output
55
56
Birthday Attack
If 23 people are in the room, what is the
chance that they all have different birthdays?
365 364 363 362 361 360
343
x
x
x
x
x
x...
365 365 365 365 365 365
365
= 49%
So theres a 51% chance that two of them
have the same birthday
59
Work Factor
Algorithms
Weak
O(240)
DES, MD5
Legacy
O(264)
RC4, SHA1
Minimum
O(280)
Standard
O(2128)
AES-128, SHA-256
High
O(2192)
AES-192, SHA-384
Ultra
O(2256)
AES-256, SHA-512
Authenticates sender
Verifies message integrity
No encryption!
Also called keyed hash
62
Playback Attack
Nonce (cont)
It is the fact that Alice knows KA-B and
uses it to encrypt a value that lets Bob
know that the message he receives was
generated by Alice.
The nonce is used to ensure that Alice is
"live." Bob decrypts the received
message. If the decrypted nonce equals
the nonce he sent Alice, then Alice is
authenticated.
66