You are on page 1of 9

LAB

4
Cryptography Extended

By the end of this section of the practical, you should be able


to:

• Explain What is Symmetric and Asymmetric Cryptography


• Implementing Caesar Cipher for Symmetric Cryptography.
• Implementing Vigeneré Cipher for Symmetric Cryptography.
• Implementing RSA algorithm for Asymmetric Cryptography

4.1 Introduction
4.1.1 What is Symmetric and Asymmetric Cryptography?

Cryptography algorithm used in cryptosystem can be


classified into two categories which is symmetric and asymmetric
encipherment. In symmetric encipherment, plaintext is encrypted
and decrypts using the same key whereas asymmetric
encipherment is using different keys to encrypt and decrypt a
plaintext.

Symmetric encipherment can be in form of substitution,


transposition or both. In substitution encryption method alphabet
(character) in the plaintext is always changed with another alphabet
(character). Each character can be either change with one
character (monoalphabetic) or multiple characters (polyalphabetic).
Caesar cipher is an example of monoalphabetic cipher and
Vigeneré cipher is an example of polyalphabetic.

Transposition encryption method does not substitute


character with another character but it changes the location of the
characters. The character in the first position might be placed on
the fifth position and the fifth position character might be placed in
another location in the plaintext. In other word, we can look this
encryption method as a process or reordering the character in the
plaintext. This method can be either keyless or key transposition;
the next topic will cover these methods in details.

Asymmetric encipherment involves two keys to encrypt and


decrypt. These algorithms allow the key to be publicized, hence
anyone can encrypt using the key, and the proper recipient who
knows the decryption key can decrypt the message. The encryption
key is called public key and the decryption key is called
secret/private key. RSA algorithm is use to produce the public and
private key.

4.2 Symmetric encipherment


4.2.1 Caesar Cipher

The Caesar Cipher is formed by shifting the letters of the


original alphabet. For example by replacing each letter of the
alphabet with the letter three places down the alphabet. It is
monoalphabetic as only one letter in plaintext is exchanged for one

plaintext alphabet 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

ciphertext key DEFGHIJKLMNOPQRSTUVWXYZABC


letter of ciphertext.

Figure 4.1: A caesar chiper with a key 3

For an example the plain text in figure 4.2 below can be


encrypted using key 3 to get the cipher text in figure 4.3

THE ATTACK TONIGHT START AT EIGHT, REGROUP AT STATION A

Figure 4.2: plain text

WKHDWWDFNWRQLJKWVWDUWDWHLJKWUHJURXSDWVWDWLRQD

Figure 4.3: cipher text


A brute-force cryptanalysis is easily performed: by simply
trying all the keys available.

The characteristics which enables the use of brute-force


cryptanalysis:

1. The encryption and decryption algorithms are known

2. There are only 26 keys to try.

3. The language of the plaintext is known and easily


recognizable. The pattern is obvious.

Task 1

Deciphering simple substitution cipher text.

Use a spreadsheet program to help you in


! encrypting your plaintext or decrypting your
ciphertext

1. By using key 9 encrypt the following phrase

• Information Technology Security

• The target is the building on the right of the zoo

• The Truck is heading toward the dock

2. The following cipher text which is intercepted by the Special


Forces during a routine surveillance on a terrorist headquarters.
It was known that the cipher text is an English text containing a
word ‘FALL’. Decrypt the cipher text.

RCTRZAVGGNJOCVORZXVIGZVMIOJNOVIYVBVDIVIYWZXJH
ZNOMJIBZM
4.2.2 Vigeneré Cipher

The cipher text encrypted using Caesar cipher method is


easily broken by using a brute force attack. An attacker can easily
try every combinations of character to break the code as the
number of possibility is just 26. In order to improve the deciphering
process we can used the vigeneré cipher method. The Vigenère
cipher is a method of encrypting alphabetic text by using a series of
different Caesar ciphers based on the letters of a keyword. It is a
simple form of polyalphabetic substitution.

You can refer to table 4.1 for making it easier to encrypt a


plaintext using this method.

Table 4.1: Polyalphabetic Substitution Cipher


A key is needed to encrypt a plaintext; a key can be a word
or a phrase. To have a strong cipher text it is advised to use
different key on each encryption. This will prevent from a brute
force attack on a second message if the first message has been
intercepted.

KEY T I M E T I M E T I M E T I

PLAINT
T H E T A R G E T I S A L I
EXT

CIPHER
M P Q X T Z S I M Q E E E Q
TEXT

Figure 4.4: Vigeneré cipher

Task 2

Encrypt and decrypt using vigeneré cipher

1. Encipher the message ‘CHAPTER 2 AUTHENTICATION AND BASIC


