CRYPTO Mod1@AzDOCUMENTS - in
CRYPTO Mod1@AzDOCUMENTS - in
CRYPTO Mod1@AzDOCUMENTS - in
com
MODULE 1
Classical Encryption Techniques: Symmetric cipher model, Substitution
techniques, and Transposition techniques (Text 1: Chapter 1)
Text Books:
Explore Electronics 1
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
MODULE 1
Symmetric cipher model
Symmetric encryption also referred to as conventional encryption or single-key
encryption.
Plaintext: This is the original intelligible message or data that is fed into the
algorithm as input.
● 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.
Explore Electronics 2
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Explore Electronics 3
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Cryptography
transpositions.
If both sender and receiver use the same key, the system is
referred to as symmetric, single-key, secret-key, or conventional
encryption.
Explore Electronics 4
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Explore Electronics 5
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
The key is also a group of bits which as a major role in the process of
encryption and decryption.
Types of Cryptography
1. Symmetric Key Cryptography (Secret Key Cryptography)
2. Asymmetric Key Cryptography (Public Key Cryptography)
3. Hash Function
1. Symmetric Key Cryptography: Symmetric key cryptography is called
secret key cryptography or shared key or private key cryptography and it uses a
same key or single-key for both of encryption & decryption method. The
Symmetric key system is the DEC (data encryption standard).Symmetric key
cryptography systems are simpler and faster.
2. Asymmetric Key Cryptography (Public Key Cryptography): where a
different
keys used for encryption and decryption. The different keys are a private key &
a public key.
3. Hash functions: uses a mathematical transformation to irreversibility
“encrypt” information. It is a one-way encryption. Uses no key for encryption
and decryption.
Advantages
Enter (key) length will be generally short.
Symmetric key cipher can be joined together to prepare stronger ciphers.
It hides those secret or confidential messages and your protection or
privacy may be sheltered or protected or safe.
Application
On line banking.
On line transaction.
Media data base system.
Medical application.
Explore Electronics 6
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
4. Cryptanalysis
Substitution Techniques
The two basic building blocks of all encryption techniques are
substitution and transposition. A substitution technique is one in which the
letters of plaintext are replaced by other letters or by numbers or symbols. If the
Explore Electronics 7
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Caesar Cipher
The Caesar cipher involves replacing each letter of the alphabet with the
letter standing three places further down the alphabet. For example,
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
Then the algorithm can be expressed as follows. For each plaintext letter p,
substitute the cipher text letter C:
C = E(3, p) = (p + 3) mod 26
C = E(k, p) = (p + k) mod 26
Explore Electronics 8
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Monoalphabetic Ciphers
Instead of shifting alphabets by the fixed amount as in Caesar cipher, any
random permutation is assigned to the alphabets. This type of encryption
called Monoalphabetic substitution cipher.
For example, a replaced by Q, B by D, C by T etc. then it will be
comparatively stronger than Caesar.
Playfair cipher
In this technique, multiple (2) letters encrypted at a time.
This technique uses a 5 X 5 matrix which also called the key matrix.
Key used is “MONARCHY”
Explore Electronics 9
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
HILL CIPHER
Another interesting multiletter cipher is the Hill cipher, developed by the
mathematician Lester Hill in 1929. The encryption algorithm takes m
successive plaintext letters and substitutes for them m ciphertext letters. The
substitution is determined by m linear equations in which each character is
assigned a numerical value (a = 0, b = 1 ... z = 25).
Explore Electronics 10
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
or
C = KP mod 26
where C and P are column vectors of length 3, representing the plaintext and
ciphertext, and K is a 3 x 3 matrix, representing the encryption key. Operations
are performed mod 26.
Table 1
A B C D E F G H I
0 1 2 3 4 5 6 7 8
J K L M N O P Q R
9 10 11 12 13 14 15 16 17
S T U V W X Y Z
18 19 20 21 22 23 24 25
S
We have to encrypt the message (plaintext) ‘ACT’ (n=3).
The key is ‘GYBNQKURP’ which can be written as the nxn matrix with the
6 24 1
help of above table as : k 13 16 10
20 17 15
Explore Electronics 11
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
0
With reference to above table the message ‘ACT’ is written as vector P 2
19
C = PK mod 26
0 6 24 1
C= 2 * 13 16 10 mod 26
19 20 17 15
67
C= 222 mod 26
319
To find mode 26 divide the number by 26 & remainder will be the answer
Eg: 67 mod 26 = 15
222 mod 26 = 14
319 mod 26 = 7
A P
So ciphertext is POH P C C O
T H
For decryption
6 24 1 P
k 13 16 10 C O
1
P= K ̄ C mod 26
20 17 15 H
Explore Electronics 12
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
=420+120-99
= 441
Step 2: find multiplicative inverse of determinant k using trial & error method
|K| ̄ 1 = 25
|K| ̄ 1 = 25
The cofactor matrix consists of cofactors of the matrix A, which are calculated
according to the formula Cij=(−1)i+jMijCij=(−1)i+jMij, where Mij is the
determinant of the submatrix formed by deleting the i-th row and the j-th
column from the matrix A.
Explore Electronics 13
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
=14*26+21 -343=21
=4*26+ 5 -99=5
-47=5
-216=18
Explore Electronics 14
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
70 21 224
Now 𝐴𝑑𝑗𝑜𝑖𝑛𝑡 𝐾 = 5 70 5
5 378 18
NOTE: To find mode 26 divide the number by 26 & remainder will be the
answer
8 5 10
K̄ 1
= 21 8 21
21 12 8
P= K ̄ 1 C mod 26
8 5 10 15
P= 21 8 21 * 14 mod 26
21 12 8 7
260 0 A
= 574 mod 26 = 2 C Plain text is ACT
539 19 T
POLYALPHABETIC CIPHERS
Another way to improve on the simple Monoalphabetic technique is to use
different Monoalphabetic substitutions as one proceeds through the plaintext
message. The best known, and one of the simplest, such algorithm is referred to
as the Vigenere cipher.The general name for this approach is polyalphabetic
substitution cipher. All these techniques have the following features in
common:
STEP 1: Find the first letter C (of CAD) in the plaintext row (as highlighted in
yellow) & A (of ADD) in key coloumn (highlighted in blue) ciphertext is C
STEP 2 : Find the second letter A (of CAD) in the plaintext row & D (of
ADD) in key coloumn ciphertext is D
STEP 1: Find the first letter D (of CAD) in the plaintext row & D (of ADD) in
key coloumn ciphertext is G
Now cipher text is CDG
Decryption: k= ADD & C=CDG
Explore Electronics 16
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
PLAIN TEXT
A B C D E F G H I J K L MN O P Q R S T U V WX Y Z
K A A B C D E F G H I J K L MN O P Q R S T U V WX Y Z
E B B C D E F G H I J K L MN O P Q R S T U V WX Y Z A
Y C C D E F G H I J K L MN O P Q R S T U V WX Y Z A B
D D E F G H I J K L MN O P Q R S T U V WX Y Z A B C
E E F G H I J K L MN O P Q R S T U V WX Y Z A B C D
F F G H I J K L MN O P Q R S T U V WX Y Z A B C D E
G G H I J K L MN O P Q R S T U V WX Y Z A B C D E F
H H I J K L MN O P Q R S T U V WX Y Z A B C D E F G
I I J K L MN O P Q R S T U V WX Y Z A B C D E F G H
J J K L MN O P Q R S T U V WX Y Z A B C D E F G H I
STEP 1: Find the first letter A (of ADD) in the key row (as highlighted in
yellow) & find C in that & check for ciphertext in respective coloumn that is C
STEP 2 : Find the second letter D (of ADD) in the key row (as highlighted in
blue) & find D in that & check for ciphertext in respective coloumn that is A
STEP 3 : Find thethird letter D (of ADD) in the key row (as highlighted in
orange) & find G in that & check for ciphertext in respective coloumn that is D
Decrypted plain text is CAD
One-Time Pad
The ultimate defense against such a cryptanalysis is to choose a keyword
that is as long as the plaintext and has no statistical relationship to it. Such a
system was introduced by an AT&T engineer named Gilbert Vernam in 1918.
His system works on binary data (bits) rather than letters.
Explore Electronics 17
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
The cipher text is generated by performing the bitwise XOR of the plaintext and
the key. Because of the properties of the XOR, decryption simply involves the
same bitwise operation.
The system can be expressed succinctly as follows
TRANSPOSITION TECHNIQUES
1) Rail-Fence Technique
Transposition Techniques are based on the permutation of the plain-text
instead of substitution. A very different kind of mapping is achieved by
performing some sort of permutation on the plaintext letters. This technique is
Explore Electronics 18
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
referred to as a transposition cipher. The simplest such cipher is the rail fence
technique, in which the plaintext is written down as a sequence of diagonals and
then read off as a sequence of rows.
For example, to encipher the message "meet me after the toga party" with a rail
fence of depth 2, we write the following:
m e m a t r h t g p r y
e t e f e t e o a a t
Now we apply the above algorithm and create the rectangle of 4 columns
(we decide to make a rectangle with four column it can be any number.)
Now let’s decide on an order for the column as 4, 1, 3 and 2 and now we will
read the text in column-wise.
Explore Electronics 19
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Cipher-text: LHIEEIUESSCEPWMNDLAO
EUCLIDEAN ALGORITHM
Answer is 5
MODULAR ARITHMETIC
Explore Electronics 21
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Equation 4-1
where is the largest integer less than or equal to Figure demonstrates that,
given a and positive n, it is always possible to find q and r that satisfy the
preceding relationship. Represent the integers on the number line; a will fall
somewhere on that line (positive a is shown, a similar demonstration can be
made for negative a). Starting at 0, proceed to n, 2n, up to qn such that qn q+
1)n > a. The distance from qn to a is r, and we have found the unique values
of q and r. The remainder r is often referred to as a residue.
.
f a is an integer and n is a positive integer, we define a mod n to be the
remainder when a is divided by n. The integer n is called the modulus. Thus, for
any integer a, we can always write:
a = n x a mod n)
Explore Electronics 22
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Note:
Example:
n=q*m+r
1) find 51 mod 10
solution: 51= q*10+r
Explore Electronics 23
CRYPTOGRAPHY https://deepaharivinod.blogspot.com
Example:
n=q*m+r
Explore Electronics 24