CPSC 467b: Cryptography and Computer Security

Similar documents
CPSC 467b: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security

Using block ciphers 1

CPSC 467: Cryptography and Computer Security

Study Guide to Mideterm Exam

Computer Security. 08r. Pre-exam 2 Last-minute Review Cryptography. Paul Krzyzanowski. Rutgers University. Spring 2018

Symmetric Encryption

CHAPTER 6. SYMMETRIC CIPHERS C = E(K2, E(K1, P))

1 Achieving IND-CPA security

CPSC 467: Cryptography and Computer Security

CPSC 467b: Cryptography and Computer Security

ISA 562: Information Security, Theory and Practice. Lecture 1

CPSC 467b: Cryptography and Computer Security

Introduction to Modern Cryptography. Lecture 2. Symmetric Encryption: Stream & Block Ciphers

Classical Encryption Techniques. CSS 322 Security and Cryptography

Homework 2. Out: 09/23/16 Due: 09/30/16 11:59pm UNIVERSITY OF MARYLAND DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

CIS 4360 Secure Computer Systems Symmetric Cryptography

CSC 474/574 Information Systems Security

Lecture 1 Applied Cryptography (Part 1)

Outline Basics of Data Encryption CS 239 Computer Security January 24, 2005

CPSC 467: Cryptography and Computer Security

Practical Aspects of Modern Cryptography

Outline. Data Encryption Standard. Symmetric-Key Algorithms. Lecture 4

Cryptography and Network Security 2. Symmetric Ciphers. Lectured by Nguyễn Đức Thái

Substitution Ciphers, continued. 3. Polyalphabetic: Use multiple maps from the plaintext alphabet to the ciphertext alphabet.

EEC-484/584 Computer Networks

Introduction to Cryptography CS 136 Computer Security Peter Reiher October 9, 2014

Cryptography Introduction to Computer Security. Chapter 8

Chapter 3 Traditional Symmetric-Key Ciphers 3.1

Cryptographic Primitives A brief introduction. Ragesh Jaiswal CSE, IIT Delhi

Math236 Discrete Maths with Applications

Block Cipher Modes of Operation

CSE 127: Computer Security Cryptography. Kirill Levchenko

CSC 580 Cryptography and Computer Security

Introduction to Cryptography. Lecture 3

Double-DES, Triple-DES & Modes of Operation

Chapter 6 Contemporary Symmetric Ciphers

Understanding Cryptography A Textbook for Students and Practitioners by Christof Paar and Jan Pelzl

Geldy : A New Modification of Block Cipher

Midterm Exam. CS381-Cryptography. October 30, 2014

CSCI 454/554 Computer and Network Security. Topic 2. Introduction to Cryptography

CS 161 Computer Security. Week of September 11, 2017: Cryptography I

COMP4109 : Applied Cryptography

Lecture 1: Perfect Security

Lecturers: Mark D. Ryan and David Galindo. Cryptography Slide: 24

Network Security Essentials Chapter 2

Information Security CS526

Basic Concepts and Definitions. CSC/ECE 574 Computer and Network Security. Outline

Classic Cryptography: From Caesar to the Hot Line

Information Security CS526

7. Symmetric encryption. symmetric cryptography 1

Behrang Noohi. 22 July Behrang Noohi (QMUL) 1 / 18

Content of this part

CIS 4360 Introduction to Computer Security Fall WITH ANSWERS in bold. First Midterm

Outline. Cryptography. Encryption/Decryption. Basic Concepts and Definitions. Cryptography vs. Steganography. Cryptography: the art of secret writing

Computer Security CS 526

CS 161 Computer Security

Homework 2: Symmetric Crypto Due at 11:59PM on Monday Feb 23, 2015 as a PDF via websubmit.

Data Integrity & Authentication. Message Authentication Codes (MACs)

Winter 2011 Josh Benaloh Brian LaMacchia

A New Symmetric Key Algorithm for Modern Cryptography Rupesh Kumar 1 Sanjay Patel 2 Purushottam Patel 3 Rakesh Patel 4

Stream Ciphers An Overview

Computer Security Exam 2 Review. Paul Krzyzanowski. Rutgers University. Spring 2018