CRYPTOGRAPHY ‘using Vigenere cipher and the enciphering key
‘MONEY’.
2. Decipher the following two ciphertexts which was intercept by the MI6
Forces during a routine surveillance on a terrorist headquarters. It is
believe that the first cipher text can be decrypted into

First ciphertext intercept

M V V X I Q R P
W C Y B O C P H
F A I J V M K Z
G H W V X T F E
C H C Y H N R N
W M M C N N R G
G G S O G
The plaintext

THE WIND WILL BLOW TONIGHT WITH THE FORCE OF TWENTY


TOWARDS NEXT

The second ciphertext intercept

M V V J I Q R U
Z F J T R K T F
U F T K S A W X
U E V H U I Z Y
D L B Z W E G O
Z B T H K V M H
Q A O E T E V H
H O E R W G O R

As one of the cryptanalysis for MI6 you are assigned to decrypt the second cipher
text using the first ciphertext and its plaintext.

4.3 Asymmetric encipherment


4.3.1 RSA Algorithm

Asymmetric encryption or called public key cryptography is


a cryptographic approach, employed by many cryptographic
algorithms and cryptosystems. The difference it has compared to
symmetric encipherment is that the asymmetric encipherment used
difference key for encryption and decryption. Each encryption and
decryption process is using a unique pair of key called public and
private key.

The private key is kept secret, while the public key may be
widely distributed. Messages are encrypted with the recipient's
public key and can only be decrypted with the corresponding
private key. The keys are related mathematically, but the private
key cannot be feasibly derived from the public key. It main purpose
is to prove the authenticity of the message source due to it
uniqueness of the private and public key pair.

RSA algorithm is one of the algorithms used to produce the


private and public key. It was developed by Rivest, Shamir &
Adleman of MIT in 1977. It main values are:-
• Value of ‘p’ and ‘q’ which are a prime number (private,
chosen)

• Value of n which is calculated n=p*q (public, calculated)

• Value of e, with gcd (Ø(n),e) =1; 1<e<Ø(n) (public and


chosen)

• Value of d = e-1 (mod Ø(n)) (private, calculated)

Each user generates a public/private key pair by selecting


two large primes at random p, q and then compute their system
modulus

n=p*q

and

ø(n)=(p-1)(q-1)

the encryption key e is select at random but must satisfied


the rules

where 1<e<ø(n), gcd(e,ø(n))=1

Once the key e is selected solve following equation to find


decryption key d

e*d=1 mod ø(n) and 0≤d≤n

The final step is publishing their public encryption key:


PU={e,n} and keep secret the private decryption key: PR={d,n}

In order to encrypt a message M the sender must :

• obtains public key of recipient PU={e,n}

• computes: C = Me mod n, where 0≤M<n

• note that the message M must be smaller than the modulus


n

and for receiver to decrypt the ciphertext C the receiver


must :

• uses their private key PR={d,n}

• computes: M = Cd mod n
Task 3

Encrypt and decrypt using RSA algorithm

1. Solve the equivalent modulo numbers for:-

a. 15 mod 11

b. 7945 mod 8570

c. – 43 mod 53

2. Perform encryption and decryption using RSA algorithm for


the following:-

a. Given p=7;q=11;e=17;m=8

Review Question

1. What is the differences between monoalphabetic and


polyalphabetic encipherment?
2. Decrypt the following Caesar cipher text

JRFGNEGGURNGGNPXNGRVTUGCZGBAVTUGORTVOLN
GGNPXVATGURZNVACBFGBHEBOWRPGVIRVFGBGNYQ
RFGEHPGVBABSGURRARZLONFRQFCNERABBARNAQN
ALGUVATQRFGEBLRIRELGUVATBALBHECNGU

What is plaintext and the key used to encrypt this message?


3. Decrypt the following Vigeneré cipher text

LIOMWGFEGGDVWGHHCQUCRHRWAGWIOWQLKGZETK
KMEVLWPCZVGTHVTSGXQOVGCSVETQLTJSUMVWVEUV
LXEWSLGFZMVVWLGYHCUSWXOHKVGSHEEVFLCFDGV
SUMPHKIRZDMPHHBVWVWJWIXGFWLTSHGJOUEEHHVU
CFVGOWICQLTJSUXGLW
By using Google search kasiski test to help you in solving
this problem
4. Solve the equivalent modulo numbers for:-

a. 999 mod 3

b. 2487(234) mod 234

c. 55 mod 57

d. 7-1 mod 53

e. 7-2 mod 53

5. Perform encryption and decryption using RSA algorithm for


the following:-

a. Given p=3;q=11,e=7;m=5

b. Given p=7,q=11,e=5,m=8

6. In a public key-stream using RSA, you intercept the cipher


text c=1- sent to whose public key is e=5, n=35. What is the
plaintext m?

You might also like