Top Banner
3. Cryptography and Public key Infrastructure Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 1 3.1 Identify and describe types of cryptography. o Symmetric encryption o Asymmetric encryption. 3.2 List and describe various Encryption Algorithms. Encryption algorithm / Cifer, Encryption and Decryption using: o Caesar’s cipher, o playfair cipher, o shift cipher(K-shit Cipher), o Vigenere(Polyalphabetic) cipher, o One time pad (vermin cipher), o Hill cipher (for practice use small matrix and apply encryption only). 3.3 Describe transposition techniques and steganography. o Transposition techniques (rail fence), o steganography
14

3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

Mar 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 1

3.1 Identify and describe types of cryptography.

o Symmetric encryption o Asymmetric encryption.

3.2 List and describe various Encryption Algorithms.

Encryption algorithm / Cifer, Encryption and Decryption using:

o Caesar’s cipher, o playfair cipher, o shift cipher(K-shit Cipher), o Vigenere(Polyalphabetic) cipher, o One time pad (vermin cipher), o Hill cipher (for practice use small matrix and apply encryption only).

3.3 Describe transposition techniques and steganography.

o Transposition techniques (rail fence), o steganography

Page 2: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 2

3.1 Identify and describe types of cryptography.

Symmetric Encryption Symmetric encryption is a form of cryptosystem in which encryption and decryption

are performed using the same key. It is also known as conventional encryption.

Symmetric encryption transforms plaintext into ciphertext using a secret key and an encryption algorithm. Using the same key and a decryption algorithm, the plaintext is recovered from the ciphertext.

The two types of attack on an encryption algorithm are cryptanalysis, based on properties of the encryption algorithm, and brute-force, which involves trying all possible keys.

Traditional (precomputer) symmetric ciphers use substitution and/or transposition techniques. Substitution techniques map plaintext elements (characters, bits) into ciphertext elements. Transposition techniques systematically transpose the positions of plaintext elements.

Rotor machines are sophisticated precomputer hardware devices that use substitution techniques.

Steganography is a technique for hiding a secret message within a larger one in such a way that others cannot discern the presence or contents of the hidden message.

Symmetric Cipher Model

A symmetric encryption scheme has five ingredients (Figure 2.1):

Plaintext: This is the original intelligible message or data that is fed into the algorithm as input.

Page 3: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 3

Encryption algorithm: The encryption algorithm performs various substitutions and transformations on the plaintext.

Secret key: The secret key is also input to the encryption algorithm. The key is a value independent of the plaintext and of the algorithm. The algorithm will produce a different output depending on the specific key being used at the time. The exact substitutions and transformations performed by the algorithm depend on the key.

Cipher text: This is the scrambled message produced as output. It depends on the plaintext and the secret key. For a given message, two different keys will produce two different ciphertexts. The ciphertext is an apparently random stream of data and, as it stands, is unintelligible.

Decryption algorithm: This is essentially the encryption algorithm run in reverse. It takes the ciphertext and the secret key and produces the original plaintext.

There are two requirements for secure use of conventional encryption:

1. We need a strong encryption algorithm. At a minimum, we would like the algorithm to be such that an opponent who knows the algorithm and has access to one or more ciphertexts would be unable to decipher the ciphertext or figure out the key.This requirement is usually stated in a stronger form:The opponent should be unable to decrypt ciphertext or discover the key even if he or she is in possession of a number of ciphertexts together with the plaintext that produced each ciphertext.

2. Sender and receiver must have obtained copies of the secret key in a secure fashion and must keep the key secure. If someone can discover the key and knows the algorithm, all communication using this key is readable.

Classical Encryption Technique.

There are two types of encryption technique

1. Substitution Technique

2. Transposition Technique

Substitution Technique:

A substitution technique is one in which the letters of plaintext are replaced by other letters or by numbers or symbols.1 If the plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with ciphertext bit patterns.

Different types of encryption techniques are listed and described below. 1. Caesar’s cipher, 2. playfair cipher,

