COMM1003 Information Theory Dr. Wassim Alexan Spring 2018 Lecture 4
Cryptology Cryptology is the most general term and it splits into two parts: Cryptography and Cryptanalysis 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 cryptosystems 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 ciphers are what many people assume cryptography is about: Two parties have an encryption and decryption method for which they share a secret key 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, 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 cryptographic protocol 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 Enigma machine 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 ciphertext y Bob receives the ciphertext and decrypts the message Oscar receives the ciphertext and is unable to decrypt the message Fig. 3. Symmetric key cryptosystem (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 plaintext, 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 secure channel 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 cipher relies on a fixed replacement structure. Such that every letter is only replaced with another letter, throughout the message Examples of mono alphabetic substitution ciphers: The Caesar Cipher The Atbash Cipher The Pigpen Cipher The Affine Cipher The Baconian Cipher Wassim Alexan 10
Substitution Ciphers A poly alphabetic substitution cipher does not rely on a fixed replacement structure. Thus allows for each letter in the alphabet to take on different substitutions Examples of poly alphabetic substitution ciphers: 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 The ciphertext would be 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 B V G Q K M N A D Z C W S E O Y F J X H T L P U I R Fig. 4. An example of a simple substitution cipher key. 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. 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 d e f g h i j k l m n o p q r s t u v w 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 Hebrew alphabet א ב ג ד ה ו ז ח ח ט י כ ל מ נ ס ע פ צ ק ר ש ת ת ש ר ק צ פ ע ס נ מ ל כ י ט ח ח ז ו ה ד ג ב א 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;... 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 Z Y X W V U T S R Q P O N M L K J I H G F E D C B A Fig. 8. The Latin alphabet 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) mod m (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 Let a = 5 and b = 8 and thus affine cipher E(x) = (a x + b) mod m (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 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 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 R W B G L Q V A F K P U Z E J O T Y D Fig. 11. The substitution table for the Affine cipher with a = 5 and b = 8. Thus, the ciphertext, after removing the spaces, 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 alphabetical order, excluding those already used in the key For example, using the word KRYPTOS as the key, the following substitution table is obtained 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 K R Y P T O S A B C D E F G H I J L M N Q U V W X Z 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 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 C O D I N G A B E F H J K L M P Q R S T U V W X Y Z Fig. 13. The Keyword cipher substitution table, with the key CODING. Carrying out the substitution, we get the following ciphertext Removing the spaces, we get TBN KEITNRK NXCK ES AMELA TM ON NCSY TBNKEITNRKNXCKESAMELATMONNCSY Wassim Alexan 27