CS Paul Krzyzanowski

A Tour of Classical and Modern Cryptography

Chapter 3 Block Ciphers and the Data Encryption Standard

Homework 1 CS161 Computer Security, Spring 2008 Assigned 2/4/08 Due 2/13/08

symmetric cryptography s642 computer security adam everspaugh

Classical Encryption Techniques

Fundamentals of Computer Security

page 1 Introduction to Cryptography Benny Pinkas Lecture 3 November 18, 2008 Introduction to Cryptography, Benny Pinkas

EE 595 (PMP) Introduction to Security and Privacy Homework 1 Solutions

Lecture 6: Symmetric Cryptography. CS 5430 February 21, 2018

2/7/2013. CS 472 Network and System Security. Mohammad Almalag Lecture 2 January 22, Introduction To Cryptography

Block Cipher Modes of Operation

L2. An Introduction to Classical Cryptosystems. Rocky K. C. Chang, 23 January 2015

Elliptic Curve Cryptography

More on Cryptography CS 136 Computer Security Peter Reiher January 19, 2017

Lecture 1: Course Introduction

9/30/2016. Cryptography Basics. Outline. Encryption/Decryption. Cryptanalysis. Caesar Cipher. Mono-Alphabetic Ciphers

Cryptography Basics. IT443 Network Security Administration Slides courtesy of Bo Sheng

CPSC 467b: Cryptography and Computer Security

Chapter 2: Classical Encryption Techniques

Introduction to Cryptography. Lecture 6

Some Aspects of Block Ciphers

Block Cipher Operation. CS 6313 Fall ASU

ECE596C: Handout #7. Analysis of DES and the AES Standard. Electrical and Computer Engineering, University of Arizona, Loukas Lazos

Security: Cryptography

CS 161 Computer Security

Data Integrity & Authentication. Message Authentication Codes (MACs)

CSE 3461/5461: Introduction to Computer Networking and Internet Technologies. Network Security. Presentation L

Overview of Conventional Encryption Techniques

Chapter 8. Encipherment Using Modern Symmetric-Key Ciphers

Classical Cryptography

Cryptography [Symmetric Encryption]

Cryptography Functions

Introduction to Network Security Missouri S&T University CPE 5420 Cryptology Overview

Secret Key Cryptography

Transcription:

CPSC 467b: Cryptography and Computer Security Michael J. Fischer Lecture 6 January 25, 2012 CPSC 467b, Lecture 6 1/46

Byte padding Chaining modes Stream ciphers Symmetric cryptosystem families Stream ciphers based on keystream generators Stream ciphers based on block ciphers Rotor machines Steganography Active adversaries CPSC 467b, Lecture 6 2/46

Byte padding CPSC 467b, Lecture 6 3/46

Padding revisited Lecture 4 presented a method of bit padding to turn an abtirary bit string into one whose length is a multiple of the block length. Often the underlying message consists of a sequence of bytes, and a block comprises some number b of bytes. This enables byte padding methods to be used, some of which are very simple. CPSC 467b, Lecture 6 4/46

PKCS7 padding PKCS7 #7 is a message syntax described in internet RFC 2315. It s padding rule is to fill a partially filled last block having k holes with k bytes, each having the value k when regarded as a binary number. For example, if the last block is 3 bytes short of being full, then the last 3 bytes are set to the values 03 03 03. On decoding, if the last block of the message does not have this form, then a decoding error is indicated. Example: The last block cannot validly end in... 25 00 03. CPSC 467b, Lecture 6 5/46

Chaining modes CPSC 467b, Lecture 6 6/46

Chaining mode A chaining mode tells how to encrypt a sequence of plaintext blocks m 1, m 2,..., m t to produce a corresponding sequence of ciphertext blocks c 1, c 2,..., c t, and conversely, how to recover the m i s given the c i s. CPSC 467b, Lecture 6 7/46

Electronic Codebook Mode (ECB) Each block is encrypted separately. To encrypt, Alice computes c i = E k (m i ) for each i. To decrypt, Bob computes m i = D k (c i ) for each i. This is in effect a monoalphabetic cipher, where the alphabet is the set of all possible blocks and the permutation is E k. CPSC 467b, Lecture 6 8/46

