12
4/21/10 1 Lecture 36: How can a computer… send a secret? UNIVERSITY of WISCONSIN-MADISON Computer Sciences Department CS 202 Introduction to Computation Professor Andrea Arpaci-Dusseau Spring 2010 What is Cryptography? Definitions 1. secret writing 2. the enciphering and deciphering of messages in secret code or cipher Used throughout History Ancient ideas (pre-1976) Complexity-based cryptography (post-1976) Essential component of digital world

CS 202 Professor Andrea Arpaci-Dusseau Introduction to

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

1  

Lecture 36: �How can a computer… �

send a secret?�

UNIVERSITY of WISCONSIN-MADISON �Computer Sciences Department �

CS 202�Introduction to Computation �

Professor Andrea Arpaci-Dusseau �Spring 2010�

""�

What is Cryptography?�

Definitions�1.  secret writing �2.  the enciphering and deciphering of messages in

secret code or cipher�

Used throughout History�•  Ancient ideas (pre-1976)�•  Complexity-based cryptography (post-1976)�

Essential component of digital world�

Page 2: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

2  

Motivation �Communicate over unprotected channel (e.g., network)�

•  Others can eavesdrop on channel�•  Others can inject messages on channel�

Eve�Alice� Bob �

Goals? �1.  Provide private, secure communication �

Eve cannot understand message contents�2.  Provide authentication �

Bob knows Alice sent message�Bob knows no one altered message�

Examples where you want privacy and authentication?�

Themes of Today’s Lecture�

1.  Seeing info does not mean understanding it �

2.  Creating problems often easier than solving �

3.  Randomness can be used to confuse�

4.  Complete strangers can exchange and agree on secret information �

Page 3: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

3  

Basic Approach of Cryptography�Theme 1: Seeing info does not mean understanding it �

Idea: Convert data to form that doesn’t make sense to others�•  Clear text (plain text): Initial readable text �•  Cipher text: Encrypted version of clear text �

Steps�1.  Sender: Encrypt clear text to cipher text �

2.  Cipher text can be stored in readable file or transmitted over unprotected channels�

3.  Receiver: Decrypt cipher text to clear text �

Eve�Alice� Bob �

Theme 2: Creating problems �often easier than solving �

Word Scramble of “scratch”�Algorithm to create?�

•  tarcchs �"O(N) steps�

Algorithm to solve?�"Try every permutation �"atrcchs�"atrccsh…�"N * N-1 * N-2 … * 1 = O(N!)�

Page 4: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

4  

Letter Scrambling: �Ancient Cryptographic Idea�

Example 1: Caesar or shift cipher (c. 100 BC)�

Ex: Clear text -- Attack at noon, agree on shift of 3 �"Cipher text -- Dwwdfn dw qrrq�

How would you crack the code?�"Enumerate all 26 possibilities until see reasonable�"Shift of 1? Cvvcej cv pqqp �"2? Buubdl bu oppo �"3? Attack at noon – Got it! �

Substitution Cipher�Example 2: Cipher of Queen Mary of Scots, 1587 �"Wanted to assassinate Queen Elizabeth I �

Possibilities?�"26 * 25 * 24 * … * 1 �"Huge number of possibilities if do stupid brute force attack �

Still cracked and Queen Mary was executed! �

Page 5: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

5  

Mafia Boss�

“Boss of bosses” Bernardo Provenzano, captured after 40 years�

Sent “pizzini” (little messages on scraps of paper) using weak cipher�•  "...I met 512151522 191212154 and we agreed that we

will see each other after the holidays...,“�•  5 = B, 12 = I, 15 = N, etc�

“It will keep your kid sister out, but it won't keep �the police out.” - Bruce Schneier (Cryptographer)�

From Discovery Channel, Apr 17 2006 �

How to Crack the Code?�Use characteristics of language�1. Frequency Analysis�

2. Letter combinations or sequences�Bigrams: Pairs of letters�

ST, NG, TH, and QU are common, NZ and QJ are rare�Trigrams: Three letters�

"THE most common �

E most common, then T �

Page 6: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

6  

Letter scrambling �in World War II�

Example 3: Enigma�•  Used by Nazi Germany (1940’s)�•  Broken by British (Turing), Polish�•  “Won us the war.” – Churchill�•  Recommend: Neal Stephenson's novel Cryptonomicon �

Moral: Computers need for new ideas for encryption �

Theme 3: �Randomness can be used to Confuse�One-time pad�

•  Random sequence of n bits �•  Shared between sender and receiver�

Use one-time pad as random “noise” for message�•  0 means “don’t flip”�•  1 means “flip”�

Message 0110010 Pad 1011001 Encrypted

Encrypted 1101011 Pad 1011001 Message

Encryption � Decryption �

1101011 0110010

Page 7: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

7  

Musings about one-time pad�Incredibly strong security�

•  Encrypted message “looks random” �•  Equally likely to be encryption of any n-bit string �•  Can’t do frequency analysis on cipher text! �

Insecure link (Internet)�

0110101010011010011011101010010010001…

How can you and a friend agree on one-time pads?�

How can you and Amazon agree on one-time pads?�

4) How can perfect strangers�send encrypted messages?�

Powerful idea: Public-key Encryption �

Diffie-Hellman-Merkle [1976] �

Rivest, Shamir, Adleman [1977] �•  RSA algorithm�

