Part 9, Basic Cryptography 1. Introduction A cryptosystem is a tuple: ( M,K,C, E,D) where M is the set of plaintexts K the set of keys C the set of ciphertexts.

Slides:



Advertisements
Similar presentations
From Crypto-Theory to Crypto-Practice 1 CHAPTER 14: From Crypto-Theory to Crypto-Practice SHIFT REGISTERS The first practical approach to ONE-TIME PAD.
Advertisements

“Advanced Encryption Standard” & “Modes of Operation”
CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (3) Information Security.
1 CIS 5371 Cryptography 5b. Pseudorandom Objects in Practice Block Ciphers.
Computer Science CSC 474By Dr. Peng Ning1 CSC 474 Information Systems Security Topic 2.1 Introduction to Cryptography.
CS 6262 Spring 02 - Lecture #7 (Tuesday, 1/29/2002) Introduction to Cryptography.
1 Introduction CSE 5351: Introduction to cryptography Reading assignment: Chapter 1 of Katz & Lindell.
7. Asymmetric encryption-
Web Security for Network and System Administrators1 Chapter 4 Encryption.
 Stream ciphers o Encrypt chars/bits one at a time o Assume XOR w the key, need long key to be secure  Keystream generators (pseudo-random key) o Synchronous.
Session 5 Hash functions and digital signatures. Contents Hash functions – Definition – Requirements – Construction – Security – Applications 2/44.
Chapter 5 Cryptography Protecting principals communication in systems.
EEC 688/788 Secure and Dependable Computing Lecture 4 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
ITIS 3200: Introduction to Information Security and Privacy Dr. Weichao Wang.
Csci5233 Computer Security & Integrity 1 Cryptography: Basics (2)
McGraw-Hill©The McGraw-Hill Companies, Inc., Security PART VII.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Introduction to Symmetric Block Cipher Jing Deng Based on Prof. Rick Han’s Lecture Slides Dr. Andreas Steffen’s Security Tutorial.
Computer Networking Lecture 21: Security and Cryptography Thanks to various folks from , semester’s past and others.
Hash Functions Nathanael Paul Oct. 9, Hash Functions: Introduction Cryptographic hash functions –Input – any length –Output – fixed length –H(x)
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
Lecture 23 Symmetric Encryption
8: Network Security8-1 Symmetric key cryptography symmetric key crypto: Bob and Alice share know same (symmetric) key: K r e.g., key is knowing substitution.
Computer Security CS 426 Lecture 3
A Cryptography Tutorial Jim Xu College of Computing Georgia Tech
L1.1. An Introduction to Classical Cryptosystems Rocky K. C. Chang, February 2013.
1 Chapter 4 Encryption. 2 Objectives In this chapter, you will: Learn the basics of encryption technology Recognize popular symmetric encryption algorithms.
Public Key Model 8. Cryptography part 2.
1 CIS 5371 Cryptography 8. Asymmetric encryption-.
Chapter 12 Cryptography (slides edited by Erin Chambers)
8. Data Integrity Techniques
Lecture 23 Cryptography CPE 401 / 601 Computer Network Systems Slides are modified from Jim Kurose & Keith Ross.
Lecture 15 Lecture’s outline Public algorithms (usually) that are each other’s inverse.
Chapter 2 Basic Encryption and Decryption. csci5233 computer security & integrity 2 Encryption / Decryption encrypted transmission AB plaintext ciphertext.
CIS 725 Security. Cryptosystem Quintuple ( E, D, M, K, C ) M set of plaintexts K set of keys C set of ciphertexts E set of encryption functions e: M 
symmetric key cryptography
One-Time Pad Or Vernam Cipher Sayed Mahdi Mohammad Hasanzadeh Spring 2004.
Chapter 20 Symmetric Encryption and Message Confidentiality.
ITIS 3200: Introduction to Information Security and Privacy Dr. Weichao Wang.
Lec. 5 : History of Cryptologic Research II
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Chapter 20 Symmetric Encryption and Message Confidentiality.
CS526: Information Security Prof. Sam Wagstaff September 16, 2003 Cryptography Basics.
Module 3 – Cryptography Cryptography basics Ciphers Symmetric Key Algorithms Public Key Algorithms Message Digests Digital Signatures.
Cryptography Wei Wu. Internet Threat Model Client Network Not trusted!!
CS555Spring 2012/Topic 111 Cryptography CS 555 Topic 11: Encryption Modes and CCA Security.
Cryptography Part 1: Classical Ciphers Jerzy Wojdyło May 4, 2001.
1 Cryptanalysis Four kinds of attacks (recall) The objective: determine the key ( Herckhoff principle ) Assumption: English plaintext text Basic techniques:
Part 9, Basic Cryptography 1. Introduction A cryptosystem is a tuple: ( M,K,C, E,D) where M is the set of plaintexts K the set of keys C the set of ciphertexts.
CSIT311: Spring 2010 Network Management and Security Ghulam Murtaza.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Security.
CRYPTANALYSIS OF STREAM CIPHER Bimal K Roy Cryptology Research Group Indian Statistical Institute Kolkata.
Stream Ciphers and Block Ciphers A stream cipher is one that encrypts a digital data stream one bit or one byte at a time. Examples of classical stream.
Traditional Symmetric-Key Ciphers
September 10, 2009Introduction to Computer Security ©2004 Matt Bishop Slide #8-1 Chapter 8: Basic Cryptography Classical Cryptography Public Key Cryptography.
Lecture 2: Introduction to Cryptography
15-499Page :Algorithms and Applications Cryptography I – Introduction – Terminology – Some primitives – Some protocols.
Lecture 23 Symmetric Encryption
Block Ciphers and the Advanced Encryption Standard
Intro to Cryptography Lesson Introduction
1 The Data Encryption Standard. 2 Outline 4.1 Introduction 4.4 DES 4.5 Modes of Operation 4.6 Breaking DES 4.7 Meet-in-the-Middle Attacks.
CS526Topic 2: Classical Cryptography1 Information Security CS 526 Topic 2 Cryptography: Terminology & Classic Ciphers.
1 Introduction to Cryptography Chapter-4. Definitions  Cryptography = the science (art) of encryption  Cryptanalysis = the science (art) of breaking.
مروري برالگوريتمهاي رمز متقارن(كليد پنهان)
Computer Security Cryptography –an introduction
PART VII Security.
ADVANCED ENCRYPTION STANDARDADVANCED ENCRYPTION STANDARD
Presentation transcript:

