Top Banner
S-38.3153 Mikko Särelä keskiviikkona 28. maaliskuuta 2012
51
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 2 crypto and basics of protocols

S-38.3153Mikko Särelä

keskiviikkona 28. maaliskuuta 2012

Page 2: Lecture 2 crypto and basics of protocols

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

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

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

What kind of security problems do you see?

keskiviikkona 28. maaliskuuta 2012

Page 6: Lecture 2 crypto and basics of protocols

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

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

How would you fix the security problems?

keskiviikkona 28. maaliskuuta 2012

Page 9: Lecture 2 crypto and basics of protocols

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

Cryptography basicsMikko Särelä, Dr. Tech

20 March 2012

keskiviikkona 28. maaliskuuta 2012

Page 11: Lecture 2 crypto and basics of protocols

Security and cryptologyThe same thing?

keskiviikkona 28. maaliskuuta 2012

Page 12: Lecture 2 crypto and basics of protocols

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

Crypto basics

• Plaintext message m

• Crypto-algorithm

• Key k

• Encrypted text

keskiviikkona 28. maaliskuuta 2012

Page 14: Lecture 2 crypto and basics of protocols

Public key cryptography

keskiviikkona 28. maaliskuuta 2012

Page 15: Lecture 2 crypto and basics of protocols

Two keys - private and public

keskiviikkona 28. maaliskuuta 2012

Page 16: Lecture 2 crypto and basics of protocols

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

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

Addition and multiplication easy

keskiviikkona 28. maaliskuuta 2012

Page 19: Lecture 2 crypto and basics of protocols

Division is hardFactoring is hard

keskiviikkona 28. maaliskuuta 2012

Page 20: Lecture 2 crypto and basics of protocols

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

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

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

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

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

Depends onFactoring being hard!

keskiviikkona 28. maaliskuuta 2012

Page 26: Lecture 2 crypto and basics of protocols

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

Diffie-Hellman

keskiviikkona 28. maaliskuuta 2012

Page 28: Lecture 2 crypto and basics of protocols

(AB)C = Ab*c = (AC)B

keskiviikkona 28. maaliskuuta 2012

Page 29: Lecture 2 crypto and basics of protocols

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

Symmetric key cryptography

keskiviikkona 28. maaliskuuta 2012

Page 31: Lecture 2 crypto and basics of protocols

Block cipherStream cipher

keskiviikkona 28. maaliskuuta 2012

Page 32: Lecture 2 crypto and basics of protocols

Block cipher

Block cipher encryption

Key

Plaintext

Ciphertext

keskiviikkona 28. maaliskuuta 2012

Page 33: Lecture 2 crypto and basics of protocols

Stream cipher

Plaintext

AIVK

Kstream

Ciphertext

Ciphertext

AIVK

Kstream

PlaintextXOR

keskiviikkona 28. maaliskuuta 2012

Page 34: Lecture 2 crypto and basics of protocols

Ciphers overview

keskiviikkona 28. maaliskuuta 2012

Page 35: Lecture 2 crypto and basics of protocols

• 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

Cryptographic hashes

keskiviikkona 28. maaliskuuta 2012

Page 37: Lecture 2 crypto and basics of protocols

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

Keyed hash

keskiviikkona 28. maaliskuuta 2012

Page 39: Lecture 2 crypto and basics of protocols

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

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

Secure Shell

keskiviikkona 28. maaliskuuta 2012

Page 42: Lecture 2 crypto and basics of protocols

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

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

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

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

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

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

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

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

User authentication

• Client authentication

• password

• public key cryptography

• host based authentication

keskiviikkona 28. maaliskuuta 2012

Page 51: Lecture 2 crypto and basics of protocols

Connection layer

• Defines logical channels

• Requests for TCP port forwarding, X11 forwarding etc.

keskiviikkona 28. maaliskuuta 2012