190 likes | 199 Views
Chapter 4. Basics of Cryptography. What is Cryptography? - Plaintext - Ciphertext - Encryption: c = E e (p) - Decryption: p = D d (c). Kerckhoff’s Principle: “The secrecy should be in the key used for decryption, not in the decryption or encryption algorithms”.
E N D
Chapter 4 Basics of Cryptography Prepared by: Mohan Gholap
What is Cryptography? - Plaintext - Ciphertext - Encryption: c = Ee(p) - Decryption: p = Dd(c) Kerckhoff’s Principle: “The secrecy should be in the key used for decryption, not in the decryption or encryption algorithms” Prepared by: Mohan Gholap
Types of Cryptography • Secret Key Cryptography: - Both sender and receiver share a common secret, ie. e = d - Also called as “Symmetric key Cryptography” 2. Public Key Cryptography: - Two distinct keys forming a key pair are used - Encryption key/ Public key - Decryption key/ Private key Prepared by: Mohan Gholap
Example: If Alka wants to send confidential message to Brijesh Case 1: Secret Key Cryptography: Both share a common key, k Operation by Alka : c = Ek(p) Opeartion by Brijech: p = Dk(c) Case 2: Public Key Cryptography: Assuming Brijesh have key public-private key pair, Operation by Alka : c = EB.pu(p) Opeartion by Brijech: p = DB.pr(c) Prepared by: Mohan Gholap
Types of Attacks • Cryptographic algorithm is secure if a cryptanalyst is unable to • Obtain plaintext from given ciphertext • Deduce the secret key or the private key • Types: • Known ciphertext attack • Known plaintext attack • Chosen plaintext attack Prepared by: Mohan Gholap
Brute force attempt to obtain a key from known plaintext Let (p1,c1), (p2,c2), … (pm,cm) be plaintext-ciphertext pairs for(each potential key value in key space) { proceed = true; i=1; while(proceed == true && i <= m) { if(ci != Ek(pi)) proceed = false; i++; } if(i = m+1) print (“Key value is k”); } Prepared by: Mohan Gholap
ELEMENTARY SUBSTITUTION CIPHERS • Monoalphabetic ciphers: - most basic cipher is substitution cipher - Let ∑ denote set of alphabets, {A,B, … ,Z} - This approach defines the permutation of elements in ∑ - There are 26! Permutations. Ex: Simplest substitution cipher is one that replaces each alphabet in a text by another alphabet k positions away. [If k = 3] D for A, E for B,…, A for X, B for Y,etc. - This scheme is called “Caeser cipher” Prepared by: Mohan Gholap
Example Cont..d Plaintext: WHAT IS THE POPULATION OF MARS Ciphertext: ZKDW LV WKH SRSXODWLRQ RI PDUV NOTE: Here, each letter is substituted by another unique letter, hence such ciphers are called “monoalphabetic” Prepared by: Mohan Gholap
2. Polyalphabetic Ciphers • Ciphertext corresponding to a particular character is not fixed. • Vigenere Cipher: - It uses a multi digit key k1,k2,….,km. - Plaintext is split into number of blocks, each of m consecutive characters - 1st letter of each block replaced by letter k1 positions to its right, 2nd by a letter k2 positions to the right, and so on. Prepared by: Mohan Gholap
Example: P’text: W i s h i n g Y o u M u c h Key : 04 19 03 22 07 12 05 11 04 19 03 22 07 12 C’text: A B V D P Y L J S N P Q J T P’text: S u c c e s s Key : 05 11 04 19 03 22 07 C’text: X F G V H O Z NOTE: Here, key length = 8. ie. Key string repeats after 8 positions Prepared by: Mohan Gholap
2. The Hill Cipher • Plaintext is broken into blocks of size m. • Here, Key is a m X m matrix of integers between 0 to 25. • Let p1, p2, p3, …,pm be the numeric representation of characters in plaintext. • Let c1, c2, c3, …,cm represent corresponding characters in ciphertext. • To compute a ciphertext, we use the mapping, A -> 0, B -> 1, . . . , Z -> 25 Prepared by: Mohan Gholap
Now, c1 = p1 k11 + p2 k21 + . . . + pm km1 mod 26 c2 = p1 k12 + p2 k22 + . . . + pm km1 mod 26 . . . cm = p1k1m + p2k2m+ . . . + pmkmm mod 26 In general, c = p K where, i) c and p are row vectors of ciphertext & plaintext resp’ly, ii) K is m X m matrix comprising the key At Receiver, plaintext can be recovered by, p = c K-1 Prepared by: Mohan Gholap
Example: Consider a Hill cipher using block size = 2 (m=2) Let, K = 3 7 15 12 Let, a block of plaintext be (H I) Numeric equivalent of this block is (7 8) Wkt, c = p K c = (7 8) * 3 7 15 12 = (11 15) = (L P) Prepared by: Mohan Gholap
ELEMENTARY TRANSPOSITION CIPHERS • A transposition cipher shuffles, rearranges or permutes the bits in a block of plaintext. • Unlike a substitution cipher, the number of 0’s and 1’s in a block doesn’t change after shuffling. Prepared by: Mohan Gholap
Example: Plaintext: b e g i Begin Operation at Noonn o p e r a t i o n a t n o o n Let us re-arrange the rows as follows, Row 1 ->3, Row 2 -> 5, Row 3 ->2, Row 4 -> 1, Row 5 -> 4. The resulting matrix is o n a t r a t I b e g i n o o n n o p e Prepared by: Mohan Gholap
We now re-arrange the columns as follows, Column 1->4, Column 2->3, Column 3->1, Column 4 ->2 The resulting matrix is a t n o t i a r g i e b o n o n p e o n Thus ciphertext generated is: A T N O T I A R G I E B O N O N P E O N Prepared by: Mohan Gholap
Another example: • An attacker may use this approach as follows, • C’text: 1 1 K C T A T A M M O C P M 5 1 C E N E • P’text: Commence Attack 11 15 pm Prepared by: Mohan Gholap
Other Cipher properties • Confusion & Diffusion: • Confusion is the property of a cipher where it doesn’t provide any description/clue regarding the relationship between cipher-text and key. • Diffusion is the property of a cipher-text, where block of the Plain-text is irretrievably scattered across the blocks of cipher-text. Prepared by: Mohan Gholap
Block Ciphers & Stream Ciphers • In Block Ciphers, plaintext is split into fixed size chunks called blocks. Here, each block is encrypted separately and usually same key is used for all blocks. Example: DES, AES, RSA, ECC, etc. • Stream Ciphers operate on bits. Stream ciphers usually generate a pseudo random key stream as a function of fixed length key and a per message bit string. Example: RC4 used in wireless LAN protocol. Stream ciphers are faster than block ciphers and are less complicated. Prepared by: Mohan Gholap