1. S-38.3153
Mikko Särelä
keskiviikkona 28. maaliskuuta 2012
2. Today’s plan
• Learn about protocols
• Remote login
• How to solve security problems?
• How can cryptography help?
keskiviikkona 28. maaliskuuta 2012
3. Remote login
• A simple protocol to remotely login to a
computer as if you were physically present
keskiviikkona 28. maaliskuuta 2012
4. Remote login
Alice Hi Hal! I’m Alice Hal
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
keskiviikkona 28. maaliskuuta 2012
5. What kind of security
problems do you see?
keskiviikkona 28. maaliskuuta 2012
6. Remote login
Alice Hi Hal! I’m Alice Hal
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
keskiviikkona 28. maaliskuuta 2012
7. Remote login
Mallory
Alice Hi Hal! I’m Alice Hal
What’s your password?
It’s BobAteMyCat
Access granted
> run emacs mythesis.txt
keskiviikkona 28. maaliskuuta 2012
8. How would you fix the
security problems?
keskiviikkona 28. maaliskuuta 2012
9. 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
10. Cryptography basics
Mikko Särelä, Dr. Tech
20 March 2012
keskiviikkona 28. maaliskuuta 2012
15. Two keys -
private and public
keskiviikkona 28. maaliskuuta 2012
16. Some math
• RSA and Diffie-Hellman based on modulo
arithmetics
• the difficulty of division operation,
logarithm, and factoring
keskiviikkona 28. maaliskuuta 2012
18. Addition and
multiplication easy
keskiviikkona 28. maaliskuuta 2012
19. Division is hard
Factoring is hard
keskiviikkona 28. maaliskuuta 2012
20. 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 = m mod n e
• Decrypting m = c mod n d
keskiviikkona 28. maaliskuuta 2012
21. Problem
• p = 11, q = 3
• e=3
• What is d?
• Encrypt message m = 7
• Decrypt the result
keskiviikkona 28. maaliskuuta 2012
22. Solution
• c = me mod n = 73 mod 33 = 343 mod 33
= 13.
• c = 13
• To check decryption:
• m’ = c = 13 mod 33 = 7
d 7
keskiviikkona 28. maaliskuuta 2012
23. Cipher text for all m
m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
c 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 32
c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32
keskiviikkona 28. maaliskuuta 2012
24. Cipher text for all m
m 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
c 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 32
c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32
keskiviikkona 28. maaliskuuta 2012
25. Depends on
Factoring being hard!
keskiviikkona 28. maaliskuuta 2012
26. 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
35. • 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
37. 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
39. 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
40. Cryptographic Hash
functions
• SHA-256 as an example
• Birthday attack
• Keyed hash is usually marked as
• h(k, M)
keskiviikkona 28. maaliskuuta 2012
42. 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
43. 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
44. Protocol details
• Client/server architecture
• Server listens to port 22
• Client wanting to connect executes an ssh
command
• port forwarding
keskiviikkona 28. maaliskuuta 2012
45. SSH Protocol Stack
SSH User Authentication protocol SSH Connection Protocol
Authenticates client-side user to the Multiplexes encrypted tunnel into several
server logical channels
SSH Transportation protocol
TCP
IP
keskiviikkona 28. maaliskuuta 2012
46. Transport layer
• Initial key exchange
• Server authentication
• Data confidentiality
• Data Integrity
• Compression (optional)
• key re-exchange
keskiviikkona 28. maaliskuuta 2012
47. Transport layer
• Server authenticates itself to client
• No man-in-the-middle attacks
keskiviikkona 28. maaliskuuta 2012
48. SSH Protocol
Client Server
TCP connection setup
SSH version string exchange
SSH Key exchange
SSH data exchange
Termination of the TCP connection
keskiviikkona 28. maaliskuuta 2012
49. 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
50. User authentication
• Client authentication
• password
• public key cryptography
• host based authentication
keskiviikkona 28. maaliskuuta 2012
51. Connection layer
• Defines logical channels
• Requests for TCP port forwarding, X11
forwarding etc.
keskiviikkona 28. maaliskuuta 2012