Cryptography
Cryptography
ripe, he must be put to death, together with the man to whom the
secret was told.
-The Art of War
From R.H.Rathod
To CO-6-I
CRYPTOGRAPHY
Cryptography is the art of achieving security by encoding messages
to make them non-readable non understandable
Ex. Hi Amit
Hope you are doing fine. How about the
conference this Monday at 11.00 am ?
Regards
Anita
Cipher Text
When a plain text message is codified using any suitable scheme, the resulting
message is called as cipher text.
Hi Amit
Plain Text Hope you are doing fine. How about the
Message conference this Monday at 11.00 am ?
Regards
Anita
Kl Dplw
Krsh brx duh griqj ilqj. Krz derxw ekh
Cipher Text frqihuhqfh wklv Prqgdb dw 11.00 dp?
Message
Uhjdugv
Dqlwd
CRYPTANALYSIS
Cryptanalysis is refers to the study of ciphers, ciphertext, or cryptosystems with
a view to finding weaknesses in them that will permit retrieval of the plaintext
from the cipher text, without necessarily knowing the key or the algorithm.
It is like breaking a code
CRYPTOLOGY
Cryptology is a combination of cryptography and cryptanalysis.
Encryption – It transforms (encodes) a plain text message into cipher text.
Decryption – It transforms (decodes) a cipher text message back into plain text
Sender Receiver
Hello Hello
Plain Text Cipher Text
Encrypt Decrypt
Internet
lfmmp lfmmp
Techniques for transforming plain text to cipher text
Substitution Transposition
Techniques Techniques
1. Caesar Cipher
2. Modified Caesar Cipher
3. Mono-alphabetic Cipher
4. Polyalphabetic Substitution Cipher
5. Homophonic Substitution Cipher
6. PolyGram Substitution Cipher
1.Caesar Cipher
Proposed by Julius Caesar. Each alphabet in a message is replaced by an
alphabet three places down the line
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
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
● ● ●
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
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
2. Modified Caesar Cipher
The Cipher Text alphabets may not be three places down the order, but can
be any places down the order, and would be constant
Attempt Number
1 L X V N Q N A N
2 M Y W O R O B O
3 N Z X P S P C P
4 O A Y Q T Q D Q
5 P B Z R U R E R
6 Q C A S V S F S
7 R D B T W T G T
8 S E C U X U H U
9 T F D V Y V I V
10 U G E W Z W J W
11 V H F X A X K X
12 W I G Y B Y L Y
13 X J H Z C Z M Z
14 Y K I A D A N A
15 Z L J B E B O B
16 A M K C F C P C
17 B N L D G D Q D
18 C O M E H E R E
19 D P N F I F S F
20 E Q O G J G T G
21 F R P H K H U H
22 G S Q I L I V I
23 H T R J M J W J
24 I U S K N K X K
25 J V T L O L Y L
3. Mono-alphabetic Cipher
Looking plain text in column and key in row, get Cipher Text
Plain
C O M P U T E R S E C U R I T Y
Text
Key S P I C E S P I C E S P I C E S
Cipher
U D U R Y L T Z U I U J Z K X Q
text
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
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 A
C 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
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
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 D
F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I J K L M N O P Q R S T U V W X Y ZZ A B C D E F G H
J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
S T U
U V W X Y Z A B C D E F G H I J K L M N O P Q R
T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U V
PlainW X Y Z A B C D E F G H I J K L M N O P Q R S T
V W X Y
C Z
OA M
B C
PD U
E F
T G
EH R
I J
SK E
L M
C N
UO R
P Q
IR T
S T
Y U
Text
W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X Y
Key Z A S B PC D I E CF E
G H S I PJ K I L CM E
N O S P PQ R I S CT E
U V SW
Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z 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
5. Homophonic Substitution Cipher
• One plain text alphabet can map to more than one cipher text alphabet
• Cipher text alphabet can be any one of the chosen set
• For eg. A can be replaced by D,H,P,R ; B can be replaced by E,I,Q,S etc.
This technique do not simply replace one alphabet with another; they also
perform some permutation over the plain text alphabet
They performs reordering
Algorithm
• Write down plain text message as a sequence of diagonals
• Read the plain text written in step1 as a sequence of rows
• The message obtained is the cipher text message
Example
Original Plain Text : Come home tomorrow
1. Write the first character on first line i.e. C, second character on second line
i.e. o, then the third character on the first line i.e. m and so on
C m h m t m r o
o e o e o o r w
2. Now read the text row-by-row and write it sequentially. Thus we have as
the cipher text :
Cmhmtmrooeoeoorw
2. Simple Columnar Transposition Technique :
It simply arranges the plain text as a sequence of rows of a rectangle that
are read in columns randomly
Algorithm
• Write the plain text message row-by-row in a rectangle of a predefined
size
• Read the message column-by-column. It need not be in the order of
columns 1, 2, 3 etc. It can be any random order such as 2, 3, 1 etc.
• The message obtained is the cipher text message
Ex. Original Plain Text : Come home tomorrow
1. Let us consider a rectangle with six columns.
Column1 Column2 Column3 Column4 Column5 Column6
C o m e h o
m e t o m o
r r o w
eowooCmroerhmmto
Perform more than one rounds of transposition
Algorithm
• Write the plain text message row-by-row in a rectangle of a predefined
size
• Read the message column-by-column. It need not be in the order of
columns 1, 2, 3 etc. It can be any random order such as 2, 3, 1 etc.
• The message obtained is the cipher text message of round 1
• Repeat steps 1 to 3 as many times as desired
Original Plain Text : Come home tomorrow
The cipher text eowoocmroerhmmto
Let us perform steps 1 through 3 once more.
Column1 Column2 Column3 Column4 Column5 Column6
e o w o o c
m r o e r h
m m t o
Now, let us use the same order of columns as before i.e. 4, 6,
1, 2, 5 and 3. Then read the text in the order of these
columns.
The cipher text obtained would be as, - in round2
oeochemmormorwot
Continue like this if more number of iterations is desired,
otherwise stop
3. Vernam Transposition Technique :
4. If the sum thus produced is greater than 26, subtract 26 from it.
5. Translate each number of the sum back to the corresponding alphabet. This
gives the output cipher text.
Plain Text : HOW ARE YOU ; One-time pad : NCBTZQARX
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
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
1.Plain Text H O W A R E Y O U
7 14 22 0 17 4 24 14 20
2.One-time N C B T Z Q A R X
pad 13 2 1 19 25 16 0 17 23
3.Initial total 20 16 23 19 42 20 24 31 43
4. Subtract 20 16 23 19 16 20 24 5 17
26, if >25
5. Cipher U Q X T Q U Y F R
Text
4. Book Cipher Transposition Technique :
• Simple and similar in principle to the Vernam Cipher.
• For producing Cipher text, some portion of text from a book is used, serves
the purpose of one-time pad.
• They are added to the input plain text message similar to the way a one-time
pad works.
Cryptography techniques
In this scheme only one key is used and the same key is used both for
encryption and decryption of messages
Two different keys are used, one key is used for encryption & another,
different key is used for decryption
Person A wants to send a highly confidential letter to another person B.
Symmetric Key Cryptography
A and B both reside in the same city, but are separated by a few miles
and for some reason, cannot meet each other.
How would you tackle this problem?
A puts the letter in an envelop, seals it and sends it by post
Letter
Envelop
Postal n/w
and
Relaxed distribution
system
Letter Envelop
Another option is to send the envelop via hand-delivery mechanism
A now puts the envelop inside a box, seals it with a highly secure lock and send it
to B
Letter
Envelop
2. At the Senders end the key transforms the plain text message into a
cipher text form. At the Receivers end the same key is used to decrypt
the encrypted message.
4. Both the parties must agree upon the key before any transmission
begins and nobody else should know about it.
Symmetric Key Cryptography
Sender Receiver
A B
At the Senders end the key transforms the plain text message into a cipher text form. At
the Receivers end the same key is used to decrypt the encrypted message.
Use of separate lock and keys per communication pair
Lock Lock
A B A C
When A wants to communicate with B & C, we need two lock-n-key pairs ( A-B & A-
C)
Thus, we need one lock-n-key pair per person with whom A wants to communicate
No of parties & corresponding no of lock-n-key pairs required
For n persons, the no of lock-n-key pairs is n * (n-1) / 2
Parties involved Number of lock-n-key pairs required
2 (A, B) 1 (A-B)
3 (A, B, C) 3 (A-B, A-C, B-C)
4 (A, B, C, D) 6 (A-B, A-C, A-D, B-C, B-D, C-D)
5 (A, B, C, D, E)10 (A-B, A-C, A-D, A-E, B-C, B-D, B-E,
C-D, C-E, D-E)
If the no of parties is 2, we need 2 * (2-1)/2 = 1 lock-n-key pair
If the no of parties is 3, we need 3 * (3-1)/2 = 3 lock-n-key pair
If the no of parties is 4, we need 4 * (4-1)/2 = 6 lock-n-key pair
If the no of parties is 5, we need 5 * (5-1)/2 = 10 lock-n-key pair
Features of Secret Key
This algorithm can be used only for key agreement, not for
encryption or decryption.
Once both the parties agree on the key to be used, they need to
use other symmetric key encryption algorithms for actual
encryption or decryption of messages.
1. Ankit and Boby agree on two large prime numbers, n and g.
2. Ankit chooses another large random number x & calculate A as
A=gx mod n.
3. Ankit sends the number A to Boby.
4. Boby independently chooses another large random integer y &
calculates B as B=gy mod n.
5. Boby sends the number B to Ankit.
6. Ankit now computes the secret key K1 as K1=Bx mod n
7. Boby now computes the secret key K2 as K2=Ay mod n
K1 is equal to K2
Diffe-Helman key Exchange / Agreement Algorithm Example
Let n = 11, g=7
Let x = 3, we have A= 73 mod 11 = 343 mod 11 = 2 A=2
K1 = 43 mod 11 = 64 mod 11 = 9
K2 = 26 mod 11 = 64 mod 11 = 9
K1 = K2 = K
Symmetric Key Encryption
Data Encryption Standard
Data Encryption Standard (DES)
DES is block cipher.
It encrypts data in blocks of size 64 bits each.
It uses a 56-bit key.
Every eighth bit of the key is discarded to produce a 56-bit key.
Bit positions 8, 16, 24, 32, 40, 48, 56 and 64 are discarded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Data Encryption Standard (DES)
DES is block cipher.
It encrypts data in blocks of size 64 bits each.
It uses a 56-bit key.
Every eighth bit of the key is discarded to produce a 56-bit key.
Bit positions 8, 16, 24, 32, 40, 48, 56 and 64 are discarded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
16
17 18 19 20 21 22 23
24 25 26 27 28 29 30 31
32
33 34 35 36 37 38 39
40 41 42 43 44 45 46 47
48
49 50 51 52 53 54 55
56 57 58 59 60 61 62 63
64
Conceptual working of DES
64-bit 64-bit 64-bit
Plain Plain Plain
Original 64-bit key
Text Text Text
…..
DES KeyDES
discarding DES
56-bit 56-bit 56-bit
key
process key
key
64-bit 64-bit 64-bit
Cipher Resulting
Cipher56-bit key Cipher
Text Text Text
Block 1 Block 2 Block 3
1. In the first step, the 64-bit plain text
block is handed over to an Initial Plain Text (64 bits)
Permutation function (IP).
2. The Initial Permutation (IP) is
performed on plain text. Initial Permutation
3. The IP produces two halves of the
permuted block Left Plain Text (LPT) LPT RPT
and Right Plain Text (RPT).
Key Key
4. Each of LPT & RPT go through 16 16 rounds 16 rounds
rounds of encryption process.
5. LPT & RPT rejoined to get Final
Permutation (FP) is performed on the Final Permutation
combined block
6. The result of this process produces 64- Cipher Text (64 bits)
bit cipher text
( Content Beyond Syllabus )
Each of the 16 rounds consists of broad level steps as …
S-box Substitution
32
Permutation (P)
32
XOR
LPT RPT C D
Dr.Panjabrao Deshmukh Polytechnic,
Shivaji Nagar, Amravati
(Maharashtra Govt-Aided Institute)
By
Rajendra H. Rathod
Lecturer, Comp. Engg. Dept.
Don't
compare
yourself with
any one in
this world.
If you compare,
you are
insulting
Asymmetric Cryptography
• Not other key can decrypt the message – not even the original
(first) key used for encryption.
• Every communicating party needs just a key pair for
communicating with any number of other communicating
parties Each party publishes its public key.
Sender A Receiver B
Customer
B Bank’s Bank’s BANK
public key private key
Customer
C Bank’s
public key
Another scheme
If A is the sender of a message and B is the receiver. A encrypts the
message with A’s private key and sends the encrypted message to B.
Plain
Sender (A) Text
Receiver (B)
Encrypt with A’s
private key
Cipher
A sends this encrypted
Text
message to B
Combining both practices to have a very efficient security solution
A’s computer encrypt the original plain text message with the help of
standard cryptographic algorithm, producing cipher text
Plain
Text
Sender (A)
Symmetric Key Cipher Text
Encryption
Algorithm
Symmetric key
A now takes one time symmetric key and encrypts it with B’s public key,
called “key wrapping”
Symmetric key
Sender (A)
Symmetric Key
Encryption Algorithm
Cipher Text
Sender (A)
Digital Envelop
Symmetric key
encrypted with
B’s public key
• B receives and opens the digital envelop. After B opens envelop, it
receives two things: cipher text and one time session key encrypted using
B’s public key
• B now uses the same symmetric key algorithm and its private key to
decrypt the logical box that contains the symmetric key encrypted using
B’s public key
• Finally B applies the same symmetric key algorithm and symmetric key
to decrypt the cipher text. This process yields the original plain text.
Plain
Sender (A)
Text Receiver (B)
Encrypt with A’s
private key
Plain
Plain Cipher Cipher
Text
Network Text
Text
Text
Decrypt with
Encrypt with
A’s public key
A’s private key
Digital Signature
A Digital Signature is a data item that vouches the origin and the
integrity of a Message
The recipient uses a verification key (Public Key) to verify the origin
of the message and that it has not been tampered with while in
transit
• Digital signature can be used in all electronic
communications
–Web, e-mail, e-commerce
User B received
Verify the signature the document with
by A’s public key stored signature attached
at the directory
User B
Digital Signature Generation and Verification
Message Sender Message Receiver
Message Message
Private
Key Encryption
Decryption
Signature
Expected Digest Digest
Message Digest or Hash
Message Digest is a fingerprint or the summery of message
Message Digest: Some requirement
Given a message digest, it should be very
easy to find its corresponding message 1Original
0 1 0 1data
01 Message Original data
block-1 Original
Digest
block-2
0101010
digest …
data
Message digest
Given a message digest, it should be very Message
Must not be algorithm
Reverse
Message
difficult to find the original message for possible Digest
Algorithm Digest
which the digest was created Algorithm
Message Message
digest 1 digest 2
Given a message digest, if we calculate 0101 These two
Message
their message digest, the two message 1 0 1 1 Original
message data
digest
Digest
… must be different
digest must be different
Dr.Panjabrao Deshmukh Polytechnic,
Shivaji Nagar, Amravati
(Maharashtra Govt-Aided Institute)
Date :
There is still a problem linked to the
“Real Identity” of the Signer
Why should I trust what the Sender
claims to be?
Public/Private Keys
User
Services,
Banks,
Webserver
4 key services
Authentication – Digital Certificate
To identify a user who claim who he/she is, in order to access the resource.
Confidentiality - Encryption
To make the transaction secure, no one else is able to read/retrieve the
ongoing transaction unless the communicating parties.
Integrity - Encryption
To ensure the information has not been tampered during transmission.
X509 PKI
Basic Components:
• Certificate Authority (CA)
• Certificate Distribution
System
The most common use of a digital certificate is to verify that a user sending
a message is who he or she claims to be
CERTIFICATE
Issuer
Subject
Issuer
Digital
Signature
Structure of Digital Certificate
X.509V3
Version
Certificate
Identifies Serial Number
a particular version of the X.509 protocol
Signature Algorithm Identifier
Version 1
Version 3
Version 2
Contains a unique integer number, which is generated by the CA
Issuer Name
Contains the subject’s public key and algorithms related to that key. This
Identifies theBefore
Validity (Not algorithm used by the CA to sign this
/ Not After)
Helps identify a CA
Subject
field never be
uniquely
Name if blank.
two or more CA’s have
Helps identify
Identifies
adate
Subject
the uniquely certificate
Distinguish if two
Nameor more
of thethe
subjects
CAtimeframe
thathave
created
used the same
Contains two – time
Subjectused values,
theKey
Public same which specify
Issuer Name over time
Information within which
the and
Subject
certificate signed
shouldName
this
be certificate
over time as valid.
considered
Issuer Unique
Identifies the Distinguish nameIdentifier
of the end entity to whom certificate refers.
Subject Unique Identifier
Extensions
Certification Authority’s Digital Signature All Versions
Certificate Authority (CA)
A CA is a trusted agency that can issue digital certificates
Basic Tasks:
• Key Generation
• Digital Certificate Generation
• Certificate Issuance and Distribution
• Revocation
• Key Backup and Recovery System
• Cross-Certification
Registration Authority (RA)
The RA is the intermediate entity between the end users and the CA, which
assists the CA in its day-to-day activities.
Basic Tasks:
Registration Certification
End User Authority Authority
End User
Certificate Creation Steps
Key generation
Registration
Verification
Certificate creation
Step 1: Key generation
The action begins with the subject who wants to obtain a certificate. There are
two approaches . . . .
a. The subject can create a private key and public key pair using some
software.
b. The RA can generate a key pair on the subject’s behalf.
Key
generation
This step is requires only if the user generates the key pair in the first step.
User sends the public key and the associated registration information and
all the evidence to the RA
For this, the software provides a wizard in which the user enters data,
submits it. This data travels over the internet.
The format for the certificate requests has been standardized and is called
Certificate Signing Request (CSR)
Step 3: Verification
After the registration process is complete, the RA has to verify the user’s
credentials. This is in two respects:
b. The second check is to ensure that the user who is requesting for the
certificate does indeed posses the private key corresponding to the public
key that is sent as a part of the certificate request to the RA. This check is
called Proof of Possession – of the private key.
1. The RA can demand that the user must digitally sign CSR using
private key.
The CA sends the certificate to the user and also retains a copy of
the certificate for its own record.
How does the CA sign a digital Certificate
Version A message digest (hash) of all but the
Certificate Serial Number
last fields of the digital certificate
Signature Algorithm Identifier
Issuer Name
Validity (Not Before / Not After) Message
Subject Name Digest
Subject Public Key Information Algorithm
Issuer Unique Identifier
Subject Unique Identifier
Extensions
Certification Authority’s Digital Signature
Message
Digest MD1
Message
CA’s public Signature
key Algorithm
Step
5
Message
Digest MD2
Verification of Digital Certificate
The verification of digital certificate consists of following steps
1. The user passes all fields except the last one of the received digital certificate to a
message digest algorithm
2. The message digest algorithm calculates a message digest (hash) of all fields of the
certificate, except the last one.
3. The user now extract the digital signature of the CA from the certificate.
4. The user de-signs the CA’s signature i.e. decrypts the signature with CA’s public key