Part 9, Basic Cryptography 1

Introduction A cryptosystem is a tuple: ( M,K,C, E,D) where M is the set of plaintexts K the set of keys C the set of ciphertexts E: M  K  C is an enciphering function D: C  K  M is a deciphering function 2

The Caesar cipher M = C is the set of sequences of Roman letters K : the set of integers: 0,1,…,25 E : is the enciphering function E k, k  K : E k (m) = m+k (mod 26) D : is the deciphering functions D k, k  K : D k (c) = c - k (mod 26) 3

Example If the key is k = 3, then: “HELLO”  “KHOR” Since: H  1 I  2 J  3 K E  F  G  H L  M  N  O O  P  Q  R 4

Cryptanalysis The goal of the cryptographer is to protect the privacy of ciphertexts. The goal of the cryptanalyst (attacker) is to disambiguate a ciphertext. Attacks on cryptosystems:  Ciphertext only attacks: the adversary has only access to ciphertexts. The adversary must find the plaintext that corresponds to a ciphertext.  Known plaintext attacks: the adversary has access to some matched ciphertexts / plaintext pairs, as well as ciphertexts. The adversary must find the plaintext of some new ciphertext.  Chosen plaintext attacks: the adversary may ask that specific plaintexts are enciphered, as well as having access to ciphertexts. The adversary must find the plaintext that corresponds to a new ciphertext. 5

Kerchoffs’ assumption The adversary knows all details of the encrypting function except the secret key 6

The transposition cipher A transposition cipher rearranges the characters in the plaintext; the key is a permutation  on the characters. The letters are not changed. So -- E  (x) =  (x) -- D  (y) =  -1 (y) Example: rail-fence cipher Let the ciphertext be “HELLO WORLD”: Write it in two columns as HLOOL ELWRD The ciphertext is “HLOOLELWRD” 7

Anagramming Attacking a transposition cipher requires a rearrangement of the letters of the ciphertext. Anagramming uses tables of n-gram frequencies to identify common n-grams. For example, for the ciphertext “HLOOLELWRD” the digram “HE” occurs with frequency in English (see textbook). Of the other possible digrams beginning with “H”, “HO” is the next highest. This suggest that “E” follows “H” in the plaintext. And so on. 8

