SlideShare a Scribd company logo
1 of 51
Download to read offline
S-38.3153
                                       Mikko Särelä




keskiviikkona 28. maaliskuuta 2012
Today’s plan

                     • Learn about protocols
                      • Remote login
                     • How to solve security problems?
                     • How can cryptography help?

keskiviikkona 28. maaliskuuta 2012
Remote login


                     • A simple protocol to remotely login to a
                             computer as if you were physically present




keskiviikkona 28. maaliskuuta 2012
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
What kind of security
                       problems do you see?


keskiviikkona 28. maaliskuuta 2012
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
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
How would you fix the
                    security problems?


keskiviikkona 28. maaliskuuta 2012
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
Cryptography basics
                                     Mikko Särelä, Dr. Tech
                                        20 March 2012




keskiviikkona 28. maaliskuuta 2012
Security and cryptology
                                     The same thing?




keskiviikkona 28. maaliskuuta 2012
Crypto overview

                     • Public key cryptography
                     • Key exchange
                     • Symmetric key cryptography
                     • Secure hash

keskiviikkona 28. maaliskuuta 2012
Crypto basics

                     • Plaintext message m
                     • Crypto-algorithm
                     • Key k
                     • Encrypted text

keskiviikkona 28. maaliskuuta 2012
Public key cryptography



keskiviikkona 28. maaliskuuta 2012
Two keys -
                                     private and public


keskiviikkona 28. maaliskuuta 2012
Some math

                     • RSA and Diffie-Hellman based on modulo
                             arithmetics
                           • the difficulty of division operation,
                                     logarithm, and factoring




keskiviikkona 28. maaliskuuta 2012
Modulo
                                                    0
                                                        1
                                           12
                                                            2
                                      11
                                                                3


                                 10
                                                                4

                                      9
                                                            5
                                                8       6
                                                    7
keskiviikkona 28. maaliskuuta 2012
Addition and
                                 multiplication easy


keskiviikkona 28. maaliskuuta 2012
Division is hard
                                     Factoring is hard



keskiviikkona 28. maaliskuuta 2012
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
Problem

                     • p = 11, q = 3
                     • e=3
                     • What is d?
                     • Encrypt message m = 7
                     • Decrypt the result

keskiviikkona 28. maaliskuuta 2012
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
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
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
Depends on
                         Factoring being hard!


keskiviikkona 28. maaliskuuta 2012
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
Diffie-Hellman



keskiviikkona 28. maaliskuuta 2012
(A B)C   =A b*c   =   (A C) B




keskiviikkona 28. maaliskuuta 2012
Diffie-Hellman
                                            http://upload.wikimedia.org/wikipedia/commons/a/a3/Diffie-Hellman-Schlüsselaustausch.png
keskiviikkona 28. maaliskuuta 2012
Symmetric key
                                      cryptography


keskiviikkona 28. maaliskuuta 2012
Block cipher
                                     Stream cipher


keskiviikkona 28. maaliskuuta 2012
Block cipher
                                         Plaintext



                         Key           Block cipher
                                        encryption



                                        Ciphertext


keskiviikkona 28. maaliskuuta 2012
Stream cipher
                                         K
                                         IV      A
                                                     Kstream


                                     Plaintext          Ciphertext

                                         K
                                         IV      A
                                                     Kstream


                              Ciphertext                 Plaintext
                                                                     XOR
keskiviikkona 28. maaliskuuta 2012
Ciphers overview



keskiviikkona 28. maaliskuuta 2012
•       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
Cryptographic hashes



keskiviikkona 28. maaliskuuta 2012
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
Keyed hash



keskiviikkona 28. maaliskuuta 2012
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
Cryptographic Hash
                                 functions
                     • SHA-256 as an example
                     • Birthday attack
                     • Keyed hash is usually marked as
                      • h(k, M)

keskiviikkona 28. maaliskuuta 2012
Secure Shell



keskiviikkona 28. maaliskuuta 2012
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
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
Protocol details

                     • Client/server architecture
                     • Server listens to port 22
                     • Client wanting to connect executes an ssh
                             command
                           • port forwarding

keskiviikkona 28. maaliskuuta 2012
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
Transport layer
                     • Initial key exchange
                     • Server authentication
                     • Data confidentiality
                     • Data Integrity
                     • Compression (optional)
                     • key re-exchange
