Lab 4 : Cryptography Extended

Cryptography is the study of secret (crypto-) writing (-graphy).

Cryptography deals with all aspects of secure messaging, authentication, digital signatures, electronic money, and other applications.

The practitioner of Cryptography is called Cryptographer.

There are two classes of key-based algorithms:
* Symmetric (or secret-key)
* Asymmetric (or public-key) algorithms

The difference is that symmetric algorithms use the same key for encryption and decryption (or the decryption key is easily derived from the encryption key),
whereas asymmetric algorithms use a different key for encryption and decryption, and the decryption key cannot be derived from the encryption key.


Methods use in Cryptography Algorithm
a)Substitution

There are two types:


* Monoalphabetic substitution : It formed by shifting the letters of the original alphabet.

* Polyalphabetic substitution : Extension of monoalphabetic substitution system which use Vigenere Tableau.

b)Transposition

Two types of transposition:

* Unkeyed transposition : Rearrange letters by using matrix

* Keyed transposition : Rearrange letters by using matrix where the size of matrix is determined by the length of the key used.


Caesar Cipher
Caesar used a shift of 3, so that plain-text letter pi was encoded as cipher-text letter ci by the rule:

ci = E(pi) = pi + 3

To encrypt this message: P = TREATY IMPOSSIBLE
we obtain: C = wuhdwb lpsrvvleoh

Characteristics of Caesar Cipher: It is simple, easy to remember in the Caesar era, but not secure enough nowadays.

Let's see some example :

Given the encrypted message

L FDPH L VDZ L FRQTXHUHG

There exist 26 possible keys. It is easily use exhaustive search

which tries all possible keys. The permutation is
A B C D E F G ……… Y Z
d e f g h i j ……… b c

so E(p) = (p + 3) mod 26 and the original plain-text message is

i came i saw i conquered


Vigenere Cipher

A set of mono-alphabetic substitution rules consists of 26 Caesar Cipher, with shifts of 0 to 25. Each Cipher is denoted by a key letter.

For example, a Caesar Cipher with shift 3 is denoted by the key letter d.

Key : d e c e p t i v e d e c e p t i v e d e c e p t i v e

Plaintext : we a r e d i s c o v e r e d s a ve y o u r s e l f

Ciphertext : ZI CV TWQNGR ZG VTWAVZHC Q YGLMGJ


The Vegenere Tableau is a polyalphabetic cipher which maps one letter to many other letters.

The Vegenere Tableau is a collection of 26 permutations, represented in a 26 * 26 matrix.

All 26 letters are shown in each row and each column.

To use the Vigenere Cipher, the plain text letter is located on the top horizontal index alphabet; the key letter is directly below noted and as the vertical index.


Encrypt and decrypt using RSA algorithm

Let's do some exercise :

Perform encryption and decryption using RSA algorithm for the following:

p = 7; q = 11, e = 17; M = 8



Encryption

Ciphertext (C) = Memod n

C = 8^17 mod (p * q)
C = 8^17 mod (7 * 11) = 8^17 mod (77)

C = [ (8^16 mod 77) * (8 ^ 1 mod 77) ] mod 77
C = [ (8^8 mod 77) * (8^8 mod 77) * (8 ^ 1 mod 77) ] mod 77
C = [(8^4 mod 77) * (8^4 mod 77) * (8^4 mod 77) * (8^4 mod 77) (8 ^ 1 mod 77) ] mod 77

C = [4096 mod 77 * 4096 mod 77 * 4096 mod 77 * 4096 mod 77 * 8] mod 77
C = [15 * 15 * 15 * 15 * 8] mod 77
C = [ 405000] mod 77
C = 57

Decryption

Plaintext (M) = Cdmod n

Need to calculate d
e and d are multiplicative inverses mod (n).

(n) = (p – 1) (q – 1)
(n).= (7 -1) (11 – 1) = 6 * 10 = 60

The multiplicative inverse of

e mod 60 = 17 mod 60 = -7
Therefore the positive multiplicative inverse of 17 mod 60 is = 53

So, lets calculate Cdmod n

57 ^ 53 mod (n) = 57 ^ 53 mod (p * q) = 57 ^ 53 mod (77)
[(57^32 mod 77) * (57 ^16 mod 77) * (57 ^4 mod 77) * (57 ^ 1 mod 77)] mod 77
[(57 ^ 16 mod 77) * (57 ^ 16 mod 77) * (57 ^ 16 mod 77) * (57 * 4 mod 77) * (57 ^ 1 mod 77)] mod 77

57 ^ 4 mod 77 = 71
57 ^ 8 mod 77 = [(57 ^ 4 mod 77) * (57 ^ 4 mod 77)] mod 77
57 ^ 16 mod 77 = [ (57 ^8 mod 77) * (57 ^ 8 mod 77)] mod 77

Therefore,

57 ^ 8 mod 77 = [71 * 71] mod 77 = 36

Therefore,

57 ^ 16 mod 77 = [ 36 * 36] mod 77 = 64

So, we have

[64 * 64 * 64 * 71 * 57] mod 77

[262144 * 4047] mod 77 = 8


Therefore a successful decryption gets the original plaintext 8

p/s : I hope everybody will get some knowledges from my page.More details, ask the expert..!!