Cipher Block Chaining Mode (CBC) Prevents identical plaintext blocks from having identical ciphertexts. To encrypt, Alice applies E k to the XOR of the current plaintext block with the previous ciphertext block. That is, c i = E k (m i c i 1 ). To decrypt, Bob computes m i = D k (c i ) c i 1. To get started, we take c 0 = IV, where IV is a fixed initialization vector which we assume is publicly known. CPSC 467b, Lecture 6 9/46

Output Feedback Mode (OFB) Similar to a one-time pad, but key stream is generated from E k. To encrypt, Alice repeatedly applies the encryption function to an initial vector (IV) k 0 to produce a stream of block keys k 1, k 2,..., where k i = E k (k i 1 ). The block keys are XORed with successive plaintext blocks. That is, c i = m i k i. To decrypt, Bob applies exactly the same method to the ciphertext to get the plaintext. That is, m i = c i k i, where k i = E k (k i 1 ) and k 0 = IV. CPSC 467b, Lecture 6 10/46

Cipher-Feedback Mode (CFB) Similar to OFB, but key stream depends on previous messages as well as on E k. To encrypt, Alice computes the XOR of the current plaintext block with the encryption of the previous ciphertext block. That is, c i = m i E k (c i 1 ). Again, c 0 is a fixed initialization vector. To decrypt, Bob computes m i = c i E k (c i 1 ). Note that Bob is able to decrypt without using the block decryption function D k. In fact, it is not even necessary for E k to be a one-to-one function (but using a non one-to-one function might weaken security). CPSC 467b, Lecture 6 11/46

OFB, CFB, and stream ciphers Both CFB and OFB are closely related to stream ciphers. In both cases, c i is m i XORed with some function of data that came before stage i. Like a one-time pad, OFB is insecure if the same key is ever reused, for the sequence of k i s generated will be the same. If m and m are encrypted using the same key k, then m m = c c. CFB avoids this problem, for even if the same key k is used for two different message sequences m i and m i, it is only true that m i m i = c i c i E k(c i 1 ) E k (c i 1 ), and the dependency on k does not drop out. CPSC 467b, Lecture 6 12/46

Propagating Cipher-Block Chaining Mode (PCBC) Here is a more complicated chaining rule that nonetheless can be deciphered. To encrypt, Alice XORs the current plaintext block, previous plaintext block, and previous ciphertext block. That is, c i = E k (m i m i 1 c i 1 ). Here, both m 0 and c 0 are fixed initialization vectors. To decrypt, Bob computes m i = D k (c i ) m i 1 c i 1. CPSC 467b, Lecture 6 13/46

Recovery from data corruption In real applications, a ciphertext block might be damaged or lost. An interesting property is how much plaintext is lost as a result. With ECB and OFB, if Bob receives a bad block c i, then he cannot recover the corresponding m i, but all good ciphertext blocks can be decrypted. With CBC and CFB, Bob needs both good c i and c i 1 blocks in order to decrypt m i. Therefore, a bad block c i renders both m i and m i+1 unreadable. With PCBC, bad block c i renders m j unreadable for all j i. Error-correcting codes applied to the ciphertext may be better solutions in practice since they minimize lost data and give better indications of when irrecoverable data loss has occurred. CPSC 467b, Lecture 6 14/46

Other modes Other modes can easily be invented. In all cases, c i is computed by some expression (which may depend on i) built from E k () and applied to available information: ciphertext blocks c 1,..., c i 1, message blocks m 1,..., m i, any initialization vectors. Any such equation that can be solved for m i (by possibly using D k () to invert E k ()) is a suitable chaining mode in the sense that Alice can produce the ciphertext and Bob can decrypt it. Of course, the resulting security properties depend heavily on the particular expression chosen. CPSC 467b, Lecture 6 15/46

Stream ciphers CPSC 467b, Lecture 6 16/46

Symmetric cryptosystem families Symmetric cryptosystem families Symmetric (one-key) cryptosystems fall into two broad classes, block ciphers and stream ciphers. A block cipher encrypts large blocks of data at a time. A stream cipher process a stream of characters in an on-line fashion, emitting the ciphertext character by character as it goes. CPSC 467b, Lecture 6 17/46

