Network Security Fundamentals Explained
Network Security Fundamentals Explained
Security
Computer Networking:
A Top-Down Approach
8th edition
Jim Kurose, Keith Ross
Pearson, 2020
What is network security?
confidentiality: only sender, intended receiver should
“understand” message contents
• sender encrypts message
• receiver decrypts message
authentication: sender, receiver want to confirm identity of
each other
message integrity: sender, receiver want to ensure message
not altered (in transit, or afterwards) without detection
access and availability: services must be accessible and
available to users
Security: 8- 2
The language of cryptography
Alice’s Bob’s
KA encryption KB decryption
key key
plaintext encryption ciphertext decryption plaintext
algorithm algorithm
m: plaintext message
KA(m): ciphertext, encrypted with key KA
m = KB(KA(m))
Security: 8- 3
Breaking an encryption scheme
cipher-text only attack: known-plaintext attack:
Trudy has ciphertext she Trudy has plaintext
can analyze corresponding to
two approaches: ciphertext
• brute force: search • e.g., in monoalphabetic
cipher, Trudy determines
through all keys pairings for a,l,i,c,e,b,o,
• statistical analysis
chosen-plaintext attack:
Trudy can get ciphertext
for chosen plaintext
Security: 8- 4
Symmetric key cryptography
KS KS
plaintext: abcdefghijklmnopqrstuvwxyz
ciphertext: mnbvcxzasdfghjklpoiuytrewq
Security: 8- 7
Symmetric key crypto: DES
DES: Data Encryption Standard
US encryption standard [NIST 1993]
56-bit symmetric key, 64-bit plaintext input
block cipher with cipher block chaining
how secure is DES?
• DES Challenge: 56-bit-key-encrypted phrase decrypted (brute
force) in less than a day
• no known good analytic attack
making DES more secure:
• 3DES: encrypt 3 times with 3 different keys
Security: 8- 8
AES: Advanced Encryption Standard
symmetric-key NIST standard, replaced DES (Nov 2001)
processes data in 128 bit blocks
128, 192, or 256 bit keys
brute force decryption (try each key) taking 1 sec on
DES, takes 149 trillion years for AES
Security: 8- 9
Public Key Cryptography
symmetric key crypto: public key crypto
requires sender, receiver radically different
know shared secret key approach [Diffie-
Q: how to agree on key in Hellman76, RSA78]
first place (particularly if sender, receiver do not
never “met”)? share secret key
public encryption key
known to all
private decryption key
known only to receiver
Security: 8- 10
Public Key Cryptography
+
K
B
Bob’s public key
-
K Bob’s private key
B
Security: 8- 12
Prerequisite: modular arithmetic
x mod n = remainder of x when divide by
n
facts:
[(a mod n) + (b mod n)] mod n = (a+b) mod n
[(a mod n) - (b mod n)] mod n = (a-b) mod n
[(a mod n) * (b mod n)] mod n = (a*b) mod n
thus
(a mod n) mod n = a mod n
d d
dx = 14 = 196 x mod 10 = 6
2 d
Security: 8- 13
RSA: getting ready
message: just a bit pattern
bit pattern can be uniquely represented by an 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 ciphertext).
Security: 8- 14
RSA: Creating public/private key pair
1. choose two large prime numbers p, q. (e.g., 1024 bits
each)
2. compute n = pq, z = (p-1)(q
-1)
3. choose e (with e<n) that has no common factors with z (e,
z are “relatively prime”).
4. choose d such that ed-1 is exactly divisible by z. (in other
words: ed mod z = 1 ).
5. public key is (n,e). private key is (n,
d).
KB+ KB-
Security: 8- 15
RSA: encryption, decryption
0. given (n,e) and (n,d) as computed above
1. to encrypt message m (<n), compute
c = me mod
n
2. to decrypt received bit pattern, c, compute
m = c d mod n
Security: 8- 16
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.
decrypt:
c cd m = cdmod n
17481968572106750915091411825223071697 12
Security: 8- 17
Why does RSA work?
must show that cd mod n = m, where c = me mod n
fact: for any x and y: xy mod n = x(y mod z) mod n
• where n= pq and z = (p-1)(q-1)
thus,
cd mod n = (me mod n)d mod n
= med mod n
= m(ed mod z) mod n
= m1 mod n
=m
Security: 8- 18
RSA: another important property
The following property will be very useful later:
- + + -
K B(K (m)) = m= K (K (m))
B B B
Security: 8- 20
Why is RSA secure?
suppose you know Bob’s public key (n,e). How hard is it to
determine d?
essentially need to find factors of n without knowing the
two factors p and q
• fact: factoring a big number is hard
Security: 8- 21
RSA in practice: session keys
exponentiation in RSA is computationally intensive
DES is at least 100 times faster than RSA
use public key crypto to establish secure connection,
then establish second key – symmetric session key –
for encrypting data
session key, KS
Security: 8- 22
Authentication
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap1.0: Alice says “I am Alice”
Security: 8- 23
Authentication
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap1.0: Alice says “I am Alice”
in a network,
Bob can not
“see” Alice, so
Trudy simply
“I am Alice” declares herself
to be Alice
Security: 8- 24
Authentication: another try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap2.0: Alice says “I am Alice” in an IP packet
containing her source IP address
Alice’s
IP address “I am Alice”
failure scenario??
Security: 8- 25
Authentication: another try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap2.0: Alice says “I am Alice” in an IP packet
containing her source IP address
Security: 8- 26
Authentication: a third try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap3.0: Alice says “I am Alice” and sends her secret
password to “prove” it.
Alice’s Alice’s
IP addr password “I am Alice” failure scenario??
Alice’s OK
IP addr
Security: 8- 27
Authentication: a third try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap3.0: Alice says “I am Alice” and sends her secret
password to “prove” it.
playback attack:
Alice’s Alice’s
IP addr password “I am Alice” Trudy records
Alice’s packet
” and later
Alice
m
e’s rd“I a
plays it back to
ic
s
l
A wo
s ce’s OK Bob
e’
Alic ddr p
as Ali ddr
IP a IP a
Security: 8- 28
Authentication: a modified third try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap3.0: Alice says “I am Alice” and sends her
encrypted secret password to “prove” it.
Alice’s encrypted
IP addr password “I am Alice” failure scenario??
Alice’s OK
IP addr
Security: 8- 29
Authentication: a modified third try
Goal: Bob wants Alice to “prove” her identity to him
Protocol ap3.0: Alice says “I am Alice” and sends her
encrypted secret password to “prove” it.
Alice’s encrypted
IP addr password “I am Alice” playback attack still
works: Trudy
Alice
” records Alice’s
y
m
ptedd“I a packet
cr
n swor s OK
e’s e
Alic ddr p
as ce’
Ali ddr and later plays it
IP a
IP a back to Bob
Security: 8- 30
Authentication: a fourth try
Goal: avoid playback attack
nonce: number (R) used only once-in-a-lifetime
protocol ap4.0: to prove Alice “live”, Bob sends Alice nonce,
R
Alice must return R, encrypted with shared secret key
“I am Alice”
R
KA-B(R) Bob know Alice is live,
and only Alice knows key
to encrypt nonce, so it
Failures, drawbacks? must be Alice!
Security: 8- 31
Authentication: ap5.0
ap4.0 requires shared symmetric key - can we authenticate
using public key techniques?
ap5.0: use nonce, public key cryptography
“I am Alice”
Bob computes
R + -
- K (K (R)) = R
K A (R) A A
and knows only Alice could
Send me your public key have the private key, that
+ encrypted R such that
K A (R) + -
K (K (R)) = R
A A
Security: 8- 32
Authentication: ap5.0 – there’s still a flaw!
man (or woman) in the middle attack: Trudy poses as Alice (to
Bob) and as Bob (to Alice)
I am Alice I am Alice
R
?
-
K (R)
T
R Where are Send me your public key
- mistakes +
K (R) K Bob computes
A made here? T + -
Send me your public key K(K T(R)) = R,
+ T
K authenticating
A Trudy as Alice
Trudy recovers m: +
Trudy recovers Bob’s m: + - + K (m) Bob sends a
- + m = K (K (m)) T
m = K (K (m)) K (m) T T personal message,
A A A sends m to Alice m to Alice
and she and Bob meet a encrypted with
week later in person and Alice’s public key
discuss m, not knowing
Trudy knows m
Security: 8- 33
Digital signatures
cryptographic technique analogous to hand-written signatures:
sender (Bob) digitally signs document: he is document owner/creator.
verifiable, nonforgeable: recipient (Alice) can prove to someone that
Bob, and no one else (including Alice), must have signed document
simple digital signature for message m:
• Bob signs m by encrypting with his private key K , creating “signed” message,
B
K -(m)
B
- -
Bob’s message, m K B Bob’s private m,K B(m)
key
Dear Alice Dear Alice
Oh, how I have missed Oh, how I have missed
you. I think of you all
Public key you. I think of you all
the time! …(blah blah encryption the time! …(blah blah
blah)
algorithm blah) -
KB(m)
Bob Bob
Security: 8- 34
Digital signatures
-
suppose Alice receives msg m, with signature: m, KB(m)
+ -
Alice verifies m signed by Bob by applying Bob’s public key KB to
+ -
KB+(m)
- then checks KB(KB(m) ) = m.
Security: 8- 35
Message digests
computationally expensive to public-key-encrypt long
messages
goal: fixed-length, easy- to-compute digital “fingerprint”
apply hash function H to m, get fixed size message digest, H(m)
large
H: Hash
messag H(m)
e Function
m
Hash function properties:
many-to-1
produces fixed-size msg digest (fingerprint)
given message digest x, computationally infeasible to find m
such that x = H(m)
Security: 8- 36
Internet checksum: poor crypto hash function
Internet checksum has some properties of hash function:
produces fixed length digest (16-bit sum) of message
is many-to-one
but given message with given hash value, it is easy to find
another message with same hash value:
message ASCII format message ASCII format
IOU1 49 4F 55 31 IOU9 49 4F 55 39
00.9 30 30 2E 39 00.1 30 30 2E 31
9BOB 39 42 D2 42 9BOB 39 42 D2 42
B2 C1 D2 AC different messages B2 C1 D2 AC
but identical checksums!
Security: 8- 37
Digital signature = signed message digest
Bob sends digitally signed Alice verifies signature,
message: integrity of digitally signed
large
message H: Hash
H(m) message:
m Function encrypted
message
-
KBdigest
(H(m))
digital
Bob’s signature large
private -
key KB (encrypt) message
m digital
Bob’s signature
public +
key KB (decrypt)
encrypted H: Hash
+ message
- function
KBdigest
(H(m))
H(m) H(m)
?
equal
Security: 8- 38
Hash function algorithms
MD5 hash function widely used (RFC 1321)
• computes 128-bit message digest in 4-step process.
• arbitrary 128-bit string x, appears difficult to construct msg m
whose MD5 hash is equal to x
SHA-1 is also used
• US standard [NIST, FIPS PUB 180-1]
• 160-bit message digest
Security: 8- 39
Authentication: ap5.0 – let’s fix it!!
Recall the problem: Trudy poses as Alice (to Bob) and as Bob (to
Alice)
I am Alice I am Alice
R
?
-
K (R)
T
R Where are Send me your public key
- mistakes +
K (R) K Bob computes
A made here? T + -
Send me your public key K(K T(R)) = R,
+ T
K authenticating
A Trudy as Alice
Trudy recovers m: +
Trudy recovers Bob’s m: + - + K (m) Bob sends a
- + m = K (K (m)) T
m = K (K (m)) K (m) T T personal message,
A A A sends m to Alice m to Alice
and she and Bob meet a encrypted with
week later in person and Alice’s public key
discuss m, not knowing
Trudy knows m
Security: 8- 40
Need for certified public keys
motivation: Trudy plays pizza prank on
Bob
• Trudy creates e-mail order:
Dear Pizza Store, Please deliver to me
four pepperoni pizzas. Thank you, Bob
• Trudy signs order with her private key
• Trudy sends order to Pizza Store
• Trudy sends to Pizza Store her public
key, but says it’s Bob’s public key
• Pizza Store verifies signature; then
delivers four pepperoni pizzas to Bob
• Bob doesn’t even like pepperoni
Security: 8- 41
Public key Certification Authorities (CA)
certification authority (CA): binds public key to particular entity,
E
entity (person, website, router) registers its public key with CE
provides “proof of identity” to CA
• CA creates certificate binding identity E to E’s public key
• certificate containing E’s public key digitally signed by CA: CA says
“this is E’s public key”
Bob’s digital
public + signature +
key KB (encrypt) KB
CA’s
Bob’s
private
key
-
K certificate for Bob’s
identifying
CA public key, signed by
information CA
Security: 8- 42
Public key Certification Authorities (CA)
when Alice wants Bob’s public key:
• gets Bob’s certificate (Bob or elsewhere)
• apply CA’s public key to Bob’s certificate, get Bob’s public key
+
digital Bob’s
KB signature + public
(decrypt) K B key
CA’s
public +
key KCA
Security: 8- 43
Firewalls
firewall
isolates organization’s internal network from larger
Internet, allowing some packets to pass, blocking
others
administered public
network Internet
trusted “good guys” untrusted “bad guys”
firewall
Security: 8- 44
Firewalls: why
prevent denial of service attacks:
SYN flooding: attacker establishes many bogus TCP connections,
no resources left for “real” connections
prevent illegal modification/access of internal data
e.g., attacker replaces CIA’s homepage with something else
allow only authorized access to inside network
set of authenticated users/hosts
three types of firewalls:
stateless packet filters
stateful packet filters
application gateways
Security: 8- 45
Stateless packet filtering
Should arriving
packet be allowed
in? Departing
packet let out?
Security: 8- 48
Stateful packet filtering
stateless packet filter: heavy handed tool
• admits packets that “make no sense,” e.g., dest port = 80, ACK bit set, even
though no TCP connection established:
Security: 8- 49
Application gateways
filter packets on host-to-gateway
telnet session application
application data as well gateway
router and filter
as on IP/TCP/UDP fields.
example: allow select
internal users to telnet gateway-to-remote
host telnet session
outside
Security: 8- 51
Intrusion detection systems
packet filtering:
• operates on TCP/IP headers only
• no correlation check among sessions
IDS: intrusion detection system
• deep packet inspection: look at packet contents (e.g., check
character strings in packet against database of known virus,
attack strings)
• examine correlation among multiple packets
• port scanning
• network mapping
• DoS attack
Security: 8- 52
Intrusion detection systems
multiple IDSs: different types of checking at different
locations
firewall
internal
network
Internet
Security: 8- 53