Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Cryptoanalysis of Vigenère cipher

Information Security

Fall 2011

Lab #1

Implementing cryptanalysis of Vigenère cipher

Objective

Implement a program, which breaks Vigenère cipher.

Input data: a text file in ANSI or ASCII encoding, containing a text encrypted by Vigenère cipher of length at least 1000 characters.

Output data: the decrypted meaningful English plaintext and the key.

Deliveries

· Print your source code and test cases

· Demonstrate your working version and describe your implementation

Background

Vigenère cipher

Let us assume that the key consists of m letters, K=(K0, K1,.., Km-1).

Encryption: for each plaintext letter Pi substitute: Ci = Pi+ Ki mod m mod 26, where i=0,1,2,...

Decryption: for each cipher text letter Ci (i=0,1,2,...), substitute: Pi = Ci- Ki mod m mod 26, where i=0,1,2,...

Example:

P:wearediscoveredsaveyourself

K:deceptivedeceptivedeceptive

C:zicvtwqngrzgvtwavzhcqyglmgj

Cryptoanalysis of Vigenère cipher

Consists of two steps:

· Find the key length m

· Find the key K=(K0, K1,.., Km-1)

Identical strings occur in a ciphertext when the same letters of the plaintext are encrypted by the same letters of the key, thus the length of the key is always a divisor of the greatest common divisor of the distances between identical strings in the ciphertext. Therefore, to find out the length of the key:

1. Search the ciphertext for pairs of identical sequences of length at least three letters;

2. Store the distances between the starting positions of the found sequences;

3. Find the greatest common divisor of the distances, m should either be equal to it or be its divisor.

Be aware that some identical sequences can be just the result of coincidence.

After you found the length of the key m, split the ciphertext into m blocks, as follows:

B0=C0,Cm,C2m,C3m,..

B1=C1,Cm+1,C2m+1,C3m+1,..

...

Bm-1=Cm-1,C2m-1,C3m-1,C4m-1,..

Compute the frequency (i.e. number of occurrences) of each letter in block B0. Compare these frequencies to known frequencies of letters in English language (Fig. 1) and deduce the first letter of the key (K0). Then, compute the frequency of each letter in block B1 and find the second letter of the key K1. Repeat this operation for blocks B2.. Bm-1 to find the rest of the key.

After obtaining the key, decrypt the ciphertext.

The easy way to check if the decrypted text is indeed an English plaintext is to compute a so-called index of coincidence Ic, which indicates the probability that any two letters of the string are identical:

where fi is a frequency of i th letter of the alphabet, and N is the total number of letters in the text.

English plaintext (and English plaintext, encrypted by monoalphabetic cipher) would have Ic closer to 0,065.

Useful links

1. Information about cryptoanalysis of Vigenère cipher with examples can be found here: http://www.nku.edu/~christensen/section%2012%20vigenere%20cryptanalysis.pdf

2. Vigenère cipher tool: http://www.sindark.com/NonBlog/CR/CR.html

PS Get rid of all non-letter characters (whitespace, punctuation, numbers etc.) and convert all letters to either upper or lower case before applying any analysis.

Try to figure out how you can use the index of coincidence to check if the length of the key is correct.

 


Дата добавления: 2015-11-14; просмотров: 28 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Почему Компания так много платит промоутерам?| The Internet can be divided into five broad areas

mybiblioteka.su - 2015-2024 год. (0.005 сек.)