COMM1003 Information Theory

Dr. Wassim Alexan Spring 2018

Lecture 4 Cryptology

◆ Cryptology is the most general term and it splits into two parts: and

◆ Cryptography is the science of secret writing with the goal of hiding the meaning of a message

◆ Cryptanalysis is the science (and sometimes art) of breaking

Fig. 1. An overview of the field of Cryptology. (Paar and Pelzl, Cryptography-A Textbook for Students and Practitioners)

Wassim Alexan 2 Cryptology

◆ A naive thinking would be that only intelligence agencies or organized crime would be involved in cryptanalysis, however most cryptanalysis is done by researchers in academia nowadays

◆ Cryptanalysis is of paramount importance for modern cryptosystems: Without people who try to break our crypto methods, we will never know whether they are really secure or not

◆ Symmetric are what many people assume cryptography is about: Two parties have an and decryption method for which they share a secret

◆ All cryptography from ancient times until 1976 was exclusively based on symmetric methods

◆ Symmetric ciphers are still in widespread use, especially for data encryption and integrity check of messages

Wassim Alexan 3 Cryptology

◆ Asymmetric (or Public–Key) ciphers are an entirely different type of ciphers was introduced in 1976 by Whitfield Diffie, Martin Hellman and Ralph Merkle

◆ In public–key cryptography, a user possess a secret key as in symmetric cryptography but also a public key

◆ Asymmetric algorithms can be used for applications such as digital signatures and key establishment, and also for classical data encryption

◆ Cryptographic Protocols are protocols that deal with the application of cryptographic algorithms

◆ Symmetric and Asymmetric algorithms can be viewed as building blocks with which applications such as secure Internet communication can be realized

◆ The Transport Layer Security (TLS) scheme, which is used in every Web browser, is an example of a

Wassim Alexan 4 Cryptology

◆ A third class of ciphers is called Hash Functions, nevertheless this class shares some properties with symmetric functions

◆ In practice, the majority of cryptographic applications involve the use of symmetric, asymmetric as well as hash functions. Such cryptosystems are referred to as hybrids schemes

Wassim Alexan 5 Symmetric Cryptography

◆ Symmetric cryptography is usually divided into three subclasses: ◆ Classical ciphers ◆ Mechanical ciphers ◆ Modern ciphers

◆ Furthermore, classical ciphers can be classified into a number of smaller subclasses: substitution and transposition ciphers

◆ For mechanical ciphers we will consider the

◆ For modern ciphers we will consider the Data Encryption Standard (DES) and its variants, as well as the Advanced Encryption Standard (AES)

Wassim Alexan 6 Symmetric Cryptography

◆ Assume we have two users, Alice and Bob, communicating over an insecure channel

◆ The problem is that Oscar is eavesdropping on their communication

◆ In this situation, symmetric cryptography offers a powerful solution

Fig. 2. Communication over an insecure channel. (Paar and Pelzl, Cryptography-A Textbook for Students and Practitioners)

Wassim Alexan 7 Symmetric Cryptography

◆ Alice encrypts her message x using a symmetric algorithm, yielding the y

◆ Bob receives the ciphertext and decrypts the message

Fig. 3. Symmetric–key (Paar and Pelzl, Cryptography-A Textbook for Students and Practitioners)

Wassim Alexan 8 Symmetric Cryptography

◆ The advantage is that if we have a strong encryption algorithm, the ciphertext will look like random bits to Oscar and will contain no information whatsoever that is useful to him

◆ x is called the , y is called the ciphertext, k is called the key and finally, the set of all possible keys is called the key space

◆ This cryptosystem needs a for the distribution of the key between Alice and Bob

◆ This could be done by a human messenger, which is then of course a cumbersome method

◆ An example where this method works nicely is the pre–shared keys used in WiFi Protected Access (WPA) encryption in wireless LANs

Wassim Alexan 9 Substitution Ciphers

◆ These are probably the most common forms of classical ciphers

◆ They are implemented by replacing each letter of the plaintext (and sometimes punctuation marks and spaces) with another letter (or even a random symbol)

◆ A mono–alphabetic substitution relies on a fixed replacement structure. Such that every letter is only replaced with another letter, throughout the message

◆ Examples: ◆ The ◆ The Cipher ◆ The ◆ The ◆ The Baconian Cipher ◆ The

Wassim Alexan 10 Substitution Ciphers

◆ A poly–alphabetic does not rely on a fixed replacement structure. Thus allows for each letter in the to take on different substitutions

◆ Examples: ◆ The Hill Cipher ◆ The Homophonic Cipher

Wassim Alexan 11 The General Case

◆ Consider the following substitution key, as in Fig. 4

◆ Using this substitution, we can encode the plaintext:

the c building is the best building in the guc.

abcdefghijklmnopqrst u v w x y z BVGQKMNADZCWSEOYFJXH TLPUIR

Fig. 4. An example of a simple substitution cipher key.

◆ The ciphertext would be

HAK G VTDWQDEN DX HAK VKXH VTDWQDEN DE HAK NTG.

◆ Removing the spaces, we get

HAKGVTDWQDENDXHAKVKXH VTDWQDENDEHAKNTG.

Wassim Alexan 12 The Caesar Cipher

◆ In the Caesar cipher there is no key

◆ We simply shift each letter by 3 places

Fig. 5. An illustration of the 3–place shifting in the Caesar cipher.

abcdefghijklmnopqrst u v w x y z defghijklmnopqrstuvw x y z a b c

Fig. 6. The full Caesar cipher substitution table.

Wassim Alexan 13 Exercise 1

