6 Security
6 Security
Based on:
Computer Networking: A Top Down Approach ,
5th edition.
Jim Kurose, Keith Ross
Addison-Wesley, April 2009.
1
security in practice:
security in application, transport, network, link
layers
Firewalls (would not be covered)
Roadmap
Alice
channel
data
secure
sender
Bob
data, control
messages
secure
receiver
data
Trudy
5
Roadmap
encryption
algorithm
Bobs
K decryption
B key
ciphertext
decryption plaintext
algorithm
m plaintext message
KA(m) ciphertext, encrypted with key K A
m = KB(KA(m))
Monoalphabetic Cipher
substitution cipher: substituting one thing for another
plaintext:
abcdefghijklmnopqrstuvwxyz
ciphertext:
mnbvcxzasdfghjklpoiuytrewq
E.g.:
Monoalphabetic Cipher
Caesar Cipher:
11
Polyalphabetic encryption
n monoalphabetic cyphers, M1,M2,,Mn
Cycling pattern:
e.g., n=4, M1,M3,M4,M3,M2; M1,M3,M4,M3,M2;
For each new plaintext symbol, use
Known-plaintext attack:
eg, in monoalphabetic
cipher, trudy determines
pairings for a,l,i,c,e,b,o,
Chosen-plaintext attack:
13
Types of Cryptography
Crypto often uses keys:
Algorithm is known to everyone
Only keys are secret
Symmetric key cryptography (DES, AES)
Involves the use one key
Public key cryptography (RSA)
KS
plaintext
message, m
encryption ciphertext
algorithm
K (m)
S
decryption plaintext
algorithm
m = KS(KS(m))
15
16
Stream Ciphers
pseudo random
key
keystream
generator
keystream
17
18
Block ciphers
Message to be encrypted is processed in
input output
100
011
101
010
110
000
111
001
Block ciphers
How many possible mappings are there for
k=3?
20
From Kaufman
et al
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
64-bit intermediate
Loop for
n rounds
8-bit to
8-bit
mapping
64-bit output
21
22
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)
23
t=1
t=17
m(1) = HTTP/1.1
block
cipher
c(1)
m(17) = HTTP/1.1
block
cipher
c(17)
= k329aM02
= k329aM02
m(i)
c(i-1)
+
block
cipher
c(i)
25
26
Symmetric key
crypto: DES
DES operation
initial permutation
16 identical rounds of
function application,
each using different
48 bits of key
final permutation
27
28
plaintext
message, m
encryption ciphertext
algorithm
+
K (m)
B
- Bobs private
B key
decryption plaintext
algorithm message
+
m = K B(K (m))
B
30
+
given public key KB , it should be
Thus
(a mod n)d mod n = ad mod n
Example: x=14, n=10, d=2:
(x mod n)d mod n = 42 mod 10 = 6
xd = 142 = 196 xd mod 10 = 6
32
integer number.
Thus encrypting a message is equivalent to
encrypting a number.
Example
m= 10010001 . This message is uniquely
represented by the decimal number 145.
To encrypt m, we encrypt the corresponding
number, which gives a new number (the
cyphertext).
33
KB
KB
34
RSA example:
Bob chooses p=5, q=7. Then n=35, z=24.
e=5 (so e, z relatively prime).
d=29 (so ed-1 exactly divisible by z).
Encrypting 8-bit messages.
encrypt:
decrypt:
bit pattern
me
0000lI00
12
248832
c
17
d
c
481968572106750915091411825223071697
c = me mod n
17
m = cd mod n
12
36
where c = me mod n
Fact: for any x and y: xy mod n = x(y mod z) mod n
Thus,
K (K (m))
+ = m = K (K (m))
B B
Why
K (K (m))
+ = m = K (K (m))
B B
39
40
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
cryptography
41
Roadmap
42
Message Integrity
Allows communicating parties to verify that
43
Message Digests
Function H( ) that takes as
large
message
m
H: Hash
Function
H(m)
Desirable properties:
Easy to calculate
Irreversibility: Cant
determine m from H(m)
Collision resistance:
Computationally difficult
to produce m and m such
that H(m) = H(m)
Seemingly random output
44
45
46
s
message
message
H( )
H( )
compare
Authenticates sender
Verifies message integrity
No encryption !
Also called keyed hash
Notation: MDm = H(s||m) ; send m||MDm
47
HMAC
Popular MAC standard
Addresses some subtle security flaws
48
End-point authentication
Want to be sure of the originator of the
49
Playback attack
MAC =
f(msg,s)
Transfer $1M
from Bill to Trudy MAC
50
Transfer $1M
from Bill to Susan
MAC
51
Roadmap
52
protocol
Originally designed by
Netscape in 1993
Number of variations:
Provides
Confidentiality
Integrity
Authentication
Original goals:
applications
53
Application
SSL
TCP
IP
IP
Normal Application
Application
with SSL
certificate
KB +(MS) = EMS
MS = master secret
EMS = encrypted master secret
56
cryptographic operation
Four keys:
Kc = encryption key for data sent from client to server
Mc = MAC key for data sent from client to server
Ks = encryption key for data sent from server to client
Ms = MAC key for data sent from server to client
Keys derived from key derivation function (KDF)
Takes master secret and (possibly) some additional
random data and creates the keys
57
write it to TCP?
length
data
MAC
58
re-order records
Solution: put sequence number into MAC:
records
59
closure
data
MAC
60
encrypted
bob.com
, data
1
q
e
s
,
0
e
typ
62
63
Real
Connection
handshake: ClientHel
lo
ServerHello
:
e
k
a
h
s
d
n
a
h
tificate
r
e
C
:
e
k
a
h
s
hand
lloDone
e
H
r
e
v
r
e
S
:
handshake
handshake: ClientK
eyExchange
ChangeCipherS
pec
handshake: Finish
ed
Everything
henceforth
is encrypted
pec
ChangeCipherS
: Fin
handshake
ished
application_dat
a
ata
application_d
Key derivation
Client nonce, server nonce, and pre-master secret
Roadmap
66
would be hidden:
for security.
68
IPsec
header
Secure
payload
IPsec
heade
r
laptop
w/ IPsec
salesperson
in hotel
ec
IPs der
a
he
I P er
ad
he
Secur
e
paylo
ad
Public
Internet
IP
heade
r
re
cu
Se load
y
pa
Router w/
IPv4 and IPsec
IP er
ad
he
pay
loa
d
Router w/
IPv4 and IPsec
IP
hea
der
ad
ylo
pa
headquarters
branch office
69
IPsec services
Data integrity
Origin authentication
Replay attack prevention
Confidentiality
Two protocols providing different service
models:
AH
ESP
70
IPsec
IPsec
end-system.
Protects upper level protocols
71
IPsec
IPsec
not be.
72
IPsec
IPsec
73
Two protocols
Authentication Header (AH) protocol
provides source authentication & data integrity
but not confidentiality
Encapsulation Security Protocol (ESP)
provides source authentication,data integrity,
and confidentiality
more widely used than AH
74
Host mode
with ESP
Tunnel mode
with AH
Tunnel mode
with ESP
state
76
Example SA from R1 to R2
Internet
Headquarters
200.168.1.100
R1
172.16.1/24
SA
Branch Office
193.68.2.23
R2
172.16.2/24
R1 stores for SA
32-bit identifier for SA: Security Parameter Index (SPI)
the origin interface of the SA (200.168.1.100)
destination interface of the SA (193.68.2.23)
type of encryption to be used (for example, 3DES with CBC)
encryption key
type of integrity check
authentication key
77
IPsec datagram
Focus for now on tunnel mode with ESP
enchilada authenticated
encrypted
new IP
header
ESP
hdr
SPI
original
IP hdr
Seq
#
Original IP
datagram payload
padding
ESP
trl
ESP
auth
pad
next
length header
79
What happens?
Internet
Headquarters
200.168.1.100
SA
Branch Office
193.68.2.23
R1
R2
172.16.1/24
172.16.2/24
enchilada authenticated
encrypted
new IP
header
ESP
hdr
SPI
original
IP hdr
Seq
#
Original IP
datagram payload
padding
ESP
trl
ESP
auth
pad
next
length header
80
ESP
hdr
SPI
original
IP hdr
Seq
#
Original IP
datagram payload
padding
ESP
trl
ESP
auth
pad
next
length header
secret key
82
Method:
Destination checks for duplicates
But doesnt keep track of ALL received packets; instead
uses a window
83
arriving datagram;
Info in the SAD indicates how to do it.
84
85
86
87
IKE Phases
IKE has two phases
Phase 1: Establish bi-directional IKE SA
Note: IKE SA different from IPsec SA
Also called ISAKMP security association
88
Summary of IPsec
IKE message exchange for algorithms, secret
89
90