Stream ciphers based on keystream generators Structure of stream cipher A stream cipher has two components: 1. a cipher that is used to encrypt a given character; 2. a key stream generator that produces a different key to be used for each successive letter. A commonly-used cipher is the simple XOR cryptosystem, also used in the one-time pad. Rather than using a long random string for the key stream, we instead generate the key stream on the fly using a state machine. CPSC 467b, Lecture 6 18/46

Stream ciphers based on keystream generators Key stream generator A key stream generator consists of three parts: 1. an internal state, 2. a next-state generator, 3. an output function. At each stage, the state is updated and the output function is applied to the state to obtain the next component of the key stream. The next-state generator and output functions can both depend on the (original) master key. Like a one-time pad, a different master key must be used for each message; otherwise the system is easily broken. CPSC 467b, Lecture 6 19/46

Stream ciphers based on keystream generators Security requirements for key stream generator The output of the key stream generator must look random. Any regularities in the output give an attacker information about the plaintext. A known plaintext-ciphertext pair (m, c) gives the attacker a sample output sequence from the key stream generator (namely, m c.) If the attacker is able to figure out the internal state, then she will be able to predict all future outputs of the generator and decipher the remainder of the ciphertext. A pseudorandom sequence generator that resists all feasible attempts to predict future outputs knowing a sequence of past outputs is said to be cryptographically strong. CPSC 467b, Lecture 6 20/46

Stream ciphers based on keystream generators Cryptographically strong pseudorandom sequence generators Commonly-used linear congruential pseudorandom number generators typically found in software libraries are quite insecure. After observing a relatively short sequence of outputs, one can solve for the state and correctly predict all future outputs. Notes: The Linux random() is non-linear and hence much better, though still not cryptographically strong. We will return to pseudorandom number generation later in this course. See Goldwasser & Bellare Chapter 3 for an in-depth discussion of this topic. CPSC 467b, Lecture 6 21/46

Stream ciphers based on keystream generators Ideas for improving stream ciphers As with one-time pads, the same key stream must not be used more than once. A possible improvement: Make the next state depend on the current plaintext or ciphertext characters. Then the generated key streams will diverge on different messages, even if the key is the same. Serious drawback: One bad ciphertext character will render the rest of the message undecipherable. CPSC 467b, Lecture 6 22/46

Stream ciphers based on block ciphers Building key stream generators from block ciphers A block cipher cannot be used directly as a stream cipher. A stream cipher must output the current ciphertext byte before reading the next plaintext byte. A block cipher waits to output the current ciphertext block until a block s worth of message bytes have been accumulated. Some block ciphers do not have to wait and can be turned into stream ciphers. CPSC 467b, Lecture 6 23/46

Stream ciphers based on block ciphers Stream ciphers from OFB and CFB block ciphers OFB and CFB block modes can be turned into stream ciphers. Both compute c i = m i X, where X = E k (k i 1 ) (for OFB); X = E k (c i 1 ) (for CFB). Each byte of X is XORed with the corresponding byte of m i to get the corresponding byte of c i. No need to wait for all of m i. Can output each byte of c i as soon as the corresponding byte of m i has been received. In this version, one must keep track of where one is within the current block. When the current block is finished, X must be recomputed. CPSC 467b, Lecture 6 24/46

Stream ciphers based on block ciphers Extended OFB and CFB modes Simpler (for hardware implementation) and more uniform stream ciphers result by also computing X a byte at a time. The idea: Use a shift register X to accumulate the feedback bits from previous stages of encryption so that the full-sized blocks needed by the block chaining method are available. X is initialized to some public initialization vector. CPSC 467b, Lecture 6 25/46

Stream ciphers based on block ciphers Some notation Assume block size b = 16 bytes. Define two operations: L and R on blocks: L(x) is the leftmost byte of x; R(x) is the rightmost b 1 bytes of x. CPSC 467b, Lecture 6 26/46