You received the following ciphertext which was encoded with the Caesar cipher

WREHRUQRWWREHWKDWLVWKHTXHVWLRQ.

Can you perform an attack on it, revealing the message?

Wassim Alexan 14 Exercise 1 Solutions

Being told that a Caesar cipher generated the given ciphertext, it is very easy to get back the plaintext as

tobeornottobethatisthequestion.

Adding spaces where appropriate, the plaintext is

to be or not to be that is the question.

Wassim Alexan 15 The Atbash Cipher

◆ A mono–alphabetic cipher originally used for the

ת ש ר ק צ פ עסנמלכיטחחזוהדגב א א ב ג ד ה ו זחחטיכלמנסעפצקרש ת

Fig. 7. The original Atbash cipher substitution table.

◆ It is one of the earliest known substitution ciphers to have been used

◆ It is very simple to implement: The first letter is exchanged with the last letter; the second letter is exchanged with the next–to–last letter; ...

abcdefghijklmnopqrst u v w x y z ZYXWVUTSRQPONMLKJIHG FEDCBA

Fig. 8. The version of the Atbash cipher substitution table.

Wassim Alexan 16 Exercise 2

You received the following ciphertext which was encoded with the Atbash cipher

RHYFITVIPRMTGSVYVHGYFITVIIVHGZFIZMGRMXZRIL?

Can you perform an attack on it, revealing the message?

Wassim Alexan 17 Exercise 2 Solutions

Being told that an Atbash cipher generated the given ciphertext, it is very easy to get back the plaintext as

isburgerkingthebestburgerrestaurantincairo?

Adding spaces where appropriate, the plaintext is

is burger king the best burger restaurant in cairo?

Wassim Alexan 18 The Pigpen Cipher

◆ This cipher is also often referred to as the Freemasons Cipher

◆ Letters are not replaced by letters, but rather by symbols, as in Fig. 9

◆ This cipher can be made much harder to break, by using it with a key

◆ Multiple variants could be introduced to this cipher, for example, by using (grid X grid X), instead of the shown arrangement in Fig. 9 (grid grid X X)

Fig. 9. An illustration of the Pigpen cipher.

Wassim Alexan 19 Exercise 3

You read the following ciphertext on one of the walls of the B building. Do you think it is just a nice graffiti or a secret message?

Can you perform an attack on it, revealing the message?

Wassim Alexan 20 Exercise 3 Solutions

A quick look at the ciphertext reveals right away that it is an encoded message using the Freemasons/Pigpen cipher. It is very easy to get back the plaintext as

wheredidiparkmycar

Adding spaces where appropriate, the plaintext is

where did i park my car

Wassim Alexan 21 The Affine Cipher

◆ A mono–alphabetic cipher where the encryption process is based on a mathematical formula

E(x) = (a x + b) modm (1) where the integer parameters a and b are the key for this cipher and m is the length of the alphabet

◆ For each letter in the plaintext, we multiply it by a and add the result to b, then we divide it by m and only take the remainder

◆ This remainder value is the reference to the letter in the ciphertext

Wassim Alexan 22 The Affine Cipher: An Example

◆ Consider the following plaintext that we are interested in applying the Affine cipher onto

affine cipher

◆ Let a = 5 andb = 8 and thus

E(x) = (a x + b) modm (2)

◆ The first step is to write up a table matching the letters in the English language with their corresponding reference values, starting with 0

abcdefghijk l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Fig. 10. The Latin alphabet and the reference values corresponding to every plaintext letter. where the integer parameters a = 5 and b = 8 are the key for this cipher

Wassim Alexan 23 The Affine Cipher: An Example

◆ The second step is to carry out the calculation as in (2), thus assigning a substitute for each of the plaintext letters

Plaintext 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

Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

5x+8 mod 26 8 13 18 23 2 7 12 17 22 1 6 11 16 21 0 5 10 15 20 25 4 9 14 19 24 3

Ciphertext I N S X C H M RWBGLQVAF KPUZEJOT YD

Fig. 11. The substitution table for the Affine cipher with a= 5 andb= 8.

◆ Thus, the ciphertext, after removing the space, would be

IHHWVCSWFRCP

◆ Note that we could have started the reference values for the plaintext letters with 1 instead of 0. But choosing to start with 0 allows for easier calculations

Wassim Alexan 24 The Keyword Cipher

◆ A mono–alphabetic cipher where a keyword is used as the key, such that the key determines the letter matchings of the cipher alphabet to the plain alphabet

◆ Repeats of letters in the word are removed, then the cipher alphabet is generated with the keyword matching to A,B,C, etc ... until the keyword is used up

◆ Then, the rest of the ciphertext letters are used in , excluding those already used in the key

◆ For example, using the word as the key, the following substitution table is obtained

abcdefghijklmnopqrst u v w x y z KRYPTOSABCDEFGHIJLMN QUVWXZ

Fig. 12. The Keyword cipher substitution table, with the key KRYPTOS.

Wassim Alexan 25 Exercise 4

Using the Keyword cipher with the key CODING, encrypt the following plaintext

the midterm exam is going to be easy

Wassim Alexan 26 Exercise 4 Solutions

We start off by writing down the proper substitution table

abcdefghijklmnopqrst u v w x y z CODINGABEFHJKLMPQRST UVWXYZ

Fig. 13. The Keyword cipher substitution table, with the key CODING.

Carrying out the substitution, we get the following ciphertext

TBN KEITNRK NXCK ES AMELA TM ON NCSY

Removing the spaces, we get

TBNKEITNRKNXCKESAMELATMONNCSY

Wassim Alexan 27