lecture 2 crypto and basics of protocols
DESCRIPTION
TRANSCRIPT
![Page 1: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/1.jpg)
S-38.3153Mikko Särelä
keskiviikkona 28. maaliskuuta 2012
![Page 2: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/2.jpg)
Today’s plan
• Learn about protocols
• Remote login
• How to solve security problems?
• How can cryptography help?
keskiviikkona 28. maaliskuuta 2012
![Page 3: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/3.jpg)
Remote login
• A simple protocol to remotely login to a computer as if you were physically present
keskiviikkona 28. maaliskuuta 2012
![Page 4: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/4.jpg)
Remote login
Alice HalHi Hal! I’m Alice
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
keskiviikkona 28. maaliskuuta 2012
![Page 5: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/5.jpg)
What kind of security problems do you see?
keskiviikkona 28. maaliskuuta 2012
![Page 6: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/6.jpg)
Remote login
Alice HalHi Hal! I’m Alice
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
keskiviikkona 28. maaliskuuta 2012
![Page 7: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/7.jpg)
Remote login
Alice HalHi Hal! I’m Alice
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
Mallory
keskiviikkona 28. maaliskuuta 2012
![Page 8: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/8.jpg)
How would you fix the security problems?
keskiviikkona 28. maaliskuuta 2012
![Page 9: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/9.jpg)
Secure Shell
• Use public key cryptography to authenticate remote end
• Leap of faith for first time connections
• User is authenticated with password or public key crypto
• This communication is encrypted
keskiviikkona 28. maaliskuuta 2012
![Page 10: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/10.jpg)
Cryptography basicsMikko Särelä, Dr. Tech
20 March 2012
keskiviikkona 28. maaliskuuta 2012
![Page 11: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/11.jpg)
Security and cryptologyThe same thing?
keskiviikkona 28. maaliskuuta 2012
![Page 12: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/12.jpg)
Crypto overview
• Public key cryptography
• Key exchange
• Symmetric key cryptography
• Secure hash
keskiviikkona 28. maaliskuuta 2012
![Page 13: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/13.jpg)
Crypto basics
• Plaintext message m
• Crypto-algorithm
• Key k
• Encrypted text
keskiviikkona 28. maaliskuuta 2012
![Page 14: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/14.jpg)
Public key cryptography
keskiviikkona 28. maaliskuuta 2012
![Page 15: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/15.jpg)
Two keys - private and public
keskiviikkona 28. maaliskuuta 2012
![Page 16: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/16.jpg)
Some math
• RSA and Diffie-Hellman based on modulo arithmetics
• the difficulty of division operation, logarithm, and factoring
keskiviikkona 28. maaliskuuta 2012
![Page 17: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/17.jpg)
Modulo0
3
1
2
5
4
9
8 7 6
10
11
12
keskiviikkona 28. maaliskuuta 2012
![Page 18: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/18.jpg)
Addition and multiplication easy
keskiviikkona 28. maaliskuuta 2012
![Page 19: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/19.jpg)
Division is hardFactoring is hard
keskiviikkona 28. maaliskuuta 2012
![Page 20: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/20.jpg)
Example: RSA
• n = p*q, p and q large primes
• Choose public key e as relative prime for (p-1)(q-1)
• Private key d = e-1 mod ((p-1)(q-1))
• Encrypting c = me mod n
• Decrypting m = cd mod n
keskiviikkona 28. maaliskuuta 2012
![Page 21: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/21.jpg)
Problem
• p = 11, q = 3
• e = 3
• What is d?
• Encrypt message m = 7
• Decrypt the result
keskiviikkona 28. maaliskuuta 2012
![Page 22: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/22.jpg)
Solution
• c = me mod n = 73 mod 33 = 343 mod 33 = 13.
• c = 13
• To check decryption:
• m’ = cd = 137 mod 33 = 7
keskiviikkona 28. maaliskuuta 2012
![Page 23: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/23.jpg)
Cipher text for all m
m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16c 0 1 8 27 31 26 18 13 17 3 10 11 12 19 5 9 4
m 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32
keskiviikkona 28. maaliskuuta 2012
![Page 24: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/24.jpg)
Cipher text for all m
m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16c 0 1 8 27 31 26 18 13 17 3 10 11 12 19 5 9 4
m 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32
keskiviikkona 28. maaliskuuta 2012
![Page 25: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/25.jpg)
Depends onFactoring being hard!
keskiviikkona 28. maaliskuuta 2012
![Page 26: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/26.jpg)
Usage
• Use public key to encrypt data
• Private key is used to decrypt it
• Or use private key to sign data
• Public key can be used to verify the signature
• Only owner of private key can sign
• Basis for certificates
keskiviikkona 28. maaliskuuta 2012
![Page 27: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/27.jpg)
Diffie-Hellman
keskiviikkona 28. maaliskuuta 2012
![Page 28: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/28.jpg)
(AB)C = Ab*c = (AC)B
keskiviikkona 28. maaliskuuta 2012
![Page 29: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/29.jpg)
Diffie-Hellmanhttp://upload.wikimedia.org/wikipedia/commons/a/a3/Diffie-Hellman-Schlüsselaustausch.png
keskiviikkona 28. maaliskuuta 2012
![Page 30: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/30.jpg)
Symmetric key cryptography
keskiviikkona 28. maaliskuuta 2012
![Page 31: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/31.jpg)
Block cipherStream cipher
keskiviikkona 28. maaliskuuta 2012
![Page 32: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/32.jpg)
Block cipher
Block cipher encryption
Key
Plaintext
Ciphertext
keskiviikkona 28. maaliskuuta 2012
![Page 33: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/33.jpg)
Stream cipher
Plaintext
AIVK
Kstream
Ciphertext
Ciphertext
AIVK
Kstream
PlaintextXOR
keskiviikkona 28. maaliskuuta 2012
![Page 34: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/34.jpg)
Ciphers overview
keskiviikkona 28. maaliskuuta 2012
![Page 35: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/35.jpg)
• Symmetric ciphers• Fast• require separate key exchange• Public key ciphers• Slow• No key exchange required• usage: signatures, certificates, encrypt
symmetric cipher key inside a message• How to get random keys?
keskiviikkona 28. maaliskuuta 2012
![Page 36: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/36.jpg)
Cryptographic hashes
keskiviikkona 28. maaliskuuta 2012
![Page 37: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/37.jpg)
Ideal hash-function
• easy to compute the hash value for any given message• infeasible to generate a message that has a
given hash• infeasible to modify a message without
changing the hash• infeasible to find two different messages
with the same hash
keskiviikkona 28. maaliskuuta 2012
![Page 38: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/38.jpg)
Keyed hash
keskiviikkona 28. maaliskuuta 2012
![Page 39: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/39.jpg)
Applications
• Verifying integrity of a message using keyed hash function
• file or data identifier
• pseudorandom number generation and key generation
• hash chains
keskiviikkona 28. maaliskuuta 2012
![Page 40: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/40.jpg)
Cryptographic Hash functions
• SHA-256 as an example
• Birthday attack
• Keyed hash is usually marked as
• h(k, M)
keskiviikkona 28. maaliskuuta 2012
![Page 41: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/41.jpg)
Secure Shell
keskiviikkona 28. maaliskuuta 2012
![Page 42: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/42.jpg)
What is SSH?
• A set of protocols that is designed to provide a secure communication channel between host and a server
• Covers authentication, encryption, and data integrity
• Originally replacement for telnet/rlogin/rsh
• SFTP also
keskiviikkona 28. maaliskuuta 2012
![Page 43: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/43.jpg)
History
• Tatu Ylönen developed the first version in 1995
• SSH protocol version 2 in 1998 because of protocol vulnerabilities
• Many open and commercial versions available for all operating systems
keskiviikkona 28. maaliskuuta 2012
![Page 44: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/44.jpg)
Protocol details
• Client/server architecture
• Server listens to port 22
• Client wanting to connect executes an ssh command
• port forwarding
keskiviikkona 28. maaliskuuta 2012
![Page 45: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/45.jpg)
SSH Protocol Stack
IP
TCP
SSH Transportation protocol
SSH Connection ProtocolMultiplexes encrypted tunnel into several
logical channels
SSH User Authentication protocolAuthenticates client-side user to the
server
keskiviikkona 28. maaliskuuta 2012
![Page 46: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/46.jpg)
Transport layer
• Initial key exchange
• Server authentication
• Data confidentiality
• Data Integrity
• Compression (optional)
• key re-exchange
keskiviikkona 28. maaliskuuta 2012
![Page 47: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/47.jpg)
Transport layer
• Server authenticates itself to client
• No man-in-the-middle attacks
keskiviikkona 28. maaliskuuta 2012
![Page 48: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/48.jpg)
SSH ProtocolClient Server
TCP connection setup
SSH version string exchange
SSH Key exchange
SSH data exchange
Termination of the TCP connection
keskiviikkona 28. maaliskuuta 2012
![Page 49: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/49.jpg)
SSH key exchange• Client and server send kex_init packet, containing a list
of crypto algorithms they support
• First common key exchange algorithm supported by server is chosen
• Used to negotiate server authentication, encryption, MAC, and compression
• Opportunistic guess allowed
• Establish shared secret k and
• Authenticate server
• with public key signature or shared key authentication with MAC
keskiviikkona 28. maaliskuuta 2012
![Page 50: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/50.jpg)
User authentication
• Client authentication
• password
• public key cryptography
• host based authentication
keskiviikkona 28. maaliskuuta 2012
![Page 51: Lecture 2 crypto and basics of protocols](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b5e7284a795948248b45bd/html5/thumbnails/51.jpg)
Connection layer
• Defines logical channels
• Requests for TCP port forwarding, X11 forwarding etc.
keskiviikkona 28. maaliskuuta 2012