Stream ciphers based on block ciphers Extended OFB and CFB similarities The extended versions of OFB and CFB are very similar. Both maintain a one-block shift register X. The shift register value X i at stage i depends only on c 1,..., c i 1 and the master key k. At stage i, Alice computes X i according to OFB or CFB rules; computes byte key k i = L(E k (X i )); encrypts message byte m i as c i = m i k i. Bob decrypts similarly. CPSC 467b, Lecture 6 27/46

Stream ciphers based on block ciphers Shift register rules The two modes differ in how they update the shift register. Extended OFB mode X i = R(X i 1 ) k i 1 Extended CFB mode X i = R(X i 1 ) c i 1 ( denotes concatenation.) Summary: Extended OFB keeps the most recent b key bytes in X. Extended CFB keeps the most recent b ciphertext bytes in X, CPSC 467b, Lecture 6 28/46

Stream ciphers based on block ciphers Comparison of extended OFB and CFB modes The differences seem minor, but they have profound implications on the resulting cryptosystem. In eofb mode, X i depends only on i and the master key k (and the initialization vector IV), so loss of a ciphertext byte causes loss of only the corresponding plaintext byte. In ecfb mode, loss of ciphertext byte c i causes m i and all succeeding message bytes to become undecipherable until c i is shifted off the end of X. Thus, b message bytes are lost. CPSC 467b, Lecture 6 29/46

Stream ciphers based on block ciphers Downside of extended OFB The downside of eofb is that security is lost of the same master key is used twice for different messages. CFB does not suffer from this problem since different messages lead to different ciphertexts and hence different key streams. Nevertheless, ecfb has the undesirable property that the key streams are the same up to and including the first byte in which the two message streams differ. This enables Eve to determine the length of the common prefix of the two message streams and also to determine the XOR of the first bytes at which they differ. CPSC 467b, Lecture 6 30/46

Stream ciphers based on block ciphers Possible solution Possible solution to both problems: Use a different initialization vector for each message. Prefix the ciphertext with the (unencrypted) IV so Bob can still decrypt. CPSC 467b, Lecture 6 31/46

Rotor machines Rotor machines Rotor machines are mechanical devices for implementing stream ciphers. They played an important role during the Second World War. The Germans believed their Enigma machine was unbreakable. The Allies, with great effort, succeeded in breaking it and in reading many of the top-secret military communications. This is said to have changed the course of the war. CPSC 467b, Lecture 6 32/46 Image from Wikipedia

Rotor machines How a rotor machine works Uses electrical switches to create a permutation of 26 input wires to 26 output wires. Each input wire is attached to a key on a keyboard. Each output wire is attached to a lamp. The keys are associated with letters just like on a computer keyboard. Each lamp is also labeled by a letter from the alphabet. Pressing a key on the keyboard causes a lamp to light, indicating the corresponding ciphertext character. The operator types the message one character at a time and writes down the letter corresponding to the illuminated lamp. The same process works for decryption since E ki = D ki. CPSC 467b, Lecture 6 33/46

Rotor machines Key stream generation The encryption permutation. Each rotor is individually wired to produce some random-looking fixed permutation π. Several rotors stacked together produce the composition of the permutations implemented by the individual rotors. In addition, the rotors can rotate relative to each other, implementing in effect a rotation permutation (like the Caeser cipher uses). CPSC 467b, Lecture 6 34/46

Rotor machines Key stream generation (cont.) Let ρ k (x) = x + k mod 26. Then rotor in position k implements permutation ρ k πρ 1 k. Several rotors stacked together implement the composition of the permutations computed by each. For example, three rotors implementing permutations π 1, π 2, and π 3, placed in positions r 1, r 2, and r 3, respectively, would produce the permutation ρ r1 π 1 ρ r1 ρ r2 π 2 ρ r2 ρ r3 π 3 ρ r3 = ρ r1 π 1 ρ r2 r 1 π 2 ρ r3 r 2 π 3 ρ r3 (1) CPSC 467b, Lecture 6 35/46

Rotor machines Changing the permutation After each letter is typed, some of the rotors change position, much like the mechanical odometer used in older cars. The period before the rotor positions repeat is quite long, allowing long messages to be sent without repeating the same permutation. Thus, a rotor machine is much like a polyalphabetic substitution cipher but with a very long period. Unlike a pure polyalphabetic cipher, the successive permutations until the cycle repeats are not independent of each other but are related by equation (1). This gives the first toehold into methods for breaking the cipher (which are far beyond the scope of this course). CPSC 467b, Lecture 6 36/46