The substitution cipher A substitution cipher changes the characters in the plaintext to produce the ciphertext. Caesar’s cipher is an example. Again the key for this cipher can be found by using a frequency analysis. 9

Difference between transposition and substitution ciphers Given the plaintext: wedo noth avea quiz today and ciphertext yadot ziuq aeva hton odew What is the cipher used? 1. A transposition cipher 2.A substitution cipher Why? 10

Block ciphers The Transposition and Substitution Ciphers are block ciphers: successive plaintext elements (blocks) are encrypted using the same key. We now consider some other block ciphers. The Affine Cipher, is a special case of the Substitution Cipher with -- E k (x) = ax + b mod26 -- D k (y) = a -1 y - a -1 b mod26 where a,b x,y is in Z 26, and a is invertible in Z

Block ciphers The Vigenere Cipher is polyalphabetic. Let m > 1 M = C = K = ( Z 26 ) m = Z 26  Z 26  Z 26 For a key k = (k 1, …, k m ) -- e K (x 1,…, x m ) = (x 1 + k 1, …, x m + k m ) -- d K (y 1,…, y m ) = (y 1 - k 1, …, y m - k m ) where all operations are in Z

Block ciphers The Hill Cipher is also polyalphabetic. Let m > 1 M = C = ( Z 26 ) m, K is the set of all m  m invertible matrices over ( Z 26 ) m For a key K in K -- e K (x) = xK -- d K (y)= yK -1 with all operations are in Z

Stream Ciphers The ciphers considered so far are block ciphers. Another type of cryptosystem is the stream cipher. 14

Stream Ciphers A synchronous stream cipher is a tuple ( M,C,K, L,E,D ) with a function g such that: M, C, K, E, D are as before. L is the keysteam alphabet g is the keystream generator: it takes as input a key K and outputs an infinite string z 1, z 2, … called the keystream, where z i are in L. For each z are in L there is an encryption rule e z in E, and a decryption rule d z in D such that: d z (e z (x)) = x for all plaintexts x in M. 15

Stream Ciphers The Linear Feedback Shift Register or LFSR. The keystream is computed as follows: Let (c 0, c 1, …,c m-1 ) be system parameters, and (k 1, k 2, …,k m ) be the initialized key vector at time t. At the next time unit the key vector is updated as follows: -- k 1 is output as the next keystream bit -- k 2, …, k m are each shifted one place to the left -- the “new” value of k m is computed by m-1 k m+1 =  c j k j+1 j=0 16

Stream Ciphers Let x 1, x 2, … be the plaintext (a binary string). Then the ciphertext is: y 1, y 2, … where y i,= x i + k i, for i = 1,2,… and the sum is bitwise xor. 17

Cryptanalysis Attacks on Cryptosystems Ciphertext only attack: the adversary has access a string of ciphertexts: y 1, y 2, … Known plaintext attack: the adversary has access a string of plaintexts x 1, x 2, … and the corresponding string of ciphertexts: y 1, y 2, … 18

Attacks on Cryptosystems Chosen plaintext attack: the adversary can choose a string of plaintexts x 1, x 2, … and obtain the corresponding string of ciphertexts: y 1, y 2, … Chosen ciphertext attack: the adversary can choose a string of ciphertexts: y 1, y 2, … and construct the corresponding string of plaintexts x 1, x 2, … 19

Attacks on Cryptosystems In all these attacks the adversary is given a new ciphertext and must find the corresponding plaintext 20

Cryptanalysis Cryptanalysis of the transposition cipher and substitution cipher: Ciphertext attack -- use statistical properties of the language Cryptanalysis of the affine and Vigenere cipher: Ciphertext attack -- use statistical: properties of the language Attacks on the affine and Vigenere cipher: Ciphertext attack -- use statistical: properties of the language 21

Cryptanalysis Cryptanalysis of the Hill cipher: Known plaintext attack Cryptanalysis of the LFSR stream cipher: Known plaintext attack 22

One-time pad This is a variant of the Vigenere cipher. The key string is chosen as a random bit string and is at least as long as the bit string message (plaintext) This cipher has perfect secrecy (defined later). Very costly: the key is as long as the plaintext. 23

