7/31/2014

cryptography5

Cryptography 5



Classical Encryption Techniques:

2- Transposition Cipher:

Transposition Cipher is an encryption method which elements are rearranged.
There are many types of Transposition Cipher such as (Rail Fence, Columnar Transposition  and Double Transposition).

Rail Fence:

Rail Fence is the simplest form of Transposition Cipher which the plaintext is written down as a sequence of diagonals and read off as a sequence of rows.

For Example :

The plaintext = WELCOME TO CRYPTOGRAPHY
Then the encryption algorithm will be

W   L   O   E   O   R   P   O   R   P   Y
  E   C   M   T   C   Y   T   G   A   H

So, the ciphertext = WLOEORPORPYECMTCYTGAH

We can make the encryption algorithm 3 rows

W  C  E  C  P  G  P
 E  O  T  R  T  R  H
  L  M  O  Y  O  A  Y

So, the Ciphertext = WCECPGPEOTRTRHLMOYOAH

Columnar Transposition:

In Columnar Transposition the plaintext is written down in rows and the read off by the order of columns.
The order of columns is the secret key to Columnar Transposition algorithm, any spare spaces are filled with null or blank.

For Example :

The plaintext     = WELCOME TO CRYPTOGRAPHY
The secret key    = 615342

Then the encryption algorithm


Note : I filled the spaces here with "ABC".

Now we read columns by it's order (secret key)

The ciphertext    =  ETTHMYACCCGAORRBLOOYWEPP

previous types are easy to break because the ciphertext has the same letters frequency as the plaintext, and cryptanalysis can put the ciphertext in a matrix and playing with column positions.

Double Transposition:

Double Transposition is the same as Columnar Transposition but twice, this one is more secure.

For Example:

As the previous example
The plaintext     = WELCOME TO CRYPTOGRAPHY
The secret key    = 615342
Then the encryption algorithm (first round)




The ciphertext    =  ETTHMYACCCGAORRBLOOYWEPP

And again

The plaintext    =  ETTHMYACCCGAORRBLOOYWEPP
The secret key    = 615342
Then the encryption algorithm (Second round)


The ciphertext   =  TCRYYAOPHCBEMGLPTCRWEAOO

Note : The ciphertext here has also the same letters frequency but playing with column positions now is harder.

7/11/2014

cryptography4

Cryptography 4


Classical Encryption Techniques 2:

B- Polyalphabetic Cipher:

Polyalphabetic Cipher is an encryption method to improve the simple substitution cipher techniques by using a larger key space and making the frequency of letters analysis harder.
Polyalphabetic Cipher is a block cipher with the following properties
1- The key space consists of all order of K = (k1, k2, k3, ... ki) i= block length.
2- Encryption of plaintext P = (p1, p2, p3 ... pi).

Encryption algorithm
E(p+k) = (k1(p1).k2(p2).k3(p3). ,,,, ki(pi))

Let's drive an example of Polyalphabetic Cipher called Vigenère Cipher

Vigenère Cipher:

Vigenère Cipher is Polyalphabetic Cipher technique and it's uses 26 letters with shifting from 1 to 25 similar to Caesar Cipher but with a dynamic key which changes every time on i interval.
The encryption algorithm for Vigenère Cipher to produce a ciphertext C
Ci = (Pi+Ki)
The decryption algorithm for Vigenère Cipher to produce a plaintext P
Pi = (Ci-Ki)

Example :

Let key K= HAMZA and plaintext = WELCOME TO CRYPTOGRAPHY



key          =   HAMZAHAMZAHAMZAHAMZAH
Plaintext   =   WELCOMETOCRYPTOGRAPHY
ciphertext =   ZEUBOTEFNCYYBSONRMOHF

simply we do addition operation on each element or by using the next table


Ci = (Pi+Ki)

Note :  If we look at letter frequencies
o : 3
n : 2
e : 2
f : 2
y : 2
b : 2
s : 1
r : 1
t : 1
z : 1
u : 1
m : 1
h : 1
c : 1

We reduced the frequency of letters analysis.


Vernam Cipher :

Vernam Cipher works on binary data rather than letters, that give us a defense against frequency letters analysis because there is no statistical relationship between the plaintext and the ciphertext.

The encryption algorithm in Vernam Cipher can be expressed as

Ci = Pi ⊕ Ki


Ci = ith binary digit of ciphertext.
Pi = ith binary digit of plaintext.
 = exclusive-OR (XOR) operation.
Ki = ith binary digit of key.

The decryption algorithm in Vernam Cipher is3

Pi = Ci ⊕ Ki



This system works by constructing a loop that takes the plaintext and the generated key bit by bit and preform XOR operation on each bit and then generate a ciphertext and so on to the end of the plaintext.


Now we have an important concept called "Prefect Secrecy".

Prefect Secrecy:

For any encryption algorithm has a perfect secrecy when the ciphertext gives us nothing about the plaintext(such as One-Time pad).

One-Time Pad :

One-Time Pad is an encryption technique and it is UNBREAKABLE, by using a secret key as long as the plaintext, so the key will not repeated to fit the plaintext.
The key generator algorithm generates a key for each plaintext.
The secret key will be used to encrypt and decrypt for only one plaintext then the secret key will be destroyed.
The ciphertext has no statistical relationship to the plaintext , so this technique is UNBREAKABLE.

For Example :

Suppose we use Vernam Cipher but with One-Time Pad method, we we generate a secret key as long as the plaintext and only for this plaintext.
Let's try to encrypt "HELLO"

Plaintext  = HELLO
Secret key = XMCKL

by adding the values of each digit
Ciphertext = EQNVZ

If we try to crack the cipher without the secret key , and only one key can gives us the original plaintext we will get a lot of plaintexts , if we use exhaustive search we could translate this ciphertext into many plaintext, for example here we used the secret key = "XMCKL" , but if we use a secret key = "TQURI" on the same ciphertext = "EQNVZ" that gives us plaintext = "LATER" but ONLY ONE KEY IS THE RIGHT KEY.

Why One-Time Pad has a perfect secrecy?

Because of the randomness on keys and only one key use for one message(plaintext) and one ciphertext can be translated into many plaintext of same length , that makes the ciphertext gives us nothing about the plaintext.