Rotor machines History Several different kinds of rotor machines were built and used, both by the Germans and by others, some of which work somewhat differently from what I described above. However, the basic principles are the same. The interested reader can find much detailed material on the web by searching for enigma cipher machine and rotor cipher machine. Nice descriptions may be found at http://en.wikipedia.org/wiki/enigma_machine and http://www.quadibloc.com/crypto/intro.htm. CPSC 467b, Lecture 6 37/46

Steganography CPSC 467b, Lecture 6 38/46

Steganography Steganography, hiding one message inside another, is an old technique that is still in use. For example, a message can be hidden inside a graphics image file by using the low-order bit of each pixel to encode the message. The visual effect of these tiny changes is generally too small to be noticed by the user. The message can be hidden further by compressing it or by encrypting it with a conventional cryptosystem. Unlike conventional cryptosystems, steganography relies on the secrecy of the method of hiding for its security. If Eve does not even recognize the message as ciphertext, then she is not likely to attempt to decrypt it. CPSC 467b, Lecture 6 39/46

Active adversaries CPSC 467b, Lecture 6 40/46

Active adversary Recall from lecture 3 the active adversary Mallory who has the power to modify messages and generate his own messages as well as eavesdrop. Alice sends c = E k (m), but Bob may receive a corrupted or forged c c. How does Bob know that the message he receives really was sent by Alice? The naive answer is that Bob computes m = D k (c ), and if m looks like a valid message, then Bob accepts it as having come from Alice. The reasoning here is that Mallory, not knowing k, could not possibly have produced a valid-looking message. For any particular cipher such as DES, that assumption may or may not be valid. CPSC 467b, Lecture 6 41/46

Some active attacks Three successively weaker (and therefore easier) active attacks in which Mallory might produce fraudulent messages: 1. Produce valid c = E k (m ) for a message m of his choosing. 2. Produce valid c = E k (m ) for a message m that he cannot choose and perhaps does not even know. 3. Alter a valid c = E k (m) to produce a new valid c that corresponds to an altered message m of the true message m. Attack (1) requires computing c = E k (m) without knowing k. This is similar to Eve s ciphertext-only passive attack where she tries to compute m = D k (c) without knowing k. It s conceivable that one attack is possible but not the other. CPSC 467b, Lecture 6 42/46

Replay attacks One form of attack (2) clearly is possible. In a replay attack, Mallory substitutes a legitimate old encrypted message c for the current message c. It can be thwarted by adding timestamps and/or sequence numbers to the messages so that Bob can recognize when old messages are being received. Of course, this only works if Alice and Bob anticipate the attack and incorporate appropriate countermeasures into their protocol. CPSC 467b, Lecture 6 43/46

Fake encrypted messages Even if replay attacks are ruled out, a cryptosystem that is secure against attack (1) might still permit attack (2). There are all sorts of ways that Mallory can generate values c. What gives us confidence that Bob won t accept one of them as being valid? CPSC 467b, Lecture 6 44/46

Message-altering attacks Attack (3) might be possible even when (1) and (2) are not. For example, if c 1 and c 2 are encryptions of valid messages, perhaps so is c 1 c 2. This depends entirely on particular properties of E k unrelated to the difficulty of decrypting a given ciphertext. We will see some cryptosystems later that do have the property of being vulnerable to attack (3). In some contexts, this ability to do meaning computations on ciphertexts can actually be useful, as we shall see. CPSC 467b, Lecture 6 45/46

Encrypting random-looking strings Cryptosystems are not always used to send natural language or other highly-redundant messages. For example, suppose Alice wants to send Bob her password to a web site. Knowing full well the dangers of sending passwords in the clear over the internet, she chooses to encrypt it instead. Since passwords are supposed to look like random strings of characters, Bob will likely accept anything he gets from Alice. He could be quite embarrassed (or worse) claiming he knew Alice s password when in fact the password he thought was from Alice was actually a fraudulent one derived from a random ciphertext c produced by Mallory. CPSC 467b, Lecture 6 46/46