One-time pad Suppose the key is the bit string k = (k 1, …, k m ) and the plaintext is the bit string (x 1, …, x m ). Then -- e k (x 1,…, x m ) = (x 1 XOR k 1, …, x m XOR k m ) -- d k (y 1,…, y m ) = (y 1 XOR k 1, …, y m XOR k m ) Note that ((x XOR k i ) XOR k i ) = x for all bits x, k i. 24

Security Computational security Computationally hard to break: requires super-polynomial computations (in the length of the ciphertext) Provable security Security is reduced to a well studied problem though to be hard, e.g. factorization. Unconditional security No bound on computation: cannot be broken even with infinite power/space. Only way to break is by “lucky” guessing. 25

Some Probability Theory The random variables X,Y are independent if: Pr[ X= x, Y= y ] = Pr[ X= x ]. Pr[ Y= y ], for all x,y in X In general, Pr[ X= x, Y= y ] = Pr[ X= x | X= y ]. Pr[ Y= y ] = Pr[ Y= y | X= x ]. Pr[ X= x ], for all x,y in X 26

Some Probability Theory Bayes’ Law: Pr[x|y] = Corollary: X,Y are independent random variables ( r.v. ) if and only if Pr[x|y] = Pr[x] for all x,y in X Pr[y] Pr[y|x]  Pr[x] for all x,y in X 27

Perfect secrecy A cryptosystem has perfect secrecy if : Pr[x|y] = Pr[x], for all x in M and y in C. That is: knowledge of the ciphertext y, offers no advantage to the adversary to determine the plaintext x. (there is no advantage in eavesdropping) 28

DES DES is a Feistel cipher. Block length 64 bits (effectively 56) Key length 56 bits Ciphertext length 64 bits 29

DES It has a round function g for which: g([L i-1,R i-1 ]),K i ) = (L i,R i ), where L i = R i-1 and R i = L i-1 XOR f (R i-1, K i ). 30

DES round encryption 31

DES inner function 32

DES computation path 33

Attacks on DES Brute force Linear Cryptanalysis -- Known plaintext attack Differential cryptanalysis –Chosen plaintext attack –Modify plaintext bits, observe change in ciphertext No dramatic improvement on brute force 34

Countering Attacks Large keyspace combats brute force attack Triple DES (say EDE mode, 2 or 3 keys) Use AES 35

AES Block length 128 bits. Key lengths 128 (or 192 or 256). The AES is an iterated cipher with Nr=10 (or 12 or 14) In each round we have: Subkey mixing A substitution A permutation 36

Modes of operation Four basic modes of operation are available for block ciphers: Electronic codebook mode: ECB Cipher block chaining mode: CBC Cipher feedback mode: CFB Output feedback mode: OFB 37

Electronic Codebook mode, ECB Each plaintext x i is encrypted with the same key K: y i = e K (x i ). So, the naïve use of a block cipher. 38

ECB (Electronic code Book) x1x1 x2x2 x3x3 x4x4 y4y4 y3y3 y2y2 y1y1 DES 39

Cipher Block Chaining, CBC Each cipher block y i-1 is xor -ed with the next plaintext x i : y i = e K (y i-1 XOR x i ) before being encrypted to get the next plaintext y i. The chain is initialized with an initialization vector: y 0 = IV with length, the block size. 40

Cipher Block Chaining, CBC x1x IV x2x2 x3x3 x4x4 y4y4 y3y3 y2y2 y1y1 DES 41

Cipher and Output feedback modes (CFB & OFB) CFB z 0 = IV and recursively: z i = e K (y i-1 ) and y i = x i XOR z i OFB z 0 = IV and recursively: z i = e K (z i-1 ) and y i = x i XOR z i 42

CFB mode IV eKeK eKeK y1y1 + x1x1 eKeK x2x2 y2y2 + 43

OFB mode IV eKeK eKeK y1y1 + x1x1 x2x2 y2y2 + 44

Public Key Cryptography Alice Bob Alice and Bob want to exchange a private key in public. 45

Public Key Cryptography Alice g a mod p Bob g b mod p The public key is: p, g, g a mod p, g b mod p, where p is a prime and g is a generator of Z p The private key is: a  Z p, which Alice knows and b  Z p, which Bob knows The output generated is a shared key: g ab mod p (only Alice and Bob can compute this) 46

