15-853:Algorithms in the Real World Cryptography Outline Cryptography
Total Page:16
File Type:pdf, Size:1020Kb
Cryptography Outline Introduction: terminology, cryptanalysis, security 15-853:Algorithms in the Real World Primitives: one-way functions, trapdoors, … Protocols: digital signatures, key exchange, .. Cryptography 1 and 2 Number Theory: groups, fields, … Private-Key Algorithms: Rijndael, DES Public-Key Algorithms: Knapsack, RSA, El-Gamal, … Case Studies: Kerberos, SSL 15-853 Page 1 15-853 Page 2 Cryptography Outline Enigma Machine Introduction: "It was thanks to Ultra – terminology that we won the war.” – cryptanalytic attacks - Winston Churchill – security Primitives: one-way functions, trapdoors, … Protocols: digital signatures, key exchange, .. Number Theory: groups, fields, … Private-Key Algorithms: Rijndael, DES Public-Key Algorithms: Knapsack, RSA, El-Gamal, … Case Studies: Kerberos, SSL 15-853 Page 3 15-853 Page 4 1 Some Terminology More Definitions Plaintext Cryptography – the general term Cryptology – the mathematics Key1 Encryption Ek(M) = C Encryption – encoding but sometimes used as general term) Cyphertext Cryptanalysis – breaking codes Key2 Decryption Dk(C) = M Steganography – hiding message Cipher – a method or algorithm for encrypting or Original Plaintext decrypting Private Key or Symmetric: Key1 = Key2 Public Key or Asymmetric: Key1 ≠ Key2 Key1 or Key2 is public depending on the protocol 15-853 Page 5 15-853 Page 6 Cryptanalytic Attacks What does it mean to be secure? C = ciphertext messages Unconditionally Secure: Encrypted message cannot M = plaintext messages be decoded without the key Shannon showed in 1943 that key must be as long as the message to be unconditionally secure – this is Ciphertext Only:Attacker has multiple Cs but does based on information theory not know the corresponding Ms A one time pad – xor a random key with a message Known Plaintext: Attacker knows some number of (Used in 2nd world war) (C,M) pairs. Security based on computational cost: it is Chosen Plaintext: Attacker gets to choose M and computationally “infeasible” to decode a message generate C. without the key. No (probabilistic) polynomial time algorithm can Chosen Ciphertext: Attacker gets to choose C and decode the message. generate M. 15-853 Page 7 15-853 Page 8 2 The Cast Cryptography Outline Alice – initiates a message or protocol Introduction: terminology, cryptanalysis, security Bob - second participant Primitives: Trent – trusted middleman – one-way functions Eve – eavesdropper – one-way trapdoor functions Mallory – malicious active attacker – one-way hash functions Protocols: digital signatures, key exchange, .. Mallory Trent Number Theory: groups, fields, … Private-Key Algorithms: Rijndael, DES Public-Key Algorithms: Knapsack, RSA, El-Gamal, … Alice Bob Case Studies: Kerberos, Digital Cash Eve 15-853 Page 9 15-853 Page 10 One-way functions: Primitives: One-Way Functions possible definition (Informally): A function Y = f(x) 1. F(x) is polynomial time is one-way if it is easy to compute y from x but 2. F-1(x) is NP-hard “hard” to compute x from y What is wrong with this definition? Building block of most cryptographic protocols And, the security of most protocols rely on their existence. Unfortunately, not known to exist. This is true even if we assume P ≠ NP. 15-853 Page 11 15-853 Page 12 3 One-way functions: Some examples (conjectures) better definition Factoring: For most y no single PPT (probabilistic polynomial time) algorithm can compute x x = (u,v) y = f(u,v) = u*v Roughly: at most a fraction 1/|x|k instances x are If u and v are prime it is hard to generate them easy for any k and as |x| -> ∞ from y. Discrete Log: y = gx mod p This definition can be used to make the probability where p is prime and g is a “generator” (i.e., g1, g2, of hitting an easy instance arbitrarily small. g3, … generates all values < p). DES with fixed message: y = DESx(m) This would assume a family of DES functions of increasing key size (for asymptotics) 15-853 Page 13 15-853 Page 14 One-way functions in One-way functions in public-key protocols private-key protocols y = ciphertext m = plaintext k = public key y = ciphertext m = plaintext k = key Is Consider: y = Ek(m) (i.e., f = Ek) y = Ek(m) (i.e. f = Ek) We know k and thus f a one-way function with respect to y and m? Ek(m) needs to be easy -1 Ek (y) should be hard What do one-way functions have to do with private- Otherwise we could decrypt y. key protocols? But what about the intended recipient, who should be able to decrypt y? 15-853 Page 15 15-853 Page 16 4 One-way functions in One-Way Trapdoor Functions private-key protocols A one-way function with a “trapdoor” y = ciphertext m = plaintext k = key The trapdoor is a key that makes it easy to invert How about the function y = f(x) Example: RSA (conjecture) y = Ek(m) = E(k,m) = Em(k) (i.e. f = Em) e should this be a one-way function? y = x mod n Where n = pq (p, q, e are prime) In a known-plaintext attack we know a (y,m) pair. p or q or d (where ed = (p-1)(q-1) mod n) can be used as trapdoors The m along with E defines f In public-key algorithms E (k) needs to be easy m f(x) = public key (e.g., e and n in RSA) E -1(y) should be hard m Trapdoor = private key (e.g., d in RSA) Otherwise we could extract the key k. 15-853 Page 17 15-853 Page 18 One-way Hash Functions Cryptography Outline Y = h(x) where Introduction: terminology, cryptanalysis, security – y is a fixed length independent of the size of x. Primitives: one-way functions, trapdoors, … In general this means h is not invertible since it Protocols: is many to one. – digital signatures – Calculating y from x is easy – key exchange – Calculating any x such that y = h(x) give y is Number Theory: groups, fields, … hard Private-Key Algorithms: Rijndael, DES Used in digital signatures and other protocols. Public-Key Algorithms: Knapsack, RSA, El-Gamal, … Case Studies: Kerberos, Digital Cash 15-853 Page 19 15-853 Page 20 5 Protocols Protocols: Digital Signatures Other protocols: Goals: – Authentication 1. Convince recipient that message was actually – Secret sharing sent by a trusted source – Timestamping services 2. Do not allow repudiation, i.e., that’s not my – Zero-knowledge proofs signature. – Blind-signatures 3. Do not allow tampering with the message without invalidating the signature – Key-escrow Item 2 turns out to be really hard to do – Secure elections – Digital cash Implementation of the protocol is often the weakest point in a security system. 15-853 Page 21 15-853 Page 22 Using private keys Using Public Keys D (m) Alice k1 Bob Eka(m) Trent Ekb(m + sig) K1 = Alice’s private key Bob decrypts it with her public key Alice Bob More Efficiently – ka is a secret key shared by Alice and Trent – kb is a secret key shared by Bob and Trent D (h(m)) + m Alice k1 Bob sig is a note from Trent saying that Alice “signed” it. To prevent repudiation Trent needs to keep m or at h(m) is a one-way hash of m least h(m) in a database 15-853 Page 23 15-853 Page 24 6 Key Exchange Cryptography Outline Private Key method Introduction: terminology, cryptanalysis, security Trent Primitives: one-way functions, trapdoors, … Eka(k) Generates k Ekb(k) Protocols: digital signatures, key exchange, .. Alice Bob Number Theory Review: (Mostly covered last week) – Groups Public Key method – Fields Ek1(k) Alice Bob – Polynomials and Galois fields Generates k k1 = Bob’s public key Private-Key Algorithms: Rijndael, DES Public-Key Algorithms: Knapsack, RSA, El-Gamal, … Or we can use a direct protocol, such as Diffie- Hellman (discussed later) Case Studies: Kerberos, Digital Cash 15-853 Page 25 15-853 Page 26 Number Theory Outline Groups Groups A Group (G,*,I) is a set G with operator * such that: – Definitions, Examples, Properties 1. Closure. For all a,b ∈ G, a * b ∈ G – Multiplicative group modulo n 2. Associativity. For all a,b,c ∈ G, a*(b*c) = (a*b)*c – The Euler-phi function 3. Identity. There exists I ∈ G, such that for all Fields a ∈ G, a*I=I*a=a – Definition, Examples 4. Inverse. For every a ∈ G, there exist a unique – Polynomials element b ∈ G, such that a*b=b*a=I – Galois Fields An Abelian or Commutative Group is a Group with the additional condition Why does number theory play such an important role? 5. Commutativity. For all a,b ∈ G, a*b=b*a It is the mathematics of finite sets of values. 15-853 Page 27 15-853 Page 28 7 Examples of groups Key properties of finite groups – Integers, Reals or Rationals with Addition Notation: aj ≡ a * a * a * … j times – The nonzero Reals or Rationals with Theorem (Fermat’s little): for any finite group Multiplication (G,*,I) and g ∈ G, g|G| = I – Non-singular n x n real matrices with Matrix Multiplication Definition: the order of g ∈ G is the smallest m – Permutations over n elements with composition positive integer m such that g = I [0→1, 1→2, 2→0] o [0→1, 1→0, 2→2] = [0→0, 1→2, 2→1] Definition: a group G is cyclic if there is a g ∈ G such that order(g) = |G| We will only be concerned with finite groups, I.e., ones with a finite number of elements. Definition: an element g ∈ G of order |G| is called a generator or primitive element of G. 15-853 Page 29 15-853 Page 30 Groups based on modular arithmetic Other properties * The group of positive integers modulo a prime p |Zp | = (p-1) * (p-1) Zp ≡ {1, 2, 3, …, p-1} By Fermat’s little theorem: a = 1 (mod p) * *p ≡ multiplication modulo p Example of Z7 * Denoted as: (Zp , *p) x x2 x3 x4 x5 x6 Required properties 1 1 1 1 1 1 1.