Page 4: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 4

3. shift cipher(K-shit Cipher), 4. Vigenere(Polyalphabetic) cipher, 5. One time pad (vermin cipher), 6. Hill cipher (for practice use small matrix and apply encryption only).

Caesar’s cipher The earliest known, and the simplest, use of a substitution cipher was by Julius Caesar.The Caesar cipher involves replacing each letter of the alphabet with the letter standing three places further down the alphabet. For example, Plaintext: meet me after the toga party Ciphertext: PHHW PH DIWHU WKH WRJD SDUWB Note that the alphabet is wrapped around, so that the letter following Z is A. We can define the transformation by listing all possibilities, as follows: plain: a b c d e f g h i j k l m n o p q r s t u v w x y z cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C Let us assign a numerical equivalent to each letter:

Encryption:

C=(P+K) mod 26 Example: for plaintext letter M number is 12 C=(12+3) mod 26 = 15 so, for number 15 alphabet is “P” Decryption P=(C-K) mod 26 Example: for cipher text “P” number is 15 P=(15-3) mod 26= 12 so, for number 12 alphabet is “M”.

Note: if result is less than 0 then add 26.

Page 5: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 5

Playfair Cipher

The best-known multiple-letter encryption cipher is the Playfair, which treats diagrams in the plaintext as single units and translates these units into ciphertext digrams. The Playfair algorithm is based on the use of a 5*5 matrix of letters constructed using a keyword. Here is an example, solved by Lord Peter Wimsey in Dorothy Sayers’s Have His Carcase:

In this case, the keyword is monarchy. The matrix is constructed by filling in the letters of the keyword (minus duplicates) from left to right and from top to bottom, and then filling in the remainder of the matrix with the remaining letters in alphabetic order. The letters I and J count as one letter. Plaintext is encrypted two letters at a time, according to the following rules: 1. Repeating plaintext letters that are in the same pair are separated with a filler letter, such as x, so that balloon would be treated as ba lx lo on. 2. Two plaintext letters that fall in the same row of the matrix are each replaced by the letter to the right, with the first element of the row circularly following the last. For example, ar is encrypted as RM. 3. Two plaintext letters that fall in the same column are each replaced by the letter beneath, with the top element of the column circularly following the last. For example, mu is encrypted as CM. 4. Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row and the column occupied by the other plaintext letter. Thus, hs becomes BP and ea becomes IM (or JM, as the encipherer wishes).

Shift Cipher:

Note: shift cipher is most like ceaser’s Cipher except it will use k-shift instead of 3-shift.

Page 6: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 6

Vigenere Cipher: -it is also known as polyalphabetic cipher. -it requires 26*26 matrix of alphabets(plaintext v/s Key) which is depicted below.

Encryption: Step 1: write plaintext and expand key upto the length of plaintext as shown below. Plaintext (Today is Friday) & Key (DAY)

T O D A Y I S F R I D A Y

D A Y D A Y D A Y D A Y D

Step 2: consider plaintext letter as a column and key letter as a row and make a straight line from both of it, whenever they intersect that letter will be used as a ciphertext for them.

Page 7: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 7

For example : For plaintext “T” and key “D” ciphertext will be “W”.likewise for others OBDYGVFPLDYB Decryption: Step 1: write ciphertext and expand key upto the length of the ciphertext as shown below.

W O B D Y G V F P L D Y B

D A Y D A Y D A Y D A Y D

Step 2: consider plaintext letter as a column and key letter as a row and make a straight line from both of it, whenever they intersect that letter will be used as a ciphertext for them. For example : For ciphertext “W” and key “D” plaintext will be “T ”.likewise for others ODAYISFRIDAY

ALGORITHM FOR ENCRYPTION AND DECRYPTION WITH EXAMPLE SHOWN BELOW.

Vigenère can also be viewed algebraically. If the letters A–Z are taken to be the numbers 0–25,

and addition is performed modulo 26, then Vigenère encryption using the key can be

