Vernam Cipher in Cryptography

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Vernam Cipher in Cryptography

Dr. Debasis Das


Department of CSE
IIT Jodhpur,Rajasthan, India.

31-01-2020 Indian Institute of Technology(IIT) Jodhpur


Vernam Cipher in Cryptography
 Vernam Cipher is a method of encrypting alphabetic text. It is
simply a type of substitution cipher. In this mechanism we assign a
number to each character of the Plain-Text, like (a = 0, b = 1, c = 2,
… z = 25).
 Method to take key:
In Vernam cipher algorithm, we take a key to encrypt the plain text
which length should be equal to the length of the plain text.

Network Security 8-2


Encryption Algorithm:
 Step 1: Assign a number to each character of the plain-text and
the key according to alphabetical order.
 Step 2: Add both the number (Corresponding plain-text character
number and Key character number).
 Step 3: Subtract the number from 26 if the added number is
greater than 26, if it isn’t then leave it.

Network Security 8-3


Example:
 Plain-Text: RAMSWARUPK
 Key: RANCHOBABA
 Now according to our encryption algorithm we assign a number to each
character of our plain-text and key.
 PT: R A M S W A R U P K
 NO: 17 0 12 18 22 0 17 20 15 10

 KEY: R A N C H O B A B A
 NO: 17 0 13 2 7 14 1 0 1 0
8-4
Example:
 Now add the number of Plain-Text and Key and after doing the addition
and subtraction operation (if required), we will get the corresponding
Cipher-Text character number.
 CT-NO: 34 0 25 20 29 14 18 20 16 10
 In this case, there are two numbers which are greater than the 26 so we
have to subtract 26 from them and after applying the subtraction operation
the new Cipher text character numbers are as follow:
 CT-NO: 8 0 25 20 3 14 18 20 16 10
 New Cipher-Text is after getting the corresponding character from the
number.
 CIPHER-TEXT: I A Z U D O S U Q K
 For the Decryption apply the just reverse process of encryption. Network Security 8-5
6

One-Time Pad
 Fix the vulnerability of the Vigenere cipher by using very long keys

 Key is a random string that is at least as long as the plaintext


 Encryption is similar to shift cipher
 Invented by Vernam in the 1920s

CS555 8-6
7

One-Time Pad
Let Zm ={0,1,…,m-1} be
the alphabet.

Plaintext space = Ciphtertext space = Key space =


(Zm)n
The key is chosen uniformly randomly
Plaintext X = (x1 x2 … xn)
Key K = (k1 k2 … kn)
Ciphertext Y = (y1 y2 … yn)
ek(X) = (x1+k1 x2+k2 … xn+kn) mod m
dk(Y) = (y1-k1 y2-k2 … yn-kn) mod m
CS555 8-7
8

The Binary Version of One-Time Pad


Plaintext space = Ciphtertext space =
Keyspace = {0,1}n
Key is chosen randomly
For example:
 Plaintext is 11011011
 Key is 01101001
 Then ciphertext is 10110010

CS555 8-8
9

Bit Operators
 Bit AND
00=0 01=0 10=0 11=1

 Bit OR
00=0 01=1 10=1 11=1

 Addition mod 2 (also known as Bit XOR)


0  0 = 0 01=1 10=1 11=0

Can we use operators other than Bit XOR for binary version of One-Time Pad?

CS555 8-9
10

How Good is One-Time Pad?


 Intuitively, it is secure …
 The key is random, so the ciphertext is completely random
 How to formalize the confidentiality requirement?
 Want to say “certain thing” is not learnable by the adversary (who sees
the ciphertext). But what is the “certain thing”?
 Which (if any) of the following is the correct answer?
 The key.
 The plaintext.
 Any bit of the plaintext.
 Any information about the plaintext.
• E.g., the first bit is 1, the parity is 0, or that the plaintext
is not “aaaa”, and so on

CS555 8-10
11

Usage of One-Time Pad


 To use one-time pad, one must have keys as long as the messages.
 To send messages totaling certain size, sender and receiver must agree on a
shared secret key of that size.
 typically by sending the key over a secure channel
 This is difficult to do in practice.
 Can’t one use the channel for send the key to send the messages instead?
 Why is OTP still useful, even though difficult to use?

Spring 2012/Topic
CS555 3 8-11
12

Usage of One-Time Pad


 The channel for distributing keys may exist at a different time from
when one has messages to send.

 The channel for distributing keys may have the property that keys
can be leaked, but such leakage will be detected
 Such as in Quantum cryptography

8-12
Caesar Cipher in Cryptography

 The Caesar Cipher technique is one of the earliest and simplest method of
encryption technique.
 It’s simply a type of substitution cipher, i.e., each letter of a given text is
replaced by a letter some fixed number of positions down the alphabet.
 For example with a shift of 1, A would be replaced by B, B would become
C, and so on.
 The method is apparently named after Julius Caesar, who apparently used
it to communicate with his officials.
 Thus to cipher a given text we need an integer value, known as shift which
indicates the number of position each letter of the text has been moved
down. Network Security 8-13
Example
 The encryption can be represented using modular arithmetic by
first transforming the letters into numbers, according to the
scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a
shift n can be described mathematically as.

Network Security 8-14


Example

Network Security 8-15


Examples :
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW

Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI

Network Security 8-16


Algorithm for Caesar Cipher:
Input:

1.A String of lower case letters, called Text.


2.An Integer between 0-25 denoting the required shift.

Procedure:

•Traverse the given text one character at a time .


•For each character, transform the given character as per the rule, depending on whether we’re
encrypting or decrypting the text.
•Return the new string generated.
Program that receives a Text (string) and Shift value( integer) and returns the encrypted text.

Network Security 8-17


Network Security 8-18
Network Security 8-19
Network Security 8-20
Network Security 8-21
Network Security 8-22
Network Security 8-23
Network Security 8-24
Network Security 8-25
Network Security 8-26
Network Security 8-27
Network Security 8-28
Network Security 8-29
Network Security 8-30
Network Security 8-31
Network Security 8-32
Network Security 8-33
Network Security 8-34
Network Security 8-35
Network Security 8-36
Network Security 8-37
Mid Sem 1 Syllabus

Network Security 8-38

You might also like