keskiviikkona 28. maaliskuuta 2012
Transport layer


                     • Server authenticates itself to client
                      • No man-in-the-middle attacks


keskiviikkona 28. maaliskuuta 2012
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
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
User authentication

                     • Client authentication
                      • password
                      • public key cryptography
                      • host based authentication

keskiviikkona 28. maaliskuuta 2012
Connection layer


                     • Defines logical channels
                     • Requests for TCP port forwarding, X11
                             forwarding etc.




keskiviikkona 28. maaliskuuta 2012

More Related Content

Viewers also liked

Viewers also liked (20)

Valor de la alegría
Valor de la alegríaValor de la alegría
Valor de la alegría
 
Presentació brenda
Presentació brendaPresentació brenda
Presentació brenda
 
Experiencia
ExperienciaExperiencia
Experiencia
 
Ode to n
Ode to nOde to n
Ode to n
 
Namibíu eyðimörkin
Namibíu eyðimörkinNamibíu eyðimörkin
Namibíu eyðimörkin
 
Alumnes de 5è modificat
Alumnes de 5è modificatAlumnes de 5è modificat
Alumnes de 5è modificat
 
Estalvi energetiic
Estalvi energetiicEstalvi energetiic
Estalvi energetiic
 
TS1: PP Estalvi Energetic
TS1: PP Estalvi EnergeticTS1: PP Estalvi Energetic
TS1: PP Estalvi Energetic
 
TS1: PP EstalviEnergetic
TS1: PP EstalviEnergeticTS1: PP EstalviEnergetic
TS1: PP EstalviEnergetic
 
Fútbol barria 31 03-2012.doc
Fútbol barria 31 03-2012.docFútbol barria 31 03-2012.doc
Fútbol barria 31 03-2012.doc
 
O aumento de awareness usando vídeos online
O aumento de awareness usando vídeos onlineO aumento de awareness usando vídeos online
O aumento de awareness usando vídeos online
 
Paginas webs tenerife
Paginas webs  tenerifePaginas webs  tenerife
Paginas webs tenerife
 
Estalvi energetic
Estalvi energeticEstalvi energetic
Estalvi energetic
 
Presentación Screenr
Presentación ScreenrPresentación Screenr
Presentación Screenr
 
Bernardtysondildo
BernardtysondildoBernardtysondildo
Bernardtysondildo
 
S 1º A mochila viaxeira
S 1º A mochila viaxeiraS 1º A mochila viaxeira
S 1º A mochila viaxeira
 
Plasmas
PlasmasPlasmas
Plasmas
 
Timidez
TimidezTimidez
Timidez
 
Curso 1
Curso 1Curso 1
Curso 1
 
Unitat 3 un gerani i una xinxeta al despatx
Unitat 3 un gerani i una xinxeta al despatxUnitat 3 un gerani i una xinxeta al despatx
Unitat 3 un gerani i una xinxeta al despatx
 

Lecture 2 crypto and basics of protocols

  • 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
  • 11. Security and cryptology The same thing? keskiviikkona 28. maaliskuuta 2012
  • 12. Crypto overview • Public key cryptography • Key exchange • Symmetric key cryptography • Secure hash keskiviikkona 28. maaliskuuta 2012
  • 13. Crypto basics • Plaintext message m • Crypto-algorithm • Key k • Encrypted text 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
  • 17. Modulo 0 1 12 2 11 3 10 4 9 5 8 6 7 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
  • 28. (A B)C =A b*c = (A C) B keskiviikkona 28. maaliskuuta 2012
  • 29. Diffie-Hellman http://upload.wikimedia.org/wikipedia/commons/a/a3/Diffie-Hellman-Schlüsselaustausch.png keskiviikkona 28. maaliskuuta 2012
  • 30. Symmetric key cryptography keskiviikkona 28. maaliskuuta 2012
  • 31. Block cipher Stream cipher keskiviikkona 28. maaliskuuta 2012
  • 32. Block cipher Plaintext Key Block cipher encryption Ciphertext keskiviikkona 28. maaliskuuta 2012
  • 33. Stream cipher K IV A Kstream Plaintext Ciphertext K IV A Kstream Ciphertext Plaintext XOR 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
  • 38. Keyed 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
  • 41. Secure Shell 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