written,

here i= letter position in the plaintext.

For example: consider previous example plaintext “Today is Friday” and key “Day”, In

this example at 0th position plaintext for “T” number is 19 and “D” number is 3. By using

above method

Ci=Ek(i)=(T+D) mod 26= (19+3) mod 26= 22= W

and decryption using the key ,

, here i= letter position in the plaintext.

For example: consider previous example plaintext “Today is Friday” and key “Day”, In

this example at 0th position plaintext for “T” number is 19 and “D” number is 3. By using

above method

Page 8: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 8

Mi=Ek(i)=(W-D) mod 26= (22-3) mod 26= 19 = T

Note: it is not same like shift or ceaser’s cipher.

One time pad(vermin Cipher):

It is also known an vermin cipher.

In cryptography, a one-time pad (OTP) is an encryption technique that cannot

be cracked if used correctly.

In this technique, a plaintext is paired with random, secret key (or pad). Then,

each bit or character of the plaintext is encrypted by combining it with the

corresponding bit or character from the pad using modular addition.

If the key is truly random, and at least as long as the plaintext, and never reused

in whole or in part, and kept completely secret, then the resulting ciphertextwill

be impossible to decrypt or break.

It has also been proven that any cipher with the perfect secrecy property must

use keys with effectively the same requirements as OTP keys.

However, practical problems have prevented one-time pads from being widely

used.

Plaintext : Hello

Random key: XMCKL

Encryption:

Step 1: write your plaintext and replace each alphabet by its according number(A=0,

B=1…….Z=25).

H E L L O

7 4 11 11 14

Page 9: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 9

Step 2: generate random key as size of the plaintext replace each alphabet by its according

number(A=0, B=1…….Z=25).

X M C K L

23 12 2 10 11

Step 3: add plaintext letter number to its respective key letter number.

Step 4: if it is greater than 26 then take module 26.

7 4 11 11 14

23 12 2 10 11

AFTER ADDITION OF ABOVE TWO ROW

30 16 13 21 25

30 16 13 21 25

% 26

4 16 13 21 25

Page 10: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 10

Step 5: replace each number by its according letter(A=0, B=1,…..Z=25)

Decryption:

Step 1: write ciphertext and replace each letter by its according number(A=0, B=1…….Z=25).

Step 2: use sender side generated random key and replace each letter by its according

number(A=0, B=1…….Z=25).

X M C K L

23 12 2 10 11

Step 3: subtract plaintext letter number from its respective key letter number.

4 16 13 21 25

E Q N V Z

E Q N V Z

4 16 13 21 25

4 16 13 21 25

23 12 2 10 11

AFTER ADDITION OF ABOVE TWO ROW

Page 11: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 11

Step 4: if it is less than 0 then add 26 to it.

Step 5: replace each number by its according letter(A=0, B=1,…..Z=25).

Hill Cipher Introduction:

The Hill Cipher was invented by Lester S. Hill in 1929, and like the other Digraphic

Ciphers it acts on groups of letters. Unlike the others though it is extendable to

work on different sized blocks of letters. So, technically it is a polygraphic

substitution cipher, as it can work on digraphs, trigraphs (3 letter blocks) or

theoretically any sized blocks.

The Hill Cipher uses an area of mathematics called Linear Algebra, and in

particular requires the user to have an elementary understanding of matrices. It

also make use of Modulo Arithmetic (like the Affine Cipher). Because of this, the

cipher has a significantly more mathematical nature than some of the others.

However, it is this nature that allows it to act (relatively) easily on larger blocks

of letters.

In the examples given, we shall walk through all the steps to use this cipher to

act on digraphs and trigraphs. It can be extended further, but this then requires a

-19 4 11 11 14

-19 4 11 11 14

ADD 26 IF LESS THAN 0

7 4 11 11 14

7 4 11 11 14

H E L L O

Page 12: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 12

much deeper knowledge of the background mathematics. Some important

concepts are used throughout: Matrix Multiplication; Modular Inverses;