The RSA cryptosystem Let n = pq, where p and q are primes. Let M = C = Z n, and let a,b be such that ed = 1 mod  (n). Define e K ( x ) = x e mod n and d K ( y ) = y d mod n, where ( x,y )  Z n. Public key = ( n,e ), Private key ( n,d ). 47

Check We have: ed = 1 mod   (n), so ed = 1 + t   (n). Therefore, d K ( e K ( m )) = (m e ) d = m ed = m t  (n)+1 = ( m  (n) ) t m = 1.m = m mod n 48

Example p = 101, q = 113, n =  ( n) = 100x112 = = For encryption use e = Then d = e -1 mod11200 = Bob publishes: n = 11413, e = Suppose Alice wants to encrypt: She computes mod = 5761 To decrypt it Bob computes: mod =

Example: how to find d from e Use the Extended Euclidean Algorithm (EEA). EEA takes as input two positive numbers a,b and outputs three numbers: s,t,d with, d = gcd(a,b) and sa+tb = d. In our case we take a = e, b =  ( n), to get: sa = 1 mod  ( n). So d = s. 50

Security of RSA 1.Relation to factoring. Recovering the plaintext m from an RSA ciphertext c is easy if factoring is possible. 2.The RSA problem Given ( n,e ) and c, compute: m such that m e = c mod n 51

The Rabin cryptosystem Let n = pq, p,q primes with p,q 3 mod 4. Let P = C = Z n * and define K = {( n,p,q )}. For K = ( n,p,q ) define e K ( x ) = x 2 mod n d K ( y ) = a square root of y mod n The value of n is the public key, while p,q are the private key. One needs the factors p,q of n to find the square root. 52

The Rabin cryptosystem Let n = pq, p,q primes with p,q 3 mod 4, and K = ( n,p,q ) To find the square roots of y mod n we first find the square roots y p = square root of y mod p y q = square root of y mod q And then use the CRT We have: y p = y ( p +1)/4 mod p y q = y ( q +1)/4 mod q 53

The Rabin cryptosystem To get the square root of y mod n (the quadratic residue ) from: y p = y (p+1)/4 mod p y q = y (q+1)/4 mod q We use the Extended Euclidean Algorithm on p, q. Let sp+tq = 1. Then the quadratic residue is: y = tqy p + spy q mod n Check: y  tqy p + spy q  tqy p  y p mod p  spy q  y q mod q 54

The RSA digital signature scheme Let n = pq, where p and q are primes. Let P = C = Z n, and define e,d such that ed = 1 mod  (n). Define sig K ( m ) = m d mod n and ver K ( m,y ) = true m = y e mod n, where ( m,y )  Z n. Public key = ( n,e ), Private key ( n,d ). 55

The Digital Signature Algorithm Let p be a an L-bit prime prime, 512  L  1024 and L  0 mod 64, let q be a 160-bit prime that divides p-1 and Let   Z p * be a q -th root of 1 modulo p. Let M = Z p -1, C = Z q x Z q and K = {( x,y ): y =  x mod p }. The public key is : p, q, , y. The private key is : ( p, q,  ), x. 56

The Digital Signature scheme Signing Let m  Z p be a message. For public key is p,g, , y, with y =  x mod p, and secret random number k  Z p -1, define: sig K ( m,k ) = ( s,t ), where – s = (  k mod p) mod q – t = (SHA-1(m)+xs)k -1 mod q Verification Let –e 1 = SHA-1(m) t -1 mod q –e 2 = st -1 mod q ver K (m,(s,t)) = true  (  e 1 y e 2 mod p) mod q = s. 57

Cryptographic hash functions Message can be quite long. Therefore, before digitally signing a message it is hashed. A hash function ( unkeyed ) is a mapping h: X  Y, where X is a set of possible messages Y is the set of possible message digests Message digests have fixed length: typically 160 bits (e.g., SHA-1), but also 256 or 516) 58

Properties of cryptographic hash funct ions 1.One way or preimage resistant : given a hash function h, and a message digest y, the equation y = h(x) cannot be solved efficiently for x. 2.Second preimage resistant : given a hash function h, a message x and the message digest y = h(x), the equation y = h(x) cannot be solved efficiently for a second preimage x, different from x, with y = h(x). 3.Collision resistant : one cannot find efficiently a pair of distinct messages x, x for which h(x)= h(x). 59