Classic Cryptosystems Key Points Modulo Operation Ring Division
Total Page:16
File Type:pdf, Size:1020Kb
3/1/2014 Ring RRiinngg ZZmm iiss:: ––SetSet of integers: ZZ =={{00,,11,,22,,……,,mm--11}} Classic Cryptosystems mm ––TwoTwo operation: “+” and “ ××”” →→ ≡≡ ∈∈ ““++”” a + b c mod m (c ZZmm)) ×× →→ ×× ≡≡ ∈∈ ““ ” a b d mod m (d ZZmm)) Example: –– m = 77,, ZZ77=={{00,,11,,22,,33,,44,,55,,66}} 66 ++ 55 == 1111 mod 77 == 44 6 ×× 55 == 3300 mod 77 == 22 6622//٤٤ ١١ Key Points Ring Z mm Properties & Operations Field: set of elements with + & * IdentityIdentity:: additive ‘‘00’’ , multiplicative ‘11’’‘ Modular Arithmetic: reduces all aa++00=a=a , ,a ××a11=a=a mod m numbers to fixed set [[00……nn--11]] InverseInverse:: additive ‘--a’,‘ a’, multiplicative ‘a --11’’ GCD: largest positive integer dividing aa++((--aa))==00mod mod m, m, a ××a aa--11 ==11 mod m Finite Field: finite number of elements Multiplicative inverse exist if gcd (a,m) = 11 n Order Finite Field: power of a prime PP Ring Addition and Multiplication is: where n = integer ClosedClosed,, Commutative,Commutative , Associative Finite Field: of order p can be defined using normal arithmetic mod p 6622//٥٥ 6622//٢٢ Modulo Operation Division on Ring ZZmm QQ::WhatWhat is 1122 mod 99?? Ring Division: 44//1155 mod 2266?????? AA::1122 mod 9 ≡≡33 44//1155 mod 2266 == 44 ×× 1155--11 mod 2266 LLeett a,r,m ∈∈ ΖΖ 1155--11 mod 2266existexist if gcd(1155,,2266))==11gcd( 1155--11 mod 2266 == 77 ((Ζ = set of all integers ) and mm >>00.. 44//1155 mod 2266 == 44××7 mod 2266 == 2288 mod 2266==22 We write r ≡ a mod m if m ––rr divides aa.. Note that the modulo operation can be applied mm is called the modulus. whenever we want: rr is called the remainder. (a + b) mod m = [(a mod m)+ (b mod m)] mod m q · a = m --rr 0 ≤ r< m ((aa ×× b) mod m = [(a mod m) ×× (b mod m)] mod m 6622//٦٦ 6622//٣٣ 1 3/1/2014 Exponentiation in ZZ mm Substitution Ring Exponentiation: 338 mod 77 ==?????? 338 mod 77 == 6561 mod 77 6561 mod 77 == 22 →→ 66556611==((993377××77))++22 A => 0 Or = 3388 == 4433××3344== 2233××3322××3322××3322 NUCLEAR B => 1 8 2 ×× 2 ×× 2 C => 2 33 mod 77 == [[((33 mod 77)) ((33 mod 77)) ((33 mod 77)) Key ××((332 mod 77)])] mod 77 D => 3 E => 4 338 mod 77 == ((22 ×× 2 ×× 2 ×× 22)) mod 77 == 1166 mod 77==22 Encryption .. Note that ring ΖΖmm (modulo arithmetic) is of .. central importance to modern publicpublic--kkeeyy cryptography. In practice,the order of the .. integers involved in PKC are in the range of[of[22116600 , 13 20 2 11 4 0 17 X => 23 2211002244]. Perhaps even larger Y => 24 Z => 25 6622//١١٠٠ 6622//٧٧ Advance Substitution Classic Cryptography (Random) Key Substitution A => D F => I K => N P => S U => G B => A G => J L => O Q => F V => Y Transposition C => T H => U M => P R => K W => Q Enigma Machine D => X I => L N => Z S => V X => E SShihifftt E => H J => R O => M T => W Y => B Z => C Affine Vigenere Block (Hill) Vernam (one time pad) NUCLEAR Encryption ??????? Stream 6622//١١١١ 6622//٨٨ Substitution Transposition (Permutation) Substitution reserves places A => B But NUCLEAR B => C Transposition reserves content C => D D => E Key E => F Encryption .. .. .. NUCLEAR Encryption LUCNARE OVDMFBS X => Y Y => Z Z => A 6622//١١٢٢ 6622//٩٩ 2 3/1/2014 Breaking a Transposition (Permutation) Monoalphabetic Substitution X ydis pq yjc xzpvpyw ya icqdepzc ayjceq xq COMPUTER ENGINEER A tact is the ability to describe others as yjcw qcc yjcuqcvrcq. Encryption Cipher text they see themselves. COM PUT Xzexjxu Vpsdavs CPEEIE.OURNNR.MT GE . ER Abraham Lincoln ENG I NE Character Frequency: c-10, y-8, q-7, x-6, j-5, p-5, v-4, d-3 ER a-3, e-3, z-3, s-2, u-2, w-2, i-1, r-1 6622//Alphabet frequency: e t a o i n s r h l d c u m f p g w y b v k x j q z١١٦٦ 6622//١١٣٣ Security Enigma Machine GermanyGermany--WorldWorld War 11 Encryption: Keys are typed in normally Machine output: Cipher text -- encrypted message typed on paper Decryption: Normal typing cipher text ––MachineMachine output: Plain text on paper Keys: Mechanical rotors 6622//١١٧٧ 6622//١١٤٤ Wheel Cipher 6622//١١٨٨ 6622//١١٥٥ 3 3/1/2014 Shift Cipher Analysis Affine Cipher Algorithm: Alphabet letters are substituted by numbers: Encryption: Ek(x) = y = α· x + β mod 26. Key: k = (α, β) where α, β ∈ Ζ Key Space??? AA BB CC DD EE FF GG HH II JJ KK LL MM 26 Key space = 26 . 26 = 676 Possibilities are they all possible? 00 11 22 33 44 55 66 77 88 99 1100 1111 1122 NN OO PP QQ RR SS TT UU VV WW XX YY ZZ Example: 1133 1144 1155 1166 1177 1188 1199 2200 2211 2222 2233 2244 2255 k = (α, β) = (13, 4) INPUT = (8, 13, 15, 20, 19) RRiingng::ZZ x = plaintext k = key Y = (4, 17, 17, 4, 17) = ERRER 2626 ALTER = (0, 11, 19, 4, 17) –– EE (x) = x + k mod 26 ((EncryptionEncryption)) kk Y = (4, 17, 17, 4, 17) = ERRER –– DD (x) = x ––kk mod 26 ((DecryptionDecryption)) kk No one-to-one map within plaintext and ciphertext. What went wrong? 6622//٢٢٢٢ -1 6622//١١٩٩ Caser Cipher: k = 33 Decryption: D k(x) = x = α · y +γ Affine Cipher Analysis Caesar Shift Key Space: β can be any number in Ζ26 ⇒ 26 possibilities -1 Since α has to exist, only selected integers in Ζ26 are useful .e.g. gcd( α, 26) = 1. {1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25} Therefore, the key space has 12 · 26 = 312 candidates. Attack types: PLAINTEXT a b c d e f g h i j k l m 1. Ciphertext only: exhaustive search or frequency analysis 2. Known plaintext: two letters in the plaintext and corresponding ciphertext letters CIPHERTEXT D E F G H I J K L M N O P would be sufficient to find the key. n o p q r s t u v w x y z PLAINTEXT Example : plaintext: IF=(8, 5) and ciphertext PQ=(15, 16) CIPHERTEXT Q R S T U V W X Y Z A B C – 8 · α + β ≡ 15 mod 26 – 5 · α + β ≡ 16 mod 26 → α = 17 and β = 9 What happens if we have only one letter of known plaintext? 3. Chosen plaintext: Chose A and B as the plaintext. The first character of the Hello There → khoor wkhuh ciphertext will be equal to 0·α + β = β and the second will be α + β. 4. Chosen ciphertext : Chose A and B as the ciphertext. 6622//٢٢٣٣ 6622//٢٢٠٠ Shift Cipher Example Vigenere Cipher Assume: key k = 17 Vigenere Cipher encrypts mm Plaintext: X = A T T A C K = (0, 19, 19, 0, 2, 10). Ciphertext: Y = (0+17 mod 26, 19+17 mod 26,…) alphabetic characters at a time Y = (17, 10, 10, 17, 19, 1) = R K K R T B Attacks on Shift Cipher each plaintext element is equivalent 1. Exhaustive Search: ttoo mm alphabetic characters – Try all possible keys. |K|= 26. – Nowadays, for moderate security, |K| ≥280 , – recommended security |K| ≥2100 . key KK is a keyword that associate 2. Letter frequency analysis (Same plaintext maps to same ciphertext) with an alphabetic string of length mm 6622//٢٢٤٤ 6622//٢٢١١ 4 3/1/2014 Example Block ciphers Substitution ciphers: changing one letter in the plaintext changes mm == 55;;KK == ((22,, 88,, 1155,, 77,, 2200)).. exactly one letter in the ciphertext. P = 44,,55,,22,,88,,1111,,22,,1144,,2200,,11,,22,,44,,55,,1166 This greatly facilitates finding the key using frequency analysis. Block ciphers: prevents this by encrypting a block of letters simultaneously. Encryption: Many of the modern (symmetric) cryptosystems are block ciphers. 44 55 22 88 111122 1144220011 22 33 44 55 1166 DES operates on 64 bits of blocks 22 88 115577 220022 88 115577 220022 88 115577 AES uses blocks of 128 bits (192 and 256 are also possible). 66 113311771155331144 222299 88 222255 112222002233 Example: Hill Cipher (1929) The key is an n × n matrix whose entries are integers in Ζ26 . 6622//٢٢٨٨ 6622//٢٢٥٥ Vigenere Cipher Secrecy Block cipher: Hill cipher number of possible keywords of length mm 2266mm Encryption: vector-matrix multiplication if mm == ,55, then then the the keyspace keyspace has has size size exceeding exceeding 11..11 ×× 110077. 1 2 3 This is already large enough to preclude Example: Let n=3, key matrix ‘M’ be M = 4 5 6 exhaustive key search by hand (but not by 11 9 8 computer). assume the plaintext is ABC=(0,1,2) having keyword length mm, an alphabetic 1 2 3 character can be mapped to one of mm possible )2,1,0( × 4 5 6 ≡ (26,23,22)mod26= (0,23,22) ⇒ AXW (ciphertext ) alphabetic characters (assuming that the keyword contains mm distinct characters). 11 9 8 Such a cryptosystem is called polyalphabetic . Decryption: 22 5 1 In general, cryptanalysis is more difficult for 22 5 1 = polyalphabetic than for monoalphabetic inverse ‘N’ of key matrix M is needed: N 6 17 24 cryptosystems. (0,23,22) × 6 17 24 ≡ (468,677,574)mod26= (0,1,2) ⇒15ABC 13( plain 1 − text ) 6622//٢٢٩٩ 15 13 1 6622//٢٢٦٦ Vigenere Cipher Attack Hill Cipher If we change one letter in the plaintext, all the letters of observe two identical segments in the ciphertext will be affected.