Determinants of Matrices; Matrix Adjugates (for finding inverses).

Encryption: Plaintext: SELL Key: RUBY Encrypted Text(Cryptic Text): ikrs Step 1: write key in the form of matrix and replace each alphabet of key by its according number(A=0, B=1, ……Z=25). And that matrix is known as key matrix. For above example R=17, U=20, B=1, Y=24

Key matrix= R UB Y

After replacing…

Key matrix= 17 201 24

Step 2:if matrix is 2*2 then convert plaintext into pair(for above example SE LL)and replace each by its according number(A=0,B=1,……..Z=25).if 3*3 matrix then convert it into form of 3.

For SE= 184

LL= 1111

Step 3: multiply key matrix and plaintext pair.

Resultant Matrix= 17 201 24

184

= 17 ∗ 18 + 20 ∗ 418 ∗ 1 + 24 ∗ 4

Step 4: take modulo 26 of the resultant matrix.

Resultant matrix = 17 ∗ 18 + 20 ∗ 418 ∗ 1 + 24 ∗ 4

= 386114

% 26 = 2210

Step 5: replace each numbers by its corresponding alphabets(0=A,1=B,……25=Z)

Page 13: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 13

2210

= Vj

IK are encrypted text for SE. likewise after doing above procedure for LL, cryptic text for it is RS.

Difference between Symmetric Encryption and Asymmetric Encryption:

Sr No. Symmetric Encryption Asymmetric Encryption

1 Symmetric cryptography uses the same secret key to encrypt and decrypt its data

Asymmetric cryptography uses two different keys for encryption and decryption.

2 It uses only shared key to encrypt and decrypt data.

It uses two different keys public and private to encrypt and decrypt data.

3 It is faster than asymmetric encryption. It is slower than symmetric encryption.

4 It faces problem of key exchange. It does not face problem of key exchange.

5 The same algorithm with the same key is used for encryption and decryption.

One algorithm is used for encryption and decryption with a pair of keys, one for encryption and one for decryption.

6 The sender and receiver must share the algorithm and the key.

One algorithm is used for encryption and decryption with a pair of keys, one for encryption and one for decryption.

7 The key must be kept secret. The sender and receiver must each have one of the matched pair of keys (not the same one).

8 Example: AES-128, AES-192 and AES-256 DES

Example :RSA

STEGANOGRAPHY A plaintext message may be hidden in one of two ways. The methods of steganography conceal the existence of the message, whereas the methods of cryptography render the message unintelligible to outsiders by various transformations of the text.

A simple form of steganography, but one that is time-consuming to construct, is one in which an arrangement of words or letters within an apparently innocuous text spells out the real message. Various other techniques have been used historically; some examples are the Following:

Page 14: 3. Cryptography and Public key Infrastructure · o Transposition techniques (rail fence), o steganography . 3. Cryptography and Public key Infrastructure ... The two types of attack

3. Cryptography and Public key Infrastructure

Prepared By: Jigar patel & Chetan Kamani, RCTI ahmedabad.Page 14

Character marking: Selected letters of printed or typewritten text are overwritten in pencil.The marks are ordinarily not visible unless the paper is held at an angle to bright light.

Invisible ink: A number of substances can be used for writing but leave no visible trace until heat or some chemical is applied to the paper.

Pin punctures: Small pin punctures on selected letters are ordinarily not visible unless the paper is held up in front of a light.

Typewriter correction ribbon: Used between lines typed with a black ribbon,the results of typing with the correction tape are visible only under a strong light.

Steganography has a number of drawbacks when compared to encryption. It requires a lot of overhead to hide a relatively few bits of information, although using a scheme like that proposed in the preceding paragraph may make it more effective.Also, once the system is discovered, it becomes virtually worthless. The advantage of steganography is that it can be employed by parties who have something to lose should the fact of their secret communication (not necessarily the content) be discovered. Encryption flags traffic as important or secret or may identify the sender or receiver as someone with something to hide.