ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
Sommaire Objectives ............................................................................................................................................ 2 0.
Introduction ................................................................................................................................. 2
1.
What Is Cryptography? ................................................................................................................ 2
2.
Classical vs. Modern Ciphers ....................................................................................................... 3
a.
Simple Substitution Cipher .......................................................................................................... 3 Caesar .............................................................................................................................................. 3 Atbash .............................................................................................................................................. 4
Cryptogram .......................................................................................................................................... 4 Pigpen .................................................................................................................................................. 4 b. Polyalphabetic Cipher .................................................................................................................. 5 Tabula Recta ........................................................................................................................................ 5 Vigenère .............................................................................................................................................. 5 Autokey ............................................................................................................................................... 6 Enigma ................................................................................................................................................. 6 c.
Polygraphic Ciphers ..................................................................................................................... 7
Polybius Square ................................................................................................................................... 7 Tap Code .............................................................................................................................................. 7 Playfair ................................................................................................................................................. 8 Transposition Ciphers .......................................................................................................................... 8 Book Cipher ......................................................................................................................................... 9 3.
Cryptanalysis ............................................................................................................................... 9
Experiment .......................................................................................................................................... 9 Guess the Cipher and the Key ............................................................................................................. 9 Guess the Plaintext ............................................................................................................................ 10 Look for Fragments of Plaintext ........................................................................................................ 10 Look for Words and Sentences.......................................................................................................... 10 Perform a Frequency Analysis ........................................................................................................... 10 Look for Pairs of Letters .................................................................................................................... 11 Look for Groups of Numbers ............................................................................................................. 11 4.
Exercise 7: Embassy Sweets ...................................................................................................... 11
1 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
Objectives ‐ ‐ ‐ ‐
Create a common ebook called DA V.I.N.C.I Codes Use the collaborative tool bookemon Write and share a message using different methods of encryption Create groups of two students to work on a method of encryption
0. Introduction For as long as there has been communication, there has been a need to share information privately. Ciphers have been used by government officials, military officers, spies, ambassadors, revolutionaries, business owners, religious leaders, and more. This lesson will not teach you enough to become a codebreaker for the NSA. But it will hopefully give you a head start in turning a bunch of nonsense into a set of coordinates. By itself, it won't teach you everything there is to know about every cipher, but it will hopefully get you thinking about ciphers the right way and will give you pointers to resources to use in solving crypto puzzles. 1. What Is Cryptography? The word cryptography is derived from Greek words meaning hidden and writing – it is the study of message secrecy. Encryption is the conversion of ordinary information (plaintext) into unintelligible gibberish (ciphertext). Decryption is the reverse, moving from ciphertext to plaintext. A cipher is a pair of methods for encryption and decryption.
The detailed operation of a cipher is controlled by both the cipher method and by a key. A key is a secret parameter to the cipher, known only to the sender and the intended receiver of an encrypted message.
2 HOUPERT N.
ACTIVITYY 17_CRYPTO OGRAPHY 26 février 201 15
The method of solvving a puzzle that invollves cryptoggraphy is co onceptually very simple e: figure d figure out the key. Th he process o of figuring o out those tw wo pieces off out the cipher, and informaation and reevealing thee message iss called cryp ptanalysis. 2. Classical vs. Moderrn Cipherrs A classiccal cipher iss one that o operates on an alphabe et of letters and is typiccally performed by hand (w with paper aand pencil) o or with simple mechan nical devices (such as aa scytale). M Modern ciphers operate on n bits and byytes and req quire speciaalized comp puter hardw ware and software. The oveerwhelming majority off ciphers yo ou’ll find in p puzzle caches are classsical ones. (Interessting Historiical Tangentt: Encryptio on software may also b be considereed a munitio on, as dangero ous as weap pons and military vehiccles. Until 1996, encryp ption softwaare could not be exporteed to other ccountries siince U.S. Go overnment Internation nal Traffic in n Arms Regu ulations (ITAR) p prohibited the export o of anything stronger than 40‐bit encryption. U Unfortunate ely, 40‐ bit encrryption isn'tt strong eno ough to prottect information over tthe internet ‐ the fact tthat the regulatiions were changed justt as the inteernet was entering a raapid growth h phase is no o coincideence.)
a Simple a. e Substitu ution Ciph her A substiitution ciph her is very siimple – replace every lletter of thee alphabet w with some o other letter or symbol. Th he key to th his cipher iss the mapping of one seet of letterss to anotherr. Caesar
The Caeesar cipher is named affter Julius C Caesar, who made use o of it to com mmunicate ssecurely with hiss trusted lieutenants. Caesar u used this cipher with aan offset (keey value) of 3. To encryptt a letter in a message, he would ffind the 3rd letter in n the alphab bet after thee one he waanted to encryptt. A would b become D, B B would beccome E, and d so on (and if he went beyond Z, h he’d start o over again att A). A cipher wheeel is a disc consisting of an inner and outer w A wheel w with the alp habet written around tthe edge off both whee els. By tu urning one of the wheels by the o offset value,, For this reason, th he Caesar ccipher is ofte en called “R ROT” (shortt for “rotate e”), and “ROT” is ofteen followed d by the offsset amount. So Caesar's cipher w would be ca lled "ROT3"". The cipheer wheel sho own below im mplements ROT7 (goin ng from insid de out) or R ROT19 (goin ng from o outside in).
3 HOUPERT N.
ACTIVITYY 17_CRYPTO OGRAPHY 26 février 201 15
The hintt in a cachee description n page is en ncrypted using a Caesar cipher witth an offset of 13 (aka, RO OT13). This value is con nvenient beecause the e encryption aand decrypttion methods are exactly the same –– A encryptss to N, and N N encrypts tto A. Atbash
The Atb bash cipher substitutess each letterr of the alph habet with tthe letter att the oppossite end of the alphabeet. For instan nce, A goess to Z, B goees to Y, C go oes to X, etcc. The namee “Atbash” ccomes from m its origins iin the Hebrew languagge, where th he letter ale eph goes to tav, betth goes to sh hin, etc. Thee method ccan be used in any languagge that has aan ordered alphabet.
Crypto ogram You’ve p probably seeen cryptograms in newspaapers, near tthe comics and the crosswo ord puzzle. A A cryptograam is a puzzzle consisting of a short quotation n encrypted d using a simple subsstitution cip pher. The mapping from plain ntext to cip phertext lettters is rando om – there iis no ordering to the cipherteext letters, like there iss in the Caesar and Atb bash cipherss. The puzzle is to figurre out the mapping an nd reveal th he quotation.
Pigpen n One of tthe more faamous substitution ciphers that doesn’t use an alp phabet is th he Pigpen ciipher (also ccalled the M Masonic or her is the arrangement of letters in n a grid like so: Freemason’s cipheer). The key to this ciph To encrypt a messaage, each leetter is replaaced with itts symbol in the grid. For examp ple:
4 HOUPERT N.
ACTIVITYY 17_CRYPTO OGRAPHY 26 février 201 15
b Polyalphabetic Cipher b. The fundamental p problem witth all simplee substitutio on ciphers is that they can be attaacked uency analyysis. This is jjust a fancy way of saying using a cryptanalyssis method called frequ or symbol ap ppears in th he ciphertexxt”. The lettter that “count tthe numberr of times each letter o appearss the most is probably E, followed closely by TT, A, O, I, an nd N. Compleex substitution ciphers were developed to foil attempts tto break thee code via n the ciphertext to frequen ncy analysis. The goal o of these methods is to ttry to get all symbols in appear with roughly the samee frequency. d to a A polyalphabetic ciipher is onee in which a single ciphertext letteer does not correspond single plaintext lettter. The lettter A at onee point in th he ciphertexxt may deco ode to a com mpletely differen nt letter thaan an A at a different point.
Tabula a Recta If the cipher wheell is one of th he primary tools used iin substitution ciphers, then the tabula recta is one of the primary too ols used in p polyalphabe etic cipherss. A tabula rrecta looks llike this:
Vigenè ère The Vigeenère cipheer is one of the most co ommon one es which uses a tabula recta. The cipher requiress the sendeer and receivver to agreee upon a wo ord to use aas they ciph her key. For examplee, suppose the plaintexxt to be enccrypted is: ATTACK KATDAWN
5 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
The sender chooses a keyword and repeats it until it matches the length of the plaintext. For example, the keyword “LEMON” would give the full encryption key: LEMONLEMONLE Use the plaintext letters as the row and the key letters as the column. Then replace each letter in the plaintext with the corresponding cell from the tabula recta. For the first letter in this example, the letter at row A column L is L. Next, the letter at row T column E is X. After that, the letter at row T column M is F. The complete ciphertext is then: LXFOPVEFRNHR
Autokey Ironically, Vigenère did not invent the cipher that bears his name ‐ it was actually invented by Giovan Batista Belaso in 1553. The cipher that Vigenère invented in 1586 is called the autokey cipher. Due to an erroneous attribution of credit in the 19th century, Vigenère's name is unfortunately associated forever with a much weaker cipher than the one he invented. The autokey cipher is sometimes called the "Vigenère autokey" cipher to distinguish it from the "Vigenère" cipher. The autokey cipher is similar to the Vigenère cipher, but with a different method of constructing the key that makes the encryption method much stronger. Instead of repeating the key word over and over again, the key starts with the keyword followed by the plaintext message itself. So the key in the above example would be: LEMONATTACKA
Enigma Enigma is one of the most sophisticated polyalphabetic ciphers ever created. It was developed by the German military and used heavily during World War II. The tale of how the Enigma cipher was broken is a fascinating story to read. An enigma machine consists of a set of 3 or more interchangeable rotors, rings of letters that can be placed onto the rotors in any of 26 positions, a plugboard that can be used to transpose one letter into another, a keyboard for entering plaintext letters, and a lampboard for reading ciphertext letters. The value of the key to a message encrypted with Enigma would be the specific rotors used, the number of rotors, the position of
6 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
each ring of letters on the rotor, the starting position of each rotor, the connections on the plugboard, and a chosen key word. Pressing a letter on the keyboard would turn the rotors and cause a light on the lampboard to turn on, indicating the encrypted or decrypted letter.
c. Polygraphic Ciphers A polygraphic cipher is one that uses groups of letters instead of single letters as the basic units of encryption. For instance, AA could be replaced with QJ, AB with RU, etc. With single letters in a simple substitution cipher, there are only 26 possibilities for how each letter is encrypted, but with two‐letter groups in a polygraphic cipher there are 676 possibilities. This makes such ciphers much more difficult to crack.
Polybius Square Some common polygraphic ciphers make use of an arrangement of letters known as a Polybius square. The basic square lists the letters in order from left‐to‐right and top‐to‐ bottom (I and J are treated as the same letter), like this:
Tap Code The tap code, which uses a Polybius square, has been used by prisoners to communicate by tapping on pipes or walls. To encode a letter, a prisoner would tap a number of times equal to the letter row, pausing, then a number of times equal to the letter column, then pausing again. So the word "THE" would be "tap tap tap tap (pause) tap tap tap tap (pause) tap tap (pause) tap tap tap (pause) tap (pause) tap tap tap tap tap".
7 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
Playfair Playfair is a cipher that regularly appears in puzzle caches, cryptic crosswords, and a variety of other contexts. The Playfair cipher was not invented by Lord Playfair, but by his friend Charles Wheatstone. While a standard Polybius square has the letters in left‐to‐right, top‐to‐bottom order, the Playfair grid begins with a key word (with duplicate letters removed), then followed by all remaining letters in the alphabet in order. The letter J is not used, and the letter J in the plaintext is replaced with the letter I before encryption. For example, the Playfair square using the word "CIPHER" as the key would look like this:
See the Wikipedia page on Playfair for details of how to use the cipher.
Transposition Ciphers A transposition cipher changes the position of letters in the plaintext to form the ciphertext. For instance, suppose the plaintext is: EIGHTFOURSEVEN One way to encrypt it is to write the plaintext evenly divided across three lines, like so (padding it with random letters at the end to make the lines even): EIGHT FOURS EVENX Now read the letters down each column to create the ciphertext: EFEIOVGUEHRNTSX
8 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015 Other patterns include spirals, alternating left‐to‐right and right‐to‐left rows, and more. Any pattern can work as long as the sender and receiver agree.
Book Cipher A book cipher uses some lengthy text as an encryption key. Common texts include dictionaries, religious books (such as the Bible), government documents (such as the Declaration of Independence), and more. A book cipher encrypts each letter in the plaintext by referencing the same letter at some position in the key document. To encrypt a plaintext letter, replace it with a set of numbers that can be used to locate the letter in the document. A triplet of numbers could indicate the page number, line number, and word number in the line. 3. Cryptanalysis The ultimate goal of cryptanalysis is to reveal the hidden message. This means determining both the cipher and the key.
Experiment Don’t be afraid to try anything. Most of your experiments will not yield the plaintext message, so don’t be discouraged just because one attempt didn’t work.
Guess the Cipher and the Key The cache itself may have hints as to what the cipher and key are. In fact, it may tell you explicitly one or both of those things. If not, it might strongly suggest through hints as to what they might be. Look for Pigpen, Morse code, and semaphore symbols – they’re easy to identify and tell you right away what the cipher and key are.
9 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
Guess the Plaintext Remember the advice from the first lesson in this series: Begin with the end in mind. You ultimately want a set of coordinates, so look for ways in which that could be expressed. If you see two rows of letters, the first row might be the latitude and the second row the longitude. Try replacing the first or last letters of a row with “NORTH” or “WEST”. Look for “NORTH TWENTY SIX”, “NORTH TWO SIX”, or “TWENTY SIX DEGREES” in the first row … if the message was encrypted using a simple substitution cipher, that may give you enough information to unlock much of the rest of the key.
Look for Fragments of Plaintext It is rare for cryptanalysis methods to yield the entire key and plaintext message all at once. Cryptanalysis usually involves piecing together fragments of the plaintext message slowly. Look for words or pieces of words to appear as you experiment. And try to find words or phrases you expect to appear, based upon what you think the message contains. Short segments of plaintext that are known (or suspected) to appear in the ciphertext are called cribs.
Look for Words and Sentences If the letters in the ciphertext appear look like badly spelled words, they probably are. A ciphertext with spaces, punctuation, and capitalization are all indicators that the message has been encrypted using a simple substitution cipher. Look for common words, such as single letter words like “A” and “I”, or three‐letter words like “THE” and “AND”. Try replacing the letters in your ciphertext with those letters and see if any other words start to appear. One way to add security to an encrypted message is to remove the spaces and punctuation and to capitalize all of the letters.
Perform a Frequency Analysis Count the number of times each letter appears in the ciphertext. The most common letters in the English language are (in order of decreasing frequency): E T A O I N S H R D L U Replace the most common ciphertext letter with E, the next most common ciphertext letter with T, the next with A, and so forth. If that doesn’t work, try shuffling the T, A, O, I, and N letters around until the cleartext starts to make things that look like real words. (Those letters should look familiar to you – they’re probably the ones you guess first when playing Hangman. And if they’re not, they should be.)
10 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
Look for Pairs of Letters If the ciphertext consists of pairs of letters, that’s a strong sign it might be encrypted with Playfair. Also, if none of the pairs of letters contains a duplicate letter (such as “EE” or “QQ”), that’s another sign it might be using Playfair, since that cipher never generates a pair of duplicate letters. If the ciphertext is not grouped into pairs, try grouping it into pairs to see if there are any duplicate letter pairs or not.
Look for Groups of Numbers If your ciphertext is made up of pairs or triplets of numbers, it is possibly a book cipher, especially if the ciphertext is related to a reference document in some way. Look for clues in the puzzle as to what the reference document might be.
4. Exercise 7: Embassy Sweets I'm still trying to figure out what went wrong. Her name is Ingeborg, the daughter of the ambassador from Norwegia. As a duchess, she's 37th in line for ascension to the throne. We met innocently enough, both wandering the racks at Borders. I'll never forget the first time I spotted her ... her long flowing flaxen hair, narrow face, pale skin, and infectious smile. It was love at first sight for both of us. Our most recent date was heavenly ... the wine (Mocha Java Zinfandel), the food (northern Italian), the dessert (ice cream sundaes with hand‐mixed fixins) ... we talked, we ate, we laughed. After dinner we poked our noses into the shops, as she was searching for a new coat to wear when she returned home for the winter. We even lazily fantasized about buying a house together some day as we walked on the beach hand in hand. But that was weeks ago. I haven't heard from her since ... my phone calls are never answered, my email and voice mail messages are never returned. And she's never on IM anymore. Yesterday morning, I found a strange note dropped through the mail slot of the door of my apartment. It smells of her perfume and is written in her careful hand. But I don't speak Norwegish, so I can't make any sense of it. FNLTDEJ: QYM D WDPP VYA PY! D SQDEX YK VYA EDJQS NEF FNV, TYEJDEJ SY CR DE VYAL NLWP NJNDE. D'W PY PYLLV VYA QNURE'S QRNLF KLYW WR. WV KNSQRL FYRP EYS
11 HOUPERT N.
ACTIVITY 17_CRYPTOGRAPHY 26 février 2015
CRTDRUR SQNS N VYAEJ TNFV YK EYLMRJDNE LYVNTSV PQYATF CR FNSDEJ NWRLDZNE WRE. QR DP PY YURLOLYSRZSDUR! D MDTT PREF WV FLDURL KYL VYA PYYE, MQRE D NW NCTR SY PERNX NMNV KLYW WV KNSQRL. ODZX WR AO NS SQR ZYYLFDENSRP JDURE NS SQR REF YK SQDP WRPPNJR. SQR NEZDRES DEFDNE CYYX YK TYUR DP SQR XRV. SQR ZYYLFDENSRP NLR KYL YER YK YAL RWCNPPV PNSRTTDSR CADTFDEJP. D PSDTT LRWRWCRL SQNS FNV MQRE MR PNS YE SQR CRNZQ NEF VYA LRNF SQNS CYYX SY WR CRERNSQ SQR PAE NEF SQR ONTW SLRRP. D TYUR VYA, DEJRCYLJ
OP BR EC VF LR WH EZ IT FH TF VG AH EG CV QF LF QP FQ BL LF UH WG EZ FV HK EL EH EC ZC FH TF VG MY KH KL OQ QG LR QF LF GN AD GE KL
I've gotta run ... someone just rang the doorbell, and there's a black sedan in the driveway ... this doesn't look good for me ...
12 HOUPERT N.