Two keys for every user�•  Public key: Known by everyone�

–  Notation: Public Key of User A is Apublic �

•  Private (secret) key: Known only by user�–  Private key of User A is Aprivate �

Page 8: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

8  

Public-key encryption: �Conceptual Story�

“Box that clicks shut, and only Amazon has the key to open it.”�

Example: Key exchange [Diffie-Hellman] �•  User generates one-time pad (random string)�•  Put it in box, ship it to Amazon �•  Amazon opens box, recovers random string �

01011 �

01011 �

Public-key cryptography�

Important: encryption and decryption algorithms are not secret, only private key! �

Message m �

Public key Apublic �(512 bit number, publicly available, e.g. from Verisign Inc) �

c = Encrypt(m, Apublic)�

Private key Aprivate �(512-bit number, known only to Amazon)�

m = Decrypt(c, Aprivate)�

Page 9: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

9  

Public Key Encryption: �Mathematical Story�

Requirements�•  Cannot derive private key from public key�

•  Public and private keys are inverses of each other�

– Encode Msg w/ private key of A decode w/ public key of A �•  Decrypt(Encrypt(Msg, Apublic), Aprivate) Msg!

– Encode Msg w/ public key of A decode w/ private key of A �•  Decrypt(Encrypt(Msg, Aprivate), Apublic) Msg!

Theme 2 Again: Easy to Generate, �Hard to Solve�

Based on Factoring of Large Numbers�Generate Integer that is Product of 2 Primes: Easy�

•  Pick two n-bit prime numbers p, q �–  Good value for n is 128 (more bits, stronger encryption)�

•  Multiply together to get r = pq �

Use r to generate public key; r, p, and q for private keys�•  Mathematical details omitted�•  Wikipedia has decent explanation! �•  If someone can infer p and q from r, break encryption! �

Factoring problem : Hard �•  Given r, can you find p and q?�

Page 10: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

10  

Factoring is Hard! �Given r, can you find p and q?�Can you suggest a basic algorithm?�

•  Set variable try to 2 �•  Repeat…�

–  Is r mod try == 0?�•  Yes p = try, r/try =q �•  Done! �

– Change try by 1 �

How many steps? Could be optimized! �•  How many values of r?�•  2128�

Despite many centuries, no efficient algorithms�•  Rely on difficulty every time you use e-commerce�

More than Privacy with Public Keys�Can also provide Authentication �

•  Reliably identify the sender of a message�•  Example: Alice sends to Bob; Bob must know Alice

sent message, not Eve�How will A encrypt message to B?�

•  Encrypt(Msg, Aprivate)�

B can decode Encrypt(Msg, Aprivate) with Apublic �•  If message can be decrypted with A’s public key,

then Msg written by A �•  No one else but A could have encoded valid message�•  Anyone can verify author of message�

Eve�Bob �

Page 11: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

11  

Public Key Cryptography Challenges�

How do you trust public keys?�•  You are told “A’s public key is K”�•  Problem: Can you trust this????�•  What if K is really C’s public key?�

Solution: Authentication Server (AS) everyone trusts�•  Everyone knows public key of authentication server: ASpublic �

•  AS->B: Encrypt(“Public key of A is PA”, ASPrivate)!•  B decodes with ASpublic and knows only AS could have sent �

Used by HTTPS�•  Certificate from server AS�

–  Encrypt(“I’m AS, A’s key is Apublic, time”, ASPrivate)!

•  Can AS read messages you encrypt with Apublic?�•  What if get message saying certificate looks funny?�

More Challenges with Cryptography�

Eavesdroppers can replay old messages�•  Even though eavesdropper doesn’t know what they are

replaying �•  Confuse parties and cause unwanted behavior �

Solution �•  Encrypt sequence numbers or timestamps in messages�

–  1, 2, 3, …�•  Discard message if repeated sequence number�•  Attacker cannot generate encrypted message with

next sequence number (does not know key)�

Page 12: CS 202 Professor Andrea Arpaci-Dusseau Introduction to

4/21/10  

12  

Encryption Safety�How safe is encryption? Can private keys be found?�

•  Crack with brute force guessing, use many machines�–  Look for understandable text in decoded version �

•  Safety depends on length of keys�–  DES 56 bit keys --> 256 possible keys�

•  Cracked in < 24 hours�–  AES has 128 bit keys�

Solutions�•  Upgrade encryption (key length) as machines become faster�•  Remove known patterns from clear text �

–  Example: compress text first �•  Do not send large amounts of data with same key�

–  Change keys frequently�

Today’s Summary�Cryptography: Basis of E-commerce�

•  Theme 1: Seeing info does not mean understanding it �–  Encrypt clear text to cipher; Others can see cipher text but not interpret it �

•  Theme 2: Creating problems often easier than solving �–  Factoring large numbers�

•  Theme 3: Randomness can be used to confuse�–  One-time pads are extremely secure�

•  Theme 4: Complete strangers can exchange secret information �–  Send one-time pad encrypted with receiver’s public key; no one else can read�

Announcements�•  Homework 8 due today�•  Exam 2 returned today�•  Homework 9 due 1 week Monday (pencil and paper algorithms)�•  Project 3: Due Wed May 5th (Game of chance)�•  Frontiers of CS: 2nd Guest Lecture Friday -- Vision �