06.01.2015 Views

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Cryptology</strong>:<br />

An Historical Introduction<br />

DRAFT<br />

Jim Sauerberg<br />

February 5, 2013


2<br />

Copyright 2013<br />

All rights reserved<br />

Jim Sauerberg<br />

Saint Mary’s <strong>College</strong>


Contents<br />

List <strong>of</strong> Figures 8<br />

1 Caesar Ciphers 9<br />

1.1 Saint Cyr Slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

1.2 Running Down the Alphabet . . . . . . . . . . . . . . . . . . . . 14<br />

1.3 Frequency Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />

1.4 Linquist’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

1.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

1.6 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

1.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23<br />

2 Cryptologic Terms 29<br />

3 The Introduction <strong>of</strong> Numbers 31<br />

3.1 The Remainder Operator . . . . . . . . . . . . . . . . . . . . . . 33<br />

3.2 Modular Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . 38<br />

3.3 Decimation Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . 40<br />

3.4 Deciphering Decimation Ciphers . . . . . . . . . . . . . . . . . . 42<br />

3.5 Multiplication vs. Addition . . . . . . . . . . . . . . . . . . . . . 44<br />

3.6 Koblitz’s Kid-RSA and Public Key Codes . . . . . . . . . . . . . 44<br />

3.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48<br />

3.8 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 48<br />

3.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49<br />

4 The Euclidean Algorithm 55<br />

4.1 Linear Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55<br />

4.2 GCD’s and the Euclidean Algorithm . . . . . . . . . . . . . . . . 56<br />

4.3 Multiplicative Inverses . . . . . . . . . . . . . . . . . . . . . . . . 59<br />

4.4 Deciphering Decimation and Linear Ciphers . . . . . . . . . . . . 63<br />

4.5 Breaking Decimation and Linear Ciphers . . . . . . . . . . . . . . 65<br />

4.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

4.7 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 67<br />

4.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68<br />

3


4 CONTENTS<br />

5 Monoalphabetic Ciphers 71<br />

5.1 Keyword Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . 72<br />

5.2 Keyword Mixed Ciphers . . . . . . . . . . . . . . . . . . . . . . . 73<br />

5.3 Keyword Transposed Ciphers . . . . . . . . . . . . . . . . . . . . 74<br />

5.4 Interrupted Keyword Ciphers . . . . . . . . . . . . . . . . . . . . 75<br />

5.5 Frequency Counts and Exhaustion . . . . . . . . . . . . . . . . . 76<br />

5.6 Basic Letter Characteristics . . . . . . . . . . . . . . . . . . . . . 77<br />

5.7 Aristocrats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78<br />

5.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80<br />

5.9 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 81<br />

5.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81<br />

6 Decrypting Monoalphabetic Ciphers 89<br />

6.1 Letter Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . 90<br />

6.2 Decrypting Monoalphabetic Ciphers . . . . . . . . . . . . . . . . 91<br />

6.3 Sukhotin’s Method for Finding Vowels . . . . . . . . . . . . . . . 97<br />

6.4 Final Monoalphabetic Tricks . . . . . . . . . . . . . . . . . . . . 99<br />

6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101<br />

6.6 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

6.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102<br />

7 Vigenère Ciphers 109<br />

7.1 Alberti, the Father <strong>of</strong> Western <strong>Cryptology</strong> . . . . . . . . . . . . . 110<br />

7.2 Trithemius, the Father <strong>of</strong> Bibliography . . . . . . . . . . . . . . . 111<br />

7.3 Belaso, the Unknown and Porta, the Great . . . . . . . . . . . . 113<br />

7.4 Vigenère Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . 114<br />

7.5 Variants and Beaufort . . . . . . . . . . . . . . . . . . . . . . . . 116<br />

7.6 How to Break Vigenère Ciphers . . . . . . . . . . . . . . . . . . . 117<br />

7.7 The Kasiski Test . . . . . . . . . . . . . . . . . . . . . . . . . . . 120<br />

7.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123<br />

7.9 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 124<br />

7.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124<br />

8 Polyalphabetic Ciphers 135<br />

8.1 Coincidences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135<br />

8.2 The Measure <strong>of</strong> Roughness . . . . . . . . . . . . . . . . . . . . . 138<br />

8.3 The Friedman Test . . . . . . . . . . . . . . . . . . . . . . . . . . 142<br />

8.4 Multiple Encipherings . . . . . . . . . . . . . . . . . . . . . . . . 145<br />

8.5 Vigenère’s Auto Key Cipher . . . . . . . . . . . . . . . . . . . . . 149<br />

8.6 Perfect Secrecy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152<br />

8.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154<br />

8.8 Terms and Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . 155<br />

8.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156


CONTENTS 5<br />

9 Digraphic Ciphers 167<br />

9.1 Polygraphic Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . 167<br />

9.2 Hill Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170<br />

9.3 Recognizing and Breaking Polygraphic Ciphers . . . . . . . . . . 174<br />

9.4 Playfair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176<br />

9.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179<br />

9.6 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 179<br />

9.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180<br />

10 Transposition Ciphers 189<br />

10.1 Route Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189<br />

10.2 Geometrical Ciphers . . . . . . . . . . . . . . . . . . . . . . . . . 190<br />

10.3 Turning Grilles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190<br />

10.4 Columnar Transposition . . . . . . . . . . . . . . . . . . . . . . . 192<br />

10.5 Transposition vs. Substitution . . . . . . . . . . . . . . . . . . . 195<br />

10.6 Letter Connections . . . . . . . . . . . . . . . . . . . . . . . . . 196<br />

10.7 Breaking the Columnar Transposition Cipher . . . . . . . . . . . 198<br />

10.8 Double Transposition . . . . . . . . . . . . . . . . . . . . . . . . 201<br />

10.9 Transposition during the Civil War . . . . . . . . . . . . . . . . 202<br />

10.10 The Battle <strong>of</strong> the Civil War Ciphers . . . . . . . . . . . . . . . . 207<br />

10.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207<br />

10.12 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . 208<br />

10.13 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209<br />

11 Knapsack Ciphers 219<br />

11.1 The Knapsack Problem . . . . . . . . . . . . . . . . . . . . . . . 219<br />

11.2 A Related Knapsack Problem . . . . . . . . . . . . . . . . . . . . 220<br />

11.3 An Easy Knapsack Problem . . . . . . . . . . . . . . . . . . . . . 221<br />

11.4 The Knapsack Cipher System . . . . . . . . . . . . . . . . . . . . 223<br />

11.5 Public Key Cipher . . . . . . . . . . . . . . . . . . . . . . . . . . 227<br />

11.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228<br />

11.7 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . . 228<br />

11.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228<br />

12 RSA 231<br />

12.1 Fermat’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . 232<br />

12.2 Complication I: a small one . . . . . . . . . . . . . . . . . . . . . 234<br />

12.3 Complication II: a substantial one . . . . . . . . . . . . . . . . . 235<br />

12.4 Complication III: a mini one . . . . . . . . . . . . . . . . . . . . 238<br />

12.5 Complication IV: the last one . . . . . . . . . . . . . . . . . . . 239<br />

12.6 Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . 241<br />

12.7 Exponential Problems (and answers) . . . . . . . . . . . . . . . 241<br />

12.8 RSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242<br />

12.9 RSA and Public Keys . . . . . . . . . . . . . . . . . . . . . . . . 245<br />

12.10 How to break RSA . . . . . . . . . . . . . . . . . . . . . . . . . . 245<br />

12.11 Authenticity – Pro<strong>of</strong> <strong>of</strong> Authorship . . . . . . . . . . . . . . . . 248


6 CONTENTS<br />

12.12 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249<br />

12.13 Topics and Techniques . . . . . . . . . . . . . . . . . . . . . . . 250<br />

12.14 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251<br />

Bibliography 253<br />

Index 257


List <strong>of</strong> Figures<br />

1.1 Saint Cyr Slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12<br />

1.2 Decrypting a Caesar cipher by running down the alphabet . . . . 15<br />

1.3 Letter Frequency, in percent. From Sinkov. . . . . . . . . . . . . 16<br />

1.4 English Letter Frequency Chart . . . . . . . . . . . . . . . . . . . 16<br />

1.5 Letter Frequency Charts for Several Languages . . . . . . . . . . 18<br />

2.1 Alice, Bob and Eve: the three names <strong>of</strong> Cryptography . . . . . . 30<br />

3.1 The <strong>St</strong>andard Translation <strong>of</strong> Letters into Numbers . . . . . . . . 31<br />

3.2 Enciphering/Deciphering pairs modulo 26. . . . . . . . . . . . . . 43<br />

5.1 Letter Frequencies – Anywhere. . . . . . . . . . . . . . . . . . . . 77<br />

5.2 Letter Frequencies – Initial Letters. . . . . . . . . . . . . . . . . . 77<br />

5.3 Letter Frequencies – Final Letters. . . . . . . . . . . . . . . . . . 78<br />

5.4 Characteristics <strong>of</strong> etaoinshr. . . . . . . . . . . . . . . . . . . . . 78<br />

5.5 Most Common Short Words . . . . . . . . . . . . . . . . . . . . . 78<br />

5.6 The 100 Most Common Words in English . . . . . . . . . . . . . 79<br />

6.1 Some Basic Letter Behaviors . . . . . . . . . . . . . . . . . . . . 91<br />

6.2 Digraph Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93<br />

6.3 Digraph Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96<br />

6.4 Letter Behaviors . . . . . . . . . . . . . . . . . . . . . . . . . . . 97<br />

7.1 Trithemius’ tabula recta . . . . . . . . . . . . . . . . . . . . . . . 112<br />

7.2 Beaufort’s Tableaux . . . . . . . . . . . . . . . . . . . . . . . . . 116<br />

7.3 A Kasiski Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123<br />

8.1 Frequency Counts: Same quote, different keylengths. . . . . . . . 138<br />

8.2 Larrabee’s Cipher Code . . . . . . . . . . . . . . . . . . . . . . . 163<br />

9.1 A Simple Digraphic Substitution Chart . . . . . . . . . . . . . . 169<br />

9.2 A More Complicated Digraphic Substitution Chart . . . . . . . . 170<br />

9.3 18 Most Frequent Bigrams, in percent . . . . . . . . . . . . . . . 171<br />

9.4 Repetitions in the unknown cipher. . . . . . . . . . . . . . . . . . 175<br />

7


8 LIST OF FIGURES<br />

10.1 A 3 × 3 turning grille. . . . . . . . . . . . . . . . . . . . . . . . . 191<br />

10.2 Appearances before and after the given letter, in %. . . . . . . . 197<br />

10.3 Bigram Frequencies (in %%), from the Brown Corpus. . . . . . . 198<br />

10.4 Codewords for keyword McClellan. . . . . . . . . . . . . . . . . . 212<br />

10.5 Five similar dispatches from 1876. . . . . . . . . . . . . . . . . . 216<br />

11.1 Binary Equivalents for the Alphabet . . . . . . . . . . . . . . . . 223


Chapter 1<br />

Caesar Ciphers<br />

There are also letters <strong>of</strong> his to Cicero, as well as to<br />

his intimates on private affairs, and in the latter,<br />

if he had anything confidential to say, he wrote<br />

it in cipher, that is, by so changing the order <strong>of</strong><br />

the letters <strong>of</strong> the alphabet, that not a word could<br />

be made out. If anyone wishes to decipher these,<br />

and get at their meaning, he must substitute the<br />

fourth letter <strong>of</strong> the alphabet, namely D, for A,<br />

and so with the others.<br />

Suetonius<br />

De Vita Caesarum<br />

(The Lives <strong>of</strong> the Caesars)<br />

The first true use <strong>of</strong> secret writing in recorded history is due to Julius Caesar,<br />

at least as explained by the Roman historian Suetonius. There had been<br />

earlier uses <strong>of</strong> what David Kahn, in his masterwork The Codebreakers: The History<br />

<strong>of</strong> Secret Writing, calls “proto-cryptography,” such as complex Egyptian<br />

hieroglyphics and certain stories in the biblical book <strong>of</strong> Jeremiah (see verses<br />

25:26 and 51:41). 1 But it is the Roman general Julius Caesar who apparently<br />

actually invented cryptography, the art and science <strong>of</strong> designing methods to<br />

send secret messages.<br />

Caesar’s method for making his messages secret is straightforward: replace<br />

every letter in a message with the one three letters down the alphabet. So, as<br />

Suetonius explains, a is replaced by D, b is replaced by E, etc. Of course, Caesar<br />

would have probably sent his message in Latin, but the point is clear.<br />

This rather simple idea, replace the letters in your message by other letters<br />

according to some rule, constitutes a cipher. One enciphers a message to make<br />

it (hopefully!) secret, and deciphers a secret message to make it readable.<br />

1 It is all but impossible to write a book involving the history <strong>of</strong> cryptography without<br />

making extensive use <strong>of</strong> The Codebreakers [Kahn]. In fact, most uncredited references in this<br />

book come from [Kahn].<br />

9


10 CHAPTER 1. CAESAR CIPHERS<br />

Examples: Encipher or Decipher the following names.<br />

(1) Encipher Julius.<br />

For each letter in the name, we count three letters down the alphabet and<br />

replace the original letter by this new letter.<br />

j – k – l – M. J is replaced by M.<br />

u – v – w – X. u is replaced by X.<br />

l – m – n – O. l is replaced by O.<br />

Finish the rest <strong>of</strong> this example, and then check your answer by looking at<br />

footnote 2 part (1).<br />

(2) Encipher Caesar.<br />

(3) Decipher EUXWXV.<br />

Since enciphering is counting forwards, deciphering must be counting backwards.<br />

E – d – c – b.<br />

U – t – s – r.<br />

X – w – v – u.<br />

Finish this example, and again check your answer against the footnote. 2<br />

(4) Decipher FLFHUR. 3<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

When one must encipher messages <strong>of</strong> more than a couple <strong>of</strong> words, it becomes<br />

quite bothersome to count three forwards and three backwards over and<br />

over. To somewhat automate the process we write out the usual alphabet, the<br />

plaintext alphabet, and underneath it the alphabet we use for enciphering,<br />

the ciphertext alphabet:<br />

plaintext alphabet<br />

ciphertext alphabet<br />

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<br />

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<br />

Then to encipher replace the plaintext letter by the ciphertext letter (underneath<br />

it), and to decipher replace the ciphertext letter by the plaintext letter (above<br />

it). Thinking “read down” or “read up” will lead to trouble later. Think instead<br />

about moving from plaintext letters to ciphertext letters, or from ciphertext<br />

letters back to plaintext letters. 4<br />

2 Some <strong>of</strong> the examples in this book will be completely worked out. But some will be only<br />

partially finished, and others not even begun. These latter types are for you to work out. Do<br />

so with paper and pencil, and then check your answers against the answer in the footnote,<br />

and you will find the exercises to be much easier.<br />

3 (1) MXOLXV, (2) FDHVDU, (3) Brutus, (4) Cicero<br />

4 The fonts used in the alphabets just above are not accidental: we will always use lower<br />

case letters like these ones to represent plaintext letters, and upper case letter LIKE THESE<br />

ONES for ciphertext letters.


11<br />

Examples: Encipher or decipher the following names.<br />

(1) Encipher Gaius.<br />

To encipher we move from plaintext alphabet to ciphertext alphabet, that<br />

is, replace each <strong>of</strong> the plaintext letters gaius by the corresponding ciphertext<br />

letters (underneath them):<br />

So JDLXV is the answer.<br />

(2) Encipher Cleopatra.<br />

(3) Decipher SRPSHB.<br />

g a i u s<br />

J D L X V<br />

To decipher we move from the ciphertext alphabet back to the plaintext<br />

alphabet.<br />

So pompey is the answer.<br />

(4) Decipher FUDVVXV. 5<br />

S R P S H B<br />

p o m p e y<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

In Caesar’s time his cipher was likely a good one. After all, it was the first<br />

one ever invented! 6 But once it is known that shifting three forwards and three<br />

back is the key, the secrecy is lost. To try to regain it we might instead agree<br />

ahead <strong>of</strong> time on a secret number that tells the amount we will shift each letter.<br />

Examples: Encipher or decipher using the given shift amount.<br />

(1) Encipher Augustus using a shift amount <strong>of</strong> 1. The counting here is simple<br />

– replace each letter by the next one, so a by b, u by V, etc. 7<br />

(2) Encipher Quintillis using a shift amount <strong>of</strong> 10.<br />

Quintillis, meaning “five” in Latin, was the name <strong>of</strong> the 5th month used<br />

Julius Caesar named it after himself.<br />

5 (2) FOHRSDWUD, (3) Pompey, (4) Crassus<br />

6 There is no reason, however, to believe that Caesar used these ciphers for long, or for<br />

important messages. Cicero, with whom Caesar would have used the system, changed political<br />

sides, making the system no longer secret. [ATTRIBUTION]<br />

7 Seutonius: “When Augustus wrote in cipher he simply substituted the next letter <strong>of</strong> the<br />

alphabet for the one required, except that he wrote AA for x” (the last letter <strong>of</strong> the Roman<br />

alphabet). [Kahn, pg 84]


12 CHAPTER 1. CAESAR CIPHERS<br />

(3) Decipher ZLEAPSSH. It was enciphered with a shift <strong>of</strong> 7.<br />

This is the same way we deciphered before, we just count more:<br />

Z - y - x - w - v - u - t - s<br />

L - k - j - i - h - g - f - e<br />

So the word starts se. (It is the name <strong>of</strong> the sixth month <strong>of</strong> the year<br />

before it was named for Caesar Augustus.)<br />

(4) Decipher FTKRMZLJ. It was enciphered using a shift amount <strong>of</strong> 17.<br />

(It may be easiest to write down the plaintext alphabet with ciphertext<br />

alphabet underneath.) 8<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Ciphers such as these are called Caesar Ciphers or Shift Ciphers, and<br />

the shift amount is called the key. While these ciphers are quite simple, they<br />

are the foundation upon which most ciphers are built.<br />

1.1 Saint Cyr Slide<br />

So far we have two methods for implementing a shift cipher: either count<br />

through the alphabet letter after letter, or write down the plaintext alphabet<br />

with a new ciphertext alphabet for each shift amount. While not exactly<br />

difficult, the first method is prone to silly errors and the second is very tedious.<br />

We remedy this by building a Saint Cyr Slide 9 , a simple device that will allow<br />

us to use any Caesar cipher we wish.<br />

Figure 1.1: Saint Cyr Slide<br />

To make one, first, on a thin strip <strong>of</strong> paper, or on something stronger like<br />

tag board, put the 51 upper case letters<br />

ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY<br />

in capital letters, repeated twice (the Z in the second alphabet is unnecessary).<br />

We need to have the letters a constant distance apart, so it is best to use lined<br />

8 (1) BVHVTUVT, (2) AESXDSVVSC, (3) Sextilla, (4) Octavius<br />

9 Slides similar to this have been used for centuries, but their modern name dates from 1883<br />

when Auguste Kerch<strong>of</strong>f named them for the famed French Military Academy [Kahn, pg 289].


1.1. SAINT CYR SLIDE 13<br />

paper turned sideways and put one letter per space. Leave a couple inches<br />

<strong>of</strong> empty paper on each end <strong>of</strong> the letters. Under the first 25 letters put the<br />

corresponding shift number: 1 below B, 2 below C, ... 25 below Z. Write on the<br />

left edge that this is the “Ciphertext Alphabet”.<br />

On a larger rectangular piece <strong>of</strong> paper write in lower case the letters <strong>of</strong> the<br />

alphabet<br />

abcdefghijklmnopqrstuvwxyz<br />

Also write the numbers 1 through 26 above the corresponding letters. Make sure<br />

to spread these letters at the same constant width that the ciphertext letters<br />

were spread. This paper should be entitled “Plaintext Alphabet”. Then below<br />

and just to the left <strong>of</strong> the a, and below and just to the right <strong>of</strong> the z, make<br />

incisions in the paper <strong>of</strong> the same height as the cipherstrip. (It also wouldn’t<br />

hurt to add an arrow entitled “key” on the plaintext page pointing to the spot<br />

under the plaintext a to remind us where the key will appear.)<br />

The cipherstrip can then be inserted into the plaintext piece and slid back<br />

and forth, making it easy to form the Caesar alphabet <strong>of</strong> choice. Simply choose<br />

a key number, slide the ciphertext strip so that this letter is under the plaintext<br />

a, and then read from plaintext to ciphertext and back. This allows us to<br />

relatively quickly and easily encipher and decipher using any key.<br />

Because <strong>of</strong> the way the Saint Cyr Slide is constructed, we may also use letters<br />

to indicate keys. The key as a number we understand: a key <strong>of</strong> 5 says move each<br />

letter five letters down the alphabet. It is actually more common to use a key<br />

letter. The key letter is the letter the plaintext a is enciphered into. So a key<br />

<strong>of</strong> R says that a will become R in the ciphertext (and b becomes S, c becomes<br />

T, etc.). In either case, we line up the key under the plaintext a and use the<br />

plaintext alphabet – ciphertext alphabet pair the Saint Cyr Slide displays.<br />

Examples:<br />

(1) Encipher Roman Holiday using key S. What shift amount is this<br />

To encipher, first line up the cipherstrip’s first S under the a <strong>of</strong> the plain<br />

alphabet. Under S you should have written 18, so the shift amount is<br />

18. Now encipher the title by finding the letters <strong>of</strong> roman holiday in the<br />

plaintext alphabet and replace them one by one with the letters <strong>of</strong> the<br />

ciphertext alphabet (underneath). You should see J under r, G under o<br />

and E under m. If so, keep going. If not, make sure you positioned your<br />

slide correctly and double check to see if you left out any letters <strong>of</strong> the<br />

alphabet on your slide!<br />

(2) Encipher Marc Antony, key 6.<br />

(3) Decipher PEXANEQO, key W.<br />

Line up the key letter W under the plaintext letter a. Remembering to<br />

read from ciphertext back to plaintext (“up”), you should see t above P<br />

and i above E.


14 CHAPTER 1. CAESAR CIPHERS<br />

(4) Decipher RXRTGD, key 15.<br />

(5) Decipher SQJE, key Q. 10<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Examples: Here are a few instances <strong>of</strong> a Caesar cipher turning one word<br />

into another.<br />

(1) Encipher wheel with key H.<br />

(2) Encipher jolly with key T.<br />

(3) Decipher SLEEP with a key R.<br />

(4) Decipher KNOW with key 10. 11<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

1.2 Running Down the Alphabet<br />

Now let us look at ciphers from a new direction. Suppose our enemy has sent<br />

the message PX PBEE FXXM TM FBWGBZAM and somehow we capture it. How<br />

can we determine what it says when we don’t have the key<br />

A simple way is to “decipher” the message 26 times, using each possible key<br />

once. Hopefully the deciphered message will make sense using one and exactly<br />

one <strong>of</strong> those keys. If so, we will have decrypted the message by determining<br />

the message and key without being told.<br />

This is called the method <strong>of</strong> exhaustion, because we exhaust all possibilities.<br />

For Caesar ciphers this can be done quickly by running down the<br />

alphabet: under each ciphertext letter write the next 25 letters <strong>of</strong> the alphabet,<br />

following Z with A if need be. In at most twenty-five steps something legible will<br />

appear, and we will have determined the message.<br />

In Figure 1.2 we do this for the “captured” ciphertext. Reading across<br />

the rows, We will meet at midnight must be the plaintext. Since it took us<br />

seven steps forward to find the plaintext, and we usually move backwards in the<br />

alphabet to decipher, the key number must be -7 or 19. 12<br />

Why does running down the alphabet work Because letters that are adjacent<br />

in the plaintext remain adjacent in the ciphertext. In our last example,<br />

the consecutive letters ghi appearing in midnight became ZAB or ABC or BCD,<br />

10 (1) JGESF ZGDAVSQ, (2) SGXI GTZUTE, (3) tiberius, (4) cicero, (5) cato<br />

11 (1) DOLLS, (2) CHEER, (3) bunny, (4) aden<br />

12 Yes, −7 = 19 when we are dealing with the 26 letters <strong>of</strong> the alphabet! We will explore<br />

this in Chapter 3.


1.3. FREQUENCY ANALYSIS 15<br />

PX PBEE FXXM TM FBWGBZAM<br />

QY QCFF GYYN UN GCXHCABN<br />

RZ RDGG HZZO VO HDYIDBCO<br />

SA SEHH IAAP WP IEZJECDP<br />

TB TFII JBBQ XQ JFAKFDEQ<br />

UC UGJJ KCCR YR KGBLGEFR<br />

VD VHKK LDDS ZS LHCMHFGS<br />

WE WILL MEET AT MIDNIGHT<br />

XF XJMM NFFU BU NJEOJHIU<br />

YG YKNN OGGV CV OKFPKIJV<br />

Figure 1.2: Decrypting a Caesar cipher by running down the alphabet<br />

etc. There is no mixing <strong>of</strong> the alphabet – every letter moves the exact same<br />

distance. This is why Caesar ciphers are not very secure ones.<br />

Examples: Decrypt the following ciphertexts by running down the alphabet.<br />

(1) NQYFP YIWFI WE.<br />

(2) MBZXK. 13<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Since before long we will have ways <strong>of</strong> enciphering that have hundreds <strong>of</strong> keys,<br />

rather than only twenty-six, the method <strong>of</strong> exhaustion will be too exhausting to<br />

do by hand. To develop a better method for decrypting ciphers we must think<br />

more carefully about the ciphertext message we are trying to read.<br />

1.3 Frequency Analysis<br />

Let’s reconsider the situation in which we have captured a message written in<br />

cipher. What might we be able to figure out about this message without reading<br />

it Well, first, we probably know that it is in English (as all <strong>of</strong> our messages will<br />

be) and we know a lot about English. For instance, that e, t, and a are all very<br />

common, and that x, z and q are among the least common letters in English.<br />

Abraham Sinkov, an important codebreaker during World War II, made a count<br />

<strong>of</strong> the letters appearing in 16410 words, and Figure 1.3 contains the results.<br />

What do we see in this chart First, the two most common letters are e<br />

and t. Nearly 13% <strong>of</strong> all letters in an English text are e’s, and over 9% are t’s.<br />

Almost always, e or t will be the most common letter in a text.<br />

13 (1) twelve o’clock. This took six steps, so the key is −6 = 20. (2) Sorry, but it’s a trick.<br />

Either a shift <strong>of</strong> 3 to produce pecan, or a shift <strong>of</strong> 7 to give tiger.


16 CHAPTER 1. CAESAR CIPHERS<br />

8.2 1.5 2.8 4.3 12.7 2.2 2.0 6.1 7.0 0.2 0.8 4.0 2.4<br />

a b c d e f g h i j k l m<br />

6.7 7.5 1.9 0.1 6.0 6.3 9.1 2.8 1.0 2.3 0.1 2.0 0.1<br />

n o p q r s t u v w x y z<br />

Figure 1.3: Letter Frequency, in percent. From Sinkov.<br />

The next most common letters are a, o, i, n, s, h, and r, each occurring<br />

between 6% and 9% <strong>of</strong> the time. With e and t, they make up 70% <strong>of</strong> all letters<br />

in English. So if you know which ciphertext letters stand for the letters e, t, a,<br />

o, i, n, s, h and r then you have probably already figured out 7 out <strong>of</strong> every 10<br />

letters in a text. To remember these high frequency letters, use a mnemonic,<br />

like a sin to er(r), trainhose or satinhero.<br />

Of the remaining letters, d and l appear about 4% <strong>of</strong> the time each, while<br />

the letters cumwfgypb occur between 1.5% and 3% each, for a total <strong>of</strong> 20%.<br />

Finally vkjxqz each seldom occur, less than 1% <strong>of</strong> the time, and less than 2.2%<br />

in total.<br />

A useful way <strong>of</strong> representing Sinkov’s frequency information is with a frequency<br />

chart. Above each letter put one dash for each percentage the letter has<br />

in the frequency count. So above e will be 13 bars, and above v there will be<br />

only one. We have done this to produce Figure 1.4.<br />

\<br />

\ \ \ \ \ \ \ \ \<br />

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<br />

Figure 1.4: English Letter Frequency Chart<br />

Several patterns appear in this so-called normal pr<strong>of</strong>ile. As David Kahn<br />

so dramatically put it<br />

“The single most durable and detectable feature <strong>of</strong> the normal pr<strong>of</strong>ile is<br />

the long, low peneplane <strong>of</strong> uvwxyz, which extends almost a quarter <strong>of</strong> the<br />

pr<strong>of</strong>ile and is extremely depressed. This basin is sharply walled <strong>of</strong>f by the<br />

rst cordillera at one end and the single peak <strong>of</strong> a at the other. The other<br />

features <strong>of</strong> the pr<strong>of</strong>ile are more easily eroded by decreases in size <strong>of</strong> sample.<br />

The pinnacle <strong>of</strong> e normally soars midway between a and the double tower<br />

<strong>of</strong> hi, which is followed by the severe drop to jk. High-frequency n and<br />

o also rise to twin peaks. In short samples, however, the troughs <strong>of</strong> the<br />

pr<strong>of</strong>ile are <strong>of</strong>ten more reliable indicators than the crests”. [Kahn, page<br />

210]


1.3. FREQUENCY ANALYSIS 17<br />

A bit more concretely, a, e and i form a set <strong>of</strong> high frequency letters 4 steps<br />

or letters apart. Next, hi and no are high pairs and rst a high triplet. Finally,<br />

uvwxyz is a set <strong>of</strong> six very low values that directly follows the rst triplet and<br />

occurs directly before a.<br />

To see how these patterns are used let’s look at an example.<br />

Example: Use frequency analysis to decrypt YPYH NBCM MBILN GYMMUAY XIYM<br />

HIN LYGUCH MYWLYN ZIL FIHA.<br />

We first construct a frequency chart by counting the number <strong>of</strong> times each<br />

letter appears:<br />

ciphertext<br />

\ \ \<br />

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<br />

The most common letters are M and Y, so one <strong>of</strong> these is probably e. (Of<br />

course, e might instead be N, H or L, but these are less likely.) If M were e,<br />

we’d expect to find the aei-triple <strong>of</strong> high counts separated at intervals <strong>of</strong> four<br />

at IMQ. There are several I’s, but no Q’s. Worse, H would be z, and four z’s is<br />

unlikely. On the other hand, if Y were e, the aei-triple would be at UYC. This<br />

message is very short, so a “high”-triple is not all that high, and so UYC might<br />

be reasonable fit for aei.<br />

Where might rst fit The highest consecutive triple is at LMN. This fits<br />

pretty well, since the low septet uvwxyz would fit at OPQRST. Finally, just before<br />

LMN is a high pair HI, so we might guess that HI is no.<br />

Putting this plaintext guess above the frequency chart will help us see if<br />

everything fits:<br />

plaintext<br />

ciphertext<br />

g h i j k l m n o p q r s t u v w x y z a b c d e f<br />

\ \ \<br />

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<br />

The fit is good – the peaks at e, no, and rst, and the long valley at uvwxyz give<br />

us confidence we’ve done this correctly. Finally, the keyletter is the ciphertext<br />

letter that a becomes, so the key is U. Now we simply decipher to find that the<br />

message is Even this short message does not remain secret for long.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

A message’s frequency chart will seldom have all <strong>of</strong> the patterns, but it<br />

should have good evidence <strong>of</strong> several. When trying to fit the patterns generally<br />

we start with the tallest peaks <strong>of</strong> e and t, and the long low valley <strong>of</strong> uvwxyz.<br />

Then we look for the aei and rst triples. Finally, we see if the no pair is present.<br />

If there are several “probably”’s when trying to fit these patterns, then the key<br />

likely is the ciphertext letter posing as a. Try this possible key by deciphering<br />

ten or so letters from the ciphertext. If a message seems to be appearing, we’ve


18 CHAPTER 1. CAESAR CIPHERS<br />

found the key. If no message appears, try again, repeating until you are able to<br />

decipher the message.<br />

This process <strong>of</strong> making a frequency count and then trying to fit the hills<br />

and valleys to the proper letters is called doing a frequency analysis. It is certainly<br />

the most powerful tool in all <strong>of</strong> cryptanalysis, the science <strong>of</strong> decrypting<br />

other people’s ciphers.<br />

In fact, we don’t even really need to be able to read the language <strong>of</strong> the cipher<br />

to use frequency analysis. Consider the frequency charts for French, German,<br />

Italian and Spanish found in Figure 1.5 [Nichols, page 70]. Each <strong>of</strong> these<br />

\<br />

\<br />

\ \ \ \ \ \ \ \ \ \<br />

French 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<br />

\<br />

\ \<br />

\ \ \ \ \ \ \ \ \<br />

German 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<br />

\ \ \<br />

\ \ \ \ \ \ \ \ \ \<br />

Italian 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<br />

\ \<br />

\ \ \ \ \ \ \ \ \<br />

Spanish 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<br />

Figure 1.5: Letter Frequency Charts for Several Languages<br />

languages has its own characteristics, the extreme peak <strong>of</strong> e in German, or the<br />

predominance <strong>of</strong> vowels in Italian, for example. But in each case the specifics<br />

<strong>of</strong> the frequency chart allows a cryptanalyst to attack and break Caesar ciphers<br />

in that language. The use <strong>of</strong> frequency analysis, really nothing more than<br />

counting letters, makes Caesar ciphers very easy to decrypt, no matter the<br />

original language <strong>of</strong> the sender or the breaker.<br />

Having developed a method for decrypting Caesar ciphers, we are said to<br />

have broken that cipher system. Notice the difference between breaking and<br />

decrypting – breaking a cipher system means producing a method that allows<br />

you to decrypt most messages sent in that system. Conversely, one may be<br />

able to decrypt a particular message without knowing how to decrypt messages<br />

enciphered using that system in general.


1.3. FREQUENCY ANALYSIS 19<br />

Examples: Use Frequency Analysis to decrypt the following Caesar ciphers.<br />

(1) ZU SGQK G VXUVKX YKTZKTIK KBKXE RKZZKX SAYZ VRGE OZY VXUVKX XURK<br />

We begin by making a frequency count:<br />

ciphertext<br />

\<br />

\ \ \ \<br />

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<br />

The giant peak at K surrounded by a vast wasteland jumps out at us.<br />

If we guess that the six letters LMNOPQ are uvwxyz, then the peak <strong>of</strong> K<br />

is t, which would be fine, and RVXYZ=aeghi. Putting our guess at the<br />

plaintext alphabet next to the ciphertext alphabet we may compare.<br />

plaintext<br />

ciphertext<br />

\<br />

\ \ \ \<br />

j k l m n o p q r s t u v w x y z a b c d e f g h i<br />

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<br />

The peaks and valleys seem reasonable. To test, we decipher the message.<br />

Since our prediction is that a became R, we use the key <strong>of</strong> R. Unfortunately,<br />

the message then begins id bpzt p edgetg. This is not right. We must<br />

try again.<br />

Perhaps the low sextet belongs at the beginning <strong>of</strong> the ciphertext alphabet.<br />

If we guess that K = e, then a must be G, and before G is a sextet <strong>of</strong><br />

nothingness. This is likely uvwxyz. Let’s again add the plaintext alphabet<br />

to compare:<br />

plaintext<br />

ciphertext<br />

\<br />

\ \ \ \<br />

u v w x y z a b c d e f g h i j k l m n o p q r s t<br />

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<br />

The lmnop and rst sets are both relatively high since in such a short<br />

cipher appearing even three or four times counts as “many”. We ought to<br />

be quite confident <strong>of</strong> our plaintext placement. As always, the key is the<br />

letter a becomes, which is G. To finish, we decipher the first couple letters<br />

using a key G. This gives to make a proper, which seems correct. We’ve<br />

found the key! (Now finish up the decryption by deciphering the rest <strong>of</strong><br />

the message using the key G.)


20 CHAPTER 1. CAESAR CIPHERS<br />

(2) MVIP WVN JVTIVK DVJJRXVJ TRE JLIMZMV NYVE RKKRTBVU SP WIVHLVETP<br />

RERCPJZJ<br />

Here the frequency count is given to you:<br />

\<br />

\ \ \<br />

ciphertext 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<br />

Look for high aei and rst sets bracketing the low uvxwyz.<br />

(3) Decrypt the following message. Don’t be bothered by the five letter<br />

groups, the analysis remains the same.<br />

HMALY HDOPS LPAIL JVTLZ CLYFL HZFAV YLJVN UPGLD OHAAO LZOPM APZMY<br />

VTAOLMYLXB LUJFA HISL.<br />

(4) Here is a trickier one.<br />

HDBIH DYHDB SMUHI YEHLI HZEDD SXQHO HDBKH VODDO BCHSX HDROH WOCCK<br />

QO 14<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

It has become tradition to transmit the ciphertext with word spacing eliminated<br />

and the letters recombined in 5-letter segments. Doing this hides word<br />

beginnings and endings, which makes a cipher more difficult to decrypt. Further,<br />

it takes only a glance for a person to determine that a “word” consists<br />

<strong>of</strong> exactly five letters. In the days when messages were sent via telegraph, this<br />

helped prevent the person doing the actual transmission from accidentally forgetting<br />

letters from ciphertexts. (Why 5 rather than 4 or 6 The 1875 tariff<br />

regulations <strong>of</strong> the International Telegraph Union limited the length <strong>of</strong> a word to<br />

10 letters [Kahn, pg 842]. Dividing a 10 letter word in half leaves two 5 letters<br />

words. Perhaps had these regulations limited word length to 8 or 12 then it<br />

would now be common to send ciphers in 4 or 6 letter segments.)<br />

1.4 Linquist’s Method<br />

Once a person has become comfortable with using frequency analysis to decrypt<br />

Caesar ciphers he/she needs only about 50 letters <strong>of</strong> the ciphertext to accurately<br />

determine the key. What if we have significantly less than this, say only 15 or<br />

25 letters 15 Then we use Linquists’s method. [Gaines, page 133]<br />

Consider ZWUM PIA AMDMV PQTTA, a text <strong>of</strong> 18 letters. We start, as always,<br />

with the frequency count, and use it to determine the most common letters in<br />

14 (1) to make a proper sentence every letter must play its proper role, key = G.<br />

(2) very few secret messages can survive when attacked by frequency analysis, key = R.<br />

(3) after a while it becomes very easy to recognize what the shift is from the frequency<br />

table, key = H.<br />

(4) xtry xto xtrick xyou xby xputting xextra xletters xin xthe xmessage, key = K.<br />

15 This will <strong>of</strong>ten be the case later when we study the very important Vigenère cipher.


1.4. LINQUIST’S METHOD 21<br />

the ciphertext. In this example, the only letters occurring more than once are<br />

A, P and T, twice each, and M, which appears three times. Even for such a short<br />

message (when the frequencies can be quite messed up) it many <strong>of</strong> these letters<br />

must come from etaoinshr. Linquist’s idea is to see if there is one shift amount<br />

that would produce all or most <strong>of</strong> the most common ciphertext letters from the<br />

common plaintext letters.<br />

To do this, make a chart with the common plaintext letters across the top<br />

and common ciphertext letters down the side. For each <strong>of</strong> the etaoinshr letters<br />

determine what key produces the ciphertext letter from this plaintext letter. For<br />

instance, e must be shifted by 22 letters to become A, so we enter 22 in the e-th<br />

column and A-th row. To find the shift amount using the Saint Cyr slide, line up<br />

A under e and then see what the key is. Similarly, lining up M under e produces<br />

an 8, so 8 is the second entry in the first column.<br />

e t a o n i r s h<br />

A 22 7 0 12 13 18 9 8 19<br />

M 8 19 12 24 25 4 21 20 5<br />

P 11 22 15 1 2 7 24 23 8<br />

T 15 0 19 5 6 11 2 1 12<br />

We are looking for one shift amount that would cause four <strong>of</strong> etaoinshr to<br />

become AMPT. So we are searching for numbers that appear in every row, or,<br />

failing that, occur in at least in three <strong>of</strong> the four rows. No number appears in<br />

each row, but 8, 12 and 19 appear in appear in three <strong>of</strong> the four rows. It is most<br />

likely that one <strong>of</strong> these three is the proper shift amount. We simply decipher<br />

the message using each to see which one it is. 16<br />

Example: Decrypt WZRVM ZOCSD YZNGA HVMXC using Linquist’s method.<br />

The only letters than appear more than once are C, M, V and Z, so our chart<br />

is set up as<br />

e t a o n i r s h<br />

C 24 11<br />

M 19 4<br />

V 8 3<br />

Z 25 17<br />

Some <strong>of</strong> the chart has been filled in for you. Complete it, find the most common<br />

letter (i.e., the possible keys) and try them to determine the key. Finally,<br />

decipher the message. 17<br />

⋄<br />

16 It is 8. Deciphering gives Rome has seven hills.<br />

17 Beware the Ides <strong>of</strong> March, key = 17.


22 CHAPTER 1. CAESAR CIPHERS<br />

1.5 Summary<br />

The Caesar Cipher, sometimes called the Shift Cipher, is history’s first example<br />

<strong>of</strong> a cryptosystem. In the Caesar version the keyletter indicates what ciphertext<br />

letter the plaintext a becomes, while in the Shift version the keynumber tells<br />

how many letters down the alphabet each plaintext letter is moved. The Saint<br />

Cyr Slide is a simple device that allows for rapid enciphering and deciphering<br />

<strong>of</strong> either version <strong>of</strong> this cipher.<br />

Decrypting a Caesar Cipher starts with a frequency count. If the ciphertext<br />

is sufficient, comparing the frequency count with that <strong>of</strong> standard English and<br />

looking for the characteristic peaks and valleys leads one to the key needed to<br />

decipher the cipher. When one has only a small amount <strong>of</strong> ciphertext, say under<br />

thirty letters, Linquist’s chart will generally give the key, albeit with a bit more<br />

work. Since we have methods that allow for the routine decryption <strong>of</strong> Caesar<br />

Ciphers we can be said to have broken the cipher.<br />

Caesar ciphers are very rigid; the alphabet is only shifted during enciphering<br />

and is not mixed. This is the reason this cipher system is easy to break. Despite<br />

their lack <strong>of</strong> security, they remain fundamental for almost all that we will do.<br />

The ideas <strong>of</strong> letter-for-letter replacement, keys, frequency count and frequency<br />

analysis will appear over and over again.<br />

1.6 Topics and Techniques<br />

1. Why would we use a secret writing system Give at least two examples.<br />

2. Why do we call it a Caesar Cipher Why do we call it a Shift Cipher<br />

3. What is the difference between enciphering and deciphering<br />

4. What is a Saint Cyr Slide How is it used to encipher How is it used to<br />

decipher<br />

5. What is a key to a Caesar Ciphers<br />

6. Are letter keys different than number keys How<br />

7. What is the meaning <strong>of</strong> the letter in a key letter<br />

8. What is the meaning <strong>of</strong> the number in a key number<br />

9. What does it mean to decrypt a message How does this differ from<br />

deciphering a message<br />

10. What does it mean to break a cipher system How does this differ from<br />

decrypting a message<br />

11. What is the Method <strong>of</strong> Exhaustion Why do we call it that


1.7. EXERCISES 23<br />

12. What is the most common letter in English Second most common<br />

13. What are the nine most common letters in English<br />

14. What are some <strong>of</strong> the least common letters in English<br />

15. What sorts <strong>of</strong> hills and valleys does the letter frequency count <strong>of</strong> a portion<br />

<strong>of</strong> normal English have<br />

16. How do we use a frequency count to break a Caesar Cipher<br />

17. Are Caesar ciphers secure or not Why<br />

18. When would we use Linquist’s method<br />

19. How does Linquist’s method work Why does it work<br />

1.7 Exercises<br />

1. Encipher the following emperors’ names using a Caesar Cipher with the<br />

given key.<br />

(a) Pompeii, key = D.<br />

(b) Vespasian, key = P.<br />

(c) Caligula, key = H.<br />

(d) Nero, key = T.<br />

2. Encipher the following emperor’s names using a Shift Cipher with the<br />

given key.<br />

(a) Damitian, key = 11.<br />

(b) Trajan, key = 5.<br />

(c) Hadrian, key = 19.<br />

3. Decipher the following names. They have been enciphered using a Caesar<br />

cipher with the given key.<br />

(a) GULWOM UOLYFCOM, key = U.<br />

(b) IRGAJOAY, key = G.<br />

(c) TYESBUJYQD, key = Q.<br />

(d) HFXXNZX, key = F.<br />

4. Decipher the following names. They have been enciphered using a Shift<br />

Cipher with the given key.<br />

(a) RDCHIPCIXCT, key = 15.


24 CHAPTER 1. CAESAR CIPHERS<br />

(b) MXVWLQLDQ, key = 3.<br />

(c) QAGNGM YDPGAYLSQ, key = 24.<br />

(d) GVOREVHF TENPPUHF, key = 13.<br />

5. Encipher the following words using a Caesar Cipher with the given key.<br />

(a) Appian Way, key = F.<br />

(b) Punic Wars, key = B.<br />

(c) Carthage, key = N.<br />

(d) Gladiator, key = W.<br />

6. Encipher the following words using a Shift Cipher with the given key.<br />

(a) Atrium, key = 1.<br />

(b) Colosseum, key = 25.<br />

(c) Po Valley, key = 18.<br />

(d) Equestrian Order, key = 9.<br />

7. Decipher the following. They have been enciphered using a Shift Cipher<br />

with the given key.<br />

(a) OMFMOAYNE, key = 12.<br />

(b) TJNXWNVM, key = 19.<br />

(c) LHAXEWJ, key = 22.<br />

(d) DBSLEXO, key = 10.<br />

(e) GDBPC ATVXDC, key =15.<br />

8. Decipher the following. They have been enciphered using a Caesar Cipher<br />

with the given key.<br />

(a) VKDSEW, key = K.<br />

(b) VTKTGOG, key = V.<br />

(c) RCVTKEKCP, key = C.<br />

(d) OJSBHWBS, key = O.<br />

(e) AYPBTCPYHAL, key = H.<br />

9. Decipher the following. They have been enciphered using a Caesar Cipher<br />

with the given key.<br />

(a) QSBHIFWCB, key = O.<br />

(b) CQN ADKRLXW ARENA, key = J.<br />

(c) ZKBYQD SQBUDTQH, key = Q.


1.7. EXERCISES 25<br />

(d) VTXLTKBTG LXVMBHG, key = T.<br />

10. A part <strong>of</strong> a message <strong>of</strong> Caesar’s to Cicero (in Latin!) was MDEHV RSNQNRQNV<br />

PHDH XHVXNPRQNZP. Decipher it. (Remember, Latin has no J, K, W or<br />

Y.)<br />

11. Use frequency analysis to decrypt the following messages.<br />

(a) VG ZNL OR EBHAQYL NFFREGRQ GUNG UHZNA VATRAHVGL PNAABG PBAP-<br />

BPG N PVCURE JUVPU UHZNA VATRAHVGL PNAABG ERFBYIR RQTNE NYYRA<br />

CBR<br />

(b) DHVIV BZYVA OZMNJ HZRJM MTOJN JGQZO CZHZN NVBZV IYQZM TAZRO<br />

CDIBN DIVAO ZMGDA ZBVQZ HZVNH PXCKG ZVNPM ZVNYD YOCZP IMVQZ<br />

GDIBJ AOCVO XJYZC VMMTC JPYDI D<br />

(c) STHTI JTWHN UMJWN XNRUW JLSFG QJYTF YYFHP ZSQJX XNYNX NSXTQ<br />

ZGQJG DYMJN SAJSY TWMNR XJQK<br />

12. Use frequency analysis to decrypt the following messages.<br />

(a) RKXXSLKV KXXYEXMON DYNKI DRKD RO KXN DRO OVOZRKXDC GYEVN LO<br />

KBBSFSXQ SXBYWO CYWODSWO XOHD GOOU<br />

(b) GFWSZ RFSST ZSHJI YMFYM JFSIG FNQJD BTZQI FZINY NTSYM JJQJU<br />

MFSYX KTWUT XXNGQ JNSHQ ZXNTS NSYMJ NWHNW HZX<br />

13. Decrypt the following ciphertexts using Linquist’s method.<br />

(a) DROOX OWIUX YGCDR OCICD OWLOS XQECO NMVKE NOCRK XXYX<br />

(b) WUDJB UCUDT EDEJH UQTUQ SXEJX UHICQ YB<br />

This is a quote <strong>of</strong> Henry L. <strong>St</strong>imson, President Hoover’s Secretary <strong>of</strong><br />

<strong>St</strong>ate, writing later about his shutting down the US Black Chamber,<br />

the government cryptoanalytic service, in 1929.<br />

(c) IJXMT KOJBM VHRVN ZQZMN JGQZY WTNOV MDIBV ODO<br />

(d) BJUUH BNUUB NJBQN UUBKH CQNBN JBQXA N.<br />

(e) FHWDU YTLWF RNXFR JXXFL JBWNY YJSNS HNUMJ W<br />

(f) KVVDR ODRSX QCSXD ROGYB VNMYX CDSDE DOKMS ZROB<br />

(g) “The goal <strong>of</strong> a cryptosystem is to: BPZTI WTBTH HPVTX CRDBE GTWTC<br />

HXQAT IDJCP JIWDG XOTSE TGHDC H<br />

14. (a) What happens if we use a Shift Cipher with a shift <strong>of</strong> 26<br />

(b) What happens if we use a number larger than 26 for the shift amount<br />

(c) How many different Shift Ciphers are there<br />

15. According to David Gaddy, “on 1 January 1863 while touring in the west,<br />

[Confederate] President [Jefferson] Davis sent [a person a] telegram which<br />

used a simple slide <strong>of</strong> one” [Gaddy]. If the telegram began TFDSF UBSZP<br />

GXBSKBNF TBTFE EPOSJ DINPO E, to whom was it for


26 CHAPTER 1. CAESAR CIPHERS<br />

16. The Confederate Army used several rather insecure cipher systems during<br />

the Civil War [Gaddy]. For example,<br />

“To Gen. Beauregard, 11 March 1862:<br />

Sir: Your dispatch just received. The day <strong>of</strong> the month on which it<br />

is written will indicate the letter <strong>of</strong> the alphabet corresponding with<br />

A. Yesterday 10th J-A. I repeat it that we may know if the operator<br />

conveyed it correctly.<br />

EFNTI FJJZE XIZMV IIVRI FEJRK LIURP NYVIV TREKY VK-<br />

IFF GJAFZ EPFLN ZKYLK DFJKV WWVTK<br />

On the 27th <strong>of</strong> the month “A” will correspond to “C”.<br />

Gen. Albert Sidney Johnston (Decataur)”<br />

(a) Use frequency analysis to find the key and decrypt the message.<br />

(b) What date was it sent on<br />

17. Some years after the Civil War, Joseph Willard Brown described the following<br />

incident [Brown, pages 210–2].<br />

“One [message] from Gen. Beauregard just after the battle <strong>of</strong> Shiloh,<br />

(6-7 April 1862) giving the number and condition <strong>of</strong> his forces at<br />

Corinth, was formed by merely putting the last half <strong>of</strong> the alphabet<br />

first, that is, substituting M for A, N for B, O for C, etc. This<br />

dispatch fell into our hands and first reached Richmond in a northern<br />

newspaper.”<br />

Perhaps this quote refers to a long (5000-ish) word report <strong>of</strong> Beauregard’s<br />

sent on April 11th. Here is different, brief report <strong>of</strong> Beauregard’s, written<br />

during the battle, that has been enciphered via this method. Please<br />

decipher it.<br />

IQFTU EYADZ UZSMF FMOWQ PFTQQ ZQYKU ZEFDA ZSBAE UFUAZ UZRDA ZFARB<br />

UFFEN GDSMZ PMRFQ DMEQH QDQNM FFXQA RFQZT AGDEF TMZWE NQFAF TQMXY<br />

USTFK SMUZQ PMOAY BXQFQ HUOFA DKPDU HUZSF TQQZQ YKRDA YQHQD KBAEU<br />

FUAZX AEEAZ NAFTE UPQET QMHKU ZOXGP UZSAG DOAYY MZPQD UZOTU QRSQZ<br />

QDMXM EVATZ EFAZI TARQX XSMXX MZFXK XQMPU ZSTUE FDAAB EUZFA FTQFT<br />

UOWQE FARFT QRUST F<br />

18. Here are quotes in French. Use frequency analysis to decrypt them.<br />

(a) FU ALUHXYOL XY FBIGGY YMN ALUHXY YH WY KOCF MY WIHHUBUNCN<br />

GCMYLUVFY OH ULVLY HY MY WIHHUCN JUM GCMYLUVFY.<br />

(b) DXOLH XGHPH SODLQ GUHGH FHTXH ODURV HDGHV HSLQH VMHPH IHOLF<br />

LWHGH FHTXH OHSLQ HHVWV XUPRQ WHHGH URVHV HWGHF HTXLH OHEXL<br />

VVRQS RUWHG HIOHX UV.<br />

(c) VY AL N CNF ZBVAF QVAIRAGVBAF N OVRA NCCYVDHRE HAR CRAFRR DHR<br />

YBA GEBHIR QNAF HA YVIER DHN UNGRGER YR CERZVRE NHGRHE QR PRGGR<br />

CRAFRR.


1.7. EXERCISES 27<br />

(d) IKSUT JKIOT KYZWA ATKUK ABXKI USOWA KUAIN GIATL GOZYK YXNGZ<br />

URKYJ OLLKX KTZYR GYAXR GYIKT KKTNG HOZJX GSGZO WAKHX ORRKT<br />

ZVXKR GZYSO TOYZX KYIUT WAKXG TZYVU AXTUA YBORV KAVRK GYYOY<br />

GADJK XTOKX YXGTM YZXUA VKLAZ ORKKZ JKYMX GTJYX KHAZK KVGXT<br />

UAYJK THGYR GVOKI KKYZK IUAZK K.<br />

19. Here are several quotes in German. Use frequency analysis to decrypt<br />

them.<br />

(a) LQM XWTQBQS QAB SMQVM EQAAMVAKPINB EQM DQMTM LMZ PMZZMV XZW-<br />

NMAAWZMV AQKP MQVJQTLMV AWVLMZV MQVM SCVAB.<br />

(b) XL BLM UXLLXK WTL ZXKBGZLMX WBGZ OHG WXK PXEMD TEL XBGX ATEUX<br />

LMNGWX YNK ZXKBGZ ATEMXG.<br />

(c) YCQBJ UHLUH IJUXJ CQDRU IIUHT YUKDW BKSAI VQBBU PKLUH XKJUD<br />

YDTUH ZKDWU DTIYU PKUHJ HQWUD.<br />

20. Here are several quotes in Italian. Use frequency analysis to decrypt them.<br />

(a) LQR JLLNLJCX MJUU JVKRIRXWN BR LXWMDLN RW UDXPX MXEN WXW YDX<br />

YRD JUCX BJURA N YXR LXW VJBBRVX MJWWX MR LJMNAN WNLNBBRCJCX.<br />

(b) XTDPCL WL GZWRLCP P NTPNL RPYEP NSP AZY BFT DFP DAPCLYKP TY<br />

NZDP ELWT NSP W EPXAZ WP YP AZCEL DT CPAPYEP.<br />

(c) ES TWSLJAUW KA TWDDS W JAVWFLW EA KA EGKLJG UZW LJS IMWDDW<br />

NWVMLW KA NMGD DSKUASJ UZW FGF KWYMAJ DS EWFLW.<br />

21. What is the question that goes along with this quote Think frequency<br />

analysis.<br />

Upon this basis I am going to show you how a bunch <strong>of</strong> bright young<br />

folks did find a champion; a man with boys and girls <strong>of</strong> his own; a<br />

man <strong>of</strong> so dominating and happy individuality that Youth is drawn<br />

to him as is a fly to a sugar bowl. It is a story about a small town. It<br />

is not a gossipy yarn; nor is it a dry, monotonous account, full <strong>of</strong> such<br />

customary “fill-ins” as “romantic moonlight casting murky shadows<br />

down a long, winding country road.” Nor will it say anything about<br />

twinklings lulling distant folds; robins carolling at twilight, nor any<br />

“warm glow <strong>of</strong> lamplight” from a distant cabin window. No. It is<br />

an account <strong>of</strong> up-and-doing activity; a vivid portrayal <strong>of</strong> Youth as it<br />

is today; and a practical discarding <strong>of</strong> that worn-out notion that “a<br />

child don’t know anything.”<br />

22. Use frequency analysis to decrypt the following Caesar ciphers. They are<br />

a bit trickier.<br />

(a) W LWNWCNWLD SEPD JK AO EO ZEBBEYQHP PK YKJOPNQYP WJZ YKJBQOEJC<br />

PK YNULPWJWHUV<br />

(b) BLABX LOMZF DKFTL FDUOW ARDLB XMOUZ SMHLD KBABG XMDXL FFLDI<br />

UFTAZ LFTMF UEZAF ZLMDX KMEBA BGXMD NGFMO MDLRG XRDLC GLZOK<br />

MZMXK EUEOM ZEFUX XPLOA PLFTL YLEEM SL


28 CHAPTER 1. CAESAR CIPHERS<br />

(c) TWIPG TDUTG PCHBX TTXCV AITTI GHLXT WDJTA ITTXC VDTWI GHZCD<br />

LLWPT TWDHI AITTI GHPGI BPCNT XBIHX CKDAK IHTGX RZH<br />

(d) GDQDIB JM IJO GDQDIB OCVO DN RCVO D VNF DA ODN V NOVHK JA<br />

CJIJPM OJ NPWHDO OJ NGDIBN VIY VMMJRN RVAOY PN WT DGG RDIYN<br />

JM WMVIYDNC VMHN VB VDINO V AGJJY JA VAAGDXODJIN RCDXC WT JPM<br />

JKKJNDODJI DN NPWYPY YTDIB YMJRNDIB RVFDIB IJO<br />

7 7 6 23 0 2 7 3 15 19 3 0 9 18 14 6 2 7 0 3 0 15 5 2 9 0<br />

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<br />

Here are two ciphertexts to be decrypted. They are not Caesar Ciphers,<br />

but they are Caesar-like.<br />

(a) ZM ZNYZHHZWLI SZH ML MVVW LU HKRVH SRH XSZIZXGVI RH ZODZBH<br />

HZXIVW<br />

(b) The following was written by George Washington in 1799, describing<br />

to his spy Samuel Woodhull the invisible ink he was sending him.<br />

Use careful frequency analysis to determine how to decrypt this cipher.<br />

(You do not necessarily need to decipher the entire thing, but<br />

decipher the first several words and explain how you determined how<br />

to decipher it.)<br />

ETTLX AIXWL AWRUW RQIXE KA(WR BAABE TTLXE LLXAN AWMER GPNQM<br />

PACLQ ZYALL WRYMQ QR)WM MARLW RPXWE TRQ1D GCQTI ADDLX ATWOK<br />

WBWRR Q2WML XACQK RLANP ENLIX WCXNA RBANM LXAQL XANJW MWDTA<br />

GDIAL LWRYL XAPEP ANIWL XEZWR ADNKM XEZLA NLXAZ WNMLX EMDAA<br />

RKMAB ERBWM BNG<br />

28 7 4 7 12 0 4 0 6 1 5 22 13 12 1 6 10 17 0 8 1 0 21 17 3 4<br />

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


Chapter 2<br />

Cryptologic Terms<br />

Cryptography is the art or science <strong>of</strong> designing methods to send secret messages.<br />

(In Greek crypt or kryptos means “secret” or “hidden” and graphy<br />

means “writing”). Cryptologia, meaning “secrecy in speech”, and Cryptographia<br />

meaning “secrecy in writing” were used first by John Wilkens in<br />

his 1641 book “Mercury, <strong>of</strong> the Secret and the Swift Messenger,” the first English<br />

book about cryptography. Wilkins went on to be the first secretary <strong>of</strong><br />

the Royal Society, which he co-founded with John Wallis. The words took their<br />

modern forms, cryptology and cryptography, in 1645 and 1658, respectively.<br />

Cipher or cypher comes from the same Arabic word that also provides the<br />

root for zero, and has been used to mean a secret manner <strong>of</strong> writing in English<br />

since the 1500’s. Once we have a cipher algorithm, telling us which cipher<br />

is going to be used and how to use that cipher, and a key, we have a cipher<br />

system or cryptosystem. For example, in the Caesar cryptosystem, the<br />

algorithm is “shift the alphabet by a given amount” and the key is the amount.<br />

The sender composes the plaintext, the original message which understandable<br />

to all, uses the key to encipher it into the ciphertext, the “secret” version <strong>of</strong><br />

the message that is, hopefully, understandable only to those who have the key<br />

and are able to decipher the message back into plaintext.<br />

The word cryptanalysis was coined by William Friedman in 1923 and is the<br />

name for the art or science <strong>of</strong> reading another person’s message without the key.<br />

One decrypts a message and breaks a cipher system. While cryptography<br />

held its meaning, cryptology no longer refers to speech but is the name for the<br />

subject that combines cryptography and cryptanalysis. 1<br />

It has become traditional to attach the names Alice, Bob and sometimes Eve<br />

1 It will be clear that each <strong>of</strong> our secret messages is indeed a secret message. That is, we will<br />

not worry about keeping the existence <strong>of</strong> the secret message secret, but rather about keeping<br />

the meaning <strong>of</strong> the message secret. <strong>St</strong>enanography (Greek steganos, meaning covered, apparently<br />

first used by Trithemius in 1499) is the study <strong>of</strong> methods to keep the very existence<br />

<strong>of</strong> the secret message secret, and is clearly a very interesting subject to spies.<br />

29


30 CHAPTER 2. CRYPTOLOGIC TERMS<br />

to cryptography. As is seen in Figure 2.2, Alice takes plaintext and enciphers<br />

it to produce ciphertext that she then transmits. Bob, the intended receipient,<br />

presumably has the knowledge needed to decipher the ciphertext to obtain his<br />

copy <strong>of</strong> the plaintext. Eve, the eavesdropper, is without this knowledge, and so<br />

will try to break the encryption. 2<br />

Figure 2.1: Alice, Bob and Eve: the three names <strong>of</strong> Cryptography<br />

A cipher system is somewhat analogous to a high-school locker. That system<br />

consists <strong>of</strong> (1) a lock <strong>of</strong> some sort (a padlock or a keyed lock) with instructions on<br />

how to use such a device (turn the knob, turn the key), (2) the exact information<br />

<strong>of</strong> how to lock and unlock (the combination, the correct key), and the actual<br />

locker spacing holding books or gym shorts. In a cipher system (1) is the<br />

“algorithm”, (2) is the “key” and (3) is the message.<br />

Traditional cryptosystems are like the keyed lock system in that the enciphering<br />

and deciphering methods are very similar, once you have the key.<br />

(Hence the name “key”.) One must have the key to either encipher or decipher.<br />

Further, if you can either encipher or decipher, then you, in fact, must have the<br />

key and can do both.<br />

This differs from the padlock system, in which one only needs the key (for<br />

example, 24 left - 12 right - 19 left) to open the lock, but anyone can close<br />

it. Later we will study several modern cryptosystems that work in this way.<br />

Although it perhaps seems intuitively obvious that if someone can encipher a<br />

message they should also be able to decipher it, that is, in fact, not always the<br />

case. But this must wait for a later chapter.<br />

Experts differentiate between ciphers, when the message is made secret<br />

letter-by-letter a→D, b →E, c→F, etc, and codes, where the message is made<br />

secret word-by-word, bad→1211, ball→3214, bat→4790, etc. (or, occasionally,<br />

phrase-by-phrase). So one should speak and write <strong>of</strong> enciphering and<br />

deciphering when using a cipher, and encoding and decoding when using<br />

a code. However, code is much more pervasive in English than cipher, and<br />

people tend to use encoding or decode, when they really means enciphering<br />

and decipher. For this reason, books and movies that involve “Breaking the<br />

Code” probably are actually about breaking a cipher.<br />

2 Sometimes one speaks <strong>of</strong> Oscar, the opponent, rather than Eve.


Chapter 3<br />

The Introduction<br />

<strong>of</strong> Numbers<br />

“We shall see that cryptography is more than a<br />

subject permitting mathematical formulation, for<br />

indeed it would not be an exaggeration to state<br />

that abstract cryptography is identical with abstract<br />

mathematics.”<br />

A. Adrian Albert, 1941<br />

Pr<strong>of</strong>essor <strong>of</strong> Mathematics<br />

University <strong>of</strong> Chicago<br />

The Caesar Ciphers we studied in Chapter 1 were very easy to use, and<br />

seemed to <strong>of</strong>fer some secrecy. But we quickly found several ways to decrypt<br />

any message enciphered in this manner. What should we try to regain some<br />

secrecy The Caesar method <strong>of</strong> “shift by three” or “add three” having failed,<br />

to regain some secrecy we are going to try “multiply by three.”<br />

Before we can study this new method, we need to first carefully analyze<br />

our Caesar ciphers. Suppose our message is <strong>St</strong>op, Turn Back. To encipher it<br />

with a key <strong>of</strong> 3=D, we simply replace each letter in our message with the one<br />

three letters further down the alphabet. To be very explicit, we think <strong>of</strong> which<br />

position <strong>of</strong> the alphabet each letter is in (as in Figure 3.1), add three to that<br />

number, and use the letter in this latter number’s position. Of course, since we<br />

are comfortable with this process, we generally simply say “shift three” or “add<br />

three”.<br />

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<br />

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 26<br />

Figure 3.1: The <strong>St</strong>andard Translation <strong>of</strong> Letters into Numbers<br />

31


32 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

Example: Encipher <strong>St</strong>op, Turn Back with a shift <strong>of</strong> 3.<br />

We make a chart, giving the plaintext letters and their numerical equivalents.<br />

Then we add 3 to each number and translate back into letters:<br />

plaintext s t o p t u r n b a c k<br />

plainnumbers 19 20 15 16 20 21 18 14 2 1 3 11<br />

ciphernumbers 22 23 18 19 23 24 21 17 5 4 6 14<br />

ciphertext V W R S W X U Q E D F N<br />

The ciphertext is VWRS WXUQ EDFN.<br />

⋄<br />

What if we had shifted by a larger number<br />

Example: Encipher <strong>St</strong>op, Turn Back with a shift <strong>of</strong> 7.<br />

plaintext s t o p t u r n b a c k<br />

plainnumbers 19 20 15 16 20 21 18 14 2 1 3 11<br />

ciphernumbers 26 27 25 26 27 28 25 24 9 8 10 18<br />

ciphertext Z W X Y X I H J R<br />

Which letters are the 27th and 28th <strong>of</strong> the alphabet Since 27 follows 26, and<br />

26 represents Z, we start over again, and so the 27th letter <strong>of</strong> the alphabet is A,<br />

the 28th is B, and so on. So a shift <strong>of</strong> 7 gives the ciphertext ZAWX QBYX IJHF. ⋄<br />

We can now (tentatively) define the mathematical version <strong>of</strong> Shift ciphers.<br />

Mathematical Caesar Ciphers: To use a Caesar cipher<br />

1) Convert plainletters and keyletter into plainnumbers via Figure 3.1.<br />

2) Add the keynumber to each plainnumber.<br />

3) For plainnumbers larger than 26, replace 27 by A, 28 by B, 29 by C, etc.<br />

4) Convert the ciphernumbers into cipherletters.<br />

Example: Encipher Julius with a shift <strong>of</strong> 9.<br />

The ciphertext is SDURBD.<br />

plaintext j u l i u s<br />

plainnumbers 10 21 12 9 21 19<br />

ciphernumbers 19 30 21 18 30 28<br />

ciphertext S D U R D B<br />

⋄<br />

With the translation between letters and numbers now clear, we return to<br />

our goal <strong>of</strong> changing from “adding three” to “‘multiplying by three.”


3.1. THE REMAINDER OPERATOR 33<br />

Example: Encipher <strong>St</strong>op Turn Back with a multiplication <strong>of</strong> 3.<br />

We start as usual, by listing the letters <strong>of</strong> the message as well as their<br />

numerical values. But rather than adding three, we multiply these values by<br />

three.<br />

plaintext s t o p t u r n b a c k<br />

plainnumbers 19 20 15 16 20 21 18 14 2 1 3 11<br />

ciphernumbers 57 60 45 48 60 63 54 42 6 3 9 33<br />

ciphertext E H S V H K B P F C I G<br />

Turning this ciphernumbers back into letters takes a bit <strong>of</strong> work. Replacing 6<br />

by F and 3 by C was easy. Replacing 42 and 45 by G and J demands some<br />

counting, and figuring out what to do with 54, 57, 60 and 63 means we have<br />

to count through the alphabet two-and-a-half times. It’s a good thing we only<br />

multiplied by 3 and not 13!<br />

The answer is EHSV HKBP FCIG.<br />

⋄<br />

Was all the counting worth it Remember that a Caesar cipher is a weak<br />

cipher because <strong>of</strong> a lack <strong>of</strong> mixing – letters that are adjacent in the alphabet<br />

move to letters that are also adjacent. In the two <strong>St</strong>op Turn Back examples<br />

the letters rstu from the message became UVWX and YZAB, respectively, and<br />

abc similarly became DEF and HIJ. (In fact, I picked these words because <strong>of</strong><br />

the many consecutive letters.) A Caesar cipher succeeds only in shifting the<br />

aei, no, and rst-uvwxyz patterns, but does not destroy them. A better cipher<br />

should destroy these patterns and move the letters away from their neighbors.<br />

And our multiplication example did exactly this: the letters rstu became BEHK,<br />

and abc became CFI. Based on this one example, it appears that multiplication<br />

will provide more security than addition. 1<br />

So multiplication can produce a cipher system that is better than the Caesar<br />

ciphers – if we can find a quick way <strong>of</strong> turning large numbers into the equivalent<br />

letters <strong>of</strong> the alphabet. This must be our next goal.<br />

3.1 The Remainder Operator<br />

Which ciphernumbers will be converted to the cipherletter A Of course 1. Also<br />

27, since 27 is one more than once through the alphabet. Similarly 53 which is<br />

one more than twice through the alphabet. And 79, 105, . . . In fact, we could<br />

1 You may have wondered why <strong>Cryptology</strong> belongs to the field <strong>of</strong> Mathematics, rather than<br />

that <strong>of</strong> English. After all, a cipher is supposed the hide the meaning <strong>of</strong> the message, and<br />

surely English is about detecting the meanings <strong>of</strong> letters and words. Well, we’ve just seen the<br />

answer. The translation a=1, b=2, c=3, ... z=26, turns the subject <strong>of</strong> <strong>Cryptology</strong> into an area<br />

<strong>of</strong> mathematics. Similarly, once we’ve tried “add three” and “multiply by three”, almost any<br />

mathematical device that turns one number into another may be tried out as a enciphering<br />

method.


34 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

do this for every letter <strong>of</strong> the alphabet to come up with a table like<br />

A = 1 = 27 = 53 = 79 = . . .<br />

B = 2 = 28 = 54 = 80 = . . .<br />

C = 3 = 29 = 55 = 81 = . . .<br />

.<br />

Y = 25 = 51 = 77 = 103 = . . .<br />

Z = 26 = 52 = 78 = 104 = . . .<br />

We could continue this chart to handle the numbers like 195 and 208 that will<br />

occur when we encipher by multiplying by 13, but this seem quite cumbersome.<br />

Further, although it may not be readily apparent, there are really two questions<br />

lurking here. The first is one <strong>of</strong> conversion: how can we convert a number,<br />

say 54, into a number from 1 to 26 to see which letter it represents The second<br />

is one <strong>of</strong> equivalence: the numbers 54 and 28 and 2 are all equivalent because<br />

they all represent the letter b. What does this equivalence mean<br />

Let’s start with the conversion. Converting 54 to 2 is an operation, just<br />

as addition and multiplication are operations. What is involved is the number<br />

being operated on, 54, and the number doing the operating, which is 26 as<br />

there are twenty-six letters in the alphabet. To represent this operator we will<br />

borrow the symbol % from various programming languages and use it in the<br />

form 54%26 = 2. This is pronounced “fifty-four modulo twenty-six equals two.”<br />

Now how did we find the 2 from the 54 We knew that 28 and 2 both<br />

represent b, since 28 is 2 more than once through the alphabet. Numerically,<br />

28 = 2 + 26 or 28 − 26 = 2. Similarly, 54 = 28 + 26 is one more alphabet than<br />

28, which was b. So 54 must also be b. Or, working backwards, 54 − 26 = 28,<br />

28 − 26 = 2 and 2 = b, so 54 = b. Hence we found 2 from 54 by repeatedly<br />

subtracting 26’s until we obtained a number no bigger than 26. Of course, we<br />

can do this with any number.<br />

Examples: Compute the following numbers.<br />

(1) 32%26 =<br />

Since 32 − 26 = 6, the answer must be 6.<br />

(2) 39%26 =<br />

(3) 55%26 =<br />

Subtracting once gives 55−26 = 29. Since 29 is larger than 26 we subtract<br />

again, 29 − 26 = 3. So 55%26 = 3.<br />

(4) 79%26 =<br />

(5) 144%26 = 2<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

2 (2) 13, (4) 1, (5) 14.


3.1. THE REMAINDER OPERATOR 35<br />

Performing the %26 operation is not particularly difficult, but what if the<br />

number we are trying to reduce is 48924 Then repeatedly subtracting 26 is<br />

rather unappealing. Fortunately, we are not interested in the number <strong>of</strong> times<br />

we subtract 26, but rather in the number that is remaining when we are done.<br />

Just as multiplication is addition done quickly (4 × 3 just means 4 sets <strong>of</strong> 3, or<br />

3 added to itself 4 times), subtracting 26 many times is very closely connected<br />

to dividing by 26.<br />

To illustrate, we divide 85 by 26 using the form we learned as children:<br />

3 r = 7<br />

26 √ 85<br />

78<br />

7<br />

In multiplicative form this says 85 = 3 × 26 + 7. The 3 represents the quotient,<br />

how many times 26 goes into 85, and 7 is the remainder. Compare this with<br />

the subtraction method. 85%26 = Subtracting once: 85 − 26 = 59, and 59<br />

is larger than 26. Subtracting again: 59 − 26 = 33, still too large. Once more<br />

33 − 26 = 7. Small enough. So 85%26 = 7. Notice that the quotient 3 is the<br />

same as the number <strong>of</strong> subtractions, and that the remainder 7 is the same as<br />

the modulus answer.<br />

Let us try again with 109%26.<br />

4 r = 5<br />

26 √ 109<br />

104<br />

5<br />

so 109 = 4 × 26 + 5. On the other hand,<br />

109 − 26 = 83<br />

83 − 26 = 57<br />

57 − 26 = 31<br />

31 − 26 = 5.<br />

So 109%26 = 5. Again the quotient indicates how many 26’s need to be removed,<br />

and the remainder in the division gives the same result as the remainder<br />

operator.<br />

For numbers larger than about fifty the division method is generally quicker


36 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

than the subtraction method. For example, to compute 219%26:<br />

8 r = 15<br />

26 √ 219<br />

208<br />

15<br />

So 219%26 = 15 in much less time than 8 subtractions would have taken.<br />

Of course, the only people that do division in this form are school children<br />

– the rest <strong>of</strong> us use a calculator. With a calculator we see 85 ÷ 26 = 3.2692 and<br />

109÷26 = 4.1923 (rounding to four digits). The 3 and 4 represent the quotients.<br />

How do the fractional portions, .2692 and .1923, represent the remainders Since<br />

85 = 3 × 26 + 7, when we divide by 26 we have<br />

85<br />

26 = 3 + 7<br />

26 = 3.2692<br />

So 7 = .2692 or 7 = .2692 × 26. Similarly, 109 = 4 × 26 + 5 so<br />

26<br />

109<br />

26 = 4 + 5<br />

26 = 4.1923.<br />

Thus 5 = .1923 or 5 = .1923 × 26.<br />

26<br />

Notice that in both examples %26 gave the remainder when dividing by 26.<br />

For this reason we call % the remainder operator. We perform %26 by first<br />

dividing by 26 and then multiplying the decimal part <strong>of</strong> the answer by 26.<br />

Examples: Compute the following remainders.<br />

(1) 121%26 =<br />

121 ÷ 26 = 4.6538. The decimal is .6538, so the remainder is .6538 × 26 =<br />

17. Answer: 121%26 = 17.<br />

(2) 888%31 =<br />

What if the modulus is not 26 Then divide and later multiply by whatever<br />

the modulus is. 888 ÷ 31 = 28.6451, so the decimal is .6451 and<br />

remainder is .6451 × 31 = 20. Answer: 888%31 = 20.<br />

(3) 624%17 =<br />

624 ÷ 17 = 36.7059 has decimal .7059 and .7059 × 17 = 12. Answer:<br />

624%17 = 12.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄


3.1. THE REMAINDER OPERATOR 37<br />

As a bit <strong>of</strong> a time saver, notice that after doing the division you do not need<br />

to clear the screen (on your calculator) before punching in the decimal, but<br />

can instead subtract <strong>of</strong>f the quotient. For example, redoing 888%31, we have<br />

888 ÷ 31 = 28.6451. Subtract 28 to leave .6451 which we then multiply by 31. 3<br />

Examples: Compute the following remainders.<br />

(1) 424%26 =<br />

424/26 = 16.3077. Subtracting 16 leaves .3077. Answer is .3077 × 26 = 8.<br />

(2) 58%7 =<br />

58/7 = 8.2857 → .2857 × 7 = 2. Answer: 2.<br />

(3) 101%11 =<br />

(4) 2045%21 =<br />

(5) 48924%30 = 4<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

What about −29%12 Following our procedure (divide by 12, discard the<br />

quotient, multiply by 12) gives −5. Since the goal was a small positive number,<br />

we now simply add 12. So −29%12 = 7. In the shortcut notation, −29/12 =<br />

−2.4167 → −2.4167 + 2 = −.4167 → −.4167 × 12 = −5 → −5 + 12 = 7.<br />

Examples: Compute the following remainders.<br />

(1) −89%23 =<br />

−89/23 = −3.869 → −3.869 + 3 = −.869 → −.869 × 23 = −20 →<br />

−20 + 23 = 3. Ans: 3<br />

(2) −134%17 =<br />

(3) −748%73 = 5<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Let’s summarize our work.<br />

3 The presence <strong>of</strong> division, and the comment about rounding, might make one concerned<br />

about the validity <strong>of</strong> this algorithm. Indeed, calculators only hold so many digits, so error is<br />

possible, especially when a is very large. These are valid concerns, but ones we will not worry<br />

about.<br />

4 (4) 12, (5) 2, (6) 8, (7) 24<br />

5 (2) 2, (3) 55


38 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

The Remainder Operator: The symbol % is called the remainder<br />

operator. For a positive number n, and any number a, a%n is shorthand<br />

for the remainder when a is divided by n. We pronounce a%n as “a modulo<br />

n” or “a mod n” and say that n is the modulus.<br />

To compute a%n:<br />

1) Divide a by n.<br />

2) Remove the integer part <strong>of</strong> this quotient.<br />

3) Multiply this number by n.<br />

4) If the resulting number is negative, add n.<br />

5) The final number (perhaps rounded up or down to the obvious integer)<br />

is the answer a%n.<br />

3.2 Modular Arithmetic<br />

The translation <strong>of</strong> 54 to b had two related questions: how and what. Our<br />

work with the remainder operator answered how, so we now turn to what it<br />

means that 2 and 28 and 54 all represent b. Or, perhaps more accurately, the<br />

consequences <strong>of</strong> saying that 2 and 28 and 54 are all “equal.”<br />

We say that two numbers A and B are equivalent if they represent the same<br />

letter. With our work on %, we now know this means that A%26 = B%26.<br />

This last mathematical statement is a bit clunky and fortunately we have a<br />

replacement available. It was the great scientist Carl Fredrick Gauss 6 who chose<br />

the symbol ≡ to use in this situation: “We have adopted this symbol because<br />

<strong>of</strong> the analogy between equality and congruence.” Instead <strong>of</strong> A%26 = B%26 we<br />

will write A ≡ B (mod 26). The ≡ is the equivalence symbol, and this whole<br />

equation is pronounced “a is equivalent to b modulo 26” or “A is congruent to<br />

B modulo 26.”<br />

In 1801 Gauss published his great work on Number Theory, Disquisitiones<br />

Arithmeticae. It begins<br />

Section I. Congruent Numbers in General<br />

1. If a number a divides the difference <strong>of</strong> the numbers b and c, b and c<br />

are said to be congruent relative to a; if not, b and c are noncongruent.<br />

The number a is called the modulus. . . . Henceforth we shall designate<br />

congruence by the symbol ≡, joining to it in parentheses the modulus<br />

when it is necessary to do so; e.g. −7 ≡ 15(mod.11), −16 ≡ 9(mod.5).<br />

6 Carl Friedrich Gauss (1777-1855), “The Prince <strong>of</strong> Mathematicians,” is probably the greatest<br />

mathematician <strong>of</strong> all time. Simply a list <strong>of</strong> his major accomplishments would take most<br />

<strong>of</strong> this page, so we will restrict ourselves to a varied few. He gave the first pro<strong>of</strong> the the Law<br />

<strong>of</strong> Quadratic Reciprocity, the highlight <strong>of</strong> classical number theory; he calculated the orbit <strong>of</strong><br />

the asteroid Ceres, inventing the method <strong>of</strong> least-squares to do so; he invented the heliotrope<br />

while surveying the state <strong>of</strong> Hanover; he founded the mathematics subjects <strong>of</strong> differential<br />

geometry and non-Euclidean geometry; and invented a primitive telegraph device. Of all his<br />

work, Gauss was most proud <strong>of</strong> his discovery that a regular 17-gon could be drawn using only<br />

a compass and straight-edge, apparently asking that a heptadecagon be carved on his tombstone.<br />

This was the first advance in this field since the time <strong>of</strong> the Greeks, and came on March<br />

30th, 1796 when Gauss, only 18 at the time, was deciding between a career in mathematics<br />

or philology.


3.2. MODULAR ARITHMETIC 39<br />

While % and ≡ are very closely related, they have an important difference:<br />

% performs an operation and ≡ is a statement. The symbol % is an operation,<br />

like addition. It turns two numbers into a third. But ≡ is a true/false statement,<br />

like equals. The mathematical statement 7 = 9 is a false one, while 7 = 9 − 2 is<br />

a true one. Similarly, 28 ≡ 2 (mod 26) is true and 29 ≡ 2 (mod 26) is false.<br />

If A%n = B then A ≡ B (mod n). For example, 78%10 = 8 so 78 ≡ 8<br />

(mod 10). Conversely, if A ≡ B (mod n), then A%n = B%n. For example,<br />

31 ≡ 17 (mod 7) since 31%7 = 3 = 17%7. Notice, however, that 31%7 ≠ 17<br />

and 17%7 ≠ 31. So the “equivalence modulo” statement, ≡ (mod n), is slightly<br />

weaker than “ equal remainder,” %n =.<br />

For the next several chapters the remainder operator will dominate and it<br />

will be a while until we see how powerful equivalence is. But since we’ve done<br />

most <strong>of</strong> the work, let us state the following.<br />

Theorem 1 Suppose A and B are any integers, and n is a positive integer. We<br />

write A ≡ B (mod n) if any <strong>of</strong> the following equivalent statements are true:<br />

1. A%n = B%n.<br />

2. A and B have the same remainder when divided by n.<br />

3. n divides B − A with remainder 0.<br />

4. A and B differ by a multiple <strong>of</strong> n.<br />

Perhaps the language in the theorem is a bit unfamiliar. By “equivalent<br />

statements” we simply mean that when numerical values are substituted for A,<br />

B and n, then either all <strong>of</strong> the statements will be true, or all <strong>of</strong> them will be<br />

false. In less formal language, each statement contains the same information,<br />

they just present it in different ways. For example if A and B have the same<br />

remainder when divided by n, then A − B will have no remainder. So A − B<br />

will be a multiple <strong>of</strong> n, or A and B will differ by n.<br />

Doing algebra using ≡ is very similar to the algebra you are used to. In fact,<br />

+, −, × and the Associate, Commutative, and Distributive Rules all work using<br />

≡ just like they always did with =. Division, however, is more complicated, as<br />

the following examples show.<br />

Examples: Examples <strong>of</strong> Division in Modular Arithmetic.<br />

(1) 3x ≡ 9 (mod 7) has the usual solution x = 3.<br />

(2) 3x ≡ 9 (mod 12) has the usual solution x = 3, but also x = 7 and x = 11.<br />

(3) 3x ≡ 8 (mod 7) has the unusual solution x = 5.<br />

(4) 3x ≡ 8 (mod 12) has no solutions.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄


40 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

Why this happens is a very interesting question, but one that we will leave<br />

unanswered for the moment. What we do need to take away from this example<br />

instead is simply that division is more complicated in modular arithmetic. That<br />

is not to say that it cannot be done, but rather that we will have to be careful<br />

when we do it.<br />

3.3 Decimation Ciphers<br />

Before getting caught up with remainders and equivalence we were trying to<br />

build a cipher built on multiplication rather than addition, but had difficulty<br />

with translating the ciphernumbers back into cipherletters. With our work with<br />

the remainder operator, this is now easy.<br />

To use a Decimation Cipher:<br />

1) Choose a proper keynumber k.<br />

2) Convert the plaintext to plainnumbers.<br />

3) Multiply each number by k to produce ciphernumbers.<br />

4) Find the remainder %n <strong>of</strong> each ciphernumber.<br />

5) Convert the reduced cipher numbers back into letters.<br />

(We will study the meaning <strong>of</strong> “proper” in Chapter 4.)<br />

Examples: Enciphering using a Decimation 7 Cipher.<br />

(1) Encipher About Face using k = 5. (k for “key”.)<br />

We follow the steps given in the definition:<br />

plaintext a b o u t f a c e<br />

plain numbers 1 2 15 21 20 6 1 3 5<br />

multiplied numbers 5 10 75 105 100 30 5 15 25<br />

%26 5 10 23 1 22 4 5 15 25<br />

ciphertext E J W A V D E O Y<br />

The ciphertext is EJWAV DEOY.<br />

(2) Encipher Midnight using k = 5.<br />

(3) Encipher Revolution using k = 19. 8<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Recall that the weakness in the shift ciphers was that adjacent letters in<br />

the plaintext alphabet remained adjacent even after being enciphered. The<br />

7 Why “Decimation” It is not clear. In Roman times, to decimate your troops meant<br />

to have the troops choose one-tenth <strong>of</strong> their numbers by lots, and then kill those soldiers.<br />

Hopefully this cipher will not be that painful.<br />

8 (2) MSTRS INV, (3) DQBYT IPOYF


3.3. DECIMATION CIPHERS 41<br />

previous about face example shows that decimation ciphers apparently will<br />

not have this weakness. The adjacent letters ef and tu were enciphered to YD<br />

and VA, respectively, and the adjacent triple abc to EJO. In fact, if we go ahead<br />

and encipher the entire alphabet with key k = 5 we find the following cipher<br />

alphabet:<br />

plaintext<br />

ciphertext<br />

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<br />

E J O T Y D I N S X C H M R W B G L Q V A F K P U Z<br />

None <strong>of</strong> the letters are next to their former neighbors. 9 Decimation ciphers<br />

destroy letter ordering!<br />

We have not explained how to “properly” choose our keynumbers, but to see<br />

that there must be some care taken consider enciphering anna or bob using a<br />

decimation cipher with k = 2. The ciphertexts are BBBB and DDD, respectively.<br />

How would anyone decipher BBBB It is impossible to tell which B is an a and<br />

which is an n. So no one would be able to decipher a message whose enciphering<br />

key was 2. Hence, only certain keys can be used to multiply. In this chapter<br />

you will be given only proper keys, so we can safely put <strong>of</strong>f solving this problem<br />

until Chapter 4.<br />

Thus far we have enciphered letters and only letters. What if we wish to<br />

keep spacing Or to add punctuation in our messages The next examples will<br />

do that.<br />

Examples:<br />

(1) Work modulo 28 with key k = 5 to encipher a space here. Use the usual<br />

plainnumbers with the addition that = 27, where the symbol means<br />

“space”.<br />

We do this as we did before, being careful to find the remainders using 28<br />

rather than 26.<br />

plaintext a s p a c e h e r e<br />

plain numbers 1 27 19 16 1 3 5 27 8 5 18 5<br />

multiplied numbers 5 135 95 80 5 15 25 135 40 25 90 25<br />

%28 5 23 11 24 5 15 25 23 12 25 6 25<br />

ciphertext E W K X E O Y W L Y F Y<br />

The answer is EQAXE OYWLY FY.<br />

(2) Encipher no one here using the same method with key k = 9.<br />

9 The careful reader may notice an oddity in the last plaintext–ciphertext alphabet pair.<br />

(If you didn’t, try enciphering zzz using any key before reading further.) Since we think <strong>of</strong><br />

a as the first letter <strong>of</strong> the alphabet, z is the 26th. But 26 times any keynumber will be a<br />

multiple <strong>of</strong> 26, and so when divided by 26 it will have a remainder <strong>of</strong> 0. Since 0 is just before<br />

1, 0 must represent Z. Hence, z will always be enciphered into Z. Fortunately z is uncommon<br />

enough that this doesn’t really threaten the security <strong>of</strong> this cipher.


42 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

(3) Encipher one, two, three using the usual plainnumbers with = 27 and<br />

, =28. Use a decimation cipher modulo 29 with key k = 8.<br />

The first part <strong>of</strong> this one is set up for you.<br />

plaintext o n e , t w o , t h r e e<br />

plain numbers 15 14 5 28 27<br />

multiplied numbers 120 112 40 224 216<br />

%29 4 25 11 21 13<br />

ciphertext D Y K U M<br />

(4) Encipher I’m his, he’s mine using k = 7 in a a decimation cipher modulo<br />

30, where = 27, , = 28 and ’ = 29. 10<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

3.4 Deciphering Decimation Ciphers<br />

How do we decipher a message enciphered with a decimation cipher To decipher<br />

a shift cipher we simply subtracted the number that had been added.<br />

Since decimation ciphers involve multiplication, it seems that division must be<br />

the key to enciphering. Let’s look at the first example from Section 3.3.<br />

Example: Decipher EJWAV DEOY, whose enciphering key was k = 5<br />

We begin with the usual set-up. Since enciphering was done by multiplying<br />

by 5, we try here to decipher by dividing by 5.<br />

ciphertext E J W A V D E O Y<br />

ciphernumbers 5 10 23 1 22 4 5 15 25<br />

divided ciphernumbers 1 2 4.6 0.2 4.4 0.8 1 3 5<br />

plaintext a b a c e<br />

Several <strong>of</strong> the plaintext letters are correct, but which is the 4.6th letter <strong>of</strong><br />

the alphabet Or the .2th Simply dividing the ciphernumbers does not work.<br />

And the reason is clear: we shouldn’t be dividing the (reduced) ciphernumbers<br />

(5, 10, 23, 1, etc.), but rather the non-reduced ones (5, 10, 75, 105, etc.) And<br />

it’s not clear that we can determine what they were.<br />

⋄<br />

What we need is a way to “unmultiply,” or, to be more precise, to undo<br />

the multiplication modulo 26. We all know that to “unadd” we simply add the<br />

negative, also called the additive inverse. So to unmultiply we will need to<br />

multiply by the multiplicative inverse. Just as a number plus its additive inverse<br />

equals 0, the additive identity, a number times its multiplicative inverse<br />

equals 1, the multiplicative identity.<br />

10 (2) NWSWN QWPWV W, (3) DYKUM OJDUM OF,KK, (4) CXAIZ CMPIZ EXMIA CHE.


3.4. DECIPHERING DECIMATION CIPHERS 43<br />

To decipher a decimation cipher with key K we will need to find the inverse<br />

<strong>of</strong> K modulo 26 (the number that satisfies (K × )%26 = 1). It turns out<br />

that the inverse <strong>of</strong> 5 when working modulo 26 is 21: (5 × 21)%26 = 1. Since<br />

multiplying by 1 changes nothing, following a multiplication by 5 with another<br />

by 21 brings us back to our original message.<br />

The same is true for several other pairs <strong>of</strong> numbers. (The numbers that have<br />

multiplicative inverses are “proper” in the sense <strong>of</strong> the definition <strong>of</strong> Decimation<br />

ciphers on page 40.) We will learn how to produce these pairs in Chapter 4.<br />

For now, we simply list them.<br />

enciphering key 1 3 5 7 9 11 15 17 19 21 23 25<br />

deciphering key 1 9 21 15 3 19 7 23 11 5 17 25<br />

Figure 3.2: Enciphering/Deciphering pairs modulo 26.<br />

Notice that the deciphering key is seldom the same as the enciphering key. Do<br />

not make the mistake <strong>of</strong> simply reusing the enciphering key, or using its negative.<br />

A Decimation Cipher will only decipher properly when the correct key is used.<br />

Examples:<br />

(1) Decipher EJWAV DEOY, whose enciphering key was k = 5<br />

From Figure 3.2 the multiplicative inverse <strong>of</strong> 5 is 21. So if we multiply the<br />

ciphernumbers by 21 and then find their remainders mod 26 we should<br />

have our message back. Let’s see.<br />

ciphertext E J W A V D E O Y<br />

ciphernumbers 5 10 23 1 22 4 5 15 25<br />

×21 105 210 483 21 462 84 21 63 105<br />

%26 1 2 15 21 20 6 1 3 5<br />

plaintext a b o u t f a c e<br />

Multiplying by 21 really did undo the multiplication by 5 and so did<br />

decipher our message.<br />

(2) Decipher MKCCKFI, if the enciphering number was 7.<br />

The key was multiply by 7. However, if we try to divide by 7 to decipher<br />

we have troubles:<br />

ciphertext M K C C K F I<br />

ciphernumbers 13 11 3 3 11 6 9<br />

divide by 7 1.857 1.571 .429 .429 1.571 .857 1.286<br />

plaintext


44 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

Instead, we need to multiply by the inverse <strong>of</strong> 7, which from Figure 3.2 is<br />

15.<br />

ciphertext M K C C K F I<br />

ciphernumbers 13 11 3 3 11 6 9<br />

×15 195 165 45 45 165 90 135<br />

%26 13 9 19 19 9 12 5<br />

plaintext m i s s i l e<br />

This works much better. The answer is missile.<br />

(3) Decipher JCPCJS if the enciphering key was k = 9.<br />

(4) Decipher RDYRSCSPQ if enciphering key was k = 19.<br />

(5) Decipher AWVFWYKLC if the enciphering key was k = 11. 11<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

3.5 Multiplication vs. Addition<br />

We have seen that decimation ciphers cause letters which are adjacent in the<br />

plaintext alphabet to be separated in the ciphertext alphabet. How much does<br />

this improve security<br />

Consider the following ciphertext that was enciphered with a decimation<br />

cipher.<br />

UQESF YFTGW SGPVS PPVQX QEDGR PMQFP YJSFG EORVQ DQBQF PVQWO<br />

MRTQW PUOTT SPPOM QWOFE TIXQS FIMLQ DYJUY FXQDO FCW<br />

It has the letter frequency table<br />

0 1 1 4 4 9 4 0 2 2 0 1 4 0 6 9 13 3 6 5 3 4 5 3 4 0<br />

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<br />

There are no obvious places to fit the aei, no, rst and uvwxyz patterns. Nor,<br />

for that matter, any non-obvious place! Clearly our efforts to construct and<br />

understand the Decimation Ciphers have been fruitful – the techniques that<br />

allow us to decrypt Caesar ciphers no longer suffice.<br />

3.6 Koblitz’s Kid-RSA and Public Key Codes<br />

To demonstrate the powers <strong>of</strong> the ideas we’ve studied in this chapter we are going<br />

now to explain Neal Koblitz’s toy system, “Kid-RSA”. The RSA cryptosystem,<br />

due to Rivest, Shamir, and Adelman, is one <strong>of</strong> the most important systems<br />

11 (3) divide, (4) propagate, (5) subjugate.


3.6. KOBLITZ’S KID-RSA AND PUBLIC KEY CODES 45<br />

in use today. We will study it in Chapter 12. The Kid-RSA is a Decimation<br />

Cipher with a slightly complicated setup. It <strong>of</strong>fers no actual security, hence it<br />

is a “toy” system, but will allow us to introduce the concept <strong>of</strong> public keys.<br />

Set-up <strong>of</strong> Kid-RSA:<br />

1. Choose four integers, calling them a, b, A and B.<br />

2. Compute AB − 1 and call it M.<br />

3. Compute aM + A and bM + B and call them e and d, respectively.<br />

4. Compute (ed − 1)/M and call it n.<br />

Then e and d will serve as the enciphering and deciphering keys in a Decimation<br />

Cipher modulo n.<br />

A couple <strong>of</strong> examples will help clarify.<br />

Examples:<br />

(1) Suppose we choose a = 5, b = 7, A = 4 and B = 3. Then we compute the<br />

other parameters:<br />

M = AB − 1 = 11<br />

e = aM + A = 59 and d = bM + B = 80, and<br />

n = (ed − 1)/M = (59 · 80 − 1)/11 = 429.<br />

Now we encipher numerical as usual:<br />

plaintext n u m e r i c a l<br />

plainnumbers 14 21 13 5 18 9 3 1 12<br />

×59 826 1239 767 295 1062 531 177 59 708<br />

%429 397 381 338 295 204 102 177 59 279<br />

ciphertext 397 381 338 295 204 102 177 59 279<br />

Because we are working modulo 429 we cannot at this point reduce modulo<br />

26 to retrieve a ciphertext. Instead we simply use the reduced ciphernumbers<br />

as our ciphertext. So numerical is enciphered to 397, 381, 338,<br />

295, 204, 102, 177, 59, 279.<br />

To decipher we multiply by d and reduce modulo 429:<br />

ciphertext 397 381 338 295 204 102 177 59 279<br />

×80 31760 30480 27040 23600 16320 8160 14160 4720 22320<br />

%429 14 21 13 5 18 9 3 1 12<br />

plaintext n u m e r i c a l<br />

So we retrieve our plaintext numerical.


46 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

(2) Given a = 3, b = 9, A = 5 and B = 4,<br />

1. Compute M, e, d, and n.<br />

2. Encipher public.<br />

3. Decipher {111, 310, 408}. 12<br />

(3) Given a = 7, b = 2, A = 3, B = 6,<br />

1. Compute M, e, d, and n.<br />

2. Encipher private.<br />

3. Decipher {29, 108, 79, 194}. 13<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

While the setup <strong>of</strong> Kid-RSA is a bit <strong>of</strong> work, there is a very nice pay<strong>of</strong>f that<br />

we illustrate with names. Suppose Alice wishes others to be able to send her<br />

private messages. She (secretly) chooses values for a, b, A and B, and then<br />

computes M, e, d and n. (For this example we will assume e = 165, d = 121<br />

and n = 868.) Then she adds these public keys to her business cards<br />

Alice Anderson<br />

Phone: 1-800-CALL-ALC<br />

Email: alice a○mymail.com<br />

I use Koblitz’s Kid-RSA. My public<br />

keys are e = 165 and n = 868.<br />

and web page and her company’s contact information sheet. The reason for the<br />

name is now obvious: a public key is a key that is made known to the public.<br />

The value d Alice should keep secret and is called her private key.<br />

If Bob wants to send Alice a secret message, he first looks up her enciphering<br />

key and modulus. Then to say “Hi”, he computes<br />

plaintext h i<br />

plainnumbers 8 9<br />

×165 1320 1485<br />

%868 452 617<br />

and sends Alice the ciphertext {452, 617}. Notice that Bob didn’t need a, b,<br />

A or B to do this. Further, because Alice has previously computed d, she can<br />

quickly decipher the message.<br />

How does Kid-RSA differ from our earlier Decimation Ciphers For Alice<br />

and Bob to use a standard Decimation Cipher they must agree upon e, d and n.<br />

And they must keep these values private, for anyone who knows these numbers<br />

12 1. M = 19, e = 62, d = 175, n = 571, 2. {421, 160, 124, 173, 558, 186}, 3. key<br />

13 1. M = 17, e = 122, d = 40, n = 287, 2. {230, 187, 237, 101, 122, 144, 36}, 3. lock


3.6. KOBLITZ’S KID-RSA AND PUBLIC KEY CODES 47<br />

can read the ciphertext messages just as easily as Alice and Bob can. They are<br />

private keys. In particular, Alice and Bob cannot simply transmit these numbers<br />

to one another for fear that someone will eavesdrop on that transmission.<br />

A bit <strong>of</strong> thought shows this implies that for Alice and Bob to set up a method<br />

for exchanging secret messages, they must already be able to secretly exchange<br />

messages! 14<br />

A public key cryptosystem removes this difficulty. Bob and Alice need never<br />

have met, or have had contact <strong>of</strong> any kind. When, for whatever reason, Bob<br />

decides to send Alice a secret message he looks up her public key and enciphers<br />

using it. Similarly, if Alice wants to reply, she can look up Bob’s public key and<br />

use it.<br />

Example: Bob sends Alice the message “Part 1: Using your public key, the<br />

enciphering key was 517.<br />

Part 2: Message is ’Meet on WIFXSG’.” If Alice’s public key is based on a = 4,<br />

b = 5, A = 4 and B = 10, what day will they meet<br />

Doing the computations, d = 205 and n = 841. Since (205×517)%841 = 19,<br />

Bob used k = 19 to encipher WIFXSG. From Figure 3.2, using the key 11 will<br />

decipher the message. (You can now finish by deciphering the message.) 15 ⋄<br />

In order for a public key system to be secure it must be impossible, or at<br />

least really difficult, for someone to use the public information to determine the<br />

private information. If Ed, Alice’s enemy, notices that Bob sent her the message<br />

{452, 617}, how might he break it Ed can look up Alice’s public keys e and<br />

n just as Bob did. Can he use these numbers to compute her private key d If<br />

so, he simply deciphers the message.<br />

In this case, Ed knows that d is an integer, somewhere between 1 and n =<br />

868. As in the method <strong>of</strong> exhaustion for Caesar Ciphers, Ed could successively<br />

try d = 1, d = 2, d = 3, . . ., until the message pops out. And it would after at<br />

most 868 attempts. While this is too many computations to do by hand, it is<br />

a triviality for a computer. (Alice would be better <strong>of</strong>f to choose larger values<br />

for the parameters: a = 195, b = 191, A = 184 and B = 177 would lead to<br />

n = 1, 213, 027, 575, and a billion computations will take a bit more time, even<br />

by computer.)<br />

Is there another method Ed might use He knows the values <strong>of</strong> e and n,<br />

and wants a value d so that (d × e)%n = 1. The difficulty we had with the<br />

standard Decimation Ciphers (How do we determine the deciphering key from<br />

the enciphering key) is now supplying the security in the Kid-RSA! Overcoming<br />

this difficulty (and hence breaking the Kid-RSA) is the main goal <strong>of</strong> Chapter 4.<br />

14 Of course, Alice and Bob could either meet in person or would allow a trusted third party<br />

to carry the numerical keys from one <strong>of</strong> them to the other. But these are hardly practical<br />

solutions in general.<br />

15 Sunday.


48 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

3.7 Summary<br />

The mathematical operation underlying Caesar and Shift Ciphers is addition.<br />

Since these ciphers are insecure, it seems natural to try to build a cipher based<br />

on multiplication. These so-called Decimation Ciphers are somewhat more complicated,<br />

as they involve numbers much larger than 26 and it is not obvious how<br />

to determine their deciphering keys from their enciphering keys. On the other<br />

hand, they do not immediately fall prey to the type <strong>of</strong> frequency analysis that<br />

makes Caesar Ciphers insecure.<br />

To handle numbers larger than 26 we introduced the remainder operator<br />

%. For A and n integers, A%n is the remainder when A is divided by n. For<br />

positive A’s finding this value with a calculator is very quick: divide A by n,<br />

subtract the integer part <strong>of</strong> the result away, and then multiply by n.<br />

Using the remainder operator, Decimation Ciphers seem to be a fine replacement<br />

for our broken Caesar Ciphers. At least, the weakness that plagues those<br />

latter ciphers, adjacent letters being enciphered into adjacent letters, seems to<br />

not be a problem with our new ciphers.<br />

In Koblitz’s Kid-RSA, a somewhat fancy choice <strong>of</strong> the parameters produces<br />

a public key system. One party, “Alice”, makes certain keys public and keeps<br />

others private, and then other parties can use her public key(s) to send messages<br />

to Alice even if they have never met her. The implications <strong>of</strong> Public Key Codes<br />

are many and far reaching. Although the ideas behind public key codes did not<br />

coalesce until the 1970’s 16 , their advantages quickly became clear. Nearly all<br />

modern uses <strong>of</strong> cryptography now involve some combination <strong>of</strong> private key and<br />

public key cryptosystems.<br />

3.8 Topics and Techniques<br />

1. Why do we replace the letters <strong>of</strong> the alphabet with the numbers 1 through<br />

26<br />

2. Why must we consider numbers larger than 26 Give an example.<br />

3. What does A%n mean How do we determine which number this is<br />

4. What does A ≡ B (mod n) mean How do we determine if this equivalence<br />

is true<br />

5. What does it mean for two numbers to be equivalent<br />

6. What is a modulus<br />

7. What is a Decimation Cipher<br />

16 The first clear remarks along this line were made by Martin Hellman and Whitfield Diffie<br />

in 1976.


3.9. EXERCISES 49<br />

8. How do we encipher with a Decimation Cipher<br />

9. Is the deciphering process for a Decimation Cipher the same process as<br />

enciphering, or different Explain.<br />

10. How are the encipher key, deciphering key, and modulus in a Decimation<br />

Cipher related<br />

11. What is a multiplicative inverse<br />

12. Suppose we know a cipher is either a Caesar Cipher or a Decimation.<br />

Cipher. How can a frequency count help us determine which<br />

13. Can a frequency count help break a Decimation Cipher Explain.<br />

14. How many Decimation Ciphers are there modulo 26<br />

15. What does it mean to be a Public Key How does this differ from a<br />

Private Key<br />

16. What parts <strong>of</strong> the Kid-RSA are made public What parts are kept private<br />

17. How do Public Key systems differ from Private Key systems<br />

3.9 Exercises<br />

Show your work, and explain any non-standard steps.<br />

1. Find the following remainders.<br />

(a) 41%12.<br />

(b) 53%9.<br />

(c) 110%43.<br />

(d) 332%23.<br />

2. Find the following remainders.<br />

(a) 87%17.<br />

(b) 95%13.<br />

(c) 195%15.<br />

(d) 3389%201.<br />

3. Find the following remainders.<br />

(a) −8%10.<br />

(b) −37%11.<br />

(c) −621%34.


50 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

(d) −309%26.<br />

4. Find the following remainers.<br />

(a) 192%18.<br />

(b) 1829%82.<br />

(c) −381%91.<br />

(d) 8391%5.<br />

5. Test to see whether the following equivalence statements are true or not<br />

by computing the remainder <strong>of</strong> both sides.<br />

(a) 72 ≡ 44 (mod 19).<br />

(b) 87 ≡ 103 (mod 11).<br />

(c) 327 ≡ 199 (mod 32).<br />

(d) 411 ≡ 879 (mod 39).<br />

6. Encipher the following, using a Decimation Cipher modulo 26 with the<br />

given key.<br />

(a) Quotient, key = 11.<br />

(b) Remainder, key = 23.<br />

(c) Fraction, key = 5.<br />

(d) Integer, key = 19.<br />

7. Decipher the following words. They have been enciphered using a Decimation<br />

Cipher modulo 26 with the given key.<br />

(a) LOIAMCJ, key = 3.<br />

(b) UNGDL MADGK, key = 21.<br />

(c) QVOGH TQ, key = 17.<br />

(d) SOXSC XCY, key = 15.<br />

(e) MIRWBKP, key = 11.<br />

8. Sending a message asking for 5293 men is a lot easier than sending for five<br />

thousand two hundred and ninety-three men. One way to simplify the<br />

transmission <strong>of</strong> numbers is to let the numbers 0 to 9 stand for themselves<br />

in the plaintext, save 10 for space, use the numbers 11 to 36 to represent<br />

the letters <strong>of</strong> the alphabet, and work modulo 37. So a = 11, b = 12, . . ., z<br />

= 36, and for example, the numerical version <strong>of</strong> 10 to 15 people is then<br />

1 0 10 30 25 10 1 5 10 26 15 25 26 12 15.<br />

(a) Encipher 1 if by land using a Caesar Cipher with key 10.<br />

(b) Decipher TU2AK 2326G R7F. It was enciphered using a Caesar Cipher<br />

with key 29.


3.9. EXERCISES 51<br />

(c) Encipher 54 40 or fight using a Decimation Cipher with key 11.<br />

(d) Decipher EF2 G QOX3R It’s a Decimation Cipher with deciphering key<br />

5.<br />

(e) Decipher DRWEQ VAH. It’s a Decimation Cipher with deciphering key<br />

16.<br />

(f) Decipher 832Q3 AS35M 7. It’s a Decimation Cipher with deciphering<br />

key 28.<br />

9. The ASCII code (American <strong>St</strong>andard Code for Information Interchange) is<br />

commonly used method for translating letters and characters into numeric<br />

equivalents. Lower-case and upper-case letters have their own values, as do<br />

the numbers, punctuation marks, and other useful symbols. (The numbers<br />

0 to 32 represent computer controls – 9 is the tab key, for example, and<br />

do not much interest us.)<br />

ASCII Symbol ASCII Symbol ASCII Symbol ASCII Symbol<br />

0 NUL 32 (space) 64 @ 96 ‘<br />

1 SOH 33 ! 65 A 97 a<br />

2 STX 34 ” 66 B 98 b<br />

3 ETX 35 # 67 C 99 c<br />

4 EOT 36 $ 68 D 100 d<br />

5 ENQ 37 % 69 E 101 e<br />

6 ACK 38 & 70 F 102 f<br />

7 BEL 39 ’ 71 G 103 g<br />

8 BS 40 ( 72 H 104 h<br />

9 TAB 41 ) 73 I 105 i<br />

10 LF 42 * 74 J 106 j<br />

11 VT 43 + 75 K 107 k<br />

12 FF 44 , 76 L 108 l<br />

13 CR 45 - 77 M 109 m<br />

14 SO 46 . 78 N 110 n<br />

15 SI 47 / 79 O 111 o<br />

16 DLE 48 0 80 P 112 p<br />

17 DC1 49 1 81 Q 113 q<br />

18 DC2 50 2 82 R 114 r<br />

19 DC3 51 3 83 S 115 s<br />

20 DC4 52 4 84 T 116 t<br />

21 NAK 53 5 85 U 117 u<br />

22 SYN 54 6 86 V 118 v<br />

23 ETB 55 7 87 W 119 w<br />

24 CAN 56 8 88 X 120 x<br />

25 EM 57 9 89 Y 121 y<br />

26 SUB 58 : 90 Z 122 z<br />

27 ESC 59 ; 91 [ 123 {<br />

28 FS 60 < 92 \ 124 |<br />

29 GS 61 = 93 ] 125 }<br />

30 RS 62 > 94 ˆ 126 ˜<br />

31 US 63 95 127 DEL


52 CHAPTER 3. THE INTRODUCTION OF NUMBERS<br />

Figure 9. ASCII Code<br />

In the examples below, we use the ASCII code by first translating plaintext<br />

characters into their ASCII equivalents, perform some numerical operations<br />

on those equivalents modulo 128, and then send the numerical results<br />

as the ciphertext.<br />

For example, if doing a Caesar Cipher with key 3 on “$ = Dollars,”<br />

the ASCII form is 36 61 68 111 108 108 97 114 116 127, and shifting<br />

gives the ciphertext 39 64 71 114 111 111 100 117 119 2.<br />

(a) Encipher <strong>St</strong>alag 17 using a Caesar Cipher with key 90.<br />

(b) Decipher 5 5 110 33 67 60 65 51 66 110 33 66 64 55 62.<br />

It was enciphered with a Caesar Cipher with key 78.<br />

(c) Encipher 12 O’Clock High using a Decimation Cipher with key 17.<br />

(d) Decipher 46 40 24 75 93 91 103 102 92 107 24 103 110 93 106<br />

24 76 103 99 113 103. It was enciphering using a Caesar Cipher<br />

with key 120.<br />

(e) Decipher 7 61 112 32 90 45 47 97 74 32 119 100 74 97 97 100.<br />

It was enciphered using a Decimation Cipher. The deciphering key<br />

is 11.<br />

(f) Decipher 35 59 40 92. It was enciphered using a Decimation Cipher.<br />

The deciphering key is 27.<br />

(g) Decipher 13 7 58 98 3 109 120 124 96 43 124 96 124 120 87 96<br />

101 122 96 57 122 97 69 102 102 43 36. It was enciphered using a<br />

Decimation Cipher. The deciphering key is 35.<br />

(h) Decipher 42 26 121 48 121 38 68 92 32 104 101 58 28 121 53 73 13<br />

38 37 42 32 31 101 13 116 32 68 8 121 32 36 13 111 23 68 43 111<br />

23 32 1 101 38. It was enciphered using a Decimation Cipher. The<br />

deciphering key is 77.<br />

10. Roberta’s MRSA has parameters a = 5, b = 1, A = 6 and B = 7.<br />

(a) Find the other parameters.<br />

(b) Encipher privacy.<br />

(c) Decipher 133, 187, 141, 50, 137, 112, 137, 17, 71.<br />

(d) Nikki has looked up Roberta’s public key and has sent her the following<br />

two part message. Decipher it.<br />

First part: 21 187 50 17 137 133 50 71 141 71 46 137 100 21 162<br />

83 17 129 54 191 17 71 191 137 191 54<br />

Second part: QRCVC PWEMY OEYHE CZYIP HA.<br />

11. Henry’s MRSA has parameters a = 2, b = 6, A = 5 and B = 4.<br />

(a) Find the other parameters.


3.9. EXERCISES 53<br />

(b) Encipher secrecy.<br />

(c) Decipher 129, 111, 68, 258, 120, 172, 68, 59, 120, 43, 249.<br />

(d) Frita has sent Henry the following two-part message. The first part<br />

used Henry’s public key. Decipher both parts.<br />

First part: 129, 43, 215, 16, 43, 240, 206, 215, 7, 188, 43,<br />

16, 77.<br />

Second part: AOL IBASLY KPK PA.


54 CHAPTER 3. THE INTRODUCTION OF NUMBERS


Chapter 4<br />

The Euclidean Algorithm<br />

It is sometimes said that, next to the Bible, the<br />

“Elements” may be the most translated, published,<br />

and studied <strong>of</strong> all the books produced in<br />

the Western world.<br />

B. L. van der Waerden<br />

In Chapter 3 we developed Decimation Ciphers. By means <strong>of</strong> multiplication<br />

and the remainder operator these ciphers seem to <strong>of</strong>fer some degree <strong>of</strong> security.<br />

However, only some enciphering keys could be used, and it wasn’t clear how<br />

to determine the deciphering key from the enciphering key. Our work in this<br />

chapter is intended to surmount these difficulties.<br />

Let us start with a review in the form <strong>of</strong> a new cipher system.<br />

4.1 Linear Ciphers<br />

To try to make an even better cipher we might combine the two types <strong>of</strong> ciphers<br />

we’ve seen so far, by first multiplying and then adding.<br />

Caesar Cipher: Pick a keynumber c. Then enciphering is “Add c mod<br />

26”, that is, the message m becomes (m + c)%26.<br />

Decimation Cipher: Pick a (proper) keynumber k. Then enciphering is<br />

“multiply by k mod 26”, that is, the message m becomes (k × m)%26.<br />

Combining these, we define a linear cipher to be one that first multiplies and<br />

then adds.<br />

Linear Cipher: Pick a (proper) keynumber k and (any) keynumber c.<br />

Then enciphering is “multiply by k then add c mod 26”, that is, the<br />

message m becomes (k × m + c)%26.<br />

55


56 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

Examples:<br />

(1) Encipher multiply with key 7m + 2.<br />

Rather than just adding or multiplying we combine the two.<br />

plaintext m u l t i p l y<br />

plainnumbers 13 21 12 20 9 16 12 25<br />

×7 91 147 84 140 63 112 84 175<br />

+2 93 149 86 142 65 114 86 177<br />

%26 15 19 8 12 13 10 8 21<br />

ciphertext O S H L M J H U<br />

So the ciphertext is OSHLMJHU<br />

(2) Encipher decimate with key 5m + 8.<br />

(3) Encipher conquer with key 9m + 3. 1<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

4.2 GCD’s and the Euclidean Algorithm<br />

Our Decimation and Linear Ciphers have two problems: the enciphering key<br />

must be chosen “properly” (a term I still haven’t defined) and once it is chosen<br />

the corresponding deciphering key must somehow be determined. It is perhaps<br />

not surprising that the solutions to these two problems are related. However it<br />

is probably surprising that the solutions involve greatest common divisors and<br />

were known to Euclid, some 2500 years ago.<br />

Euclid (c. 350 B.C.E.) textbook, The Elements, is the most successful ever<br />

written, and, with The Bible, one <strong>of</strong> the most published books <strong>of</strong> all time,<br />

appearing in over 1000 editions. Euclid taught at the academy in Alexandria,<br />

but this is about all we know about his life. The Elements deals with plane<br />

and solid geometry and number theory, while other books <strong>of</strong> Euclid cover such<br />

topics as astronomy, mechanics, music, and optics.<br />

The Greatest Common Divisors, or gcd, <strong>of</strong> two integers is exactly what<br />

the name suggests: it is the largest integer that divides both. For example, 14<br />

is divisible by 1, 2, 7 and 14, while 10 is divisible by 1, 2, 5 and 10. The largest<br />

divisor that 14 and 10 have in common is 2, and so gcd(14, 10) = 2.<br />

For some reason most people seem able to rather automatically compute the<br />

gcd’s <strong>of</strong> small numbers.<br />

1 (2) BGWAU MDG, (3) DHYZJ VI.


4.2. GCD’S AND THE EUCLIDEAN ALGORITHM 57<br />

Examples: Compute the gcd’s.<br />

(1) gcd(35, 15).<br />

(2) gcd(20, 12).<br />

(3) gcd(21, 12).<br />

(4) gcd(16, 8).<br />

(5) gcd(22, 15). 2<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

To hint that there is a connection between gcd’s and the enciphering keys,<br />

recall from Figure 3.2 that modulo 26 the proper enciphering keys are 1, 3, 5,<br />

7, 9, 11, 15, 17, 19, 21, 23, and 25. In other words, the numbers from 1 to 26<br />

excluding the even numbers and 13, that is, excluding those numbers whose gcd<br />

with 26 is larger than 1.<br />

Although the gcd’s <strong>of</strong> small numbers are easy to compute, it is not obvious<br />

how to quickly compute the gcd <strong>of</strong> larger numbers, say gcd(182, 217). We next<br />

work to develop a method to do this. Euclid’s key observation was that gcd’s<br />

and the remainder operator are intimately related. Precisely, any number that<br />

divides both <strong>of</strong> the numbers a and b will also divide a%b. This is because, as<br />

we recall from Chapter 3, a%b = a − bq where q is the quotient, the integer<br />

part <strong>of</strong> a ÷ b. So if some number d divides both a and b, then it will divide<br />

a − bq = a%b. On the other hand, if a number d divides a%b and b then it will<br />

also divide a = a%b + bq. Since this is true for all divisors, it is certainly true<br />

for the largest divisor. Hence gcd(a, b) = gcd(b, a%b).<br />

For example, gcd(35, 15) = gcd(15, 35%15) = gcd(15, 5). In trading a 35<br />

for a 5 we’ve made our problem much simpler. Doing this again, gcd(15, 5) =<br />

gcd(5, 15%5) = gcd(5, 0). Since every number divides 0, the largest number<br />

that divides both 0 and 5 is the largest that divides 5, which is 5.<br />

Example: Use this method to compute gcd(69, 27).<br />

gcd(69, 27) = gcd(27, 69%27) = gcd(27, 15)<br />

= gcd(15, 27%15) = gcd(15, 12)<br />

= gcd(12, 15%12) = gcd(12, 3)<br />

= gcd(3, 12%3) = gcd(3, 0)<br />

= 3.<br />

So gcd(69, 27) = 3. Of course, we’d probably abbreviate this as<br />

gcd(69, 27) = gcd(27, 15) = gcd(15, 12) = gcd(12, 3) = gcd(3, 0) = 3.<br />

⋄<br />

2 (1) 5, (2) 4, (3) 3, (4) 8, (5) 1.


58 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

The individual computations are not difficult, but the continual swapping <strong>of</strong><br />

gcd entries, as well as the rewriting <strong>of</strong> “gcd” is a bit much. In addition while<br />

we have kept the remainder information, we have lost the quotients that we will<br />

soon need. So we are going to introduce a more compact way <strong>of</strong> presenting this<br />

computation, perhaps due to [Glasby].<br />

To see how this is built, consider gcd(69, 27) = gcd(27, 69%27). The remainder<br />

69%27 is 15, and the quotient <strong>of</strong> 69 ÷ 27 is 2. So we write<br />

q<br />

r 69<br />

2<br />

27 15<br />

where q and r remind us which line contains the quotient and which the remainder.<br />

Similarly, for gcd(27, 15) = gcd(15, 27%15) we write<br />

q<br />

r 17<br />

1<br />

15 12<br />

since the quotient <strong>of</strong> 27 ÷ 15 is 1 and the remainder is 12.<br />

The advantage <strong>of</strong> this representation is that<br />

,<br />

q<br />

r 69<br />

2<br />

27 15<br />

and<br />

q<br />

r 17<br />

1<br />

15 12<br />

may be combined as<br />

q<br />

r 69<br />

Adding the 12 ÷ 3 results then gives<br />

2<br />

27<br />

1<br />

15 12<br />

.<br />

q<br />

r 69<br />

2<br />

27<br />

1<br />

15<br />

1<br />

12<br />

4<br />

3 0<br />

.<br />

Examples:<br />

(1) Compute gcd(15, 85).<br />

For this first example we work one division step at a time and write in<br />

bold the numbers added at each step.<br />

Enter the two numbers, larger one first:<br />

q<br />

r 85 15<br />

from 85 ÷ 15:<br />

from 15 ÷ 10:<br />

from 10 ÷ 5:<br />

q<br />

r 85<br />

q<br />

r 85<br />

q<br />

r 85<br />

5<br />

15<br />

5<br />

15<br />

1<br />

10<br />

5<br />

15 10<br />

1<br />

10 5<br />

2<br />

5 0<br />

The gcd is the final non-zero remainder. So gcd(15, 85) = 5.


4.3. MULTIPLICATIVE INVERSES 59<br />

(2) Find gcd(79, 201).<br />

q<br />

r 201<br />

2<br />

79<br />

1<br />

43<br />

1<br />

36<br />

5<br />

7<br />

7<br />

1 0<br />

gcd(79, 201) = 1.<br />

(3) Find gcd(182, 217).<br />

q<br />

r 182<br />

1<br />

35<br />

5<br />

7 0<br />

gcd(217, 182) = 5.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

This process is called the Euclidean Algorithm, 3 and the general rule is that<br />

at any stage <strong>of</strong> four numbers in a triangle<br />

a<br />

q<br />

b<br />

we have q = a ÷ b, the quotient <strong>of</strong> the division, and r = a%b, the remainder.<br />

Even for large numbers the Euclidean Algorithm takes relatively few steps. 4<br />

r<br />

,<br />

Example: Compute gcd(191, 156)<br />

q<br />

r 191<br />

1<br />

156<br />

4<br />

35<br />

2<br />

16<br />

5<br />

3<br />

3<br />

1 0<br />

gcd(191, 156) = 1.<br />

⋄<br />

Being that this is math book, we should justify the algorithm, that is, explain<br />

how we know it always works. Fortunately this is easy. We know that gcd(a, b) =<br />

gcd(b, a%b), so by letting r = a%b, each consecutive pair <strong>of</strong> numbers in the “r<br />

line” has the same gcd. Since a > b > r ≥ 0, the values in the r line are<br />

positive but shrinking, so the algorithm must end. And when it does it, with<br />

a 0, because gcd(r, 0) = r the final non-zero entry equals the gcd <strong>of</strong> any two<br />

consecutive values in the line, in particular, the first two values in the line.<br />

4.3 Multiplicative Inverses<br />

For us to fully understand the multiplicative ciphers, decimation and linear, we<br />

need to know how to get from enciphering key to deciphering key. An extension<br />

3 An algorithm is a step-by-step procedure that solves a particular problem or produces<br />

some desired outcome. The word comes from the name <strong>of</strong> Mohammed ibn-Muse al-Khwarizmi,<br />

a mathematician in the royal court <strong>of</strong> Bagdad c. 800 A.D. Algebra likely also comes from his<br />

name.<br />

4 A theorem named for Gabriel Lamé, a French engineer, physicist and mathematician, says<br />

that the number <strong>of</strong> divisions needed to find the greatest common divisor <strong>of</strong> two numbers is<br />

no more than five times the number <strong>of</strong> decimal digits in the smaller <strong>of</strong> the two numbers.


60 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

<strong>of</strong> the Euclidean Algorithm will do this for us.<br />

For example, suppose we had used k = 9 as our multiplicative key (modulo<br />

26). To decipher we need to use the key c satisfying (9c)%26 = 1, or, equivalently,<br />

9 × c ≡ 1 (mod 26). To find c we extend Euclid’s Algorithm by adding a<br />

new line, a “coefficient line,” that begins with a 0 and a 1 and is continued by<br />

the formula<br />

old c − current q × current c = new c.<br />

Examples:<br />

(1) Find gcd(9, 26) and the inverse <strong>of</strong> 9 modulo 26.<br />

For this example we will first work one step at a time.<br />

Begin with gcd entries and 0 and 1:<br />

From 26 ÷ 9,<br />

From 9 ÷ 8,<br />

From 8 ÷ 1,<br />

{<br />

q = 2, r = 8, and<br />

0 − (2 × 1) = −2 :<br />

{<br />

q = 1, r = 1, and<br />

1 − (1 × −2) = 3 :<br />

{<br />

q = 8, r = 0, and<br />

2 − (8 × 3) = −26 :<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

26<br />

0<br />

26<br />

0<br />

26<br />

0<br />

26<br />

0<br />

2<br />

9<br />

1<br />

2<br />

9<br />

1<br />

2<br />

9<br />

1<br />

9<br />

1<br />

8<br />

-2<br />

1<br />

8<br />

−2<br />

1<br />

8<br />

−2<br />

1<br />

3<br />

8<br />

1<br />

3<br />

0<br />

-26<br />

Just as the final (non-zero) entry in the remainder line is the gcd, the entry<br />

in the coefficient line under the gcd gives us the solution to 9 × x ≡ gcd<br />

(mod 26). So 9 × 3 ≡ 1 (mod 26). (The −26 at the end <strong>of</strong> the coefficient<br />

line is ignored.)


4.3. MULTIPLICATIVE INVERSES 61<br />

(2) Compute gcd(12, 45) and find a solution to 12x ≡ gcd (mod 45).<br />

From 45 ÷ 12,<br />

From 12 ÷ 9,<br />

From 9 ÷ 3,<br />

{<br />

q = 3, r = 9, and<br />

0 − (3 × 1) = −3 :<br />

{<br />

q = 1, r = 3, and<br />

1 − (1 × −3) = 4 :<br />

{<br />

q = 3, r = 0, and<br />

−3 − (3 × 4) = −15 :<br />

Setup:<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

q<br />

r<br />

c<br />

45<br />

0<br />

45<br />

0<br />

45<br />

0<br />

45<br />

0<br />

12<br />

1<br />

3<br />

12<br />

1<br />

3<br />

12<br />

1<br />

3<br />

12<br />

1<br />

9<br />

-3<br />

1<br />

9<br />

−3<br />

1<br />

9<br />

−3<br />

3<br />

4<br />

3<br />

3<br />

4<br />

0<br />

So gcd(12, 45) = 3 and x = 4 is a solution to 12x ≡ gcd (mod 45), which<br />

we can check by seeing that (12 × 4)%45 = 3%45. (The entry in the<br />

coefficient row under the final remainder <strong>of</strong> 0 is ignored, so we didn’t<br />

bother to enter it.)<br />

(3) Compute gcd(27, 50) and find a solution to 27x ≡ gcd (mod 50).<br />

q<br />

r<br />

c<br />

50<br />

0<br />

1<br />

27<br />

1<br />

1<br />

23<br />

−1<br />

5<br />

4<br />

2<br />

1<br />

3<br />

−11<br />

3<br />

1<br />

13<br />

0<br />

So gcd(27, 50) = 1. Since −11 ≡ 39 (mod 50), we have 27 × 39 ≡ 1<br />

(mod 50).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

As we’ve seen, gcd(a, n) always divides (ab)%n, for any choice <strong>of</strong> integer b.<br />

That is, (ab)%n is always a multiple <strong>of</strong> gcd(a, n). So for there to be a solution<br />

x to ax%n = 1 we must have gcd(a, n) = 1. And if so, then the solution x is<br />

found in the coefficient line.<br />

These concepts are important enough that they have names. If two numbers<br />

have a gcd <strong>of</strong> 1, they are said to be relatively prime. And when two numbers<br />

a and n are relatively prime then they each have a multiplicative inverse<br />

with respect to the other – there are solutions x and y to (ax)%n = 1 and<br />

(ny)%a = 1.


62 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

Before summarizing, let’s do a couple more examples.<br />

Examples:<br />

(1) Does 7 have a multiplicative inverse modulo 26 If so, what is it<br />

This is asking us to find gcd(7, 26). If the gcd is 1, then we may solve<br />

7x ≡ 1 (mod 26).<br />

q<br />

r<br />

c<br />

26<br />

0<br />

3<br />

7<br />

1<br />

1<br />

5<br />

−3<br />

2<br />

2<br />

4<br />

2<br />

1<br />

−11<br />

0<br />

Since gcd(7, 26) = 1, 7 and 26 are relatively prime and 7 does have a<br />

multiplicative inverse modulo 26. It is −11 or its positive version 15<br />

(since −11 ≡ 15 (mod 26)). Thus 7 may be used as the multiplicative<br />

enciphering key in a decimation or linear cipher, and 15 will be (part <strong>of</strong>)<br />

the deciphering key.<br />

(2) Does 8 have a multiplicative inverse modulo 26 If so, what is it<br />

q<br />

r<br />

c<br />

26<br />

0<br />

3<br />

8<br />

1<br />

4<br />

2<br />

−3<br />

0<br />

Since gcd(8, 26) = 2 is not 1, 8 and 26 are not relatively prime, and so<br />

there is no multiplicative inverse for 8. Hence 8 may not be used as the<br />

multiplicative enciphering key in a Decimation or Linear Cipher.<br />

(3) Find gcd(49, 13) and, if possible, solve 13x ≡ 1 (mod 49)<br />

q<br />

r<br />

c<br />

49<br />

0<br />

3<br />

13<br />

1<br />

1<br />

10<br />

−3<br />

3<br />

3<br />

4<br />

1<br />

1<br />

−12<br />

0<br />

gcd(49, 13) = 1 so they are relatively prime and since −12 ≡ 37 (mod 49),<br />

the inverse <strong>of</strong> 13 modulo 49 is 37.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Euclid’s Extended Algorithm is quite simple. Nonetheless it is very powerful.<br />

Let’s end this section by summarizing it and some <strong>of</strong> its consequences.<br />

Because we will mostly be using it for computing a deciphering key from a<br />

known enciphering key k and modulus n, we state it in terms <strong>of</strong> k and n.


4.4. DECIPHERING DECIMATION AND LINEAR CIPHERS 63<br />

Theorem 2 (The Extended Euclidean Algorithm) Given two integers n<br />

and k with n > k, construct the table<br />

q<br />

r<br />

c<br />

n<br />

0<br />

⋆<br />

k<br />

1<br />

· · ·<br />

· · ·<br />

· · ·<br />

∗<br />

q<br />

by, at each step, from<br />

form<br />

a b<br />

a b r<br />

α β<br />

α β α − qβ<br />

quotient and r the remainder are computed from a ÷ b. Then<br />

⋆<br />

g<br />

d<br />

0<br />

where q the<br />

1. This process eventually terminates by producing a 0 in the “remainder”<br />

line.<br />

2. The last non-zero entry in the remainder line is gcd(n, k).<br />

3. At each step, β × k ≡ b (mod n). In particular, if d is the entry in the<br />

coefficient line directly below the gcd g = gcd(n, k), then a × d ≡ gcd(n, k)<br />

(mod n).<br />

4. When n and k are relatively prime, d is the inverse <strong>of</strong> i modulo n.<br />

We haven’t formally proven all <strong>of</strong> this important theorem, although all <strong>of</strong><br />

the necessary ingredient have been stated. See any text on number theory, such<br />

as [KRosen], for the missing parts. Nonetheless, the theorem does explain the<br />

oddities in division we noticed at the end <strong>of</strong> Section 3.2.<br />

Examples: Examples <strong>of</strong> Division in Modular Arithmetic.<br />

(1) 3x ≡ 9 (mod 7) has the usual solution x = 3.<br />

Since gcd(7, 3) = 1 divides 9 there is exactly gcd = 1 solution.<br />

(2) 3x ≡ 9 (mod 12) has the usual solution x = 3, but also x = 7 and x = 11.<br />

Since gcd(12, 3) = 3 divides 9 there are gcd = 3 solutions.<br />

(3) 3x ≡ 8 (mod 7) has the unusual solution x = 5.<br />

Since gcd(7, 3) = 1 divides 8 there is gcd = 1 solution.<br />

(4) 3x ≡ 8 (mod 12) has no solutions.<br />

Since gcd(12, 3) = 3 doesn’t divide 8 there are no solutions.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

4.4 Deciphering Decimation and Linear Ciphers<br />

We now finally understand what needs to be “proper” about the multiplying<br />

keynumbers in Decimation and Linear Ciphers. When we work modulo 26,


64 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

in order for the multiplicative keynumber number k to have a multiplicative<br />

inverse, its greatest common divisor with 26 must be 1. And if so, the Extended<br />

Euclidean Algorithm computes the multiplicative inverse <strong>of</strong> k. This allows us<br />

to finalize our description <strong>of</strong> the multiplicative ciphers.<br />

Computing Keys for Decimation and Linear Ciphers:<br />

1) Pick an integer k.<br />

2) Use the Euclidean Algorithm to check that gcd(k, N) = 1.<br />

3) If not, pick a new k.<br />

4) If so, use the Euclidean Algorithm to find the inverse d. (If d is<br />

negative, use N + d instead.)<br />

Examples:<br />

(1) Decipher OXXMT MEB. It was enciphered with key 19m + 12 modulo 26.<br />

A Linear Cipher first multiplies and then divides. To undo this we must go<br />

backwards: first subtract and then “divide.” Dividing, <strong>of</strong> course, means<br />

multiplying by the inverse <strong>of</strong> 19 modulo 26, which from Figure 3.2 is 11.<br />

ciphertext O X X M T M E B<br />

ciphernumbers 15 24 24 13 20 13 5 2<br />

−12 3 12 12 1 8 1 -7 -10<br />

×11 33 132 132 11 88 11 -77 -110<br />

%26 7 4 4 9 20 9 15 14<br />

plaintext a d d i t i o n<br />

The answer is addition.<br />

(2) Decipher FRGPN I. The enciphering key was 14 modulo 27.<br />

First we need to find the inverse <strong>of</strong> 14 modulo 27:<br />

q<br />

1 1 1<br />

r<br />

c<br />

27<br />

0<br />

14<br />

1<br />

13<br />

−1<br />

The inverse is 2. So we decipher by multiplying by 2 modulo 27.<br />

The answer is linear.<br />

1<br />

2<br />

ciphertext F R G P N I<br />

ciphernumbers 6 18 7 16 14 8<br />

×2 12 36 14 32 28 16<br />

%27 12 9 14 5 1 16<br />

plaintext l i n e a r<br />

(3) May 13 be used as the multiplicative part <strong>of</strong> a key in a Decimation or<br />

Linear Cipher modulo 33<br />

Yes: gcd(33, 13) = 1. (We didn’t even need Euclid’s Algorithm for this<br />

one!)<br />

0


4.5. BREAKING DECIMATION AND LINEAR CIPHERS 65<br />

(4) Decipher JWNIC G. It was enciphered with the Linear Cipher 13m + 4<br />

modulo 33.<br />

Ok, now we do need Euclid’s algorithm:<br />

q<br />

r<br />

c<br />

33<br />

0<br />

2<br />

13<br />

1<br />

1<br />

7<br />

−2<br />

1<br />

6<br />

3<br />

6<br />

1<br />

−5<br />

0<br />

Since −5%33 = 28 the inverse <strong>of</strong> 13 is 28.<br />

subtracting by 4 and multiplying by 28. 5<br />

Now we may proceed by<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

As one last example, recall from Chapter 3 that the Kid-RSA cipher has<br />

as public information an enciphering key e and modulus n. In order for this<br />

cipher to be worthwhile, it must be infeasible for an adversary to compute the<br />

secret deciphering key d from the public keys e and n. Because <strong>of</strong> the Euclidean<br />

Algorithm, not only is computing d not infeasible, it is simple.<br />

To illustrate, if Albert has published e = 893 and n = 8106 as his public<br />

keys, we simply compute gcd(8106, 893):<br />

q<br />

r<br />

c<br />

8106<br />

0<br />

9<br />

893<br />

1<br />

12<br />

69<br />

−9<br />

1<br />

65<br />

109<br />

16<br />

4<br />

−118<br />

4<br />

1<br />

1997<br />

0<br />

So in a very few steps, the “secret” deciphering key is d = 1997. Even though<br />

there is no real security in Koblitz’s system, it did allow us to introduce the<br />

important concepts related to public keys.<br />

4.5 Breaking Decimation and Linear Ciphers<br />

Earlier we saw that decimation and linear ciphers cause letters which are adjacent<br />

in the plaintext alphabet to be separated in the ciphertext alphabet. How<br />

much does this improve security Consider the ciphertext from Section 3.5 that<br />

was enciphered with a linear cipher.<br />

UQESF YFTGW SGPVS PPVQX QEDGR PMQFP YJSFG EORVQ DQBQF PVQWO<br />

MRTQW PUOTT SPPOM QWOFE TIXQS FIMLQ DYJUY FXQDO FCW<br />

It has the following letter frequency table.<br />

5 cipher.<br />

0 1 1 4 4 9 4 0 2 2 0 1 4 0 6 9 13 3 6 5 3 4 5 3 4 0<br />

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


66 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

As we saw in Chapter 3 this is not a Caesar cipher; none <strong>of</strong> the standard hill and<br />

valley patterns can be found in the frequency count. Are there any new patterns<br />

that might replace our old ones To find out, study carefully the following two<br />

plaintext/ciphertext alphabet pairs:<br />

Key k = 5 :<br />

plaintext<br />

ciphertext<br />

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<br />

E J O T Y D I N S X C H M R W B G L Q V A F K P U Z<br />

Key k = 3m + 4:<br />

plaintext<br />

ciphertext<br />

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<br />

E H K N Q T W Z C F I L O R U X A D G J M P S V Y B<br />

In the first, we have a → E, b→ J, c→ O, and while abc are consecutive, EJO<br />

are not; they are 5 letters apart. In fact, any two consecutive plaintext letters<br />

are sent to ciphertext letters five letters apart. The multiplicative key <strong>of</strong> 5<br />

apparently spreads out the letters by a factor <strong>of</strong> 5. Why is this Two consecutive<br />

plaintext letters will have plainnumbers that differ by one, say α and α + 1.<br />

When enciphered the (unreduced) ciphernumbers are 5α and 5α + 5, which<br />

differ by 5.<br />

Does the same work for the linear cipher k = 3m + 4 (Check it and<br />

see!) 6 At first glance it seems that Decimation and Linear ciphers do a good<br />

job <strong>of</strong> “unordering” the plain alphabet, mixing it up well. But these examples<br />

should convince us that this is not so. In fact, the rule is that the distance<br />

consecutive plain alphabet letters are spread apart equals the multiplicative key<br />

<strong>of</strong> the cipher.<br />

We can use this idea to decrypt our ciphertext. In our unsolved cipher, B<br />

and U are the two most common letters in the ciphertext: perhaps they are e<br />

and t, respectively Since a linear cipher has the formula mk + c, so guessing<br />

that B = e tells us 5k + c ≡ 2 and guessing U = t gives us 2km + c ≡ 21, both<br />

equations modulo 26. So c ≡ 2 − 5k and c ≡ 21 − 20k. Setting these equal gives<br />

20k − 21 ≡ 5k − 2 or 15k ≡ 19. From Figure 3.2 the inverse <strong>of</strong> 15 is 7. So if<br />

we multiply both sides <strong>of</strong> 15k ≡ 19 by 7, since 15 × 7 ≡ 1 and 19 × 7 ≡ 3, we<br />

are left with k ≡ 3. Finally, from 5k + c ≡ 2 and k = 3, we can substitute and<br />

solve to see that c = 13. Thus the original cipher was a linear cipher with rule<br />

3k + 13. We can then simply decipher the message. 7<br />

Now this only worked because we were lucky enough to guess both e and<br />

t. However, a cipher that is easily broken once your enemy correctly guesses<br />

only two letters is probably not a very strong one. Just as Caesar ciphers<br />

proved to be weak because they do not separate adjacent letters in the plaintext<br />

alphabet, Decimation and Linear ciphers are weak because the plaintext letters<br />

are enciphered using an easily recognized pattern.<br />

6 Yes. The letters are spread out by a factor <strong>of</strong> 3 and then shifted 4 more letters down the<br />

alphabet.<br />

7 We can only say that the decryptment <strong>of</strong> any cipher, even the simplest, will<br />

at times include a number <strong>of</strong> wonderings. Helen Fouché Gaines.


4.6. SUMMARY 67<br />

To put it more bluntly, guessing one letter correctly allows us to break Caesar<br />

ciphers. Guessing two letters correctly allows us to break Decimation and Linear<br />

ciphers.<br />

4.6 Summary<br />

A Linear Cipher is a combination <strong>of</strong> a Decimation and a Shift Cipher, and<br />

so has both a multiplicative and an additive key. The additive key can be<br />

chosen at random, like in a Shift Cipher, but, like in a Decimation Cipher, the<br />

multiplicative key must be chosen so that it is relatively prime to the modulus.<br />

A relatively quick way <strong>of</strong> computing greatest common divisors is with the<br />

Euclidean Algorithm. To compute the gcd <strong>of</strong> two numbers, the algorithm uses a<br />

process <strong>of</strong> repeated remainder operations in which the larger <strong>of</strong> the two numbers<br />

is continually replaced by the remainder <strong>of</strong> the larger divided by the smaller.<br />

By putting this into a table and making use <strong>of</strong> the quotients involved, the multiplicative<br />

inverse can also quickly be found. Since Koblitz’s Kid-RSA depends<br />

for its security on the inability for an adversary to compute multiplicative inverses,<br />

we see it not secure at all, but is intended as a toy system, intended to<br />

demonstrate the concept <strong>of</strong> public keys.<br />

Decimation and Linear Ciphers do a better job <strong>of</strong> mixing the ciphertext<br />

alphabet than a Caesar Cipher does. Letters that are adjacent in the plaintext<br />

alphabet are not adjacent once enciphered, they are k letters apart, where k<br />

is the multiplicative key <strong>of</strong> the cipher. While this prevents us from using the<br />

hills and valley patterns <strong>of</strong> the normal frequency to break the cipher, it provides<br />

enough order so that if two ciphertext letters can be matched with their plaintext<br />

counterparts either <strong>of</strong> these ciphers can be broken.<br />

4.7 Topics and Techniques<br />

1. How many keys does a Linear Cipher need<br />

2. How do we encipher with a Linear Cipher<br />

3. What is the greatest common divisor <strong>of</strong> two numbers<br />

4. What is the Euclidean Algorithm<br />

5. What does relatively prime mean When are two numbers relatively<br />

prime<br />

6. How do we use the Euclidean Algorithm to find a gcd<br />

7. What is a multiplicative inverse<br />

8. When does a number have a multiplicative inverse modulo n


68 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

9. How do we use the Euclidean Algorithm to find a multiplicative inverse<br />

10. How many Linear Ciphers are there modulo 26<br />

11. What information is needed to decipher a Decimation Cipher A Linear<br />

Cipher<br />

12. Are Decimation Ciphers secure or not Why<br />

13. Are Linear Ciphers secure or not Why<br />

14. Can a frequency count help break a Decimation or Linear Cipher Explain.<br />

4.8 Exercises<br />

1. Use the Euclidean Algorithm to find the following gcd’s.<br />

(a) gcd(32, 54).<br />

(b) gcd(45, 39).<br />

(c) gcd(78, 53).<br />

(d) gcd(102, 78).<br />

2. Use the Euclidean Algorithm to find the following gcd’s.<br />

(a) gcd(61, 56).<br />

(b) gcd(121, 77).<br />

(c) gcd(735, 140).<br />

(d) gcd(297, 201).<br />

3. Use the Euclidean Algorithm to find the following gcd’s, and then find a<br />

solution to the related modular equation.<br />

(a) Find gcd(25, 85). Find a solution to 25x ≡ gcd (mod 85).<br />

(b) Find gcd(27, 17). Find a solution to 17x ≡ gcd (mod 27).<br />

(c) Find gcd(24, 102). Find a solution to 24x ≡ gcd (mod 102).<br />

(d) Find gcd(149, 78). Find a solution to 78x ≡ gcd (mod 149).<br />

4. Use the Euclidean Algorithm to find the following gcd’s, and then find a<br />

solution to the related modular equation.<br />

(a) Find gcd(16, 110). Find a solution to 16x ≡ gcd (mod 110).<br />

(b) Find gcd(31, 79). Find a solution to 31x ≡ gcd (mod 79).<br />

(c) Find gcd(298, 79). Find a solution to 79x ≡ gcd (mod 298).<br />

(d) Find gcd(306, 192). Find a solution to 192x ≡ gcd (mod 306).


4.8. EXERCISES 69<br />

5. Here we work with Decimation Ciphers modulo 28, using 27 = .<br />

(a) Encipher no spaces allowed with key 19.<br />

(b) Decipher CUDAZ KOTQW A. The enciphering key was 17.<br />

(c) Decipher XDOMQM HKE Q JYBQM KT . The enciphering key was 11.<br />

(d) Decipher P WHO ENOWL MKI. The enciphering key was 13.<br />

6. Encipher the following words, using the given linear cipher modulo 26.<br />

(a) Geometry, 3m + 7.<br />

(b) Algebra, 11m + 19.<br />

(c) Trigonometry, 7m + 2.<br />

7. Decipher the following words. They were enciphered with a linear cipher,<br />

modulo 26.<br />

(a) VFQDY DMBMP O, key 5m + 20.<br />

(b) TKIAB CVFQ, key 23m + 4.<br />

(c) YVZGN YNX, key 19m + 8.<br />

(d) HGZGR HGRXH, key 25m + 1.<br />

8. What happens if we follow a linear cipher by another linear cipher<br />

9. In this problem we work as we did in Chapter 3 Exercise 8: the numbers<br />

0 to 9 stand for themselves in the plaintext, 10 is for spaces, 11 to 36<br />

represent the letters <strong>of</strong> the alphabet, and we work modulo 37.<br />

(a) Encipher 8 or 9 using a Caesar cipher with key 11.<br />

(b) Encipher 25 cents using a Decimation cipher with key 18.<br />

(c) Encipher Tea for 2 using a Linear Cipher with key 13m + 6.<br />

(d) Decipher NAA52 5I5NB 75I52 5NAA. It was enciphered with a Decimation<br />

cipher with key k = 19.<br />

(e) Decipher 9AIB ZE0AD ZAEJB A9D66 PL. It was enciphered with a<br />

Linear Cipher with key 15m + 9.<br />

(f) Decipher REHQD HMHTQ H7. It was enciphered with a Linear Cipher<br />

with key 8m + 12.<br />

(g) Decipher A0L6O ISS. It was enciphered with a Linear Cipher with<br />

key 16m + 7.<br />

(h) Decipher 5UHUE XUKEL U5UH. It was enciphered with a Linear Cipher<br />

with key 31m + 17.<br />

(i) Decipher L2 83 3 T20 JIQ. It was enciphered with a Linear Cipher<br />

with key 13m + 20.


70 CHAPTER 4. THE EUCLIDEAN ALGORITHM<br />

10. In a Decimation Cipher the enciphering key must be smaller than an<br />

relatively prime to the modulus. Since there are 12 numbers between 1<br />

and 26 whose gcd with 26 is 1, there are 12 Decimation Ciphers modulo<br />

26.<br />

(a) How many Decimation Ciphers are there modulo 7 (Hint: how<br />

many numbers are smaller and relatively prime to 7) How many<br />

(b) How many Decimation Ciphers are there modulo 18<br />

(c) How many Decimation Ciphers are there modulo 28<br />

(d) How many Decimation Ciphers are there modulo 35 (It might be<br />

easier to first find the numbers that are not proper enciphering keys.)<br />

11. The following is a decimation cipher. Use the techniques <strong>of</strong> this chapter<br />

to decrypt it.<br />

PYETO MLWPQ QRVOT TWDQK IODQW WTYUR SEQSP JODWP UOTTO SMWVS AQWRQ<br />

SDQ.<br />

12. The following is a linear cipher. With the hint that the three most common<br />

letters are eit (although not necessarily in that order), can you decrypt<br />

it<br />

JXYVK MDZYJ PNFJK NLXLD SHYNM NWZMD HGNXG JPLJW NWZLO NFMFQ TMNFW<br />

DMNPP LENJM LIVKL YXLKM NQIL<br />

13. Alex’s public Kid-RSA gives e = 361 and N = 4063. Suppose you’ve<br />

captured the message “I used your PK. 630, 3518, 269, 3157, 722, 899,<br />

3157, 177, 1352, 630, 1352, 1444, 3157, 177, 1805, 991, 3157, 899, 2166,<br />

3249, 3879, 1805.<br />

GTTGM JNQJZ DMFF.<br />

Can you decrypt the message<br />

14. Corrine’s public Kid-RSA lists e = 495 and N = 2644. You’ve intercepted<br />

a message for her: “Use<br />

978, 2475, 314, 2475, 978, 1473, 2475, 1980, 495, 652, 2632, 1316, 495,<br />

990, 2475, 1968.<br />

XZHS RM YLC MFNYVI GVM.<br />

Can you decrypt the message


Chapter 5<br />

Monoalphabetic Ciphers<br />

Here is an example <strong>of</strong> a plaintext – ciphertext alphabet pair for each type <strong>of</strong><br />

cipher we have seen thus far.<br />

1. A Caesar cipher with key 5:<br />

plaintext alphabet<br />

ciphertext alphabet<br />

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<br />

F G H I J K L M N O P Q R S T U V W X Y Z A B C D E<br />

2. A Decimation Cipher modulo 26 with key 21:<br />

plaintext alphabet<br />

ciphertext alphabet<br />

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<br />

U P K F A V Q L G B W R M H C X S N I D Y T O J E Z<br />

3. A Linear Cipher modulo 26 with key 7m + 9:<br />

plaintext alphabet<br />

ciphertext alphabet<br />

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<br />

P W D K R Y F M T A H O V C J Q X E L S Z G N U B I<br />

These are all monoalphabetic ciphers, ciphers in which the same plaintext<br />

letters are always replaced by the same ciphertext letters. Mono, meaning one,<br />

indicates that each letter has a single substitute. In this chapter we look at<br />

other ways <strong>of</strong> creating monoalphabetic ciphers. 1<br />

To construct a monoalphabetic cipher, we need to create some ordering <strong>of</strong><br />

the alphabet, such as S O M E R D I N G X H B V L T U J W K Y Z F A C P Q, and<br />

pair it with a plaintext alphabet,<br />

plaintext alphabet<br />

ciphertext alphabet<br />

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<br />

S O M E R D I N G X H B V L T U J W K Y Z F A C P Q<br />

1 When the ciphertext alphabet is in the usual order just shifted, as in (1), it is said to be<br />

a regular or direct substitution alphabet. When the ciphertext alphabet is mixed up, as in<br />

(2) and (3), it is said to be a mixed substitution alphabet. A reversed alphabet is another<br />

possibility, and is exactly what it sounds like.<br />

71


72 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

We then encipher and decipher by translating from the plaintext to ciphertext<br />

alphabets and back, as usual. In this example alphabet becomes SBUNSORY.<br />

However it is not particularly easy to remember apparently random orderings<br />

<strong>of</strong> 26 letters. So we will concentrate a couple <strong>of</strong> well-known methods that use a<br />

key to develop the ciphertext alphabet’s order.<br />

5.1 Keyword Ciphers<br />

To use Keyword Cipher method to construct the ciphertext alphabet, pick a<br />

keyword and write it down, ignoring repeated letters. Follow it with the letters<br />

<strong>of</strong> the alphabet that have not yet been used.<br />

Example: Find the alphabet pairs for the keyword COLLEGE.<br />

Crossing out the letters that are making their second appearance leaves<br />

COLEG. To encipher then we use the pair <strong>of</strong> alphabets<br />

plaintext<br />

ciphertext<br />

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<br />

C O L E G A B D F H I J K M N P Q R S T U V W X Y Z<br />

Enciphering university then gives UMFVGRSFTY.<br />

⋄<br />

Clearly there is a problem with this cipher: it does a poor job <strong>of</strong> mixing the<br />

ciphertext alphabet. Around 1580 Giovanni Battista Argenti suggested that one<br />

also pick a keyletter and begin the keyword under that letter <strong>of</strong> the plaintext.<br />

The Argentis, Giovanni and his nephew Matteo, form one <strong>of</strong> the great cryptology<br />

families <strong>of</strong> the middle ages. After many years <strong>of</strong> trying, in 1590 Giovanni finally<br />

became papal secretary <strong>of</strong> ciphers in Rome, only to quickly weaken from the<br />

frequent necessary trips to Germany and France. Before dying on April 24,<br />

1591, he passed his knowledge to his nephew Matteo who succeeded him and<br />

held the <strong>of</strong>fice during the reign <strong>of</strong> the next five popes.<br />

To use Giovanni’s method with keyletter p we would start COLEG under<br />

pqrst, giving<br />

plaintext<br />

ciphertext<br />

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<br />

J K M N P Q R S T U V W X Y Z C O L E G A B D F H I<br />

Then university is enciphered as AYTAPLETGH. This method mixes the ciphertext<br />

alphabet better.


5.2. KEYWORD MIXED CIPHERS 73<br />

Example: Encipher university using keyword xylophone and key F. 2<br />

⋄<br />

Even with the added complication, significant parts <strong>of</strong> the alphabet are still<br />

enciphered as in a Caesar cipher. Compare the ciphertext alphabet using keyword<br />

COLLEGE and key P with the alphabet generated by the Caesar cipher with<br />

keyletter L:<br />

plaintext<br />

COLLEGE and P<br />

Caesar key L<br />

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<br />

J K M N P Q R S T U V W X Y Z C O L E G A B D F H I<br />

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K<br />

There are many overlaps and near overlaps in the two cipher alphabets, which<br />

makes a keyword cipher not much more secure than a Caesar cipher.<br />

5.2 Keyword Mixed Ciphers<br />

The cryptosystem we call Keyword Mixed Ciphers seems to have been invented<br />

in 1854 by Sir Charles Wheatstone, whom we will meet again [Bauer,<br />

page 48].<br />

Pick a keyword and write it out, again ignoring repetitions <strong>of</strong> letters. Then<br />

write the remainder <strong>of</strong> the alphabet underneath, using the same number <strong>of</strong><br />

columns as letters in the shortened keyword. Finally, pull <strong>of</strong>f the columns in<br />

order and write the letters underneath the plaintext alphabet.<br />

Example: Find the ciphertext alphabet using a Keyword Mixed Cipher and<br />

keyword COLLEGE.<br />

First we remove the repeated letters, so the shortened keyword is COLEG.<br />

Then we write the it down, followed by the remainder <strong>of</strong> the alphabet.<br />

C O L E G<br />

A B D F H<br />

I J K M N<br />

P Q R S T<br />

U V W X Y<br />

Z<br />

Finally we pull out the columns in order.<br />

plaintext<br />

ciphertext<br />

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<br />

C A I P U Z O B J Q V L D K P Q E F M S X G H N T Y<br />

This results in a nicely mixed ciphertext alphabet without obvious pattern. ⋄<br />

2 JAOKZFGOIR


74 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

Examples: Use a Keyword Mixed Cipher.<br />

(1) Encipher monoalphabetic using the keyword SIMPLE.<br />

The columnar arrangement <strong>of</strong> the alphabet is<br />

S I M P L E<br />

A B C D F G<br />

H J K N O Q<br />

R T U V W X<br />

Y Z<br />

Pulling the columns <strong>of</strong>f in order, left-to-right, and putting it under the<br />

usual alphabet gives<br />

plaintext<br />

ciphertext<br />

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<br />

S A H R Y I B J T Z M C K U P D N V L F O W E G Q X<br />

From here the enciphering should be quick.<br />

(2) Encipher cryptology using the keyword SECRET.<br />

(3) Decipher DPCRD JPUTI using the keyword HOMOPHONE.<br />

(4) Decipher COACH SHOHS EU using the keyword DIRECT. 3<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Keyword mixed ciphers are one <strong>of</strong> the best monoalphabetic ciphers. The<br />

key is simple to choose, remember and change, and the cipher itself is easy to<br />

setup and use. For these reasons there are a couple <strong>of</strong> modifications that people<br />

sometimes use: Keyword Transposed and Keyword Interrupted Ciphers.<br />

5.3 Keyword Transposed Ciphers<br />

In a Keyword Transposed Cipher we require the columns to be pulled <strong>of</strong>f in<br />

alphabetical order. So if we use again COLLEGE as the keyword, from the array<br />

C O L E G<br />

A B D F H<br />

I J K M N<br />

P Q R S T<br />

U V W X Y<br />

Z<br />

3 (1) KPUPS CDJSA YFTH, (2) HFQWP OCOEQ, (3) polyphonic, (4) substitution.


5.4. INTERRUPTED KEYWORD CIPHERS 75<br />

we first pull out the C column, followed by the E column, and then the G, L and<br />

finally O columns. This gives<br />

plaintext<br />

ciphertext<br />

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<br />

C A I P U Z E F M S X G H N T Y L D K P Q O B J Q V<br />

as the substitution alphabet.<br />

Examples: Use a Keyword Transposed Cipher.<br />

(1) Encipher monoalphabetic using the keyword SIMPLE.<br />

The columns <strong>of</strong> the alphabet look like<br />

S I M P L E<br />

A B C D F G<br />

H J K N O Q<br />

R T U V W X<br />

Y Z<br />

Pulling the columns <strong>of</strong>f in alphabetical order gives the ciphertext alphabet<br />

plaintext<br />

ciphertext<br />

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<br />

E G Q X I B J T Z L F O W M C K U P D N V S A H R Y<br />

From here the enciphering should again be quick.<br />

(2) Encipher cryptology using the keyword SECRET.<br />

(3) Decipher QFKLQ SFNYR using the keyword HOMOPHONE.<br />

(4) Decipher RMHRF YFMFY BI using the keyword DIRECT. 4<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

5.4 Interrupted Keyword Ciphers<br />

In an Interrupted Keyword Cipher instead <strong>of</strong> removing duplicated letters<br />

put in * as a placeholder. This time COLLEGE becomes<br />

C O L * E G *<br />

A B D F H I J<br />

K M N P Q R S<br />

T U V W X Y Z<br />

4 (1) WCMCE OKTEG INZQ, (2) JHQSU XFXBQ, (3) polyphonic, (4) substitution.


76 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

Then remove the ciphertext alphabet as in a keyword cipher, ignoring the *’s:<br />

plaintext<br />

ciphertext<br />

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<br />

C A K T O B M U L D N V F P W E H Q X G I R Y J S Z<br />

Finally, one can use Interrupted Keyword Transposed ciphers, but we won’t.<br />

5.5 Frequency Counts and Exhaustion<br />

Are these new monoalphabetic ciphers any more secure than the ones we saw<br />

earlier Or will frequency analysis once again save (ruin) the day Let’s try<br />

to break a message enciphered with a keyword mixed cipher and see.<br />

Example: KNHHXKK QS PXTDQSB YQFJ NSISCYS HQEJXUK QK LXTKNUXP AO<br />

FJXKX RCNU FJQSBK QS FJX CUPXU STLXP EXUKXVXUTSHX HTUXRND LXFJCPK CR<br />

TSTDOKQK QSFNQFQCS DNHI FJX TAQDQFO TF DXTKF FC UXTP FJX DTSBNTBX CR<br />

FJX CUQBQSTD QK VXUO PXKQUTADX ANF SCF XKKXSFQTD<br />

The letter frequency count <strong>of</strong> the ciphertext is<br />

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<br />

4 5 10 10 2 17 0 6 2 9 17 3 0 9 4 7 18 4 16 16 12 2 0 27 2 0<br />

Does this look like a Caesar cipher By far the most common letter is X, so<br />

this is likely e. But if so then S and T are y and z, respectively, and it is not<br />

likely that a message would have sixteen each <strong>of</strong> these letters. In fact, there<br />

is no low sextuple. This is not a Caesar cipher. The ciphertext’s letters have<br />

been well enough mixed that the standard frequency patterns have been totally<br />

destroyed.<br />

⋄<br />

This is the main advantage <strong>of</strong> the keyword ciphers: unless we know the<br />

method and the keyword, it is quite difficult to directly detect the pattern in<br />

the ordering <strong>of</strong> the ciphertext alphabet. In a Caesar cipher, once we knew where<br />

the ciphertext version <strong>of</strong> e was located we were basically done. In Decimation<br />

and Linear ciphers, knowing two letters allowed us to determine the rest. With<br />

a keyword cipher, the ciphertext alphabet is mixed enough that knowing the<br />

meanings <strong>of</strong> even five or ten ciphertext letters does not necessarily disclose the<br />

pattern <strong>of</strong> encryption.<br />

What about exhaustion, one might ask We might use a computer and<br />

simply try all the possibilities. Working modulo 26 there are 26 different Caesar<br />

ciphers. There are only 12 decimation ciphers modulo 26, and 26 × 12 = 312<br />

linear ciphers. How many monoalphabetic ciphers are there Well, we have 26<br />

choices for which letter goes is substituted for a. Then we have 25 choices for


5.6. BASIC LETTER CHARACTERISTICS 77<br />

the substitution for b, 24 for c’s substitute, etc. Thus there are<br />

26! = 26 × 25 × 24 × · · · × 2 × 1<br />

= 403, 291, 461, 126, 605, 635, 584, 000, 000<br />

different monoalphabetic substitution ciphers. How large <strong>of</strong> a number is this<br />

If we used a computer that could check one trillion different possibilities every<br />

second, we’d need about 12 million years to check all the possibilities!<br />

Of course, no one simply uses brute force to break monoalphabetic ciphers.<br />

In our current example X almost positively must be e. And most <strong>of</strong> etaoinshr<br />

probably comes from CFKQSTU. This cuts down immensely on the number <strong>of</strong><br />

possibilities. But to decrypt such a cipher in a truly finite amount <strong>of</strong> time we<br />

must go beyond simple frequency counts to consider the behaviors <strong>of</strong> the letters.<br />

5.6 Basic Letter Characteristics<br />

We’ve seen which letters are the most common (etaoinshr) and least common<br />

(vkjxqz). We next look at which letters appear first and last in words. We<br />

begin with the frequency information from earlier. (The initial and final letter<br />

percentages are from Sinkov’s study <strong>of</strong> 16410 words [Sinkov].)<br />

8.2 1.5 2.8 4.3 12.7 2.2 2.0 6.1 7.0 0.2 0.8 4.0 2.4<br />

a b c d e f g h i j k l m<br />

6.7 7.5 1.9 0.1 6.0 6.3 9.1 2.8 1.0 2.4 0.2 2.0 0.1<br />

n o p q r s t u v w x y z<br />

Figure 5.1: Letter Frequencies – Anywhere.<br />

11.0 4.6 5.6 2.8 2.5 4.1 1.8 3.9 5.6 0.6 0.5 2.1 3.5<br />

a b c d e f g h i j k l m<br />

2.4 7.2 4.7 0 3.1 7.4 15.9 1.4 0.6 5.1 0 0.7 0<br />

n o p q r s t u v w x y z<br />

Figure 5.2: Letter Frequencies – Initial Letters.<br />

Summarizing, the most common individual letters are<br />

1) Anywhere: etaoi, 4 vowels and t.<br />

2) Beginning words: tasoic, with t easily the most common.<br />

3) Ending words: edtsn (almost spells “endts”).<br />

4) Doubles: lesot.<br />

We put this summary into Figure 5.4.


78 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

2.9 0.2 0.6 10.0 20.3 4.5 2.8 2.5 0.4 0 0.1 3.7 1.3<br />

a b c d e f g h i j k l m<br />

9.7 4.5 0.5 0 5.5 12.7 9.7 0.2 0.1 1.0 0.2 5.5 0<br />

n o p q r s t u v w x y z<br />

Figure 5.3: Letter Frequencies – Final Letters.<br />

a e i o t r n h s<br />

common x X x x x<br />

start x x x X x<br />

end X x x x x x<br />

doubles x x x x<br />

Figure 5.4: Characteristics <strong>of</strong> etaoinshr.<br />

We also list the most common short words in English in Figure 5.5 and one<br />

list <strong>of</strong> the 100 most common English words, with the number <strong>of</strong> times they<br />

appeared out <strong>of</strong> 1, 000, 000 words, in Figure 5.6.<br />

1 letter words: a i<br />

2 letter words: an at as he be in is it on or to <strong>of</strong><br />

3 letter words: the and (both really common,) was for his had<br />

4 letter words: that with this from have<br />

Figure 5.5: Most Common Short Words<br />

Notice that the most common words by far, are non-context words: articles,<br />

prepositions, conjunctions and other auxiliary particles. In fact, in some lists<br />

the <strong>of</strong> and to a in make up nearly 20% <strong>of</strong> all words, and up to 70 <strong>of</strong> the 100<br />

most used words are non-context words.<br />

5.7 Aristocrats<br />

We begin our breaking <strong>of</strong> general monoalphabetic ciphers with Aristocrats.<br />

These are short quotations enciphered with a monoalphabetic substitution.<br />

They appear in almost every newspaper, usually in the comics section. We<br />

start with them since they tend to be not terribly difficult, mainly because they<br />

keep word divisions and punctuation, and are frequently given with a hint.<br />

Decrypting aristocrats is mostly simple hard work, although some <strong>of</strong> our<br />

frequency information will be <strong>of</strong> service. Some suggested steps are


5.7. ARISTOCRATS 79<br />

the 69971 or 4207 so 1984 like 1290<br />

<strong>of</strong> 36411 have 3941 said 1961 our 1252<br />

and 28852 an 3747 what 1908 over 1236<br />

to 26149 i 3700 up 1895 man 1207<br />

a 23237 they 3618 its 1858 me 1181<br />

in 21341 which 3562 about 1815 even 1171<br />

that 10595 one 3292 into 1791 most 1160<br />

is 10099 you 3286 them 1789 made 1125<br />

was 9816 were 3284 than 1789 after 1070<br />

he 9543 her 3037 can 1772 also 1069<br />

for 9489 all 3001 only 1747 did 1044<br />

it 8756 she 2859 other 1702 many 1030<br />

with 7289 there 2724 new 1635 before 1016<br />

as 7250 would 2714 some 1617 must 1013<br />

his 6997 their 2670 time 1599 through 969<br />

on 6742 we 2653 could 1599 back 967<br />

be 6377 him 2619 these 1573 where 938<br />

at 5378 been 2472 two 1412 much 937<br />

by 5305 has 2439 then 1377 your 923<br />

this 5146 when 2331 do 1363 way 909<br />

had 5133 who 2252 first 1360 well 897<br />

not 4609 more 2216 any 1345 should 888<br />

are 4393 no 2201 my 1319 because 883<br />

but 4381 if 2199 now 1314 each 877<br />

from 4369 out 2096 such 1303 just 872<br />

Figure 5.6: The 100 Most Common Words in English<br />

1. Do a frequency count. Identify which ciphertext letters are most likely<br />

etaoinshr. Be aware, however, that especially in short message, frequencies<br />

can be very strange.<br />

2. Look at the initial and final letters <strong>of</strong> words. Use this to help identify<br />

which etaoinshr letters are which.<br />

3. <strong>St</strong>udy the short words. There frequently are words like I, a, the and and<br />

present.<br />

4. Work hard. Mix effort with brain power. Remember that brilliant inductive<br />

realizations usually come only after some hard thought.<br />

Example: SDGHKHMP HP TDQJ ZBFXJQDEP KWBF LBQ, YDQ HF LBQ CDE BQJ<br />

DFGC UHGGJZ DFMJ. LHFPKDF MWEQMWHGG Hint: G = l.<br />

Substituting the given G = l gives the word UHllJZ=**ll**. So H and J<br />

must be vowels, and U and Z are probably consonants. The words HP and HF<br />

show P and F to be consonants, and H is perhaps i


80 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

Turning to the frequency count<br />

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<br />

0 5 2 8 3 7 6 5 0 5 5 3 4 0 0 3 6 0 1 1 1 0 3 1 1 2<br />

the most common letters are BDFGHJKQ. Of these, F, J and Q each occur three<br />

times as final letters. Let’s guess that one <strong>of</strong> these is e. It cannot be F, a<br />

consonant, nor Q, as then the word TDQJ would end in an e-vowel combination.<br />

So e must be J.<br />

Next, BQJ=BQe, so Q must be a consonant, and from LBQ, B is probably a<br />

vowel, hence a or o. Trying B=o doesn’t work. But when we try B=a, we quickly<br />

see Q=r, making YDQ = YDr = Yor = for, as o is the only vowel then left.<br />

At this point the cipher looks like *oli*i*s is *ore *an*ero*s **an *ar,<br />

for in *ar *o* are onl* *ille* on*e. *in*on ***r**ill. From here the<br />

quotation should be pretty easy to complete. 5<br />

⋄<br />

Clearly this example worked out a little too nicely, in part because we hid<br />

some false starts and in part because time spent thinking and scratching one’s<br />

head is hard to indicate in text. But it should still give an idea <strong>of</strong> how Aristocrats<br />

are attacked.<br />

5.8 Summary<br />

A monoalphabetic cipher is one in which the each plaintext letter is replaced by<br />

the same ciphertext letter throughout the entire message. The Caesar or Shift<br />

Ciphers, Decimation Ciphers and Linear Ciphers are all monoalphabetic, as are<br />

the various types <strong>of</strong> Keyword Ciphers introduced in this chapter.<br />

The Keyword Ciphers all use a keyword to develop an ordering <strong>of</strong> the ciphertext<br />

alphabet. The more important ones are the Keyword Mixed and Keyword<br />

Transposed Ciphers. Select a keyword and drop any repeated letters in it. Then<br />

write the remainder <strong>of</strong> the alphabet underneath in as many columns as remain<br />

in the keyword. For a Mixed Cipher the ciphertext alphabet is then the columns<br />

pulled <strong>of</strong>f in order, left-to-right, while for a Transposed Cipher the alphabet is<br />

pulled <strong>of</strong>f in alphabetical order <strong>of</strong> the top row.<br />

A popular type <strong>of</strong> decryption puzzle is an Aristocrat, which is generally<br />

a short quote enciphered with a monoalphabetic cipher. Word divisions and<br />

punctuation are generally kept, and a hint is <strong>of</strong>ten given. The keys to decrypting<br />

these ciphers include the usual frequency count, some knowledge <strong>of</strong> initial and<br />

final letters <strong>of</strong> words, and very <strong>of</strong>ten the use <strong>of</strong> common short words.<br />

5 Politics is more dangerous than war, for in war you are only killed once.<br />

Winston Churchill.


5.9. TOPICS AND TECHNIQUES 81<br />

5.9 Topics and Techniques<br />

1. What is the chief characteristic <strong>of</strong> a Monoalphabetic Cipher<br />

2. What is a Keyword Cipher How do we encipher and decipher with it<br />

3. What is a Keyword Mixed Cipher How do we encipher and decipher with<br />

it<br />

4. Keyword Ciphers and Keyword Mixed Ciphers use their keyword differently.<br />

Explain the difference.<br />

5. What is a Keyword Transposed Cipher How do we encipher and decipher<br />

with it<br />

6. How do Keyword Mixed Ciphers and Keyword Transposed Ciphers differ<br />

7. What letters most commonly begin words in English<br />

8. What letters most commonly end words in English<br />

9. What are the most common one-letter words in English Two-letter<br />

words Three-letter words<br />

10. What are the most common words in English<br />

11. What is an Aristocrat<br />

12. What steps help decrypt an Aristocrat<br />

5.10 Exercises<br />

1. Encipher or decipher the following words using a Keyword Cipher with<br />

the given keyword.<br />

(a) democrat with REPUBLICAN.<br />

(b) chocolate with HOT.<br />

(c) JUIES OP with LETTERS.<br />

(d) DSTLQ with TAILS.<br />

(e) SQGSI LT with BASEBALL.<br />

2. Encipher or decipher the following words using a Keyword Mixed Cipher<br />

with keyword COLORS.<br />

(a) canary.<br />

(b) eggplant.<br />

(c) fuchsia.


82 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

(d) lavender.<br />

(e) DXLAU EET.<br />

(f) PEGB HM.<br />

(g) WUEHF HIVLU.<br />

(h) DCOIU QC.<br />

(i) JHUII C.<br />

3. Encipher or decipher the following words using a Keyword Mixed Cipher<br />

with keyword WEEKDAYS.<br />

(a) Tuesday.<br />

(b) Thursday.<br />

(c) DOGTW J.<br />

(d) CHKTW J.<br />

(e) PYGTW J.<br />

4. Encipher or decipher the following words. They were enciphered via a<br />

Keyword Transposed Cipher with the keyword VEGETABLES.<br />

(a) turnip.<br />

(b) cabbage.<br />

(c) lentil.<br />

(d) eggplant.<br />

(e) parsnip.<br />

(f) MDHIA MI.<br />

(g) RDORG WJA.<br />

(h) RHRHP IJM.<br />

(i) GKDFM AIO.<br />

(j) RAHFOUFKVJM.<br />

5. Decipher the following words. They were enciphered via a Keyword Mixed<br />

Cipher with the given FRUITS.<br />

(a) artichoke.<br />

(b) guava.<br />

(c) tapioca.<br />

(d) mulberry.<br />

(e) papaya.<br />

(f) currant.<br />

(g) DIKYB VFQFE Y.


5.10. EXERCISES 83<br />

(h) DYVTP KKIQ.<br />

(i) EFKFV PQO.<br />

(j) FWFHFOI.<br />

(k) UMKLMFE.<br />

(l) KFQBI.<br />

6. Encipher or decipher the following words using a Keyword Transposed<br />

Cipher with the keyword AMERICA.<br />

(a) Brazil.<br />

(b) Columbia.<br />

(c) Ecuador.<br />

(d) French Guiana.<br />

(e) BXNHL H.<br />

(f) UYLYW XYAH.<br />

(g) JXDML HFY.<br />

(h) XDXBX HN.<br />

(i) ZHDHB XHN.<br />

7. Decipher the following words. They were enciphered via a Keyword Transposed<br />

Cipher with the keyword SPORTS.<br />

(a) Rugby.<br />

(b) Tennis.<br />

(c) Luge.<br />

(d) Biathlon.<br />

(e) Croquet.<br />

(f) Lacrosse.<br />

(g) COMIL NUXN.<br />

(h) ROQOR LNB.<br />

(i) VOLOD OL.<br />

(j) SWUON AZW.<br />

(k) CXEDL NB.<br />

(l) HFLHR WU.<br />

8. Encipher or decipher the following words using an Interrupted Keyword<br />

Cipher with the given keyword.<br />

(a) tea with keyword COFFEE.<br />

(b) beer with keyword PRETZELS.<br />

(c) LUAZC XE with keyword APPLES.<br />

(d) STERI with keyword TELEVISION.<br />

(e) RTJHI Z with keyword PAPER.


84 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

9. Decrypt the following Aristocrats. A hint has been given.<br />

(a) ZJG REGFF ADLH DZRFG AFDRE, EDXG DKA ZXKYFGKDXVH BJKRXKQF RJ<br />

YGJO. CQR TEJKF BDVVH RDTFG JZZ. IJEKKL BDGHJK.<br />

Hint: R = t.<br />

(b) KAHTH FN WJ XLW NJ EMHNNHC KALK NJXH RAJ NKLWC EP AFN CHLKAEHC<br />

RJW’K ALFM KAH JDDLNFJW RFKA CHMFIAK. XLTDSN LSTHMFSN.<br />

Hint: A = h .<br />

(c) E OEB IZ JVEYU KCH KVIRTZ E ZTJVTR IB EBU HRCTV KEU RCEB HBT<br />

KCIJC KIWW JHBJTEW IR XVHO RCT FAWGEV. VHGTV DEJHB.<br />

Hint: V = r.<br />

(d) D QZJSEY ZO D VEGSAX AB TYZGZMK D VEOODKE OA GSDG ZG QDMMAG IE<br />

YEDX IL DMLAME ZKMAYDMG AB GSE VEGSAX. BNEGQSEY JYDGG.<br />

Hint: X = d.<br />

10. Decrypt the following Aristocrats.<br />

(a) IOKVK MVK UKTKVMZ JGGF XVGIKLICGHU MJMCHUI IKYXIMICGH ENI IOK<br />

UNVKUI CU LGSMVFCLK YMVA ISMCH<br />

(b) EKY HZMJECDZAX US EKY AZUSECHZAE CI JLWWNYS XCEEC CI EKY AXYZ-<br />

UHAR HZMJECDZAJK ASSCHUAEUCR<br />

(c) CP TEF HALZKCTO ZM QCREFKV CT CV ZPNO TEF FGCVTFPQF ZM KFDJPD-<br />

APQO CP TEF ZKCXCPAN HFVVAXFV TEAT HAWFV A VZNJTCZP RZVVCINF<br />

(d) MOY DYKP IOJIVJPFEPV ESDOKP LJ E JVFWOYK PFEJIV BGVJ BOFZLJA<br />

OJ E IONV LP LK JOP OQPVJ NOJV CM IOJKILOYK VQQOFP DLKK QFLVN-<br />

FLIGK<br />

11. During the 1670’s The Chevalier de Rohan was imprisoned under suspicion<br />

<strong>of</strong> treason. While guilty, there was little evidence and his life depended on<br />

the fate <strong>of</strong> his accomplice who lay dying in the same prison. If his friend<br />

confessed, Rohan would be convicted and executed. If not, Rohan might<br />

be able to go free.<br />

Shortly before his trial Rohan received a note hidden in a bundle <strong>of</strong> clothing:<br />

PVQ RDOWYFQD OW XQSX VQ WSOX FYPVOFC. Should Rohan confess<br />

and throw himself on the mercy <strong>of</strong> the court Or should he stonewall<br />

and hope to be let free (The message was actually in French. For<br />

those who read French, the ciphertext is MG EULHXCCLGU GHJ YXUJ LM<br />

CT ULGC ALJ.)<br />

12. Decrypt the following monoalphabetic cipher. Kahn [page 770] says a<br />

similar method was used, albeit in Latin, to record this event.<br />

J1629 B1762, 01ug3927 <strong>of</strong> W45541m B1762, cu71927 <strong>of</strong> 932 p17483, 48<br />

b1p94820 J16u17y 1, 1645 46 C5219o7, Cumb275160, 26g5160


5.10. EXERCISES 85<br />

13. Ciphers in which pairs <strong>of</strong> numbers replace each letter are called biliteral<br />

or dinome ciphers. A simple way to construct such ciphers is to put<br />

the letters <strong>of</strong> the alphabet into a rectangle and number the rows and the<br />

columns. For example, if we use a five-by-five square, and squash i and j<br />

together, we have<br />

1 2 3 4 5<br />

1 a b c d e<br />

2 f g h ij k<br />

3 l m n o p<br />

4 q r s t u<br />

5 v w x y z<br />

To encipher, replace the letter by its row–column number pair, that is,<br />

read from the side first. So box becomes 12 34 53. Deciphering is just<br />

translating back into letters.<br />

Use the given square to encipher or decipher the following.<br />

(a) rectangle.<br />

(b) square.<br />

(c) 54 66 53 56. (Hint: 41 was added to every number before transmission).<br />

(d) 42 32 14 15 23 45 43. The alphabet was entered into the square<br />

using the keyword DINOME.<br />

(e) Perhaps the first ever use <strong>of</strong> a password was when Giovanni Argenti,<br />

around 1589, used PIETRO and a rectangle with two rows and 10<br />

columns (0 being the first). (The letters jkvwxy did not appear.) Using<br />

this method, 17 16 13 13 11 27 13 16 and 24 16 13 13 12<br />

15 gives Argenti’s middle name and his nephew’s name. What are<br />

they<br />

14. A larger bipartite cipher was used by Brig. General Leslie R. Groves<br />

[Kahn, page 546]. It took the form<br />

1 2 3 4 5 6 7 8 9 0<br />

1 I P I O U O P N<br />

2 W E U T E K L O<br />

3 E U G N B T N S T<br />

4 T A Z M D I O E<br />

5 S V T J E Y H<br />

6 N A O L N S U G O E<br />

7 C B A F R S I R<br />

8 I C W Y R U A M N<br />

9 M V T H P D I X Q<br />

0 L S R E T D E A H E


86 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

(a) Groves used this cipher for certain telephone conversations during<br />

the building <strong>of</strong> the atomic bomb. Encipher atomic bomb.<br />

(b) Decipher 01-53 72-29-01 96-22-25-70 45-74 77-47-28-92-42. He<br />

was Groves’ phone partner.<br />

(c) The bomb was developed at 28-92-66 62-01-08-19-15-39.<br />

15. Construct a complete sentence <strong>of</strong> at least six words that uses no e’s and<br />

no t’s.<br />

16. John Jay served as a delegate to the First and Second Continental Congresses,<br />

as well as in the Continental Congress, eventually being elected<br />

its president. He was only thirty-three when he was appointed Special<br />

Minister to Spain in 1779. This was an especially important post: Jay<br />

would have the responsibility for negotiating for the expected aid from<br />

Spain, perhaps even an alliance, as well as for the right for Americans<br />

to use the southern Mississippi for shipping (New Orleans then being in<br />

Spain’s control).<br />

Even before departing for Spain, Jay worried about the Spanish habit <strong>of</strong><br />

reading diplomatic correspondence. He proposed the following to Robert<br />

R. Livingston, then delegate to the Continental Congress and Jay’s former<br />

law partner.<br />

On Board the Confederacy near Reedy Island, 25 October 1779<br />

Dear Robert<br />

... To render [our correspondence] more useful and satisfactory a<br />

Cypher will be necessary. There are twenty six Letters in our alphabet.<br />

Take twenty six Numbers in Lieu <strong>of</strong> them thus.<br />

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<br />

5 6 7 11 13 8 9 10 12 14 16 19 22 1 2 3 4 15 23 25 26 24 20 21 18 17<br />

Remember in writing in this Way to place a , after each number, and<br />

a ; or : or a - after each Word. This will prevent Confusion.” [Morris,<br />

pgs 656–666]<br />

(a) A portion <strong>of</strong> the remainder <strong>of</strong> this letter has been enciphered using<br />

Jay’s method. Decipher it.<br />

12, 25; 20, 12, 19, 19: 6, 13; 26, 1, 1, 13, 7, 13, 23, 23, 5, 15,<br />

18- 25, 2; 20, 15, 12, 25, 13: 5: 20, 10, 2, 19, 13- Letter; 12, 1:<br />

Cypher- 23, 2; 22, 5, 1, 18; 20, 2, 15, 11, 23: 12, 1- Cypher- 5,<br />

23; 20, 12, 19, 19: 6, 19, 12, 1, 11; 25, 10, 13- Sense: 20, 12, 19,<br />

19; 6, 13- 23, 26, 8, 8, 12, 7, 12, 13, 1, 25; 5, 1, 11: 22, 2, 15, 13-<br />

23, 5, 8, 13: 5, 23- 5: Discovery: 20, 12, 19, 19: 25, 10, 13, 15,<br />

13, 6, 18- 6, 13; 15, 13, 1, 11, 13, 15, 13, 11- 22, 2, 15, 13: 11, 12,<br />

8, 8, 12, 7, 26, 19, 25<br />

(b) The message contains some <strong>of</strong> Jay’s thoughts on making an enciphered<br />

message more secure. Do you agree or disagree with Jay’s<br />

thoughts Explain.


5.10. EXERCISES 87<br />

17. General Pierre G.T. Beauregard, departmental commander <strong>of</strong> South Carolina,<br />

Georgia, and Florida forces <strong>of</strong> the Confederate Army sent Maj. Gen.<br />

Patton Anderson the following on 7 April 1864 [Gaddy]<br />

“General:<br />

I inclose you herewith the following simple cipher for future use in<br />

important telegrams to these headquarters. For very important telegrams<br />

the diplomatic cipher should be used. Please inform me <strong>of</strong> its<br />

reception.<br />

[Inclosure]<br />

[end quote]<br />

A by M H by R O by U U by F<br />

B by K I by S P by I V by Q<br />

C by O J by V Q by G W by D<br />

D by A K by H R by Y X by T<br />

E by N L by X S by E Y by B<br />

F by C M by P T by Z Z by J<br />

G by W N by L<br />

(a) Using this cipher, ORMYXNEZUL, EUFZR OMYUXSLM gives Beauregard’s<br />

location. Where was he<br />

(b) Using this cipher, Anderson’s location was KMXADSL CXUYSAM. Where<br />

is this<br />

18. (a) Here is a cipher sent during the controversy about the Florida electoral<br />

returns following the 1876 Presidential election. [Glover, page<br />

E-48].<br />

Jacksonville, 13.<br />

GEO. P. RANEY: 1:12 a.m., Nov. 14.<br />

Y e e i e m n s p p a i s s i t p i n s i t i t a a s h s h y y p<br />

i i m i m n s s s p e e n a a a i m a e n n s y i s n p i n s i m i<br />

m p e a a i t y y e n.<br />

DANIEL.<br />

As the New York Tribune put it, “It was evident, on a slight examination,<br />

that each letter in this cipher was not a substitute for<br />

another letter. . . . Probably, then, each letter in the cipher alphabet<br />

consisted <strong>of</strong> two characters.” Why<br />

(b) The Tribune then continued with a second message, “which, being<br />

partly in plain English, seemed to promise a clew [sic].”


88 CHAPTER 5. MONOALPHABETIC CIPHERS<br />

JACKSONVILLE, Nov. 22<br />

S. PASCO, Tallahassee:<br />

Gave p p a i s h s h<br />

charge <strong>of</strong> i t y y i t n<br />

s he sent to m a<br />

p i n s i m y y<br />

p i i t But not to<br />

the other. Brevard returns<br />

sent you to-day E m y<br />

y p i s s a i n y<br />

Gone to Tallahassee Talla<br />

with him and let me know if I<br />

shall send trusty messenger.<br />

J. J. DANIEL.<br />

The Tribune started its explanation by noting that<br />

It appeared to be nearly certain that the first cipher word [in<br />

the second message] was the name <strong>of</strong> a person, and the second<br />

and third were names <strong>of</strong> counties. If we assume that each cipher<br />

[letter] consists <strong>of</strong> two letters, we must find as the equivalent <strong>of</strong><br />

“ityyitns” a word <strong>of</strong> four letters, the first and third <strong>of</strong> which,<br />

“it,” are the same. “Dade” is the only name in the list <strong>of</strong> Florida<br />

counties which fulfils these conditions. The letters <strong>of</strong> “Dade” are<br />

repeated in the next word, and fit in with the obvious interpretation<br />

“Brevard. . . . The construction <strong>of</strong> the rest <strong>of</strong> the alphabet<br />

was now easy.<br />

Please complete the construction <strong>of</strong> the alphabet, and so decrypt the<br />

messages.


Chapter 6<br />

Decrypting Monoalphabetic<br />

Ciphers<br />

We begin with the unsolved cipher from Section 5.5:<br />

KNHHXKK QS PXTDQSB YQFJ NSISCYS HQEJXUK QK LXTKNUXP AO FJXKX RCNU<br />

FJQSBK QS FJX CUPXU STLXP EXUKXVXUTSHX HTUXRND LXFJCPK CR TSTDOKQK<br />

QSFNQFQCS DNHI FJX TAQDQFO TF DXTKF FC UXTP FJX DTSBNTBX CR FJX<br />

CUQBQSTD QK VXUO PXKQUTADX ANF SCF XKKXSFQTD<br />

The ciphertext has as its frequency chart<br />

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<br />

4 5 10 10 2 17 0 6 2 9 17 3 0 9 4 7 18 4 16 16 12 2 0 27 2 0<br />

We have previously determined that this is not a Caesar cipher (as none <strong>of</strong><br />

the usual hill and valley patterns fit) so we are treating it as a monoalphabetic<br />

cipher <strong>of</strong> unknown type. The most common letters are C, D, F, J, K, Q, S,<br />

T and X, so these are probably the substitutes for etaoinshr. But which is<br />

which and how can we decide<br />

Just as ciphers with word spacing are generally easier to decrypt than those<br />

without, long ciphers are generally easier to decrypt than short ones. And for<br />

a simple reason: the longer the cipher is, the more accurate the information<br />

given by the frequency count is likely to be. If we are given a 100, 000 letter<br />

message enciphered with a monoalphabetic substitution (without other trick!),<br />

we can be quite confident that exactly one <strong>of</strong> the ciphertext letters will occur<br />

almost 13% <strong>of</strong> the time, and this letter stands for e, that the next most common<br />

letter will appear very near 9% <strong>of</strong> the time and will stand for t, etc. Very little<br />

thought will be needed to decrypt the cipher. It is the medium length ciphers <strong>of</strong><br />

25 to 100 letters, usually without proper word division, that give the beginning<br />

codebreaker some difficulty. We will concentrate on those in this chapter.<br />

89


90 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

6.1 Letter Interactions<br />

We have previously given the frequencies <strong>of</strong> letters, initial letters and final letters.<br />

Now we must look in more detail at the characteristics <strong>of</strong> the letters: how<br />

they behave and interact with each other.<br />

Approximately 35% <strong>of</strong> letters in English are the vowels aeio and about 35%<br />

<strong>of</strong> letters are the dominant consonants hnrst. So if we can determine which<br />

ciphertext letters represent these nine letters about 70% <strong>of</strong> the decrypting will<br />

be done. (And the rest will usually be fill in the blank.) Thus the main challenge<br />

when tackling a monoalphabetic cipher is telling the etaoinshr letters apart.<br />

First, these nine letters tend to group themselves into three sets <strong>of</strong> three by<br />

the likelihood they are initial or final letters, as can be seen in Figures 5.6 and<br />

5.6.<br />

Initial and Final Letters:<br />

(1) t, o and s appear frequently as both initial and final letters.<br />

(2) a, i, and h appear frequently as initial letters, but much less so as final<br />

letters.<br />

(3) e, n and r appear frequently as final letters but much less so as initial letters.<br />

While the doubling <strong>of</strong> a letter is fairly rare, in a long message there will<br />

almost certainly be some, and this help us tell the letters apart.<br />

Doublings:<br />

(1) ee, tt, oo and ss are common doubles.<br />

(2) aa, ii, hh, nn and rr are less common.<br />

Next, the vowels.<br />

Vowels:<br />

(1) Vowels like to combine with consonants, but not with each other.<br />

(2) Vowels are friendly, willing to combine with many different letters, including<br />

the low frequency ones.<br />

(3) The only common pairs <strong>of</strong> vowels are ou, ea and io.<br />

(4) e is the easiest to find: it is very common and ends many words.<br />

(5) a frequently follows e but never precedes it.<br />

(6) The pair ie and ei is the only common vowel-vowel reversal.<br />

(7) e and o almost never touch each other and both will make doubles.<br />

Finally, the consonants.<br />

Consonants:<br />

(1) Consonants like vowels, but, as there are so many <strong>of</strong> them and so few vowels,<br />

they <strong>of</strong>ten combine with one another as well.


6.2. DECRYPTING MONOALPHABETIC CIPHERS 91<br />

(2) h can be the easiest consonant to identify. It precedes vowels, rarely follows<br />

them, and can be found most <strong>of</strong>ten in th, he and ha.<br />

(3) t acts like a vowel in that it likes to mate with many other letters. It has a<br />

very strong desire to make th’s, and will make tt’s.<br />

(4) r will appear next to any vowel, and likes the company <strong>of</strong> the other highfrequency<br />

letters.<br />

(5) n and s act behave the reverse <strong>of</strong> h. They prefer to follow vowels and precede<br />

consonants. It can be hard to tell whether nst are vowels or consonants.<br />

We summarize some <strong>of</strong> this information in Figure 6.1, using x and X to<br />

indicate strong and stronger behaviors.<br />

a e i o t r n h s<br />

common x X x x x<br />

starting words x x x X x<br />

ending words X x x x x<br />

lots <strong>of</strong> mates x X x x x<br />

doubles x x x x<br />

Figure 6.1: Some Basic Letter Behaviors<br />

6.2 Decrypting Monoalphabetic Ciphers<br />

Now its time we get decrypting. What do we do<br />

1) Make a frequency chart.<br />

2) Does the frequency count suggest a Caesar cipher Look for e and t, the aei<br />

and rst triples, the uvwxyz string, either forwards or backwards. If you find<br />

two or three <strong>of</strong> these patterns it may be a Caesar cipher and we can decrypt<br />

these. If not, continue with step 3.<br />

3) Find the most common letters: these are probably etaoinshr.<br />

4) Develop a digraph table for the probable etaoinshr letters. For each<br />

appearance <strong>of</strong> a common ciphertext letter list the letter that precedes it and<br />

the letter that follows it in the cipher. These tables are a bit time consuming<br />

to construct, but are very helpful, especially for ciphers without word breaks.<br />

5) Use the letter behaviors table, Figure 6.1, to make initial guesses.<br />

6) Work hard and be persistent.


92 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

Let us illustrate these steps with the example given earlier. We start with<br />

an example that has word breaks because these are a bit easier. To help us later<br />

lets also number the words<br />

(1)KNHHXKK (2)QS (3)PXTDQSB (4)YQFJ (5)NSISCYS (6)HQEJXUK (7)QK<br />

(8)LXTKNUXP (9)AO (10)FJXKX (11)RCNU (12)FJQSBK (13)QS (14)FJX (15)CUPXU<br />

(16)STLXP (17)EXUKXVXUTSHX (18)HTUXRND (19)LXFJCPK (20)CR (21)TSTDOKQK<br />

(22)QSFNQFQCS (23)DNHI (24)FJX (25)TAQDQFO (26)TF (27)DXTKF (28)FC<br />

(29)UXTP (30)FJX (31)DTSBNTBX (32)CR (33)FJX (34)CUQBQSTD (35)QK (36)VXUO<br />

(37)PXKQUTADX (38)ANF (39)SCF (40)XKKXSFQTD<br />

<strong>St</strong>ep 1) Make a Frequency Chart:<br />

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<br />

4 5 10 10 2 17 0 6 2 9 17 3 0 9 4 7 18 4 16 16 12 2 0 27 2 0<br />

<strong>St</strong>ep 2) Is it a Caesar Cipher<br />

This does not look like a Caesar cipher. X is probably e, but then U is a, T is z,<br />

S is y, etc., which looks bad.<br />

<strong>St</strong>ep 3) Find the common letters:<br />

The most common letters are C, D, F, J, K, Q, S, T, and X. (We usually pick the<br />

most common letters seven to ten letters.)<br />

<strong>St</strong>ep 4) Make a Digraph Chart:<br />

For each letter from <strong>St</strong>ep 3) we build a column that gives each appearance <strong>of</strong><br />

that letter. Let’s work on C’s column. C’s first appearance is in word (5), where<br />

it is preceded by S and followed by Y. So we put an SY in the C column. Similarly,<br />

an RN will come from C’s next appearance, in word (11). We will use “.” to<br />

indicate a space, or no letter. So word (15) provides with a .U, in word (28)<br />

with a , we put F. Doing this for each appearance <strong>of</strong> each common letter results<br />

in Figure 6.2.<br />

<strong>St</strong>ep 5) Make a Letter Behavior Table:<br />

The Digraph Table took some time, but makes it easy to build a Behavior Table.<br />

For example, there are four times .* appears in C’s column (here * just means<br />

“some letter”), so C must begin four words. Likewise one *. shows C ends one<br />

word.<br />

C D F J K Q S T X<br />

count 10 10 17 9 17 18 16 16 27<br />

start 4 3 7 1 1 5 2 3 1<br />

end 1 3 3 1 7 0 4 0 8<br />

mates 9 6 9 5 10 14 10 13 15<br />

doubles 0 0 0 0 0 2 0 0 0


6.2. DECRYPTING MONOALPHABETIC CIPHERS 93<br />

C D F J K Q S T X<br />

SY TQ QJ F. .N .S Q. XD HK<br />

RN N. .J EX XK DS QB XK PT<br />

.U TO .J FX K. YF NI SL JU<br />

JP .N .J FQ U. HE IC US LT<br />

.R QQ XJ FX Q. .K Y. HU UP<br />

QS .X SN FC TN JS QB .S FK<br />

F. .T QQ FX XX .S Q. SD K.<br />

.R T. .J FX B. KK .T .A J.<br />

.U AX QO FX UX .S TH .F PU<br />

SF T. T. P. NF TT XK LP<br />

K. OQ FC QF XP EU<br />

.C Q. AD C. DS KV<br />

.J TF DF TB NB VU<br />

.J Q. UB QT SD H.<br />

N. XQ BS .C UA UR<br />

C. XK .K XF QD LF<br />

SQ KX KU J.<br />

FT<br />

DT<br />

UT<br />

J.<br />

B.<br />

J.<br />

VU<br />

PK<br />

D.<br />

.K<br />

KS<br />

Figure 6.2: Digraph Table<br />

<strong>St</strong>ep 6) Make our first guesses:<br />

(1) X=e: it is common, ends many words, starts few words.<br />

(2) F=t: it is common, starts many words, appears a lot with the one letter J,<br />

which is probably h.<br />

(3) J also mates a lot but starts and ends few words, also like h.<br />

These three guesses I’d be pretty sure <strong>of</strong>, especially after noting the five<br />

times FJX = the appears.<br />

(4) K ends words, does not start them, appears as a double. Maybe s or r<br />

(5) S end words but does not start them. Maybe r or n<br />

(6) Q and T start words but do not end them. Maybe a or i<br />

(7) D doesn’t mate too much, but is common and both starts and ends some<br />

words. Maybe s


94 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

(8) Finally, C more or less matches the description o.<br />

Next, lets use the information we strongly believe to determine some other<br />

letters. <strong>St</strong>art with FJX=the. FJXKX must either be there or these, so K is r or<br />

s. From earlier we’d guessed r or n. So probably K=r. Since S was r or n, that<br />

makes S=n. Then the second word <strong>of</strong> the cipher QS=*n must be in, so Q=i and<br />

T=a. (It would be odd for the second word <strong>of</strong> a sentence to be an. Of course, if<br />

we are wrong, we can always come back and try this later.) Now FC=t* must<br />

be to, so C=o, as we’d guessed previously.<br />

Summarizing our current guesses: ciphertext C D F J K Q S T X<br />

plaintext o s t h r i n a e<br />

Now let’s substitute these.<br />

KNHHXKK QS PXTDQS B YQF J N S I S CYS HQE J XU K<br />

r e r r i n e a s i n i t h n n o n i h e r<br />

QK LXTKNUXP AO F J XKX RCNU F JQS BK QS F J X<br />

i r e a r e t h e r e o t h i n r i n t h e<br />

CUPXU S TLXP EXUKXVXUTSHX HTUXRND LXF J C P K<br />

o e n a e e r e e a n e a e s e t h o r<br />

CR T S TDOKQK QS FNQFQC S DN H I F J X TAQDQFO TF<br />

o a n a s r i r i n t i t i o n s t h e a i s i t a t<br />

DXTKF FC UXTP F J X DT S BNT B X CR F J X CUQB Q S T D<br />

s e a r t t o e a t h e s a n a e o t h e o i i n a s<br />

QK VXUO PXKQUTADX ANF S C F XKKXS FQTD<br />

i r e e r i a s e t n o t e r r e n t i a s<br />

We’ve made progress, with many words looking like real English. But we’ve<br />

also made a couple <strong>of</strong> wrong guesses. Words (1) and (7) are not words, so there<br />

is a mistake here. Perhaps QK=is, so K=s Changing this makes the final word<br />

<strong>of</strong> the cipher XKKXSFQTD=essentia*, hence D=l. (l is the tenth most common<br />

letter in English, after etaoinshr, so it is not surprising that it is one <strong>of</strong> the<br />

seven most common letters in this text.)<br />

With these two changes we have<br />

KNHHXKK QS PXTDQS B YQF J N S I S CYS HQE J XU K<br />

s e s s i n e a l i n w i t h n n o n i h e s<br />

QK LXTKNUXP AO F J XKX RCNU F JQS BK QS F J X<br />

i s e a s e t h e s e o t h i n s i n t h e<br />

CUPXU S TLXP EXUKXVXUTSHX HTUXRND LXF J C P K<br />

o e n a e e s e e a n e a e l e t h o s<br />

CR T S TDOKQK QS FNQFQC S DN H I F J X TAQDQFO TF<br />

o a n a l s i s i n t i t i o n l t h e a i l i t a t<br />

DXTKF FC UXTP F J X DT S BNT B X CR F J X CUQB Q S T D<br />

l e a s t t o e a t h e l a n a e o t h e o i i n a l<br />

QK VXUO PXKQUTADX ANF S C F XKKXS FQTD<br />

i s e e s i a l e t n o t e s s e n t i a l


6.2. DECRYPTING MONOALPHABETIC CIPHERS 95<br />

At this point it is nearly fill in the blanks. (This is the opening sentence <strong>of</strong><br />

Colonel Parker Hitt’s 1916 Manual for the Solution <strong>of</strong> Military Ciphers, one<br />

<strong>of</strong> the first serious American books on cryptology, enciphered with a keyword<br />

transposed cipher with keyword TRICKY.)<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Not all examples will be as quick as this one. You will <strong>of</strong>ten need to swap<br />

a pair <strong>of</strong> common letters, like we did from K=r to K=s. However, work methodically,<br />

on a large piece <strong>of</strong> paper, with pencil and not ink, and after a little<br />

practice soon you will be decrypting ciphers with the best <strong>of</strong> them.<br />

Example: Decrypt the following cipher without word breaks.<br />

ROXEY ZLOHE QXHUW ROXEY HUHKX TVTHO BTZPB<br />

YVPBT RHKKB WYNVU ZOOBR VEOZR HKTRV BURBT<br />

HUWVU GDURY VZUYQ BXVUW BBWPV OOZOZ UBHUZ<br />

YQBON QHYZU BWZBT YQBZY QBODU WZBTY QBVOU<br />

HYDOB TQZNB IBOWV GGBOG DUWHP BUYHK KXROX<br />

EYZLO HEQXV TYQBZ OBYVR HKHUW HMTYO HRYRO<br />

XEYHU HKXTV TVTBP EVOVR HKHUW RZURO BYBWH<br />

IVWFH QU<br />

<strong>St</strong>ep 1) Frequency Chart:<br />

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<br />

0 28 0 4 8 1 4 24 2 0 9 2 1 3 23 5 11 15 0 14 21 18 13 10 20 16<br />

<strong>St</strong>ep 2) Certainly this is not any sort <strong>of</strong> Shift Cipher.<br />

<strong>St</strong>ep 3) The most common letters are B, H, O, R, T, U, V, Y, and Z.<br />

<strong>St</strong>ep 4) See Figure 6.3.<br />

<strong>St</strong>ep 5) See Figure 6.4.<br />

<strong>St</strong>ep 6) The lack <strong>of</strong> information about initial and final letters make this cipher<br />

considerably more difficult to decrypt than the previous one. But we must start<br />

somewhere. B is most common letter, has lots <strong>of</strong> mates, is doubled, so maybe<br />

B=e. If this is so, the most common mates with B are OTUWYZ, so these may be<br />

consonants and HRV vowels.<br />

Looking at HRV, HV both have many low frequency mates, whereas R combines<br />

with mostly high frequency letters. So HV must indeed be vowels, but R is<br />

actually probably a consonant.<br />

Now V appears both before and after B=e, whereas H appears only after.<br />

Let’s guess V=i. The pair eo is very rare, so if H is to be a vowel it must be a.


96 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

B H O R T U V Y Z<br />

OT OE RX .O XV HW TT EZ YL<br />

PY XU LH WO VH HH YP EH TP<br />

PT YU RX TH BZ VZ NU BV UO<br />

KW UK HB BV BR BR RE WN OR<br />

OR TO ZO ZH KR HW RB RV VU<br />

VU RK OB TV BH VG WU UQ OO<br />

RT RK EZ UB BY DR YZ ZQ OU<br />

QX TU VO UY BY ZY XU HZ UY<br />

WB BU OZ XO BQ VW PO TQ YU<br />

BW QY ZZ VH VY ZB BO ZQ WB<br />

UH UY BN HY MY HZ WG TQ BY<br />

QO WP BD YO XV ZB XT HD WB<br />

UW YK VU VH VV DW YR UH QN<br />

ZT OE DB WZ VB OH TT EZ YL<br />

QZ RK BW UO DW TT TQ BO<br />

QO KU BG BY EO BV RU<br />

ZT WM RX HW OR TO<br />

QV OR LH HH IW RR<br />

OT YU ZB HW EH<br />

NI UK YH ZR BB<br />

IO RK RX Q.<br />

GO KU VV<br />

PU WI RB<br />

QZ FQ<br />

OY<br />

TP<br />

OY<br />

YW<br />

Figure 6.3: Digraph Table<br />

Next, Q follows Y a remarkable six times, with B right behind each time. We<br />

must have YQB=the.<br />

Turning to our other high frequency letters, ORTUWZ, which is o Of these<br />

letters, Z likes to combine with our vowels BHV the least. Is it possible Z=o<br />

The outstanding undetermined letter is O. It appears with all our vowels,<br />

both precedes and follows each, and <strong>of</strong> its common mates almost all are high<br />

frequency letters. Of nrs this sounds most like r.<br />

So we now have the guesses B=e, H=a, O=r, Q=h, V=i, Y=t, Z=o. Let’s


6.3. SUKHOTIN’S METHOD FOR FINDING VOWELS 97<br />

B H O R T U V Y Z<br />

count 28 24 23 15 14 21 18 20 16<br />

mates 17 15 15 11 10 12 14 13 12<br />

doubles 1 2<br />

favorites OPQT KORUY BHOR HOV BVY BHWZ ORT BEHQ BOUY<br />

UWYZ VXZ TZ<br />

Figure 6.4: Letter Behaviors<br />

substitute them and see how they look.<br />

ROXE Y Z LOH E Q X HUWRO X EYH U HK X T V T H O B T ZP<br />

r t o r a h a r t a a i a r e o<br />

BYVP B T RHK K BWYN V UZ OOBR V EO Z R H K T R V BUR<br />

e t i e a e t i o r r e i r o a i e<br />

BTHUW V UGD U R Y VZ U YQ B XVUWBBWP V OO Z O Z UB<br />

e a i t i o t h e i e e i r r o r o e<br />

HUZY Q B ONQ H Y Z UBWZB T YQB Z YQ B O D UW Z B TYQ<br />

a o t h e r h a t o e o e t h e o t h e r o e t h<br />

BVOU H Y DOB T Q Z NB I BOWVGG B OG D UWH P B U YHK<br />

e i r a t r e h o e e r i e r a e t a<br />

KXRO X E YZ L O H E QX V TY Q BZO B YV R H K H U W H MTY<br />

r t o r a h i t h e o r e t i a a a t<br />

OHRY R O XEY H U H KX T VT V TBP E VO V R H K H U WR ZU<br />

r a t r t a a i i e i r i a a o<br />

ROBY B WH I VWF H QU<br />

r e t e a i a h<br />

While there is always a lot <strong>of</strong> hard work in decrypting, there is also usually a<br />

point at which the discoveries start to come at you very rapidly. We are now at<br />

that stage. <strong>St</strong>aring at the message there now many places letters jump out at<br />

us. The “tio the” in the middle <strong>of</strong> the third line says “n”, for example. So we<br />

know we are both on the right track, and very close to the end. 1<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

6.3 Sukhotin’s Method for Finding Vowels<br />

In a field like cryptography, there are always new tricks and shortcuts being<br />

proposed to simplify one or another part <strong>of</strong> the enciphering, deciphering or de-<br />

1 “Cryptography and cryptanalysis are sometimes called twin or reciprocal sciences, and in<br />

function they indeed mirror one another. What one does the other undoes. Their natures,<br />

however, differ fundamentally. Cryptography is theoretical and abstract. Cryptanalysis is<br />

empirical and concrete.” David Kahn.


98 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

crypting process. Areas <strong>of</strong> frequent interest are methods for decrypting monoalphabetic<br />

ciphers more quickly. To give a flavor <strong>of</strong> these, we present a slight<br />

variation on a method for recognizing the vowels in a short ciphertext due to<br />

B. V. Sukhotin [Gray].<br />

The idea behind this method is that vowels tend to have a wide variety <strong>of</strong><br />

partners, with the vast majority being consonants. We should be able to make<br />

use <strong>of</strong> this to weed out the vowels from the consonants. The easiest way to<br />

explain the method is to use it. Let’s use our first example from Section 6.2 as<br />

the ciphertext.<br />

<strong>St</strong>ep 1: Use the digraph chart to count the number <strong>of</strong> times each proposed<br />

etaonishr letter is in contact with another <strong>of</strong> these letters, ignoring any times<br />

they contact themselves, and total the results.<br />

C D F J K Q S T X total<br />

C 0 2 1 0 1 3 0 0 5<br />

D 0 0 0 0 3 0 5 2 10<br />

F 2 0 8 1 5 2 1 1 20<br />

J 1 0 8 0 1 0 0 6 16<br />

K 0 0 1 0 5 0 2 7 15<br />

Q 1 3 5 1 5 6 1 0 22<br />

S 3 0 2 0 0 6 6 1 18<br />

T 0 5 1 0 2 1 6 4 19<br />

X 0 2 1 6 7 0 1 4 20<br />

<strong>St</strong>ep 2: The letter with the largest total is a vowel. Mark it so. Any letter<br />

contacting a vowel is probably not one. So we go through the remaining rows,<br />

and penalize each row by twice the number <strong>of</strong> times this vowel appears in their<br />

list.<br />

C D F J K Q S T X total total2<br />

C 0 2 1 0 1 3 0 0 7 5<br />

D 0 0 0 0 3 0 5 2 10 4<br />

F 2 0 8 1 5 2 1 1 20 10<br />

J 1 0 8 0 1 0 0 6 16 14<br />

K 0 0 1 0 5 0 2 7 15 5<br />

Q 1 3 5 1 5 6 1 0 22 vowel<br />

S 3 0 2 0 0 6 6 1 18 6<br />

T 0 5 1 0 2 1 6 4 19 17<br />

X 0 2 1 6 7 0 1 4 20 20<br />

<strong>St</strong>ep 3: Again, the letter with the largest remaining count is a vowel. Mark it


6.4. FINAL MONOALPHABETIC TRICKS 99<br />

and penalize those that touch it.<br />

C D F J K Q S T X total total2 total3<br />

C 0 2 1 0 1 3 0 0 7 5 5<br />

D 0 0 0 0 3 0 5 2 10 4 0<br />

F 2 0 8 1 5 2 1 1 20 10 8<br />

J 1 0 8 0 1 0 0 6 16 14 2<br />

K 0 0 1 0 5 0 2 7 15 5 -9<br />

Q 1 3 5 1 5 6 1 0 22 vowel<br />

S 3 0 2 0 0 6 6 1 18 6 4<br />

T 0 5 1 0 2 1 6 4 19 17 9<br />

X 0 2 1 6 7 0 1 4 20 20 vowel<br />

<strong>St</strong>ep 4: Repeat twice more to find the other two aeio vowels.<br />

C D F J K Q S T X total total2 total3 total4 total5<br />

C 0 2 1 0 1 3 0 0 7 5 5 5 1<br />

D 0 0 0 0 3 0 5 2 10 4 0 -10 -10<br />

F 2 0 8 1 5 2 1 1 20 10 8 6 vowel<br />

J 1 0 8 0 1 0 0 6 16 14 2 0 -16<br />

K 0 0 1 0 5 0 2 7 15 5 -9 -13 -15<br />

Q 1 3 5 1 5 6 1 0 22 vowel<br />

S 3 0 2 0 0 6 6 1 18 6 4 -8 -12<br />

T 0 5 1 0 2 1 6 4 19 17 9 vowel<br />

X 0 2 1 6 7 0 1 4 20 20 vowel<br />

So, according to this method, QXT and F are the vowels.<br />

Now no method is foolpro<strong>of</strong>. This one heavily depends on the letter that<br />

contacts the common letters the most being a vowel, and if the first “vowel”<br />

designation is wrong, this method will quickly lead into a morass. Here, Q has<br />

the largest initial total, but only by 2. Both F and S have high totals, even<br />

though they are consonants. If either had occured a couple more times, we’d<br />

have had trouble.<br />

Similarly, no method should be applied without thought. At the end <strong>of</strong> <strong>St</strong>ep<br />

4, C had a total <strong>of</strong> 5 and F a total <strong>of</strong> 6. Which is more likely to be a vowel<br />

Vowels tend to dislike one another, and C touches QTX a total <strong>of</strong> once, while F<br />

touches each <strong>of</strong> them for a total <strong>of</strong> 14 times. So, even though its total is a bit<br />

smaller, it is more likely that C is a vowel.<br />

6.4 Final Monoalphabetic Tricks<br />

The examples in this chapter hopefully have convinced you that even a good<br />

monoalphabetic substitution is not a very good cipher method. How, then,<br />

should we make a better cipher The name mono gives us a hint: we must<br />

change the one-for-one letter replacement and cause multiple letters to represent


100 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

the same letter. That is the goal <strong>of</strong> our next chapter. We end this chapter with a<br />

couple <strong>of</strong> ways that can make monoalphabetic ciphers harder to decrypt. (These<br />

tricks can actually be used with most <strong>of</strong> the ciphers we will see.)<br />

Homophones. When a substitution alphabet has multiple substitutions for a<br />

given letter these substitutes are called homophones. For instance, we may<br />

decide that every other e will be replaced by a z before the message is enciphered.<br />

Since z is so uncommon, our partner should be able to figure out we’ve replaced<br />

some e’s by z’s without prior warning. But to the enemy who intercepts the<br />

ciphertext, the tall 12% peak <strong>of</strong> e’s will be split into two far less visible 6%<br />

bumps. This would make the frequency analysis <strong>of</strong> our adversary a bit harder.<br />

Homophones are more commonly used when one is sending the ciphertext in<br />

numerical form. For example, consider the replacement list in a cipher <strong>of</strong> Henri<br />

IV <strong>of</strong> Navarre <strong>of</strong> France, c. 1600. [Pratt, page 64.]<br />

plaintext a b c d e f g h i l n o p r s t u w x y z<br />

ciphertextA 31 26 27 28 31 29 3 33 12 14 44 15 16 17 9 20 21 22 23 24 25<br />

ciphertextB 34 35 36 37 38 39 30 41 42 43 67 18 46 47 19 50 51 52 76 54 55<br />

ciphertextC 37 59 60 61 62 40 64 65 66 85 45 69 70 49 73 74 75 77 78<br />

ciphertextD 80 81 82 68 83 72 84 86 87<br />

(Most <strong>of</strong> the unassigned numbers stood for common words: 10 = le, 39 = mon.)<br />

To encipher a letter choose one <strong>of</strong> the numbers beneath it. So tres might<br />

be enciphered as 20-17-31-9 or as 50-70-38-49. These multiple substitutes<br />

flatten the frequency chart, making it much harder for our adversary to decide<br />

which number(s) represent which letter.<br />

To make this effective we would probably want several homophones for each<br />

letter, and then somehow force ourselves to pick the homophones at random.<br />

We might have six homophones for each letter and then to encipher a letter<br />

we would roll a die and if the die comes up with a 4, then pick the fourth<br />

homophone as the cipherletter. Unfortunately, homophones make enciphering<br />

and deciphering much slower.<br />

Further, if the message is thousands <strong>of</strong> letters long frequency analysis will<br />

still win out. A handwritten page will have approximately 500 characters on it<br />

(about 25 characters per line and 20 lines per page) and a typewritten page can<br />

easily consist <strong>of</strong> 3000 characters (70 characters per line and 45 lines per page).<br />

For our die-homophone example, the cipher-numerals standing for uvwxyz still<br />

would very seldom be used, while those standing for e would be popular, and<br />

<strong>of</strong>ten occur paired with those standing for t and h. So while homophones are<br />

helpful, they cannot make monoalphabetic ciphers secure.<br />

Nulls. Extra meaningless symbols that added to a text only to confuse the<br />

enemy analysts are known as nulls. One could spread a number <strong>of</strong> unpopular<br />

letters randomly throughout the plaintext. Itz yisx xnot jtooquk qdifficult<br />

wtowq jread ax meksskage cbontgainuing nzullys, but it is harder to cryptanalize<br />

it. However, it is a bother to add (and later, remove) such letters, and they make


6.5. SUMMARY 101<br />

our ciphertext much longer than it would otherwise have been. Nonetheless, all<br />

modern cipher techniques involve the use <strong>of</strong> nulls.<br />

Salting the message. Many messages begin and end with similar, repeated<br />

information. It is standard practice to begin the message with whom it is for,<br />

and who is sending it: “From: Capt. Thomas, USS Lexington. To: Admiral<br />

Nelson, Enterprise Carrier Group, US South Pacific Force.” To prevent an<br />

adversary from guessing such a stereotyped beginning <strong>of</strong> a message, one salts<br />

the message by adding a meaningless strings to the beginning and/or end <strong>of</strong> the<br />

plaintext before it is enciphered.<br />

A different method with the same purpose is Russian Copulation. Cut<br />

the message approximately in half and the swap the two halves. This hides the<br />

beginning and ending somewhere in the middle <strong>of</strong> the message. Hopefully, this<br />

is <strong>of</strong> no bother to the person who will decipher the message, but will prevent<br />

the enemy from using information about the stereotyped beginning and ending<br />

<strong>of</strong> the message. Unfortunately, it is a very small leap from guessing that<br />

“Enterprise” or “Naval Task Force” appears at the beginning and/or end <strong>of</strong> a<br />

message to using such words and phrases as cribs for the entire message. Cribs<br />

are words or phrases thought to be part <strong>of</strong> the message. If, say, “carrier” is<br />

thought to appear in a monoalphabetic cipher, a quick scan for its distinctive<br />

letter pattern **XX**X, where X represents any particular letter, should be able<br />

to determine this. And if it is found, the codebreaker has an immediate decryption<br />

<strong>of</strong> 5 letters <strong>of</strong> the code! We will not study them further, but clearly cribs<br />

are a very powerful tool to have when decrypting ciphers.<br />

6.5 Summary<br />

Decrypting shift ciphers involved only frequency analysis, really, just counting<br />

the letters. For more general monoalphabetic ciphers we need additional information<br />

about how the letters relate to one another. For example, while e and t<br />

both are very common letters, and both are among the most frequent final letters<br />

<strong>of</strong> words, e seldom starts words whereas t very frequently does. When the<br />

ciphertext is presented with word breaks, this information alone usually allows<br />

the identification <strong>of</strong> e and t, with h quickly following.<br />

Even without word breaks, vowels are much happier mating with consonants<br />

than with other vowels. We can thus use e and t as wedges to separate the vowels<br />

<strong>of</strong> aonirsh from the consonants. Using the differences in letter behavior should<br />

then give enough guesses at substitutions that we can then try out our guesses,<br />

fixing and revising as we make progress.<br />

Despite tricks like these, monoalphabetic ciphers simply are not very secure,<br />

and have not been for a very long time.


102 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

6.6 Topics and Techniques<br />

1. Of the etaoinshr letters<br />

(a) Which three appear frequently both as initial and final letters<br />

(b) Which three appear frequently as final letters, but less so as initial<br />

letters<br />

(c) Which three appear frequently as initial letters, but less so as final<br />

letters<br />

(d) Which four are most likely to make doubles<br />

2. Which are the most common vowel-vowel combinations Are they actually<br />

very common<br />

3. Which letters do vowels prefer to associate with What about consonants<br />

4. Which (type <strong>of</strong>) letters are the friendliest, associating with almost all<br />

others Which are most discriminating, preferring the company <strong>of</strong> only a<br />

few other letters<br />

5. Are ciphertexts that retain their word breaks easier or harder to decrypt<br />

Explain why.<br />

6. What is a digraph table How to construct one What does it tell us<br />

7. What is a homophone<br />

8. Why can ciphers that involve homophones be more secure than those<br />

without<br />

9. What is a null How do nulls make the cryptanalyst’s life more difficult<br />

6.7 Exercises<br />

1. Decrypt the following cipher.<br />

UN MGHHYV LNS VYETEHGUH HLY KVQFHNCVGM GDD HLGH TE VYGDDQ UYYRYR<br />

TE GU YUHVQ HLY TRYUHTATKGHTNU NA NUY SNVR NV NA HLVYY NV ANPV<br />

DYHHYVE LYDYU ANPKLY CGTUYE<br />

Frequency count:<br />

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<br />

5 0 2 6 6 1 9 15 0 0 3 7 2 12 0 2 3 4 2 8 10 12 0 0 19 0<br />

2. Decrypt the following cipher.<br />

GNLTA DTPUH IOHJQ BTCNJ QHCVN DQPIQ ZNDCN ZJTGD TQHIQ TWWHO TIGTH<br />

IQBTF NDWLQ NLPSH QVDNL XGTJC XGBCN DTPIL CXGBC NDTQD XJQFN DQBSH<br />

IZNDC PQHNI QBPIJ VHTJ


6.7. EXERCISES 103<br />

Frequency count:<br />

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<br />

1 6 8 11 0 2 7 10 9 7 0 4 0 13 2 6 14 0 2 13 1 2 3 4 0 3<br />

3. Decrypt the following cipher.<br />

PYJQG KYUQR CQEQR LOTGQ RQTRT RYTAH KYLTE HAWEJ QRWHQ RCTAW UHEWR<br />

PQAYW UQKWV YDWEH YPNGT RQHLT UYHQL YHKWR QHPYE YUVYE JKWUF YEBWB<br />

BWCY<br />

Frequency count:<br />

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<br />

4 3 3 1 8 1 3 9 0 3 5 4 0 1 1 4 13 10 0 8 6 2 11 0 14 0<br />

4. Fletcher Pratt used a Keyword Cipher to encipher the following message.<br />

Can you decrypt it, and recover the keyword<br />

SZPQP ERHKQ PCRKJ VZXPU PJSZP GKRSC GCSPT QIQXL SKNQC LZPQR ZXTFN<br />

ZPRES CSPFK JNKUP QCRDG LFPRT HRSES TSEKJ IELZP Q<br />

5. Decrypt the following cipher.<br />

AOPBO GDGPG DUKLD NWCTD OALTQ NGUMT AEDKR WDLWG WCUTD MDKAZ ZCGGC<br />

TOUFG WCNZA DKGCH GGASC KCDGW CTODK MZQUT DKMTU PNOUF LUKOG AKGZC<br />

KMGWW AXCBC CKTCN ZALCV BQUGW CTZCG GCTOF DMPTC OODMK OUTLU EBDKA<br />

GDUKO UFGWC EDKAL LUTVA KLCRD GWAVC FDKDG COQOG CEAKV SCQ.<br />

Frequency count:<br />

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<br />

14 4 25 20 4 5 23 1 0 0 18 9 7 5 14 4 5 2 2 14 14 4 11 1 0 7<br />

6. Among the techniques the British used during the Revolutionary War was<br />

a relatively simple monoalphabetic cipher. It was apparently used by Sir<br />

Henry Clinton, the commander-in-chief <strong>of</strong> His Majesty’s Forces in North<br />

America from 1778 to 1782.<br />

Decrypt the following fragment <strong>of</strong> a letter sent in this cipher.<br />

75 62 55 67 77 68 74 69 71 68 69 68 72 55 54 73 62 55 66 61<br />

73 73 55 71 73 68 66 55 63 73 62 68 74 61 62 73 63 62 51 54<br />

60 74 65 65 77 55 76 89 65 51 63 67 55 54 66 77 72 55 65 60<br />

Hint: start with a frequency count <strong>of</strong> the pairs <strong>of</strong> numbers.<br />

7. A technique for making a monoalphabetic cipher with homophones is to<br />

take a long word or phrase, number the letters in order <strong>of</strong> appearance,<br />

and then use those numbers as substitutes for the letters. Any letters that<br />

do not appear are numbered at consecutively at the end. (This method<br />

apparently originated with the Argenti’s [Kahn, 113].)<br />

In a letter on 9 Oct 1863 from 1st Lt. <strong>St</strong>ephen M. Routh, Chief Signal<br />

Officer <strong>of</strong> the District <strong>of</strong> West Louisiana, Confederate Army, to Maj. Gen.


104 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

<strong>St</strong>ephen D. Lee, it was suggested that “WILHELMINUSVOLKSVEST”<br />

be used in this manner. The numbering is<br />

W I L H E L M I N U S V O L K S V E S T<br />

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20<br />

As H appears only once, there is only one replacement for it. On the other<br />

hand, L appears three times so it has three possible replacements. The<br />

letters that don’t appear in the keyword are numbered at the end, so A is<br />

21, B is 22, and so on.<br />

When used with a long keyphrase the number <strong>of</strong> replacements for each<br />

letter will mimic how frequently they appear in normal language. If the<br />

substitute for a letter is always randomly chosen from the set <strong>of</strong> replacements,<br />

then this leads to a very flat frequency count. Hence this method<br />

can produce quite secure ciphertexts. Unfortunately, people tend to get<br />

lazy and generally reuse the same couple <strong>of</strong> replacements, destroying the<br />

strength <strong>of</strong> the system.<br />

(a) Routh’s word was later taken up by General Robert E. Lee. He<br />

used it to encipher a message he sent on 23 Nov 1863 [Gaddy]. The<br />

following contains Lee’s location and the name and location <strong>of</strong> the<br />

intended recipient. Decipher the message.<br />

25 30 13 7 4 29 23 21 12 21 3 30 32 2 9 7 8<br />

11 16 2 19 11 8 28 28 2 26 30 21 9 21 24 21 20<br />

13 23 13 6 22 5 9 27 21 7 8 9 16 1 18 1 14<br />

3 21 21 26 7 5 30 2 24 8 21 9<br />

(b) In June 1864 a Confederate major <strong>of</strong> Gen. E. Kirby Smith’s trans-<br />

Mississippi command deserted and disclosed a cipher similar to the<br />

one above, based on the word “impersonificationaly” [Gaddy].<br />

Decipher the following silly phrase (designed to take advantage <strong>of</strong> the<br />

homophones). 1 5 18 17 18 31 18 20 13 8 22 1 2 24 15 22 11 8 23 9<br />

17 2 7 17 14 18 8 13.<br />

8. The most famous cipher story in history is Edgar Allen Poe’s “The Gold<br />

Bug”. First published in 1843, it caused a sensation. By far Poe’s most<br />

popular story, it gave Poe an international reputation as a great cryptography.<br />

In the story, William Legrand is living on an island near South Carolina.<br />

By legend, this island was once the home <strong>of</strong> the pirate Captain Kidd.<br />

Legrand has found a new species <strong>of</strong> beetle, a gold-colored one. He draws a<br />

picture <strong>of</strong> this bug to show to a friend. It happens that the paper he uses<br />

contains a secret message written in invisible ink that just so happens to<br />

become visible when the friend just so happens to hold the paper close,<br />

but not too close, to a fire. Here is the message.


6.7. EXERCISES 105<br />

53++!305))6*;4826)4+.)4+);806*;48!8‘60))85;]8*:+*8!<br />

83(88)5*!;46(;88*96*;8)*+(;485);5*!2:*+(;4956*2(5*<br />

-4)8‘8*; 4069285);)6!8)4++;1(+9;48081;8:8+1;48!85;4<br />

)485!528806*81(+9;48;(88;4(+34;48)4+;161;:188;+;<br />

Legrand’s friend (the narrator <strong>of</strong> the story) is quickly able to decrypt this<br />

cipher and find the hidden treasure. Can you<br />

Hint: Do this like any monoalphabetic cipher.<br />

9. Some folks get very emotional about cryptology. The great cryptologist<br />

Blaise de Vigenére (Traicte’ des Chiffres, 1585) certainly did.<br />

02-17-17 15-2-9-8-11-24 20-10 16-24-11-24-17-4 20-20-13-21-24-11 2-15-<br />

25 2 10-24-0-11-24-9 06-11-20-9-20-15-22 9-21-24 22-11-24-2-9 15-2-16-<br />

24 2-15-25 24-10-10-24-15-0-24 14-23 22-14-25 2-15-25 21-20-10 6-14-15-<br />

25-24-11-10 9-21-24 7-24-11-4 25-24-24-25-10 13-11-14-19-24-0-9-10 6-<br />

14-11-25-10 2-0-9-20-14-15-10 2-15-25 25-24-16-24-2-15-14-11 14-23 16-<br />

2-15-18-20-15-25 6-21-2-9 2-11-24 9-21-24-4 23-14-11 9-21-24 16-14-10-9<br />

13-2-11-9 1-8-9 0-2 0-20-13-21-24-11<br />

10. E. A. Poe was aware <strong>of</strong> the use <strong>of</strong> homophones to help secure a monoalphabetic<br />

cipher. At one point he used the le gouvernement provisoire<br />

as a substitution alphabet:<br />

plain a b c d e f g h i j l m n o p q r s t u v x y z<br />

cipher L E G O U V E R N E M E N T P R O V I S O I R E<br />

(a) Encipher Monday.<br />

(b) Decipher ETONNNE.<br />

(c) William Friedman [Friedman, page 168] was not impressed with this<br />

method. Why<br />

11. Albert Myer used the following homophonic system. Set up the alphabet<br />

in columns: [SSA2, page 12 or Myers pages 101-111, 264-5.]<br />

element 1: A F K P U V<br />

element 2: B G L Q W<br />

element 3: C H M R X<br />

element 4: D I N S Y<br />

element 5: E J O T Z<br />

To encipher L, since is in the 2nd row, and the 3rd in that row, L = 23.<br />

To give homophones, now pick any letter from row 2, say W, and any from<br />

row 3, say R. So L becomes WR. Similarly f becomes FB or KW.<br />

Decipher UV CR PA FK KJ OF BH TC FG DS LL SR KU BX YI.


106 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS<br />

12. Frequency analysis was probably first invented by the Arabs. Decrypt the<br />

following message. The ideas are due to Ibn ad-Duraihim as paraphrased<br />

by Qalqashandi in 1412’s Subh al-a sha<br />

EJJLF GZPGE BAABO HJPPT OXJHA UOBVT BQAER ZQAGB XBHHD NBDQI PJXCD<br />

OBAGZ HFZAG AGBCD AABOQ JUEBA ABOUO BVTBQ PRCOB MZJTH ERXBQ AZJQB<br />

IFGBQ RJTHB BAGDA JQBEB AABOJ PPTOH ZQAGB XBHHD NBXJO BJUAB OQAGD<br />

QAGBO BHAAG BQDHH TXBAG DAZAZ HDEZU AGBQD HHTXB AGDAA GBQBY AXJHA<br />

UOBVT BQAZH EDXAG BDPPT ODPRJ URJTO PJQSB PATOB HGJTE IWBPJ QUZOX<br />

BIWRA GBUDP AZQDX DSJOZ ARJUP JQABY AHEDX UJEEJ FHDEZ U<br />

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<br />

40 45 3 20 13 4 19 21 4 24 0 1 1 2 19 15 20 8 2 13 12 3 2 13 2 15<br />

13. The aftermath <strong>of</strong> the election <strong>of</strong> 1876 provides us with a number <strong>of</strong> interesting<br />

ciphertexts [Elements and Secret 1876].<br />

Jacksonville, Nov. 16 (1876)<br />

Geo. F. Raney, Tallahassee:<br />

pp yy em ns ny yy pi ma sh ns yy ss it ep aa en<br />

sh ns pe ns sh ns mm pi yy sn pp ye aa pi ei ss ye<br />

sh ai ns ss pe ei yy sh ny ns ss ye pi aa ny it ns sh<br />

yy sp yy pi ns yy ss it em ei pi mm ei ss ei yy ei ss<br />

it ei ep yy pe ei aa ss im aa ye sp ns yy ia<br />

ns ss ei ss mm pp ns pi ns sn pi ns im im yy it em yy<br />

ss pe yy mm ns yy ss it sp yy pe ep pp ma aa yy pi it<br />

L’Engle goes up to-morrow. (signed) Daniel<br />

In this cipher pairs <strong>of</strong> letters were used as substitutes for individual letters.<br />

The quote above highlights this by seperating the pairs. (In the original<br />

letter this was not the case, and the first progress towards decyphering<br />

the letter was realizing the double-letter nature <strong>of</strong> the cipher.)<br />

Given this, and the hint that neither e nor t is the most common letter,<br />

can you decrypt it<br />

14. Consider the following telegram [Hassard and Secret 1876].<br />

J. J. DANIEL, Jacsonville, Fla.:<br />

TALLAHASSEE, Mov. 19, 1876<br />

84 55 89 31 93 27 66 89 27 20 42 66 34 55<br />

33 93 20 34 84 55 55 39 93 42 55 33 93 48 44<br />

55 52 27 66 33 20 20 55 31 31 66 42 27 82 96 96<br />

93 20 82 66 48 93 52 27 93 44 93 34 82 31 31 27


6.7. EXERCISES 107<br />

93 93 82 48 39 66 82 20 34 42 82 48 93 44 82 96<br />

39 66 42 48 82 84 52 31 66 42 27 66 75 55 52<br />

48 39 66 82 33 93 20 93 39 55 27 82 48 66<br />

52 48 44 55 42 82 48 89 84 55 96 96 52 33<br />

82 84 66 48 93 20 89 93 27 48 93 42 20 66<br />

89 27 31 93 48 48 93 42 96 55 20 82 68 82 93 20 66 27 66<br />

75 55 87 93 82 33 99 52 33 84 48 82 55 33 66 77 66<br />

82 33 27 48 77 55 87 93 42 33 55 42 84 66 33 87 66 27 27<br />

82 33 77 93 31 93 84 48 55 42 66 31 87 55 48 93 66 33 10 96 66 33<br />

20 66 96 52 27 48 55 96 66 25 93 96 84 31 82 33 66 33 20 84 55 34<br />

77 82 33 66 84 48 82 96 96 93 20 82 66 48 93 31 89 34 82 31 31<br />

75 93 27 55 52 77 44 48 48 55 96 55 42 42 55 34<br />

L’ENGLE.<br />

At the New York Tribune reported in its expose on the topic<br />

It was natural to suppose that this dispatch referred to the chief topic<br />

<strong>of</strong> the day, and if so the word “canvass” must be in it somewhere.<br />

The problem was, therefore, to find a combination <strong>of</strong> seven [pairs <strong>of</strong>]<br />

numbers, <strong>of</strong> which the second and fifth, standing for A, should be the<br />

same, and the sixth and seventh (SS) also the same. The translator<br />

began at the beginning and tried every sequence <strong>of</strong> ciphers until at<br />

the end <strong>of</strong> the twelfth line one was found which fulfilled the desired<br />

conditions, namely, ...<br />

what Find the set <strong>of</strong> 7 pairs <strong>of</strong> numbers that fit the letter pattern <strong>of</strong><br />

“canvass.” Then, with some frequency work, you should be able to decrypt<br />

this cipher. Do so.


108 CHAPTER 6. DECRYPTING MONOALPHABETIC CIPHERS


Chapter 7<br />

Vigenère Ciphers<br />

It was the amateurs <strong>of</strong> cryptology who created<br />

the species. The pr<strong>of</strong>essionals, who almost certainly<br />

surpassed them in cryptanalytic expertise,<br />

concentrated on the down-to-earth problems <strong>of</strong><br />

the systems that were then in use but are now<br />

outdated. The amateurs, unfettered to these realities,<br />

soared into the empyrean <strong>of</strong> theory.<br />

David Kahn<br />

The Codebreakers<br />

We’ve seen four types <strong>of</strong> monoalphabetic ciphers:<br />

Caesar Ciphers: shift the letters <strong>of</strong> the alphabet by some fixed amount.<br />

Decimation Ciphers: multiply by some fixed amount.<br />

Linear Ciphers: multiply and shift.<br />

Keyword Ciphers: use a keyword and columns to make a new alphabet.<br />

In these ciphers each plaintext letter is replaced throughout the entire message<br />

by the same ciphertext letter. Because <strong>of</strong> this one-to-one correspondence, frequency<br />

analysis allows anyone to decide which letter is posing as which, and<br />

hence to decrypt the message.<br />

How, then, should we make a better cipher We must change this one-forone<br />

replacement and find a way to cause multiple letters to represent the same<br />

letter. We must (re)invent polyalphabetic ciphers.<br />

Apparently, the first monoalphabetic cipher was thought up by one person<br />

in one sudden intellectual burst. Not so for the family <strong>of</strong> polyalphabetic ciphers.<br />

To fully develop this idea took four people: an architect, a cleric, a courtier and<br />

a scientist, none <strong>of</strong> whom were cryptologists by pr<strong>of</strong>ession.<br />

109


110 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

7.1 Alberti, the Father <strong>of</strong> Western <strong>Cryptology</strong><br />

Leon Battista Alberti (1404-1472) was born in Florence, Italy, the illegitimate<br />

but favored son <strong>of</strong> a rich merchant. Although not well-known today, in the<br />

Renaissance he was generally considered to be second only to Leonardo da Vinci<br />

in terms <strong>of</strong> all-around talents. For example, as an architect Alberti 1 designed<br />

the first Fountain <strong>of</strong> Trevi in Rome, his De Re Aedificatoria was the first printed<br />

book on architecture and was the “theoretical cornerstone <strong>of</strong> the architecture <strong>of</strong><br />

the Renaissance” (Kahn). He was one <strong>of</strong> the best organists <strong>of</strong> his day, as well<br />

as a painter. His writings include poems, fables, comedies, law, and the first<br />

scientific study <strong>of</strong> perspective. He was also an excellent athlete. [Kahn]<br />

In 1466, at age 62 or 63, wrote for his friend Leonardo Dato, the papal<br />

secretary, what is the West’s oldest book on cryptology, De cifris. It was only<br />

25 pages long, but included<br />

1. Frequency analysis. Probably not invented by him, but presented in a<br />

relatively developed form.<br />

2. The use <strong>of</strong> code letters for common words and phrases. For example, ZZ<br />

= rome, XZ = pope, etc. Further, he changed these regularly, so later<br />

Pope might be ZAZ and later still XXY. These letters are enciphered along<br />

with the rest <strong>of</strong> the text, in a method called enciphered code. So Pope<br />

would be first replaced by XZ and then XZ would be enciphered like any<br />

other plaintext word. This method was so far ahead <strong>of</strong> its time that it<br />

was almost 400 years until it was generally used.<br />

3. The first mechanical cipher device. Known as the Alberti disc, it is very<br />

similar in function to the Saint Cyr slide but has the alphabets arranged<br />

in circles, the plaintext inside and ciphertext outside.<br />

4. Primitive polyalphabetic ciphers. His idea is both very clever and very<br />

simple: use a different Caesar cipher with each word! 2<br />

Examples: Use Alberti’s methods on the following.<br />

(1) Encipher Vatican City and Rome by using the first letter <strong>of</strong> each word<br />

as the key.<br />

Vatican we encipher with key V, giving QVODXVI. For City we use key<br />

C, giving EKVA. Similarly with key A, and = AND (A is a foolish key) and,<br />

finally, Rome = IFDV. So the ciphertext is QVODXVI EKVA AND IFDV.<br />

(2) Encipher Fountain <strong>of</strong> Trevi using the second letter <strong>of</strong> the word as the<br />

key.<br />

1 who shouldn’t be confused with Giovanni Battista Argenti <strong>of</strong> 5.1, despite the similar<br />

names<br />

2 Alberti actually only changed the key every couple <strong>of</strong> words.


7.2. TRITHEMIUS, THE FATHER OF BIBLIOGRAPHY 111<br />

(3) Decipher JCQNGI RRIIZMVJ MUZLLAZ BUIVSTEBZ. Hint: The first letter <strong>of</strong><br />

each word is the key.<br />

(4) Decipher LZWS XYXY RDGGV SBHSFJWOO CQNBRMNJ KVVYH Hint: the last<br />

letter <strong>of</strong> the word is the key. 3<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Look again at part (1) <strong>of</strong> this example. The i in Vatican became O but the i<br />

in City became K. Similarly, the t once became D and once V. A single plaintext<br />

letter was enciphered to different ciphertext letters! This is the trademark <strong>of</strong> a<br />

polyalphabetic cipher. A monoalphabetic (mono = one) cipher uses only<br />

one ciphertext alphabet throughout the message, so each plaintext letter can<br />

become only one ciphertext letter. A polyalphabetic cipher (Poly = many)<br />

provides for several ciphertext alphabet, which allows each plaintext letter to<br />

become several different ciphertext letters.<br />

As we will see, that the same plaintext letter can become different ciphertext<br />

letters provides for a very strong cipher. The weakness <strong>of</strong> Alberti’s method is<br />

a bit more subtle. Can you find it (Try to decipher parts (1) or (2) from the<br />

example.) 4<br />

7.2 Trithemius, the Father <strong>of</strong> Bibliography<br />

Johannes Trithemius (February 2, 1462 – December 15, 1516) is the second <strong>of</strong><br />

our four developers. By the age <strong>of</strong> 22, Trithemius was the abbot <strong>of</strong> the Benedictine<br />

abbey <strong>of</strong> Saint Martin. His most important work, Liber de scriptoribus<br />

ecclesiasticis, was a chronological list <strong>of</strong> about 7000 theological works, it was<br />

published in 1494 and led to his title.<br />

In 1499 he wrote <strong>St</strong>enanographia, meaning “covered writing”. In it are some<br />

examples <strong>of</strong> simple substitutions (swapping all i’s and t’s with each other, for<br />

instance) and some null ciphers. (These ciphers appear like normal correspondence<br />

but hide messages within them, for example, by having only certain<br />

letters be meaningful, such as the initial letters in “Can’t order donuts every<br />

Sunday”.) The third portion was a study <strong>of</strong> what we’d now call magic and the<br />

occult. This portion brought him fame and notoriety and in 1609 the book was<br />

placed on the Catholic Church’s Index <strong>of</strong> Prohibited Books.<br />

<strong>St</strong>arting in 1508 Trithemius published the six-part Polygraphia (“many ways<br />

<strong>of</strong> writing”). In Book V appears the world’s first known tableau, or table. The<br />

simplest tableau is known as Trithemius’ tabula recta, and appears as Figure<br />

7.1. (Trithememius’ recta came from the Latin alphabet, and so was 24 × 24,<br />

rather than 26 × 26.)<br />

3 (2) TCIBHOWB TK KIVMZ, (3) The XZ=pope arrives in ZZ=Rome on thursday, (4) The<br />

ZAZ=pope will enter the side door.<br />

4 We must include the keyletter(s) with the message. If the method is simply “use the first<br />

letter <strong>of</strong> the words as the key”, then that letter is enciphered and is hard to determine!


112 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

A<br />

B<br />

C<br />

D<br />

E<br />

F<br />

G<br />

H<br />

I<br />

J<br />

K<br />

L<br />

M<br />

N<br />

O<br />

P<br />

Q<br />

R<br />

S<br />

T<br />

U<br />

V<br />

W<br />

X<br />

Y<br />

Z<br />

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<br />

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<br />

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 A<br />

C 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<br />

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<br />

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 D<br />

F G H I J K L M N O P Q R S T U V W X Y Z A B C D E<br />

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F<br />

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G<br />

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H<br />

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I<br />

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J<br />

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K<br />

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L<br />

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M<br />

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N<br />

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O<br />

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P<br />

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q<br />

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R<br />

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S<br />

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T<br />

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U<br />

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V<br />

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W<br />

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X<br />

Z 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<br />

Figure 7.1: Trithemius’ tabula recta<br />

To use the tabula recta, find your plaintext letters in the outside top row.<br />

Use the first row as the ciphertext alphabet for the first letter, the second row<br />

as the ciphertext alphabet for the second letter, the third row as the ciphertext<br />

alphabet for the third letter etc., repeating after 26 letters. In the language <strong>of</strong><br />

our Caesar ciphers, we encipher each letter using a Caesar cipher but change the<br />

key with each letter. We use A as the key for the first letter <strong>of</strong> the message, B as<br />

the key for the second letter, C for the third, etc. This gives a key progression<br />

(or a progressive key), since the key progresses with each new letter.<br />

Examples:<br />

(1) Encipher table.<br />

To use Trithemius’ tabula, find the first letter <strong>of</strong> the message t and read<br />

down to the A row, a T. Then find the next letter a and read down to the<br />

B row, a B. Find b and read down to the C row, a D. Find l and read down<br />

to the D row, a O. Finally e in the E row is an I. The answer is TBDOI.<br />

Using a Saint Cyr slide one enciphers as usual, simply remembering that<br />

each letter gets its own key. With the slide, move the key one letter<br />

forward each time you encipher a letter.<br />

(2) Encipher rectangle.<br />

(3) Decipher DJCJS SGS.


7.3. BELASO, THE UNKNOWN AND PORTA, THE GREAT 113<br />

(4) Decipher FFFHVFR. 5<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

The influence <strong>of</strong> this system was great, in part because <strong>of</strong> Trithemius’ notoriety<br />

and in part because his was the first published book on cryptology.<br />

Letter-by-letter enciphering quickly became common and the basis for many<br />

cipher systems.<br />

In some ways this system is better than Alberti’s because a new alphabet<br />

is used with each letter. Even very recognizable words like Mississippi will<br />

become well-enciphered. (Alberti’s method with key F gives FRNXXNXXNUUN,<br />

putting the keyletter first, while Trithemius’ method gives MJUVMXYPXYS.)<br />

It also has clear weaknesses. For example, if the plaintext contains alphabetically<br />

anti-consecutive letters, as in pon <strong>of</strong> pontoon or fed <strong>of</strong> federal then<br />

the cipher text will contain a consecutive copies <strong>of</strong> the same letter. 6 While not<br />

terribly common, this allows easy entries to decrypting the cipher. (This last<br />

is Porta’s idea.) Nonetheless, Trithemius contributed the idea <strong>of</strong> changing the<br />

key with each letter.<br />

7.3 Belaso, the Unknown and Porta, the Great<br />

Giovan Batista Belaso, unlike the others appearing in this chapter, is someone<br />

we know little about. He was from Brescia, Italy and lived during the 1500’s.<br />

What we do know is that in 1553 he published La cifra del. Sig. Giovan Balista<br />

Belaso in which he described a ciphersystem with an easily remembered and<br />

easily changed key. He called the key a countersign, although we will just<br />

call it the keyword. His cipher became known as the Vigenère cipher and is<br />

the most important and most used cipher in history. (Vigenère will appear in<br />

Chapter 8.)<br />

Belaso’s idea is an extension <strong>of</strong> Trithemius’s: to encipher pick a keyword<br />

and use its letters cyclically as the key in a Caesar cipher to encipher the text.<br />

Example: Encipher eek, eek, I saw a mouse near that computer using<br />

the keyword TYPE. 7<br />

plaintext e e k e e k i s a w a m o u s e n e a r t h a t c o m p u t e r<br />

key T Y P E T Y P E T Y P E T Y P E T Y P E T Y P E T Y P E T Y P E<br />

ciphertext X C Z I X I X W T U P Q H S H I G C P V M F P X V M B T N R T V<br />

Answer: XCZIX IXWTU PQHSH IGCPV MFPXV MBTNR TV.<br />

⋄<br />

5 (2) RFEWESMSM, (3) diagonal, (4) federal.<br />

6 pontoon is enciphered as PPPWSTT.<br />

7 Belaso was careful to use longer keywords, or better, phrases, like OPTARE MELIORA and<br />

BIRTUTI OMNIA PARENT.


114 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

Giovanni Battista Porta (1535–1615) was probably the outstanding cryptographer<br />

<strong>of</strong> the Renaissance. In addition, he organized the first association <strong>of</strong><br />

scientists, the “Academia Secretorum Naturae”. He was also a prolific writer:<br />

between 1586–1609 published books on human physiognomy, meteorology, the<br />

design <strong>of</strong> villas, astronomy, as well as 14 prose comedies.<br />

In 1563 8 he published De Furtivis Libetarum Notis. Its four books dealt<br />

with, respectively, ancient ciphers, modern ciphers, cryptanalysis, and linguistic<br />

peculiarities, and encompassed all the cryptologic knowledge <strong>of</strong> the time.<br />

According to Kahn, it is one <strong>of</strong> the few books <strong>of</strong> the period that is still readable.<br />

(In it it appears that Porta nearly learned out how to break the Vigenère<br />

ciphers. If he had, they probably would not have become popular, in which case<br />

this chapter wouldn’t exist. But he didn’t quite, and so here we are.)<br />

Porta’s contribution was two-fold. First, his book was very influential and<br />

made the polyalphabetic ciphers popular. Second, he combined the letter-byletter<br />

encipherments <strong>of</strong> Trithemius, the easily changed key <strong>of</strong> Belaso, and the<br />

mixed alphabet suggested by Alberti. Rather than simply using the 26 regular<br />

alphabets (from Trithemius’ table) as the ciphertext alphabets, his cipher<br />

allowed for mixed alphabets.<br />

7.4 Vigenère Ciphers<br />

The Vigenère cipher is one <strong>of</strong> the most influential ciphers in history. It is simple<br />

to use and easy to remember, and, because it is polyalphabetic, is much more<br />

secure that the ciphers we have previously studied.<br />

Examples:<br />

(1) Encipher Meet me at the Met at the time ten twenty using the keyword<br />

CODE.<br />

plaintext<br />

key<br />

ciphertext<br />

m e e t m e a t t h e m e t a t t h e t i m e t e n t w e n t<br />

C O D E C O D E C O D E C O D E C O D E C O D E C O D E C O D<br />

O S H X O S D X V V H Q G H D X V V H X K A H X G B W A G B W<br />

Yes, this is a silly message. But notice how many times the e’s and t’s<br />

and m’s go to different letters. There are 9 e’s and 10 t’s in the plaintext,<br />

but in the ciphertext no letter appears more than 5 times.<br />

(2) As his example <strong>of</strong> Vigenére, Parker Hitt used the key GRANT to encipher<br />

All radio messages must hereafter be put in cipher. What<br />

is the ciphertext<br />

(3) Charles Dodgson (Lewis Carroll) reinvented the Vigenère cipher in 1868,<br />

calling it the Alphabet Cipher. In his diary he used the keyword VIGILANCE<br />

8 Why did the 1500’s have this sudden explosion <strong>of</strong> interest in cryptology ”The growth <strong>of</strong><br />

cryptology [in the west in the 1500’s] resulted directly from the flowering <strong>of</strong> modern diplomacy”<br />

[Kahn, pg 108] since permanent ambassadors needed to send home regular reports.


7.4.<br />

VIGENÈRE CIPHERS 115<br />

to encipher Meet me on tuesday eve [Abeles, p. 326]. What did he find<br />

as the ciphertext<br />

(4) Decipher TMOQE JKCNF SJDOE ESF using the keyword HOLMES.<br />

Deciphering is set up as you probably think:<br />

ciphertext<br />

T M O Q E J K C N F S J D O E E S F<br />

H O L M E S H O L M E S H O L M E S<br />

(5) Decipher WYONT REJOL BXNUQ IZHS using the keyword AROUND.<br />

(6) During World War I the German Army used a cipher that is equivalent to<br />

a Vigenère cipher with keyword ABC. To find out in which year, decipher<br />

NJPEUGEO HOVTTFGN.<br />

(7) Joseph Willard Brown claims that IN GOD WE TRUST was used as a key<br />

to encipher the message Longstreet is marching on Fisher’s Hill<br />

[Brown]. If so, what was the ciphertext 9<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

How does being polyalphabetic influence the frequency counts Here is an<br />

enciphered message.<br />

QNTQH PIECN SCPOE QXPZC FFILF ACNMY FRRPW XUTKK RROLV CVEQX KASFS<br />

IMGSY XYRRM POEFH MYROI OEEUO EVSET EVPIX KAEFC ZGKEQ AHTAK KXTEI<br />

EGRNA DZPKM MDCAC ZGPVT QTFHZ OXZDE RFEWX YFWVN ARIGW AANUG RNQAE<br />

FXSMT FHCZG RWTMP ZDJII YQRRN QLDCV NKTHI VTKP<br />

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<br />

11 0 10 5 16 12 7 6 10 1 10 3 8 9 7 10 9 14 6 11 3 8 5 9 6 8<br />

Could this be from a monoalphabetic cipher Almost all the letters appear,<br />

and most appear between 5 and 10 times each. This frequency chart is much<br />

flatter than any we’ve see in the past. So, no, this ciphertext cannot be from a<br />

monoalphabetic cipher.<br />

Perhaps we could break this cipher by exhaustion, by trying each possible<br />

keyword Well, there are 26 one-letter keywords, 26 2 = 576 two-letter keywords,<br />

26 3 = 17576 three-letter ones, etc.. Here I used a five-letter keyword, and<br />

there are 26 5 = 11, 881, 376 possible five-letter keywords! It takes very little<br />

imagination to realize that trying all possible keywords is impossible.<br />

The Vigenère cipher, for much <strong>of</strong> its lifetime, had two very strong advantages<br />

over the ciphers we have previously seen:<br />

1. It was apparently unbreakable, in fact, it was basically unbroken until the<br />

19th century.<br />

9 (2) GCLET JZOZX YJATX YDUFM NVRRT LKEEU KGUGB TTICA KI, (3) HMKBX EBPXP MYLLY<br />

RXI, (4) my dear doctor watson, (5) what goes around comes, (6) nineteen fourteen, (7)<br />

TBTUV PVXVN ALUNX QKERZ FHXBA UKFVD MEC


116 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

2. Each ambassador, messenger and spy could have their own key that could<br />

be changed easily if stolen or lost. (Generally the keywords were phrases,<br />

i.e., “God save the Queen”.)<br />

It did, however, have the reputation for being cumbersome and prone to error,<br />

which meant it was used less than one would otherwise expect. Even so, it<br />

served as a prototype for many ciphers used by pr<strong>of</strong>essionals.<br />

7.5 Variants and Beaufort<br />

In 1857 Admiral Sir Francis Beaufort <strong>of</strong> the Royal Navy (known for his scale <strong>of</strong><br />

wind speed) and his brother published what they thought was a new cipher. 10<br />

They put their Beaufort Tableaux (Figure 7.2) on 4×5-inch cards and sold these<br />

as a new way <strong>of</strong> secret writing “adapted for telegrams and postcards” (postcards<br />

having recently been invented).<br />

To use the card, they wrote<br />

Let the key for the foregoing [message] be a line <strong>of</strong> poetry or the name<br />

<strong>of</strong> some memorable person or place, which cannot easily be forgotten ...<br />

Now look in the side column for the first letter <strong>of</strong> the text (t) and run<br />

the eye across the table until it comes to the first letter <strong>of</strong> the key (v),<br />

then at the top <strong>of</strong> the column in which v stands will be found the letter<br />

c. ([Kahn], page 202.)<br />

So the plainletter t is enciphered by V to give the cipherletter C. (Actually, one<br />

can look either up or down to find the ciphertext.) Clearly this cipher method<br />

is very closely related to the Vigenère cipher. It does have one small advantage:<br />

deciphering is exactly the same process as enciphering.<br />

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<br />

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 A<br />

C 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<br />

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<br />

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 D<br />

F G H I J K L M N O P Q R S T U V W X Y Z A B C D E<br />

G H I J K L M N O P Q R S T U V W X Y Z A B C D E F<br />

H I J K L M N O P Q R S T U V W X Y Z A B C D E F G<br />

I J K L M N O P Q R S T U V W X Y Z A B C D E F G H<br />

J K L M N O P Q R S T U V W X Y Z A B C D E F G H I<br />

K L M N O P Q R S T U V W X Y Z A B C D E F G H I J<br />

L M N O P Q R S T U V W X Y Z A B C D E F G H I J K<br />

M N O P Q R S T U V W X Y Z A B C D E F G H I J K L<br />

N O P Q R S T U V W X Y Z A B C D E F G H I J K L M<br />

O P Q R S T U V W X Y Z A B C D E F G H I J K L M N<br />

P Q R S T U V W X Y Z A B C D E F G H I J K L M N O<br />

Q R S T U V W X Y Z A B C D E F G H I J K L M N O P<br />

R S T U V W X Y Z A B C D E F G H I J K L M N O P Q<br />

S T U V W X Y Z A B C D E F G H I J K L M N O P Q R<br />

T U V W X Y Z A B C D E F G H I J K L M N O P Q R S<br />

U V W X Y Z A B C D E F G H I J K L M N O P Q R S T<br />

V W X Y Z A B C D E F G H I J K L M N O P Q R S T U<br />

W X Y Z A B C D E F G H I J K L M N O P Q R S T U V<br />

X Y Z A B C D E F G H I J K L M N O P Q R S T U V W<br />

Y Z A B C D E F G H I J K L M N O P Q R S T U V W X<br />

Z 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<br />

Figure 7.2: Beaufort’s Tableaux<br />

10 It had already been studied by Giovanni Sestri in 1710.


7.6. HOW TO BREAK VIGENÈRE CIPHERS 117<br />

The Beaufort cipher may also be performed using a Saint Cyr slide: simply<br />

replace the ciphertext slide with one on which the alphabet is reversed.<br />

Examples:<br />

(1) Encipher send supplies using keyword COMET.<br />

plaintext<br />

key<br />

ciphertext<br />

s e n d s u p p l i e s<br />

C O M E T C O M E T C O<br />

K K Z B B I Z X T L Y W<br />

The ciphertext is KKZBB IZXTL YW.<br />

(2) Encipher Admiral using the keyword NAVY.<br />

(3) Decipher GWFDY XGTPW U using keyword CASH. 11<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

To use the Variant Beaufort (confusingly also known as the Variant Vigenère)<br />

instead <strong>of</strong> starting with the plaintext letter and moving inwards to the<br />

keyletter, we start with the keyletter and trace inwards to the plaintext letter.<br />

Examples: Using the Variant Beaufort:<br />

(1) Encipher send supplies using keyword COMET.<br />

(2) Decipher WNQ OOTA FVKD using keyword EAT. 12<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

7.6 How to Break Vigenère Ciphers<br />

“The method used for the preparation and reading<br />

<strong>of</strong> code messages is simple in the extreme and<br />

at the same time impossible <strong>of</strong> translation unless<br />

the key word is known.”<br />

From “A New Cipher Code”<br />

Scientific American Supplement, Jan 27, 1917,<br />

The Proceedings <strong>of</strong> the Engineer’s<br />

Club <strong>of</strong> Philadelphia.<br />

In 1550 Belaso invents the Vigenère cipher. In 1563 Porta almost figures out<br />

how to break it, but not quite. And then for the next 300 years the Vigenère is<br />

11 (2) NXJQV AK, (3) we need money.<br />

12 (1) QQBZZ SBDHP CE, (2) And some food.


118 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

unbreakable. So how finally was the Vigenère Cipher broken By turning the<br />

power <strong>of</strong> the keyword against the cipher.<br />

Let’s start by backing up. What enabled us to decrypt a Caesar cipher<br />

We knew that every letter in the message was enciphered using the same key<br />

letter. And we could detect this key letter from the frequency habits <strong>of</strong> normal<br />

English. Why can’t we do this with a Vigenère cipher Because not all <strong>of</strong> the<br />

letters are enciphered using the same key letter. In other words, a Caesar cipher<br />

is monoalphabetic, a Vigenère cipher is polyalphabetic.<br />

Now suppose we did know which letters were enciphered by the same letters<br />

<strong>of</strong> the keyword. Then we could split up the ciphertext into groups in such a way<br />

that all the letters in each group would be enciphered with the same keyletter.<br />

Each group <strong>of</strong> letters would be like a (different) Caesar cipher. And we know<br />

how to break Caesar ciphers. Since we could decrypt each <strong>of</strong> these groups <strong>of</strong><br />

letters, then we could decrypt all <strong>of</strong> the letters in the ciphertext, thus breaking<br />

the message.<br />

So (perhaps) we don’t actually need to know the keyword, but we do need to<br />

determine which ciphertext letters have been enciphered with the same letter <strong>of</strong><br />

the keyword. How can we do this Imagine rewriting the ciphertext downward<br />

into columns, with as many letters per column as there are letters in the keyword.<br />

Of course, we’d need to know how many letters there are in the keyword,<br />

but pretend for a moment we know that. Then the letters in the first row <strong>of</strong> our<br />

re-written ciphertext would all have been enciphered using the first letter <strong>of</strong> the<br />

keyword. And the letters in the second row <strong>of</strong> the re-written ciphertext would<br />

all have been enciphered using the second letter <strong>of</strong> the keyword. Similarly for<br />

the other rows. We would be left with several Caesar ciphers to break.<br />

To make this a bit less abstract, let’s suppose the keyword contained 5<br />

letters, and we number them k 1 k 2 k 3 k 4 k 5 , and similarly number the ciphertext<br />

letters ct 1 ct 2 ct 3 · · · . Then the complex <strong>of</strong> rows and columns from the previous<br />

paragraph takes the form<br />

k 1 ct 1 ct 6 ct 11 ct 16 . . .<br />

k 2 ct 2 ct 7 ct 12 ct 17 . . .<br />

k 3 ct 3 ct 8 ct 13 ct 18 . . .<br />

k 4 ct 4 ct 9 ct 14 ct 19 . . .<br />

k 5 ct 5 ct 0 ct 15 ct 10 . . .<br />

The letters ct 1 , ct 6 , ct 11 , ct 16 , . . . all have been enciphered by the key k 1 . So we<br />

can treat ct 1 ct 6 ct 11 ct 16 . . . as a Caesar cipher with unknown key k 1 . Likewise,<br />

ct 2 , ct 7 , ct 12 , ct 17 , . . . all have been enciphered by k 2 , so ct 2 ct 7 ct 12 ct 17 . . . can<br />

be treated as a Caesar cipher.<br />

So to decrypt a Vigenère-enciphered message, assuming we know the length<br />

<strong>of</strong> the keyword, first rewrite the ciphertext in columns with as many letters per<br />

column as letters in the keyword. Then the letters <strong>of</strong> each row will constitute a<br />

Caesar cipher that can be broken with our techniques from Chapter 1.<br />

To summarize, from what does the Vigenère cipher get its security Ob-


7.6. HOW TO BREAK VIGENÈRE CIPHERS 119<br />

viously from its keyword. But, surprisingly, the important thing about the<br />

keyword, at least from a security standpoint, is not which letters are in it, but<br />

rather how many!<br />

Let’s illustrate the method with the example we considered earlier.<br />

Example:<br />

QNTQH PIECN SCPOE QXPZC FFILF ACNMY FRRPW XUTKK RROLV CVEQX KASFS<br />

IMGSY XYRRM POEFH MYROI OEEUO EVSET EVPIX KAEFC ZGKEQ AHTAK KXTEI<br />

EGRNA DZPKM MDCAC ZGPVT QTFHZ OXZDE RFEWX YFWVN ARIGW AANUG RNQAE<br />

FXSMT FHCZG RWTMP ZDJII YQRRN QLDCV NKTHI VTKP<br />

Now suppose somehow, by hook or by crook, we learned that this is indeed a<br />

Vigenère cipher with a keyword consisting <strong>of</strong> 5 letters. This would mean that<br />

every fifth letter <strong>of</strong> the message is enciphered by the same letter <strong>of</strong> the keyword.<br />

So the letters appearing first in each five-letter grouping are enciphered, as a<br />

Caesar cipher, using the same keyletter. Similarly, the letters occurring second<br />

in each five-letter grouping are enciphered using the same keyletter. Likewise<br />

for the third, the fourth and the fifth letters. So if we group together the letters<br />

that are enciphered by the same keyletter, then we can decipher each <strong>of</strong> these<br />

groups as a Caesar Cipher.<br />

First, we regroup and make new frequency counts.<br />

First letters: QPSQFAFXRCKIXPMOEEKZAKEDMZQORYAARFFRZYQNV<br />

4 0 1 1 3 4 0 0 1 0 3 0 2 1 2 2 4 4 1 0 0 1 0 2 2 3<br />

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<br />

Second letters: NICXFCRURVAMYOYEVVAGHXGZDGTXFFRANXHWDQLKT<br />

3 0 2 2 1 3 3 2 1 0 1 1 1 2 1 0 1 3 0 2 1 3 1 4 2 1<br />

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<br />

Third letters: TEPPINRTOESGRERESPEKTTRPCPFZEWINQSCTJRDTK<br />

0 0 2 1 6 1 1 0 2 1 2 0 0 2 1 5 1 5 3 6 0 0 1 0 0 1<br />

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<br />

Fourth letters: QCOZLMPKLQFSRFOUEIFEAENKAVHDWVGUAMZMIRCHP<br />

3 0 2 1 3 3 1 2 2 0 2 2 3 1 2 2 2 2 1 0 2 2 1 0 0 2<br />

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<br />

Fifth letters: HNECFYWKVXSYMHIOTXCQKIAMCTZEXNWGETGPINVI<br />

1 0 3 0 3 1 2 2 4 0 2 0 2 3 1 1 1 0 1 3 0 2 2 3 2 1<br />

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


120 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

Our eyes should be sufficiently trained by this point to detect the five Caesar<br />

ciphers here. For example, the first two have the following fit:<br />

First letters:<br />

plain: o p q r s t u v w x y z a b c d e f g h i j k l m n<br />

4 0 1 1 3 4 0 0 1 0 3 0 2 1 2 2 4 4 1 0 0 1 0 2 2 3<br />

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 Key is M.<br />

Second letters:<br />

plain: 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<br />

3 0 2 2 1 3 3 2 1 0 1 1 1 2 1 0 1 3 0 2 1 3 1 4 2 1<br />

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 Key is A.<br />

The other three letters <strong>of</strong> the keyword are quickly determined. (Do it!) 13<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

This example shows that if we can determine the length <strong>of</strong> the keyword <strong>of</strong> a<br />

Vigenère cipher, the difficult work will be done, because breaking the Vigenère<br />

cipher will be the same as breaking several Caesar ciphers. In other words, a<br />

bit time-consuming, but pretty easy.<br />

This is actually where Linquist’s method becomes useful. If one has a complete<br />

Caesar cipher, running down the alphabet is a quick and simply-minded<br />

<strong>of</strong> decrypting it. But when working on a Vigenère cipher we do not have consecutive<br />

groups <strong>of</strong> letters, and so running down the alphabet looking for words<br />

will not work. Further, there will be cases in which each group <strong>of</strong> similarlyencrypted<br />

letters is quite small, making traditional frequency analysis hard.<br />

Linquist’s method, however, is designed with small groups <strong>of</strong> letters in mind,<br />

and will sometimes be helpful.<br />

7.7 The Kasiski Test<br />

Friedrick W. Kasiski (1805–81) was born in what is now Poland, entered East<br />

Prussia’s Infantry in 1823 and retired 1852. In 1863 he published Die Geheimschriften<br />

und die Dechiffrir-kunst, a book <strong>of</strong> only 95 pages. After his book<br />

made no apparent impact, he quit cryptography and became an anthropologist<br />

<strong>of</strong> some local fame. His book contained a method for determining the number <strong>of</strong><br />

letters in a Vigenère keyword, and by the beginning <strong>of</strong> the 20th century experts<br />

considered polyalphabetic ciphers to be vulnerable.<br />

13 The key is MARCEL and the plaintext is “Encode well or do not encode at all. In transmitting<br />

cleartext, you give only a piece <strong>of</strong> information to the enemy, and you know what it is; in<br />

encoding badly, you permit him to read all your correspondence and that <strong>of</strong> your friends.”<br />

General Marcel Givierge, head <strong>of</strong> French cryptology during WWI, author <strong>of</strong> Course de<br />

Cryptographie, 1925. [Kahn, pg 349]


7.7. THE KASISKI TEST 121<br />

Kasiski’s idea was to not look directly for the length <strong>of</strong> the keyword, but to<br />

instead look for multiples <strong>of</strong> that length. Suppose a sequence <strong>of</strong> letters appears<br />

more than once in the plaintext. And suppose the plaintext and keyword are<br />

such that the same letters <strong>of</strong> the keyword encipher the same letters <strong>of</strong> these<br />

repeated bits. Then the resulting ciphertext would be the same.<br />

Now turn this around. If there is a repetition <strong>of</strong> some group <strong>of</strong> letters in<br />

the ciphertext, perhaps this was caused by the same plaintext letters being<br />

enciphered by the same keyword letters. If so, then the keyword would have<br />

had to repeat just the right number <strong>of</strong> times to fit both the first and second<br />

appearances <strong>of</strong> the plaintext letters. The distance these appearances are apart<br />

would then be a multiple <strong>of</strong> the keyword length. If we can find several such<br />

repetitions, so several such distances, then we ought to be able to focus in on<br />

the length <strong>of</strong> the keyword.<br />

To give a short example, consider the following cipher, with every fifth letter<br />

numbered ([Kahn], page 208):<br />

5 10 15 20 25 30<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

There are two repetitions here, one <strong>of</strong> KIOV and one <strong>of</strong> NU. The second KIOV<br />

starts at letter 10, the first at letter 1, so they occur a distance 9 apart. The<br />

second NU starts at letter 20, the first at letter 14, a distance <strong>of</strong> 6. Let’s put this<br />

information in a chart:<br />

Repetition <strong>St</strong>art Positions Distance Factors<br />

KIOV 1, 10 10 − 1 = 9 3 × 3<br />

NU 14, 20 20 − 14 = 6 2 × 3<br />

What number(s) are both 2 × 3 and 3 × 3 a multiple <strong>of</strong> 3. So, Kasiski would<br />

conclude, the keyword must be 3 letters long.<br />

In fact, the plaintext is To be or not to be. That is the question.<br />

and by putting the repeating keyword underneath we see that KIOV came from<br />

the combination <strong>of</strong> tobe and RUNR, and NU from th and UN:<br />

plaintext<br />

key<br />

ciphertext<br />

t o b e o r n o t t o b e t h a t i s t h e q u e s t i o n<br />

R U N R U N R U N R U N R U N R U N R U N R U N R U N R U N<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

Summarizing gives Kasiski’s Test.


122 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

Kasiski’s Test:<br />

1. Look for repetitions in the ciphertext <strong>of</strong> two, three, or more letters.<br />

Determine the distances (= position <strong>of</strong> first letter in second appearance<br />

minus position <strong>of</strong> first letter in first appearance) between the<br />

beginnings <strong>of</strong> these repetitions. This is doing a Kasiski Examination.<br />

2. Find the largest number that divides most <strong>of</strong> your distances in step<br />

1 by first factoring those distances. This number should give a good<br />

idea <strong>of</strong> the length <strong>of</strong> the keyword. We call this length the keylength.<br />

Be aware that longer repetitions are more significant than shorter<br />

ones, so repeated triples are more meaningful than repeated pairs,<br />

and 4 letter strings are even more significant. Also, repetitions can<br />

arise that do not come from a repeat in the text. So the keylength<br />

will not necessarily divide all <strong>of</strong> the repetition distances.<br />

3. Write the ciphertext in columns, with the number <strong>of</strong> letters per column<br />

being equal to the keylength. This will result in a keylength<br />

number <strong>of</strong> rows, with each row being simply a Caesar cipher. This is<br />

building up a depth.<br />

4. Use frequency analysis on each row to determine the keyletter for<br />

each, and put the keyletters together to find the keyword. Then<br />

decipher the message.<br />

Example: Determine the keylength <strong>of</strong> the following ciphertext using Kasiski’s<br />

method. To ease the counting, there are 50 letters to a line. (This<br />

example is stolen from [Kahn], page 209)<br />

ANYVG YSTYN RPLWH RDTKX RNYPV QTGHP HZKFE YUMUS AYWVK ZYEZM<br />

EZUDL JKTUL JLKQB JUQVU ECKBN RCTHP KESXM AZOEN SXGOL PGNLE<br />

EBMMT GCSSV MRSEZ MXHLP KJEJH TUPZU EDWKN NNRWA GEEXS LKZUD<br />

LJKFI XHTKP IAZMX FACWC TQIDU WBRRL TTKVN AJWVB REAWT NSEZM<br />

OECSS VMRSL JMLEE BMMTG AYVIY GHPEM YFARW AOAEL UPIUA YYMGE<br />

EMJQK SFCGU GYBPJ BPZYP JASNN FSTUS STYVG YS<br />

We start by listing the repetitions, their starting positions, the distance between<br />

the starting positions, and the factorization <strong>of</strong> that distance in Figure 7.3.<br />

What factors appear in (almost) every distance All the distances are divisible<br />

by 2, most are divisible by 2 × 3, and many by 2 × 2. The key length is<br />

probably either 6 or 4. (The factors 5, 7, 19, and 137 appear only once each,<br />

and 11 only twice, and can be ignored.) If the keylength is 4 then the long<br />

repetition LEEBMMTG would have to be ignored, while if the keylength is 6 we<br />

only need ignore the short repeat STY. The keylength is most likely 6. 14 ⋄<br />

14 key = SIGNAL, “If signals are to be displayed in the presence <strong>of</strong> an enemy, they must be


7.8. SUMMARY 123<br />

Repetition <strong>St</strong>art Positions Distance Factors<br />

YVGYS 3, 283 280 2 × 2 × 2 × 5 × 7<br />

STY 7, 281 271 2 × 137<br />

GHP 28, 226 198 2 × 3 × 3 × 11<br />

EZM 48, 114 66 2 × 3 × 11<br />

EZM 48, 198 150 2 × 3 × 5 × 5<br />

ZUDLJK 52, 148 96 2 × 2 × 2 × 2 × 2 × 3<br />

LJK 55, 151 96 2 × 2 × 2 × 2 × 2 × 3<br />

LEEBMMTG 99, 213 114 2 × 3 × 19<br />

CSSVMRS 107, 203 96 2 × 2 × 2 × 2 × 2 × 3<br />

SEZM 113, 197 84 2 × 2 × 3 × 7<br />

ZMX 115, 163 48 2 × 2 × 2 × 2 × 3<br />

RWA 138, 234 96 2 × 2 × 2 × 2 × 2 × 3<br />

GEE 141, 249 108 2 × 2 × 3 × 3 × 3<br />

Figure 7.3: A Kasiski Table<br />

7.8 Summary<br />

The Vigenère cipher is the most successful cipher in history. It is really nothing<br />

but a Caesar cipher with the key being changed in a pattern provided by a<br />

keyword or keyphrase, but produces a polyalphabetic cipher. One continually<br />

enciphers by using the next letter <strong>of</strong> the keyphrase to encipher the next letter<br />

<strong>of</strong> the message, repeating the keyphrase when necessary. When the key consists<br />

<strong>of</strong> many letters the frequency counts produces are quite flat, successfully hiding<br />

the pattern <strong>of</strong> the repetition <strong>of</strong> the key.<br />

Misnamed though it was, when used correctly the Vigenère cipher was all but<br />

unbreakable for 300 years and remained in use even after techniques for routinely<br />

decrypting its messages were known. A sign <strong>of</strong> the value <strong>of</strong> an idea is the number<br />

<strong>of</strong> times it is rediscovered, and the numerous times the Vigenère was reinvented,<br />

sometimes in its standard form, sometimes in the form that the Beaufort and<br />

the Variant Vigenère take, show the idea behind this polyalphabetic cipher to<br />

be a very good one indeed.<br />

It wasn’t until Kasiski’s test that a general test for decrypting a carefully<br />

enciphered Vigenère cipher was known. To perform this test, find the distances<br />

between repetitions in the ciphertext. The largest number that divides most <strong>of</strong><br />

these distances is likely the length <strong>of</strong> the keyword (or a multiple <strong>of</strong> it). From<br />

here, divide the ciphertext into groups <strong>of</strong> letters that were enciphered by the<br />

same keyletter and decrypt these individual groups as simple Caesar ciphers.<br />

As we will see, the next 70 years <strong>of</strong> cipher history would be dominated by<br />

guarded by ciphers. The ciphers must be capable <strong>of</strong> frequent changes. The rules by which<br />

these changes are made must be simple. Ciphers are undiscoverable in proportion as their<br />

changes are frequent and as the messages in each change are brief.” From Albert J. Myer’s<br />

Manual <strong>of</strong> Signals.


124 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

attempts to fix the Vigenère cipher and make it once again secure.<br />

7.9 Topics and Techniques<br />

1. What is a polyalphabetic cipher<br />

2. What is the difference between a polyalphabetic and monoalphabetic cipher<br />

3. Who was Alberti Give two <strong>of</strong> his contributions to the development <strong>of</strong><br />

cryptography.<br />

4. Who was Trithemius Give two <strong>of</strong> his contributions to the development<br />

<strong>of</strong> cryptography.<br />

5. Who was Belaso What did he contribute to the development <strong>of</strong> cryptography<br />

6. What is a countersign How do we use it<br />

7. What is a Vigenère cipher How do we encipher using a Vigenère cipher<br />

8. How do we decipher a Vigenère cipher<br />

9. Who invented the Vigenère cipher<br />

10. Suppose we are given the frequency count for an unknown cipher. What<br />

will it look like if the cipher was a monoalphabetic one What will it look<br />

like if the cipher was a polyalphabetic one<br />

11. Who was Beaufort What is his cipher<br />

12. How do we go about breaking a Vigenère cipher if we know the length <strong>of</strong><br />

the keyword used in enciphering<br />

13. Who was Kasiski What is his contribution to the development <strong>of</strong> cryptography<br />

14. What is the Kasiski test How to perform it Why does it work What<br />

does it tell us<br />

7.10 Exercises<br />

For Problems 1 through 4, encipher the first line <strong>of</strong> the following Mother Goose<br />

rhymes using the given keyword, part (a) using a Vigenère Cipher, (b) using<br />

Beaufort Cipher, and (c) using a Variant Cipher.<br />

1. This little pig went to market. Keyword TOES.


7.10. EXERCISES 125<br />

2. Little Miss Muffet sat on a tuffet. Keyword CURDS.<br />

3. Humpty Dumpty sat on a wall. Keyword HORSES.<br />

4. Old Mother Hubbard went to her cupboard. Keyword DOG.<br />

5. Decipher the first line <strong>of</strong> the Mother Goose rhymes using a Vigenère cipher<br />

with the given keyword.<br />

(a) FAVOR JDCMC HWXRK QPMLV DIEP. Keyword WATER.<br />

(b) OWELE ZYISX GJAEK KFREL KR. Keyword GREAT.<br />

(c) JOJPL RAMVO PWKSV WESDA OBWSP. Keyword CANDLE.<br />

(d) BWQOH XFEAX HMKHO LUMAT TTOI. Keyword TAMBOURINE.<br />

6. Decipher the first line <strong>of</strong> the Mother Goose rhymes using a Vigenère cipher<br />

with the given keyword.<br />

(a) HWPQE LDBIY JLXLR ORVT. Keyword POCKET.<br />

(b) JRSII SWOJE QYFCP FGCJ. Keyword BE ONE.<br />

(c) WLWHI ONREG TNEDN ELIBB WSXNZ N. Keyword RAIN.<br />

(d) KYAGO WALVF YYZKJ VVGCI RVTKL V. Keyword ORANGE HER.<br />

7. Decipher the first line <strong>of</strong> the Mother Goose rhymes using a Beaufort cipher<br />

with the given keyword.<br />

(a) ZMKWA WTWNP KNVGE ZBOUE HFBHD OBGKA SCUFR OQZTS D. Keyword<br />

STONE.<br />

(b) WWEYQ YISKG EXAAV ESNAM MRX. Keyword ERIE.<br />

(c) RUBNY MQZXH PBOTN ZBZPH LQSIU AMZXQ KNLPH YMFNU M. Keyword<br />

DUSTY.<br />

(d) BZXFK QNCCK IJXOL CDUAU ZOBKP VABCU LQOIK RWZAW MSPEW MURO.<br />

Keyword CHOICES.<br />

8. Decipher the first line <strong>of</strong> the Mother Goose rhymes using a Variant cipher<br />

with the given keyword.<br />

(a) QNAVF TCWXS ZDDGJ SQNAR XRERL IWI. Keyword DUEL.<br />

(b) ERZGM GNHGG WAVTZ ZVHPK VXZEO AF. Keyword SHOE.<br />

(c) KNSXL WJBKU GDPAJ IJOSU TLDMP JWC. Keyword JUMBLIES.<br />

(d) OKEZQ CBNPH WHNUC ZHMLG YEQLS KC. Keyword SUPPER.<br />

9. The Confederate Army made frequent use <strong>of</strong> Vigenère ciphers during the<br />

Civil War, calling them “court” or “diplomatic” ciphers. In 1863 the<br />

Union forces under General Ulysses S. Grant were engaged in a siege <strong>of</strong><br />

Vicksburg and captured a ciphertext. Here is his report on this [Bates].


126 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

Headquarters Department <strong>of</strong> the Tennessee,<br />

Near Vicksburg, May 25, 1863.<br />

Col. J.C. Kelton, Assistant Adjutant-General, Washington, D.C.<br />

COLONEL: Eight men, with 200,000 percussion caps, were arrested<br />

whilst attempting to get through our lines into Vicksburg. The inclosed<br />

[sic] cipher was found upon them. Having no one with me who<br />

has the ingenuity to translate it, I send it to Washington, hoping that<br />

some one there may be able to make it out. Should the meaning <strong>of</strong><br />

this cipher be made out, I request a copy be sent to me.<br />

Very respectfully,<br />

U.S. Grant, Major-General.<br />

The enclosed message was<br />

[General Joe] Jackson (miss), May 25, 1863<br />

Lieutenant General Pemberton: My XAFV. USLX was VVUFLSJP<br />

by the BRCYAJ. 200000 VEGT. SUAJ. NERP. ZIFM. It will be<br />

GFOECSZOD as they NTYMNX. Bragg MJTPHIHZG a QRCM-<br />

KBSE. When it DZGJS. I will YOIG. AS. QHY. NITWM do you<br />

YTIAM the IIKM. VFVEY. How and where is the JSQMLGUGS-<br />

FTVE. HBFY is your ROEEL.<br />

J. E. Johnston<br />

Decipher the enciphered words. The keyphrase is Manchester Bluff.<br />

(Note: there are several errors. Can you fix them)<br />

10. After Vicksburg fell to the Union, soldiers found the following cipher message:<br />

Vicksburg, Dec. 26, 1862<br />

Gen J.E. Johnston, Jackson:<br />

I prefer O A A V V R. It has reference to X H V K H Q C H F F I<br />

B P Z E L R E Q P Z Q N Y K to prevent P N U Z E Y X S W S<br />

T P J W at that point. R O E E L P S G H V E L V T Z F I U T<br />

L I L A S L T L H I F N O I G T S M M L F G C C A J D<br />

J.C. Pemberton<br />

Somebody (Pemberton’s clerk) failed to destroy the enciphered message<br />

after translating it. Military telegraph clerks in Washington broke<br />

the message and recovered the key Manchester Bluff. They were very<br />

surprised when they subsequently found that this key worked for many<br />

message. Eventually the Confederates, suspecting the cipher was broke,<br />

switched to new key.<br />

Decipher the message.<br />

11. Captain William Plum [Antonucci] was in charge <strong>of</strong> Union communications<br />

at New Orleans. He received an intercepted message addressed


7.10. EXERCISES 127<br />

to Gen. E. K. Smith, the commander <strong>of</strong> the Conferederacy’s Trans-<br />

Mississippi Department. In the fall <strong>of</strong> 1964, the southwest campaign was<br />

not going well for the Union. Smith’s forces’ next target (north into Missouri<br />

Raid the west Advance south to New Orleans Fight to regain a<br />

foothold across the Mississippi river) was unknown. Perhaps the cipher<br />

gave this target!<br />

September 30<br />

To Genl. E. K. Smith:<br />

What are you doing to execute the instructions sent you to HCDL-<br />

LVW XMWQIG KM GOEI DMWI JN VAS DGUGUHDMITD. If<br />

success will be more certain you can substitute EJTFKMPG OPG-<br />

EEVT KQFARLF TAG HEEPZZU BBWYPHDN OMOMNQQG.<br />

By which you may effect O TPQGEXYK above that part HJ OPG<br />

KWMCT patrolled by the ZMGRIK GGIUL CW EWBNDLZL.<br />

Jeffn. Davis<br />

The last part <strong>of</strong> the message mentioned patrolling. Perhaps it referred to<br />

gunboat patrols on the river, the only patrols likely to interest Confederate<br />

high command. So Plum guessed that “that part HG OPB KWMCT<br />

patrolled” stood for “that part <strong>of</strong> the river patrolled”. Plum wrote “this<br />

meaning occurred to the author, at first sight, and doubtless would to any<br />

one familiar with military affairs in that section.”<br />

He then turned to “By which you may effect O TPQGEZYK above that<br />

part <strong>of</strong> the river ...” Perhaps “a crossing” He soon had decrypted the<br />

message. Can you (Hint: use Plum’s guesses to help find the keyword.)<br />

(So word division led to complete solution. Why leave in word division 15<br />

During the battle <strong>of</strong> Vicksburg Grant drove between the forces <strong>of</strong> Permberton<br />

and Joe Johnston, forcing Johnston into the city, which Grant then<br />

besieged. Johnston telegraphed for reinforcements. Unfortunately, the<br />

cipherer made mistakes, and the telegrapher added his own (confusing R<br />

(− −−) with S (− − −), and I (− −) with a pair <strong>of</strong> E’s (−)). After Kirby<br />

Smith spent 12 fruitless hours trying to read this message, he finally sent<br />

his chief <strong>of</strong> staff, Major Cunningham, on horseback around the flank <strong>of</strong> the<br />

Union armies to retrieve the message directly. By the time Cunningham<br />

reached Johnston, Johnston’s army was completely cut <strong>of</strong>f from Smith.<br />

After this, the Confederates retained word division [Pratt 186–7].<br />

This is not to imply that the North was cryptologically far more advanced<br />

than the South. General Albert Myer, in his A Manual <strong>of</strong> Signals: for the<br />

use <strong>of</strong> Signal Officers in the Field, he seemed to imply that in Vigenèretype<br />

systems the keys should be chosen at will by the sender and sent at<br />

the start <strong>of</strong> the transmission! That is, send both the key and ciphertext!<br />

15 “In 1862 South adopted the centuries-old Vigen’ere as its principal <strong>of</strong>ficial cipher, the<br />

proceeded to violate its inherent strengths for the time by such practices as retaining plaintext<br />

word length, interspersing plain text and cipher, etc” Ralph E. <strong>Web</strong>er, [<strong>Web</strong>er]


128 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

It is true that the Confederate’s signal service was organized by Captain<br />

(later General) E. Porter Alexander, who had known Myer in the old U.S.<br />

Army while Myer was organizing his signals. So it could well be believed<br />

that the Confederates knew the system being used. But Myer’s confidence<br />

in his system shows how little cryptanalysis was understood at the time.<br />

[SSA2])<br />

12. By 1865 the Civil War was going very badly for the Confederates. The<br />

following message from General Robert E. Lee to John Breckenridge, the<br />

Secretary <strong>of</strong> War for the Confederacy was intercepted [Plum].<br />

Dated Head-<br />

Confederate <strong>St</strong>ates <strong>of</strong> America, Military Telegraph.<br />

quarters,<br />

February 25, 1865.<br />

Received at Richmond, Va., 12:25 minutes, A.M.<br />

To Hon. J.C. Breckenridge, Sec’y <strong>of</strong> War :- I recommend that the<br />

tsysmee fn qoutwp rfatvvmp ubwaqbqtm exfvxj and iswaqjru ktmtl<br />

are not <strong>of</strong> immediate necessity, uv kpgfmbpgr mpc thnlfl should be<br />

lmqhtsp. (signed) R.E. Lee<br />

It was known that the key was COME RETRIBUTION. Decipher the message.<br />

13. In his Manual, Parker Hitt uses a ciphertext given in the 1914 Signal Book,<br />

enciphered using a cipher disk, to introduce Kasiski examination. The ciphertext<br />

is DRZCS XOTFG EYRIF HZRWC SXETA EBKSX MQQQW CKBPT DMF.<br />

What keylength did he determine<br />

14. Use Kasiski’s method to find the length <strong>of</strong> the keyword in the following<br />

Vigenère cipher. Then decrypt the cipher. The quote is from Charles<br />

Babbage’s autobiography Passages from the Life <strong>of</strong> a Philosopher.<br />

OOPSF USIMP DXSJY KUMLV CILVA DEIRJ DXIDD SFUSI ASESF EPGIQ SIRJY<br />

KITEL ETEVO ORGOO GMCUT SNQZW SFDWE EMCEW PVYQP VSPYI VFYQO EPVAU<br />

PPYBN UUBTR TFOAI USMTU SETIP MSBMP EUZGO ODXRV NXADT THFCA HJNLN<br />

PMSDZ PPSFN ENEPG IQSIR JSEVF LPSPZ FSFCZ EEELA UELED WIVFC IRUSI<br />

PFCWO OELEN ZVEJY XINLX EJDLI TNSNW TGTJZ R<br />

15. Use Kasiski’s method to decrypt the following Vigenère cipher. (Find the<br />

keylength and then decrypt the cipher.) The quote is from Belaso’s book.<br />

PVZVU KIEWW NGZJF IOPFG JGZVL KTJRE AKFUV OWELL WZZDF KFCDL<br />

EBFUS JMFWZ AFCDF CIRJW WBUWZ AKFUV OARBT ATVZG NARQQ WGNDF<br />

PSUWZ ABNHL WYVWZ AKFUV OKVZA OVKRO NWKHS JRGXL PVVPG JDRSW<br />

NKILL EBXWZ AAERL PCFFD KGVWG CSKKW NHYHF KJVUW WQYRX PVVOW<br />

PHVUK SSGOS YSROW PHVUG BCLUU KIEWW NGZJF<br />

16. This cipher contains Kasiski’s instructions for computing the keylength:


7.10. EXERCISES 129<br />

MEJMY JKXCD LCNMQ DELMI QOTCB ERSRE DLCBI NOXGD MMXWD BSKYR CKRMD<br />

LCBEL NILNI YFSPD SZBIY UYNDL GCRSW FCBML DSGDW DKGRY VQDLC PEADS<br />

PWSQD JPOUS ORRVC DYYLN MLNMA KXCCX FORSW FCBSD VIRDI PCMLD LCUIW<br />

Use Kasiski’s method to decrypt it [Kasiski].<br />

17. Use Kasiski’s method to decrypt this message [Antonucci].<br />

Head-Quarters, C.S. Armies, March 24, 1865.<br />

Gen. E. Kirby Smith, comdg. Trans-Miss. Dept., Gen.:-<br />

VVQ ECILMYMPM RVCOG UI LHOMNIDES KFCH KDF WASPTF US TFCFSTO<br />

ABXCBJX AZJKHMGJSIIMIVBCEQ QB NDEL UEISU HT KFG AUHD EGH OPCM<br />

MFSUVAJWH XRYMCOCI YU DDDXTMPT IU ICJQKPXT ES VVJAU MVRR TWHTC<br />

ABXCIU EOIEG O RDCGX EN UCR PV NTIPTYXEC RQVARIYYB RGZQ RSPZ<br />

RKSJCPH PTAXRSP EKEZ RAECDSTRZPT MZMSEB ACGG NSFQVVF MC KFG<br />

SMHE FTRF WHMVV KKGE PYH FEFM CKFRLISYTYXL XJ JTBBX RQ HTXD<br />

WBHZ AWVV FD ACGGAVXWZVV YCIAG OE NZY FET LGXA SCUH<br />

(Signed) R.E.Lee<br />

18. Joseph Willard Brown [Brown] describes the Confederate cipher wheel.<br />

“To facilitate reading the cipher messages, Capt. William N. Barker,<br />

<strong>of</strong> the Confederate Signal Corps, invented a simple but convenient<br />

apparatus. The alphabetical square was pasted on a cylinder and<br />

revolved under a bar on which was a sliding pointer. The pointer<br />

was brought to the letter in the key on the bar, and the letter in the<br />

word to be converted was rolled up under the bar and the pointer<br />

rested on the required substitute letter.”<br />

Make a Confederate cipher wheel.<br />

19. If we know the plaintext and the ciphertext, we can, <strong>of</strong> course, find the<br />

key. The Zig-Zag attack on polyalphabetic ciphers is based on this. <strong>St</strong>art<br />

with a probable word (also called a crib), a word that is probably in<br />

the plaintext. Assuming it starts at the first letter <strong>of</strong> the ciphertext, use<br />

it to find the beginning <strong>of</strong> the key. If the key appears to be nonsensical,<br />

try again starting with the second letter <strong>of</strong> the ciphertext, and then third,<br />

fourth, and so on, until part <strong>of</strong> the key appears. Then zig-zag back and<br />

forth from the key to the ciphertext and back again, gradually building<br />

both out.<br />

(a) As a very simple example, was are the last three letters <strong>of</strong> the ciphertext<br />

OSQSW. Find the three associated letters <strong>of</strong> the key, and then see<br />

if you cannot guess the rest <strong>of</strong> the key and use it to find the rest <strong>of</strong><br />

the ciphertext.<br />

(b) The very common phrase and the appears in the ciphertext PHWWZ<br />

RYBRR JTSUL GNXTV NSLSI QE. Find where, and use it as a key to<br />

decrypt the text.<br />

(c) At least one <strong>of</strong> the common endings -tion or -ing appear in this<br />

text: WEQCN IVEDO PHWWK OQHCQ KXLYL LGWGL OAFHX MLP. Use this<br />

information to decrypt it.


130 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

20. A common reinvention <strong>of</strong> the Vigenère Cipher reduces it to a progressive<br />

key cipher. From [Pall] we have “The Pass-Word Cipher.” To use it, select<br />

a keyword, say PRUDENTIA, and then encipher using the table produced,<br />

using a new line for each new word.<br />

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<br />

P q r s t u v w x y z a b c d e f g h i j k l m n o p<br />

R s t u v w x y z a b c d e f g h i j k l m n o p q r<br />

U v w x y z a b c d e f g h i j k l m n o p q r s t u<br />

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 d<br />

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 d e<br />

N o p q r s t u v w x y z a b c d e f g h i j k l m n<br />

T u v w x y z a b c d e f g h i j k l m n o p q r s t<br />

I j k l m n o p q r s t u v w x y z a b c d e f g h i<br />

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 a<br />

The example given is JXU KGDVAWJK HPODIT JSV BFSY CT PCWNOUFMA<br />

BDYYUH VT EH LZWQ RDGG VIZSPX YT HVS YHYGS. Decipher it.<br />

21. Graf Gronsfeld suggested that the Vigenère keyword be replaced by a short<br />

series <strong>of</strong> numbers. For example, come here enciphered with keynumber<br />

1403 is DSMH IIRH. Now known as the Gronsfeld Cipher, in effect it is<br />

a Vigenère Cipher as a composite <strong>of</strong> Shift Ciphers, rather than the usual<br />

composite <strong>of</strong> Caesar Ciphers.<br />

(a) Encipher Gronsfeld with keynumber 296.<br />

(b) Decipher JVIMZ HTXLL LR. The keynumber was 34870.<br />

(c) Decipher EMSLH MCOF. The keynumber was 2625.<br />

(d) Considering the example given in the question, what makes this a<br />

good cipher<br />

(e) For a sizable ciphertext, we can use the techniques for decrypting a<br />

Vigenère Cipher to decrypt a Gronsfeld Cipher. But because <strong>of</strong> the<br />

restricted choice <strong>of</strong> keys (really, only words made up from the first<br />

ten letters <strong>of</strong> the alphabet), the Gronsfeld is considerably less secure<br />

than the Vigenère.<br />

The following ciphertext has been enciphered using a Gronsfeld Cipher<br />

in which the keynumber uses only (some <strong>of</strong>) 0’s, 1’s, 2’s and<br />

3’s. By trial-and-error, can you decrypt the message (Hint: each<br />

ciphertext letter could come from at most four plaintext letters: D<br />

from a, b, c, or d. Neatly list them, and see if you cannot build a<br />

message.)<br />

LHEBE SQGLL OUSWB KRZBA TRIGA YFP.


7.10. EXERCISES 131<br />

22. (a) Use Kasiski’s method to decrypt the message:<br />

CT OSB UHGI TP IPEWF H CEWIL NSTTLE FJNVX XTYLS FWKKHI BJLSI SQ<br />

VOI BKSM XMKUL SK NVPONPN GSW OL IEAG NPSI HYJISFZ CYY NPUXQG<br />

TPRJA VXMSI AP EHVPPR TH WPPNEL UVZUA MMYVSF KNTS ZSZ UAJPQ<br />

DLMMJXL JR RA PORTELOGJ CSULTWNI XMKUHW XGLN ELCPOWY OL ULJTL<br />

BVJ TLBWTPZ XLD K ZISZNK OSY DL RYJUAJSJF ZIEQN ASC YQ LNFFTR<br />

CIKQYF XMG TBWY KU TSRG VVXBCYE FTWUE Z JUZFP HTLXW BKSM RTV<br />

IF WHTBUMSKGFH XQ ZIEWRSZ EX RHTWJPNFVX VOFVJ CYF XMQZF AMQ<br />

DJPQ NLU CTW ROSB OF NSAGTFRYU MPV YJL QSQKJF QFA ABQUGY XM YJ<br />

FPYW EVSVJUWPRIGUDI GWA MEYGY PR BJLO LZG HOH HTF IEAG KJII<br />

FVXR BKSM PJV FPY PPVX EQN<br />

(b) This message appears in Parker Hitt’s book [Hitt, page 59]. He claims<br />

it appeared in the “personals” column <strong>of</strong> a London newspaper, and<br />

after breaking hit he looked back at the column from the day before<br />

and found the message “M.B. Will deposit £27 14s 5d tomorrow.”<br />

How are the messages related<br />

23. Trithemius’ tabula recta is used in three different ways to produce the<br />

Vigenère Cipher, Beaufort Cipher and their Variant Cipher.<br />

In the chart below we encipher money with SEND using a Vigenère cipher<br />

as usual. Next to it, the letters are converted to their equivalent numbers.<br />

plaintext m o n e y plain numbers 13 15 14 5 25<br />

key S E N D S key numbers 18 4 13 3 18<br />

ciphertext E S A H Q cipher numbers 31≡5 19 27≡1 8 43≡17<br />

(a) Using P , C and K to represent the plaintext, ciphertext and key,<br />

respectively, how, mathematically, do P and K determine C That<br />

is, give an equation C =, where is some combination <strong>of</strong> P<br />

and K. This gives a mathematical formulation <strong>of</strong> enciphering with<br />

Vigenère.<br />

(b) Find the similar formula for deciphering a Vigenère cipher.<br />

(c) Create similar charts, using the same plaintext and key, but this time<br />

using a Beaufort Cipher. Use your charts to find the mathematical<br />

formulation <strong>of</strong> enciphering with the Beaufort.<br />

(d) Find the similar formula for deciphering a Beaufort cipher.<br />

(e) Repeat parts (c) and (d) but this time using a Variant Cipher.<br />

(f) What does this problem tell us about the possibility for other polyalphabetic<br />

ciphers


132 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

24. (Continuation <strong>of</strong> 23.) In I, Claudius by Robert Graves, the character<br />

Claudius writes<br />

The key <strong>of</strong> the ... cipher ... was provided by the first hundred lines<br />

<strong>of</strong> the first book <strong>of</strong> the Iliad, which had to be read concurrently with<br />

the writing <strong>of</strong> the cipher, each letter in the writing being represented<br />

by the number <strong>of</strong> letters <strong>of</strong> the alphabet intervening between it and<br />

the corresponding letter in Homer. Thus the first letter <strong>of</strong> the first<br />

word <strong>of</strong> the first line <strong>of</strong> the first book <strong>of</strong> the Iliad is Mu. Suppose the<br />

first letter <strong>of</strong> the first word <strong>of</strong> an entry in the dossier to be Upsilon.<br />

There are seven letters in the Greek alphabet intervening between<br />

Mu and Upsilon so Upsilon would be written as 7. In this plan the<br />

alphabet wouild be thought <strong>of</strong> as circular, Omega, the last letter,<br />

following Alpha, the first, so that the distance between Upsilon and<br />

Alpha would be 4, but the distance between Alpha and Upsilon sould<br />

be 18. It was Augustus’s invention and must have taken rather a long<br />

time to write and decode.<br />

Although Graves describes a cipher using Greek, it should not be Greek<br />

to you. (Sorry – couldn’t resist.) This is clearly a polyalphabetic cipher.<br />

What kind – Vigenére, Beaufort or Variant<br />

If it helps, the Greek alphabet is<br />

αβγδɛζηθικλµνξoπρστυφχψω<br />

25. Admiral Beaufort was neither the first nor the last person to invent the<br />

cipher named for him. In his diary on April 22, 1868 Charles Dodgson<br />

wrote that while “Sitting up at night I invented a new cipher, which I think<br />

<strong>of</strong> calling the Telegraph Cipher.” He told George Ward Hunt, First Lord<br />

<strong>of</strong> the Admiralty about his invention. No response is known [Abeles2].<br />

His method involves two alphabets:<br />

Key Alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ<br />

Message Alphabet: abcdefghijklmnopqrstuvwxyza<br />

“To translate a message into cipher, write the key-word, letter for<br />

letter, over the message, repeating it as <strong>of</strong>ten as may be necessary:<br />

slide the message-alphabet along under the other, so as to bring the<br />

first letter <strong>of</strong> the message under the first letter <strong>of</strong> the key-word, and<br />

copy the letter that stands over ’a’: then do the same with the second<br />

letter <strong>of</strong> the message and the second letter <strong>of</strong> the key-word, and so<br />

on.<br />

Translate back into English by the same process.<br />

For example, if the key-word be WAR, and the message meet me at<br />

six, we write it thus:–<br />

warw ar wa rwa<br />

meet me at six<br />

kwnd on wh zod


7.10. EXERCISES 133<br />

(a) Construct a device on which to do the Telegraph Cipher.<br />

(b) Encipher Through the Looking Glass with key ALICE.<br />

(c) Decipher KHDKD WLDGG R using key HOLE.<br />

(d) The Saint Cyr slide uses the alphabet three times, whereas Dodgson’s<br />

device needs only two. Why<br />

(e) Explain why the Telegraph Cipher is the same as the Beaufort Cipher.<br />

(Dodgson was likely aware <strong>of</strong> Beaufort’s 1857 cipher. That they were<br />

equivalent was not pointed out until 1883 by Auguste Kerckh<strong>of</strong>fs in<br />

his La Cryptographi Militaire.)<br />

26. Charles Dodgson also (see Exercise 25) invented two ciphers on February<br />

23rd and 26th <strong>of</strong> 1858. From his diary entry on the 26th [Abeles3]:<br />

Invented another cypher, far better than the last: it has these advantages.<br />

(a) The system is easily carried in the head.<br />

(b) The key-word is the only thing necessarily kept secret.<br />

(c) Even one knowing the system cannot possibly read the cipher<br />

without knowing the key-word.<br />

(d) Even with the English to the cipher given, it is impossible to<br />

discover the key-word.<br />

To use this cipher, Dodgson writes the (latin) alphabet in form <strong>of</strong> square<br />

A F L Q W<br />

B G M R X<br />

C H N S Y<br />

D I O T Z<br />

E K P V *<br />

(so I=J, U=V, and * just fills the square.)<br />

With keyword <strong>of</strong> GROUND he enciphers send as follows<br />

Measuring from G to S we find it to be “2nd column 1st line,” and<br />

write 21. In re-translating [deciphering] we begin at G, & go “2<br />

columns to the right, & 1 line further down,” and this gives us S<br />

again.<br />

Measuring from R to E gives 23. from O to N - 04. from U to D -<br />

24 .... we write 21.23.04.24.<br />

So we always read to the right and then down. If we need to move <strong>of</strong>f the<br />

end <strong>of</strong> the square, simply re-enter on the top or left, as appropriate.<br />

Dodgson added some complications:<br />

i) Putting pairs in parentheses, such as (2.5), would mean to restart the<br />

keyword at its fifth letter N. Or (2.5)(1.2) says restart with the letter that<br />

is 1.2 from the 5th letter: N + (1.2) = V.


134 CHAPTER 7.<br />

VIGENÈRE CIPHERS<br />

ii) Putting a pair with a letter says to use the keyletter corresponding to<br />

the second number <strong>of</strong> the pair to encipher this letter. The first and last<br />

number <strong>of</strong> the result tells how many nulls are at the front and rear <strong>of</strong> the<br />

message. So (1.2)Q says encipher Q with R - gives 04, says no nulls at<br />

start, 4 at rear.<br />

iii) Deliberately misspelling words, by leaving out letters or adding extra<br />

letters, would increase safety.<br />

(a) Dodgson gives as an example<br />

(2.3)(V)10.14.20.00.00.01.33.40.42.40.01.20.23.02.<br />

Decipher it.<br />

(b) Dodgson added that an “improvement on this again is instead <strong>of</strong><br />

03 to write D ... and so on.” Explain why this makes his system a<br />

Variant Beaufort system.<br />

27. As Vigenére said, ”the longer the key is, the more difficult it is to solve the<br />

cipher.” Does using words that have some repetition in them, like Banana,<br />

Concoct, Tomorrow or Rococo Change this conclusion<br />

28. As the end <strong>of</strong> World War II drew near, plans were drawn up for the<br />

future <strong>of</strong> the SSA. Included in this were studies <strong>of</strong> the history <strong>of</strong> U.S.<br />

cryptography prepared under the Direction <strong>of</strong> the Chief Signal Officer.<br />

The following quote is from the study Codes and Ciphers during the Civil<br />

War dated 20 April 1945.<br />

Careful use <strong>of</strong> Vigenère requires [the] cipher clerk to first underline<br />

any repetitions in the body <strong>of</strong> the plaintext. Then copy the text into<br />

columns under the keyword/phrase and make sure that none <strong>of</strong> these<br />

repetitions appear in the same column, and if any do, insert nulls to<br />

throw the repetition out <strong>of</strong> phase.<br />

Explain what this quote means. That is, explain what the underlining is<br />

trying to accomplish.<br />

29. In his column in Philadelphia’s Alexander’s Weekly Messenger Edgar<br />

Allen Poe challenged readers that he could break any monoalphabetically<br />

enciphered text. A Mr. G. W. Kulp sent the ciphertext<br />

GEIEI ASGDX VZIJQ LMWLA AMXZY ZMLWD YXRTV JCIML LHJXA MXZYF IFIWA<br />

FEPML BGPXW DLNRW EQWBC KMHJT NWSLB RZLEW MKDTC HUCMK WZZXN TGUIE<br />

LBRJL HTAIV UGMBX LKIUU PAMUM WXKJX EWEQM CZXZL GNSBW LBRNT YOLPI<br />

MLQIH WKXKW IOLXE UFBXV V<br />

that was published February 26th, 1840. Poe showed in a later issue that<br />

the ciphertext was not a monoalphabetic cipher, and called it “A jargon<br />

<strong>of</strong> random characters having no meaning whatsoever.” Indeed, it is a<br />

Vigenère cipher. Even knowing this does not necessarily make this an<br />

easy text to break. Can you do it


Chapter 8<br />

Polyalphabetic Ciphers<br />

The key cipher is the noblest and the greatest in<br />

the world, the most secure and faithful that never<br />

was there man who could find it out.<br />

Matteo Argenti<br />

Following our work in Chapter 7 we have a way to decrypt Vigenère ciphers:<br />

the Kasiski Examination followed by frequency analysis. The frequency analysis<br />

is relatively easy once we know the length <strong>of</strong> the keyword. However the Kasiski<br />

Examination, although it works fine, is quite time consuming since we must go<br />

through the message letter by letter looking for repetitions. It would be fifty<br />

years before an improvement was found.<br />

8.1 Coincidences<br />

On what does the Kasiski test depend That repetition <strong>of</strong> parts <strong>of</strong> the ciphertext<br />

are meaningful. To recall our original example:<br />

plaintext<br />

key<br />

ciphertext<br />

t o b e o r n o t t o b e t h a t i s t h e q u e s t i o n<br />

R U N R U N R U N R U N R U N R U N R U N R U N R U N R U N<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

Kasiski’s idea is that the repeated KIOV and NU hint at the length <strong>of</strong> the keyword.<br />

To have such repetitions we (the crytanalysts) need some luck: the same<br />

plaintext part must lie under the same key part. Before Kasiski people presumably<br />

thought <strong>of</strong> such repetitions as mere coincidences – unrelated events that<br />

are unlikely to occur together but just happen to do so. Kasiski’s test showed<br />

that sometimes these coincidences are, in fact, meaningful.<br />

Can we look for these meaningful repetitions, these meaningful coincidences,<br />

in another way A (relatively) quick way to see when individual letters are<br />

repeated is to write the ciphertext one two slips <strong>of</strong> paper, and hold one under<br />

135


136 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

the other, <strong>of</strong>fset by various amounts. Let’s do this for the “KIOV” ciphertext,<br />

using the <strong>of</strong>fsets or shifts <strong>of</strong> 1 through 6. Whenever there is a coincidence, we<br />

mark it with an asterisk.<br />

1: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

*<br />

2: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

3: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

* * * * * *<br />

4: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

*<br />

5: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

*<br />

6: K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

K I O V I E E I G K I O V N U R N V J N U V K H V M G Z I A<br />

* * * *<br />

Obviously this is a very short ciphertext, so the number <strong>of</strong> coincidences is low,<br />

no matter the shift. But it is striking that the shifts <strong>of</strong> 3 (the keylength)<br />

and 6 (twice the keylength) have many more coincidences than the other shift<br />

amounts.<br />

For a longer ciphertext doing this “shift examination” would be quite time<br />

consuming. So let’s think more carefully about these coincidences. A coincidence<br />

will occur when the same letter occurs twice in the ciphertext. How likely<br />

are coincidences Or, to be more precise, how likely is it that two randomly<br />

chosen letters from the ciphertext are the same<br />

This brings us near the field <strong>of</strong> Probability. One <strong>of</strong> the first things anyone<br />

learns in probability is that the likelihood <strong>of</strong> something particular happening is<br />

the number <strong>of</strong> ways that thing can occur divided by the number <strong>of</strong> total things<br />

that can occur:<br />

Probability that A occurs =<br />

Number <strong>of</strong> ways A can occur<br />

Number <strong>of</strong> ways anything can occur<br />

For example, my birthday is February 25th. How likely is it that I was born<br />

on a weekend Since I didn’t tell you what year I was born, the best guess you<br />

can make is 2/7-ths. There are two ways I could have been born on a weekend


8.1. COINCIDENCES 137<br />

(being born on Saturday or being born on Sunday) and a total <strong>of</strong> seven days <strong>of</strong><br />

the week that I could have been born on.<br />

How does this work for us To make the explanation clear, let’s write #A to<br />

mean the number <strong>of</strong> A’s in the ciphertext. So #B represents the number <strong>of</strong> B’s,<br />

#C is the number <strong>of</strong> C’s, and so on. How many ways are there to choose two<br />

different A’s from the ciphertext There are #A ways to pick one A, and then<br />

#A−1 ways to pick a different A. (Minus 1 because we’ve already picked one, so<br />

there are one fewer to choose from.) So there are #A(#A−1) ways to pick two<br />

A’s. Likewise #B(#B−1) ways to pick two B’s, and #C(#C−1) ways to pick two<br />

C’s. Doing this for all the letters in the ciphertext gives us<br />

#A(#A − 1) + #B(#B − 1) + · · · + #Z(#Z − 1)<br />

ways <strong>of</strong> having a coincidence. To see how likely a coincidence is we must divide<br />

by the number <strong>of</strong> ways <strong>of</strong> choosing any two letters. If the total number <strong>of</strong> letters<br />

in our ciphertext is N, then this number is N(N − 1). 1<br />

Putting the pieces together, we 2 have reinvented Friedman’s famed Index<br />

<strong>of</strong> Coincidence. Designated Φ (“phi”), this is the likelihood that two letters,<br />

picked randomly from a ciphertext, are the same. As we’ve just determined, the<br />

formula for Φ is<br />

Φ =<br />

#A(#A − 1) + #B(#B − 1) + · · · + #Z(#Z − 1)<br />

, (8.1)<br />

N(N − 1)<br />

where #A is the number <strong>of</strong> A’s in the ciphertext, #B is the number <strong>of</strong> B’s in the<br />

ciphertext, etc., and N = #A + #B + · · · + #Z is the total number <strong>of</strong> letters in<br />

the ciphertext.<br />

Friedman was, justifiably, quite proud <strong>of</strong> his Index. In the introduction<br />

to The Index <strong>of</strong> Coincidence and Its Applications in Cryptography Riverbank<br />

Publications No 22., 1920 he wrote “when such a treatment is possible, it is<br />

one <strong>of</strong> the most useful and trustworthy methods in cryptography.” 3 However,<br />

from our development, it is not quite clear what Φ tells us, or how to use it.<br />

Clearly Φ measures, somehow, the frequency <strong>of</strong> coincidences in a polyalphabetic<br />

cipher. But what does Φ = 0.045 mean To find out, we need to think about<br />

the frequency counts in a different way.<br />

1 (Actually, from n objects there are n(n − 1)/2 ways <strong>of</strong> choosing two <strong>of</strong> them: we must<br />

divide by 2 because it doesn’t matter which one is chosen first and which is chosen second. So<br />

the denominator and each term in the numerator should have included a “/2”. Fortunately,<br />

all the two’s cancel out.)<br />

2 Our presentation <strong>of</strong> these ideas borrows liberally from that <strong>of</strong> Abraham Sinkov’s book<br />

Elementary Cryptanalysis. Sinkov (1907–1998) was one <strong>of</strong> the first three people hired by<br />

Friedman to work in the Army’s Signal Intelligence Service. He headed the Communications<br />

Intelligence Organization during World War II, the group largely in charge <strong>of</strong> intercepting and<br />

breaking Japanese messages. His book was published in 1966 and is quite influential.<br />

3 Kahn [Kahn, pg 376] tells the story that General Cartier <strong>of</strong> the French indexCartier,<br />

General Cryptographic section saw Riverbank No. 22 and “thought so highly <strong>of</strong> it that he<br />

had it translated and published forthwith – false-dating in “1921” to make it appear as if the<br />

French work had come first!”


138 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

8.2 The Measure <strong>of</strong> Roughness<br />

It is not necessarily clear how the Index <strong>of</strong> Coincidence is connected to polyalphabetic<br />

ciphers. To glimpse this connection we must think back to the differences<br />

between the frequencies count <strong>of</strong> monoalphabetic and polyalphabetic<br />

ciphers. We have learned to recognize a Caesar Cipher from the intense highs<br />

and lows <strong>of</strong> its frequency count: there are many letters that occur quite <strong>of</strong>ten<br />

(the ciphertext versions <strong>of</strong> the etaoinshr letters) and many that seldom occur<br />

(the uvwxyz-types). However, in polyalphabetic ciphertexts the frequencies are<br />

less sharp; the highs are lower and the lows are higher. We might say that a<br />

Caesar Cipher has a frequency count that is much rougher than the frequency<br />

count <strong>of</strong> a Vigenère Cipher. Further, the longer the keyword <strong>of</strong> a Vigenère<br />

Cipher is, the smoother the frequency count is.<br />

To illustrate with an example, I’ve enciphered the quote <strong>of</strong> General Givierge<br />

from Section 7.6 using keys <strong>of</strong> various lengths. (I used the alphabet as the key, so<br />

the five letter key was ABCDE.) The frequency counts <strong>of</strong> the resulting ciphertexts<br />

appear in Figure 8.1. Notice that as the keys get longer, there are fewer numbers<br />

keylength 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<br />

one 13 1 7 10 20 4 3 4 14 0 1 9 5 19 21 3 0 11 4 16 5 1 3 1 8 0<br />

three 3 6 6 7 15 10 8 4 6 7 4 5 3 10 13 17 9 4 6 9 11 6 2 2 5 5<br />

five 5 4 5 8 10 5 12 7 7 7 3 5 10 7 12 10 7 12 8 4 8 9 7 6 3 2<br />

ten 10 5 7 5 7 5 6 4 6 5 4 10 6 11 13 4 6 13 6 7 9 6 10 7 3 8<br />

twenty 10 11 9 10 11 7 8 5 7 8 5 8 6 6 6 5 5 6 4 3 8 6 7 9 7 6<br />

Figure 8.1: Frequency Counts: Same quote, different keylengths.<br />

that are much larger or much smaller than “average” and more that are in the<br />

middle. In general, the longer a keyword is, the smoother the frequencies are,<br />

and the shorter the keyword, the rougher the frequencies, which makes sense.<br />

After all, the point <strong>of</strong> polyalphabetic ciphers was to have each plaintext letter<br />

become many different cipherletters, causing the individual frequency counts to<br />

become more and more similar.<br />

Does the converse hold Can we somehow measure the “roughness” <strong>of</strong> a<br />

frequency count, and then use the measurement to estimate the keylength<br />

Let’s start by thinking about measuring roughness.<br />

Example: Consider the three sets <strong>of</strong> numbers<br />

{3, 3, 3, 3} {4, 0, 4, 4} {1, 4, 1, 6}.<br />

We can probably all agree that all these sets move from “smoothest” to “roughest.”<br />

Why do we feel so The latter two sets are rougher because their numbers<br />

are more spread out, are farther away from each other. What mathematical<br />

device can measure this


8.2. THE MEASURE OF ROUGHNESS 139<br />

Interestingly, we all know the device that measures the opposite: if numbers<br />

are not spread out, they are all close to average. In mathematics we tend to<br />

use mean and average interchangeably, and, <strong>of</strong> course,<br />

sum <strong>of</strong> the numbers<br />

average = mean =<br />

number <strong>of</strong> numbers .<br />

Since each <strong>of</strong> the sets in our example contain 4 numbers that sum to 12, each<br />

has a mean or average <strong>of</strong> 3. This gives us an idea <strong>of</strong> how to measure roughness:<br />

a set <strong>of</strong> numbers is rougher when it contains many numbers that are far from<br />

the mean. So we might try to define roughness by “sum how far the numbers<br />

are from their mean.” How far implies distance which implies subtraction. But<br />

it also implies that 5 and 1 are both a distance <strong>of</strong> 2 from 3, no matter that<br />

one is larger than 3 and one is smaller. So we cannot use simple subtraction to<br />

measure distance (5 − 3 = +2 but 1 − 3 = −2) but would have to use absolute<br />

value ((|5−3| = +2 and |1−3| = +2). Unfortunately, as a mathematical device,<br />

absolute value is somewhat <strong>of</strong> a pain to work with.<br />

What is traditionally chosen instead is to square the result (as the square<br />

<strong>of</strong> a number is positive). This gives us our second attempt at a definition<br />

for roughness: “the sum <strong>of</strong> the squares <strong>of</strong> the distances from the mean.” For<br />

example, the middle set <strong>of</strong> numbers then would have roughness<br />

(4 − 3) 2 + (0 − 3) 2 + (4 − 3) 2 + (4 − 3) 2 = 1 1 + 3 2 + 1 2 + 1 2 = 1 + 9 + 1 + 1 = 11,<br />

while the final set would have roughness 18. (Check this!)<br />

While this agrees with our intuition that the final set is rougher than the<br />

middle one, the definition is not quite right yet. The sets {103, 103, 103, 103},<br />

{104, 100, 104, 104} and {101, 104, 101, 106} created by adding 100 to our sets<br />

have 103 as their means and also would have roughness 0, 11 and 18. But it<br />

ought to be that an error <strong>of</strong> 2 is more forgivable when the target, the mean, is<br />

103 than when it is 3. So we must adjust for the sum. Since we are squaring<br />

the numbers, it makes sense to take the total sum into account by dividing by<br />

its square.<br />

We thus define what Sinkov calls the Measure <strong>of</strong> Roughness or M.R. 4<br />

to be<br />

M.R. =<br />

sum <strong>of</strong> the squares <strong>of</strong> the distances to the mean<br />

.<br />

square <strong>of</strong> the sum <strong>of</strong> the numbers<br />

The first set has roughness 0, since all <strong>of</strong> its numbers, and so its mean, are 3’s.<br />

For the second we compute:<br />

M.R. <strong>of</strong> {4, 0, 4, 4} = (4 − 3)2 + (0 − 3) 2 + (4 − 3) 2 + (4 − 3) 2<br />

12 2<br />

= 1 + 9 + 1 + 1<br />

144<br />

= .076.<br />

Check that you understand this by computing M.R. for the third set. 5<br />

4 For those with some statistics background, M.R. is very closely related to variance.<br />

5 .125.<br />


140 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

Examples: Compute the mean and M.R. for each <strong>of</strong> the following sets.<br />

(1) {5, 9, 2, 10, 8}.<br />

The sum <strong>of</strong> the five numbers is 5 + 9 + 2 + 10 + 8 = 34, so their mean is<br />

34/5 = 6.8. The M.R. is<br />

(5 − 6.8) 2 + (9 − 6.8) 2 + (2 − 6.8) 2 + (10 − 6.8) 2 + (8 − 6.8) 2<br />

34 2 = 42.8<br />

1156<br />

or .037. (Our formulation <strong>of</strong> roughness will generally lead to small numbers.<br />

That’s ok: we are currently worried about relative degrees <strong>of</strong> roughness,<br />

rather than the meaning <strong>of</strong> the roughness measurement.)<br />

(2) {4, 11, 13, 8, 5, 7}. 6<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

With roughness now understood, let us return to our goal: understanding<br />

frequency counts. What is the roughness <strong>of</strong> a frequency count Using the same<br />

notation as before, we have<br />

M.R. = (#A − x)2 + (#B − x) 2 + · · · + (#Z − x) 2<br />

N 2 ,<br />

where x = #A+#B+···+#Z<br />

26<br />

= N 26<br />

is the usual mathematical symbol for mean.<br />

Notice that if we multiply out the term contributed by A, we have<br />

(#A − x) 2 = #A 2 − 2#Ax + x 2 .<br />

Concentrating on the numerator <strong>of</strong> roughness, we have 26 similar terms, each<br />

with three parts. Summing the first parts gives<br />

#A 2 + #B 2 + · · · + #Z 2 .<br />

Summing the last part gives 26 copies <strong>of</strong> x 2 . But x = N/26, so these terms<br />

contribute<br />

( 2 N<br />

26x 2 = 26 =<br />

26) N 2<br />

26<br />

to the numerator. The middle terms are a bit more complicated, so we saved<br />

them for last:<br />

−2#Ax − 2#Bx − · · · − 2#Zx = −2x(#A + #B + · · · + #Z)<br />

= −2x(N)<br />

= −2 N 26 N<br />

= −2 N 2<br />

26<br />

6 The mean is 8 and M.R. = .026.


8.2. THE MEASURE OF ROUGHNESS 141<br />

Putting everything together,<br />

M.R. = (#A − x)2 + (#B − x) 2 + · · · + (#Z − x) 2<br />

N 2<br />

= #A2 + #B 2 + · · · + #Z 2<br />

N 2 − 2 N 2 N 2<br />

26<br />

N 2 + 26<br />

N 2<br />

= #A2 + #B 2 + · · · + #Z 2<br />

N 2 − 2<br />

26 + 1<br />

26<br />

= #A2 + #B 2 + · · · + #Z 2<br />

N 2 − 1<br />

26 .<br />

This looks a lot like the index <strong>of</strong> coincidence. Are they related We start<br />

with the formula for Φ:<br />

#A(#A − 1) + #B(#B − 1) + · · · + #Z(#Z − 1)<br />

Φ =<br />

N(N − 1)<br />

= #A2 + #A + #B 2 + #B + · · · + #Z 2 + #Z<br />

(multiplying out)<br />

N(N − 1)<br />

(<br />

#A 2 + #B 2 · · · + #Z 2) + (#A + #B + · · · + #Z )<br />

=<br />

(regrouping)<br />

N(N − 1)<br />

(<br />

#A 2 + #B 2 · · · + #Z 2) + N<br />

=<br />

(the sum <strong>of</strong> the letters is N)<br />

N(N − 1)<br />

(<br />

#A 2 + #B 2 · · · + #Z 2) N<br />

=<br />

+<br />

(separating the fractions)<br />

N(N − 1) N(N − 1)<br />

= N ((<br />

#A 2<br />

N − 1 × + #B 2 · · · + #Z 2)<br />

N 2 + 1 )<br />

N<br />

(factoring out<br />

N<br />

N−1 )<br />

For a long ciphertext,<br />

close to 0. So<br />

N<br />

N−1 will be very close to 1, and, likewise 1 N<br />

will be very<br />

Φ ≈ #A2 + #B 2 · · · + #Z 2<br />

N 2 . (8.2)<br />

Hopefully this last fraction looks familiar: it is the final form for M.R. except<br />

for a 1 26<br />

. Taking care <strong>of</strong> that, we (finally!) conclude<br />

Φ ≈ M.R. + 1 26 . (8.3)<br />

The Index <strong>of</strong> Coincidence is basically a measure <strong>of</strong> roughness <strong>of</strong> the frequency<br />

table! This is how Φ is connected to polyalphabetic ciphers.<br />

William Friedman wrote any number <strong>of</strong> books and pamplets on cryptography.<br />

Of particular interest to people like us, trying to break polyalphabetic ciphers,<br />

is The Index <strong>of</strong> Coincidence and Its Applications in Cryptography, Riverbank<br />

Publications No 22., 1920. This, according to David Kahn, “must be<br />

regarded as the most important single publication in cryptology.”


142 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

“Before Friedman, cryptology eked out an existence as a study unto itself,<br />

as an isolated phenomenon, neither borrowing from nor contributing to<br />

other bodies <strong>of</strong> knowledge. ... It dwelt a recluse in the world <strong>of</strong> science.<br />

Friedman let cryptology out <strong>of</strong> this lonely wilderness.” David Kahn [Kahn,<br />

pg 383]<br />

8.3 The Friedman Test<br />

We have finished the preliminary work and can now start to exploit our formulas<br />

to understand Φ. First, how large and how small can the values <strong>of</strong> Φ be<br />

From Formula 8.3, Φ is large when M.R. is large. And M.R. will be large<br />

when the frequency count is rougher. And the frequency count is roughest<br />

for monoalphabetic ciphers. Our standard monoalphabetic frequencies counts<br />

come from Figure 1.3. Using these numbers and Formula 8.2 (with N = 100<br />

since the numbers are percentages) gives Φ = 0.065601 for monoalphabetically<br />

enciphered ciphertexts. (See exercise 8.18.)<br />

On the other hand, M.R. is always positive, and its smallest value is 0, when<br />

all the numbers are the same. So from Formula 8.3, the smallest value <strong>of</strong> Φ is<br />

0 + 1 26 ≈ .03846.<br />

Do these values agree with our experimental data Adding Φ to Figure 8.1,<br />

we have<br />

length 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 Φ<br />

one 13 1 7 10 20 4 3 4 14 0 1 9 5 19 21 3 0 11 4 16 5 1 3 1 8 0 0.0655738<br />

three 3 6 6 7 15 10 8 4 6 7 4 5 3 10 13 17 9 4 6 9 11 6 2 2 5 5 0.0442563<br />

five 5 4 5 8 10 5 12 7 7 7 3 5 10 7 12 10 7 12 8 4 8 9 7 6 3 2 0.0392122<br />

ten 10 5 7 5 7 5 6 4 6 5 4 10 6 11 13 4 6 13 6 7 9 6 10 7 3 8 0.0387318<br />

twenty 10 11 9 10 11 7 8 5 7 8 5 8 6 6 6 5 5 6 4 3 8 6 7 9 7 6 0.0364499<br />

A keylength <strong>of</strong> 1 has a Φ value <strong>of</strong> near .065, and as the keys get longer, the<br />

value <strong>of</strong> Φ rapidly decreases to about 0.038.<br />

Friedman did not stop here, however, but continued until he found a direct<br />

relationship between the keylength and Φ. We won’t do that here (see exercise<br />

8.19), but Friedman was able to show that<br />

Φ ≈<br />

.065(N − k) + .038N(k − 1)<br />

,<br />

k(N − 1)<br />

where k is the keylength and the values .065 and .038 are those we found above.<br />

Friedman then solved directly for k, giving us Friedman’s test.


8.3. THE FRIEDMAN TEST 143<br />

The Friedman Test: Given a ciphertext, perhaps from a polyalphabetic<br />

cipher, compute<br />

Then<br />

Φ =<br />

#A(#A − 1) + #B(#B − 1) + · · · + #Z(#Z − 1)<br />

.<br />

N(N − 1)<br />

1. If Φ is near .065, the cipher is likely to be a monoalphabetic one. If<br />

Φ is closer to .038, the cipher is likely to be polyalphabetic.<br />

2. The value <strong>of</strong> Φ to be expected from a polyalphabetic ciphers <strong>of</strong> given<br />

keylength is<br />

Keylength Expected Φ<br />

1 .065601<br />

2 .052036<br />

3 .047515<br />

4 .045254<br />

5 .043898<br />

6 .042994<br />

10 .041186<br />

large .038461<br />

Suppose, for example, we compute that a cipher text has Φ = 0.47. Then<br />

Friedman’s Test 7 would suggest that the keyword is probably three or four letters<br />

long. Notice from the wiggle words (“suggest” and “probably”) that this method<br />

gives only an approximation and there will frequently be cases in which the<br />

Φ = .043 but the length <strong>of</strong> the keyword is actually 3. To double check that the<br />

correct keylength was found one can either<br />

1. Do a brief Kasiski Examination <strong>of</strong> the text to see if you can find 3 or 4<br />

sequences <strong>of</strong> letters that support the Friedman computation. Or<br />

2. Use the keylength suggest by the Friedman test to divide the ciphertext<br />

into that number <strong>of</strong> rows. Recompute Φ for each row. These Φ’s will<br />

be between .03 and .07. If most <strong>of</strong> them are closer to .07 than .03 you<br />

have probably discovered the correct keylength. (It might seem time consuming<br />

to recompute several mini−Φ’s, but since we will need to do a<br />

frequency count for each <strong>of</strong> the rows anyway there is relatively little extra<br />

computation.)<br />

7 Calling this “The Friedman Test” is wildly unfair to Friedman. The Index <strong>of</strong> Coincidence<br />

has many applications, only one <strong>of</strong> which is estimating the keylength <strong>of</strong> a polyalphabetic<br />

cipher. Another application (see Exercises 8.20) is the determination <strong>of</strong> a ciphertext’s original<br />

language. Another, more important, one is to solve the superimposition problem: given<br />

several, perhaps partial, polyalphabetic ciphertexts with the same key, how should the texts<br />

be lined up under one another (“superimposed”) so that the letters in each column have the<br />

same keyletter. This is especially valuable when breaking machine ciphers <strong>of</strong> the type used in<br />

the 1930’s and 1940’s.


144 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

Example: Compute Φ for the following message, and then decrypt it.<br />

EFBTL QUUEH JMDRV EFBTL CBDPQ UWVEJ GGRQW VWPIK EOOPW FHZMF QFUIU KDUSU<br />

CZVGA GBFIK CBGMF HIQGL KCQXZ GMLRV GSGQA TFRVG PSDRG VVHVO JOWSF GRRIK<br />

VVHSL JSUYF FCHWL JSLVF CHXVW UVRAW XSUHA HTHVX WBGEE GBWED NMFVQ RHRKJ<br />

CDKCA UHKIG TSWMU CZDRV CPVXJ CQWGJ ADWEF CZBWA UWVIE RWUMU CZDRV ECQGJ<br />

GHHHS XWGOS JB<br />

The frequency count is<br />

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 total<br />

7 9 14 9 11 14 19 15 7 10 8 7 7 1 5 5 10 13 11 5 15 20 17 6 1 6 252<br />

Computing, Φ = 0.0446152, which suggests a keyword length <strong>of</strong> 5. We next use<br />

Kasiski’s idea <strong>of</strong> building up a depth based on a keylength <strong>of</strong> 5:<br />

First letters: EQJECUGVEFQKCGCHKGGTPVJGVJFJCUXHWGNRCUTCCCACURCEGXJ<br />

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 total<br />

1 0 10 0 4 2 7 2 0 5 2 0 0 1 0 1 2 2 0 2 4 3 1 2 0 0 51<br />

Φ 1 = 0.0768627. (Here Φ 1 represents the computation for the letters enciphered<br />

by the 1st letter <strong>of</strong> the keyword.)<br />

Second letters: FUMFBWGWOHFDZBBICMSFSVORVSCSHVSTBBMHDHSZPQDZWWZCHWB<br />

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 total<br />

0 6 3 3 0 4 1 5 1 0 0 0 3 0 2 1 1 1 6 1 1 3 5 0 0 4 51<br />

Φ 2 = 0.0588235.<br />

Third letters: BUDBDVRPOZUUVFGQQLGRDHWRHUHLXRUHGWFRKKWDVWWBVUDQHG<br />

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 total<br />

0 3 0 5 0 2 4 5 0 0 2 2 0 0 1 1 3 5 0 0 6 4 5 1 0 1 50<br />

Φ 3 = 0.0620408.<br />

Fourth letters: TERTPEQIPMISGIMGXRQVRVSISYWVVAHVEEVKCIMRXGEWIMRGHO<br />

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 total<br />

1 0 1 0 5 0 4 2 6 0 1 0 4 0 1 2 2 5 3 2 0 6 2 2 1 0 50<br />

Φ 4 = 0.0579592.<br />

Fifth letters: LHVLQJWKWFUUAKFLZVAGGOFKLFLFWWAXEDQJAGUVJJFAEUVJSS<br />

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 total<br />

5 0 0 1 2 6 3 1 0 5 3 5 0 0 1 0 2 0 2 0 4 4 4 1 0 1 50<br />

Φ 5 = 0.0587755.<br />

The values <strong>of</strong> Φ for each <strong>of</strong> the depths are larger than 0.052, so within the<br />

range <strong>of</strong> values we’d expect from the Friedman test for a monoalphabetic cipher.


8.4. MULTIPLE ENCIPHERINGS 145<br />

Being confident <strong>of</strong> our keyword length, we now have five simple Caesar ciphers<br />

to break and soon the message is decrypted. 8<br />

To further emphasize the power <strong>of</strong> Friedman’s Index, we provide the values<br />

<strong>of</strong> Φ that are produced assuming various keylengths.<br />

Keylength Φ 1 Φ 2 Φ 3 Φ 4 Φ 5 Φ 6 Φ 7 Average<br />

One .045 .045<br />

Two .046 .042 .044<br />

Three .047 .043 .045 .045<br />

Four .048 .044 .052 .036 .045<br />

Five .077 .059 .062 .058 .059 .063<br />

Six .048 .045 .046 .041 .038 .043 .043<br />

Seven .044 .052 .044 .043 .048 .048 .040 .046<br />

The values in the Keylength Five row are clearly the largest. In particular, the<br />

average <strong>of</strong> .063 stands out. Five must indeed be the keylength. Especially when<br />

coupled with a computer program, Friedman’s Test provides for the almost<br />

routine determination <strong>of</strong> keylength.<br />

⋄<br />

As a method for computing the keylength for a ciphertext <strong>of</strong> only a couple<br />

hundred letters the Friedman Test is too highly influenced by quirks <strong>of</strong> the individual<br />

ciphertext and keyword. However, as the ciphertext grows, the Friedman<br />

Test hones in on the keylength with amazing accuracy.<br />

8.4 Multiple Encipherings<br />

Kasiski’s and Friedman’s tests are a very powerful one-two combination to use on<br />

polyalphbetic ciphers, especially when used on a computer, enabling the almost<br />

automatic detection <strong>of</strong> a polyalphabetic cipher’s keylength. Is there anything<br />

about the polyalphabetic ciphers that might be saved<br />

Ever since Section 7.6 we have been working under the (<strong>of</strong>ten implicit) assumption<br />

that determining the keylength <strong>of</strong> a polyalphabetic ciphertext was<br />

hard, but once we know the keylength breaking the cipher was easy. This is<br />

because the polyalphabetic ciphers are really just several Caesar ciphers twisted<br />

together – once we could pull the strands apart we were back to Chapter 1<br />

material.<br />

Since it appears relatively easy to pull the strands apart, is there a way to<br />

make the strands shorter That is, to make the number <strong>of</strong> letters per Caesar<br />

alphabet so small that decryption <strong>of</strong> the individual Kasiski depths is difficult<br />

For example, if our message has 1000 letters in it, but we could use a 100 letter<br />

keyword, there would be only 10 letters per alphabet! Even Linquist’s method<br />

8 Keyword is CODES. “Cryptography and cryptanalysis are sometimes called twin or reciprocal<br />

sciences, and in function they indeed mirror one another. What one does the other<br />

undoes. Their natures, however, differ fundamentally. Cryptography is theoretical and abstract.<br />

Cryptanalysis is empirical and concrete.” David Kahn


146 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

fails with such few letters. 9<br />

How can we make such long keywords One way would be to use phrases,<br />

or paragraphs from agreed upon books. This works well, but becomes harder<br />

to remember. Apparently, when people write to the National Security Agency<br />

(NSA), the cryptographic arm <strong>of</strong> the US Government, saying “I’ve discovered<br />

a great new and unbreakable code for you to use”, this is most frequently the<br />

method they describe. 10<br />

Another method we will call the Double Vigenère. We carefully pick two<br />

keywords and encipher the message twice, using each keyword once.<br />

Examples:<br />

(1) Encipher aaaaaaaaaaaaaa. First use the keyword IT and then re-encipher<br />

with the keyword WAS.<br />

plaintext a a a a a a a a a a a a a a a a a a a a<br />

key 1 I T I T I T I T I T I T I T I T I T I T<br />

partial ciphertext I T I T I T I T I T I T I T I T I T I T<br />

key 2 W A S W A S W A S W A S W A S W A S W A<br />

ciphertext E T A P I L E T A P I L E T A P I L E T<br />

IT and WAS act like a 6-letter keyword!<br />

(2) Encipher banana banana banana banana using LAKE and then OCEANS.<br />

How long is the combination keyword 11<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

What is the pattern How long a “keyword” does the use <strong>of</strong> two keywords<br />

produce The combination keyword will start to repeat whenever each individual<br />

keyword starts to repeat. The last letter enciphered before this repetition<br />

starts must be enciphered with the last letter <strong>of</strong> each keyword. So each keyword<br />

has repeated some number <strong>of</strong> times up to this point. The number <strong>of</strong> letters<br />

enciphered so far must then be a multiple <strong>of</strong> each keylength, and so the smallest<br />

multiple <strong>of</strong> each is when this first occurs.<br />

The smallest multiple <strong>of</strong> each has a formal name, the least common multiple<br />

or lcm. These Double Vigenère ciphers act like a single Vigenère cipher<br />

whose keyword is as long as the least common multiple <strong>of</strong> the original keywords.<br />

9 Another way to strengthen the polyalphabetic ciphers would be to avoid Caesar ciphers<br />

as the components but instead use better mixed alphabets. We will look at this in Exercise<br />

8.10.<br />

10 This method was first discovered in the 1500’s by Giacolomo Cardano. He, however,<br />

started the key over each time for each word in the message. Cardano is best remembered in<br />

mathematics for discovering – or stealing, depending on whose version <strong>of</strong> history you believe<br />

– the cubic formula (like the quadratic formula but for equations <strong>of</strong> degree three).<br />

11 They act like a 12 letter keyword. ACBEL SZGCA KWACB ELSZG CAKW.


8.4. MULTIPLE ENCIPHERINGS 147<br />

Just as the gcd is the largest number that divides both, the lcm is the<br />

smallest number that both divide. (Obviously word order matters!) Are they<br />

connected in anyway besides word order Consider the following chart:<br />

m n mn gcd(m, n) lcm(m, n)<br />

4 8 32 4 8<br />

4 6 24 2 12<br />

3 8 24 1 24<br />

8 10 80 2 40<br />

5 12 60 1 60<br />

8 9 72 1 72<br />

From the examples it appears that gcd(m, n) × lcm(m, n) = m × n, and this is<br />

correct. Since we have a method for computing gcd’s, it is perhaps better to<br />

write<br />

mn<br />

lcm(m, n) =<br />

gcd(m, n) .<br />

In particular, if m and n are relatively prime then lcm(m, n) is just the product<br />

mn.<br />

Examples: What keylength do the following keys produce<br />

(1) hamburger and FrenchFries give a 9 × 11 = 99 letter keyword<br />

(2) Francisco and <strong>California</strong> and Oakland. letter keyword.<br />

(3) SanFrancisco and <strong>California</strong> and Oakland give a 12×10×7<br />

2<br />

= 350 letter<br />

keyword.<br />

(4) SanFrancisco and <strong>California</strong> and Oakland and FrenchFries. 12<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Using multiple keywords thus produces the equivalents <strong>of</strong> very long keywords<br />

relatively easily. How helpful is this Suppose our goal is to have no more than<br />

20 letters <strong>of</strong> depth per keyword letter in a Vigenère cipher. There are about<br />

70 characters per line <strong>of</strong> typed text and about 50 lines <strong>of</strong> text per page, so<br />

about 3500 characters per page. Since 3500/20 = 180, for each page <strong>of</strong> message<br />

we would need more than 180 letters worth <strong>of</strong> keyword. So Francisco and<br />

<strong>California</strong> and Oakland would safely encipher no more than (9 × 10 × 7 =<br />

630)/180 = 3.5 pages <strong>of</strong> message.<br />

Suppose we must send 100 pages <strong>of</strong> messages a day We must have keyword<br />

<strong>of</strong> about 100×180 = 18, 000 letters (= 6 pages), or a clever selection <strong>of</strong> 4 words,<br />

with lengths 7, 9, 13, and 17. And these words must be changed everyday.<br />

Modern life is making this problem even more severe: speaking at 200 words<br />

per minute on a cell phone means to have a secure conversation one needs in<br />

12 (2) 9 × 10 × 7 = 630, (4) 12×10×7×11<br />

2 = 3850.


148 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

excess <strong>of</strong> 11 keyletters per minute <strong>of</strong> conversation. Or a modern business sending<br />

2000 pages everyday needs more than 120 new pages <strong>of</strong> keywords everyday.<br />

This is our first encounter with the key management problem. A cipher<br />

system isn’t much good if every few days we must hand-deliver a brand-new<br />

book full <strong>of</strong> never-been-used keys to everyone we wish to communicate with.<br />

Even if we could develop such “books” our business would go bankrupt from<br />

the printing and delivery costs!<br />

The German Enigma machines <strong>of</strong> World War II fame, as well as some <strong>of</strong><br />

the cipher machines used by the Americans like the M-94, were, in many ways,<br />

simply mechanical versions <strong>of</strong> multiple Vigenère ciphers. These machines used a<br />

number <strong>of</strong> linked wheels, or “rotors,” to perform the enciphering and deciphering.<br />

Each rotor can be thought <strong>of</strong> as giving a monoalphabetic cipher. When<br />

coupled several such rotors combine only to give a monoalphabetic cipher. But<br />

when one rotor rotates even one step, a new monoalphabetic cipher is created.<br />

As long as the rotors continue to rotate, in whatever pattern, and do not come<br />

back to their original position, an ever-longer keyword is produced. With the<br />

5 rotors <strong>of</strong> the latter Enigma machines, the “keyword” had functional length<br />

26 5 = 11, 881, 376, longer than the Iliad and Odyssey combined! 13 (The rotor<br />

machines have their own weaknesses. The rotors get stolen or captured. The<br />

setting <strong>of</strong> the rotors – how exactly they are positioned at the beginning <strong>of</strong> a<br />

message – must be sent. And each particular type <strong>of</strong> machine has its own peculiarities.<br />

For example, the Enigmas were unable to encipher a letter to itself.<br />

We mustn’t overstate the power <strong>of</strong> our techniques, the weaknesses <strong>of</strong> Enigma<br />

contributed a great deal to the Allies breaking it. But advanced versions <strong>of</strong> the<br />

techniques we’ve developed in this chapter played an important role.)<br />

Although the Vigenère-based Ciphers were great in their time, the development<br />

<strong>of</strong> Friedman’s and other more sophisticated tests, coupled with the modern<br />

need for vast quantities <strong>of</strong> keys, makes such ciphers relatively insecure.<br />

13 A keylength <strong>of</strong> eleven million sounds large, but numbers get big fast. For a “small”<br />

example, consider The War <strong>of</strong> the Rebellion: a compilation <strong>of</strong> the <strong>of</strong>ficial records <strong>of</strong> the<br />

Union and Confederate armies. Pub. under the direction <strong>of</strong> the ... Secretary <strong>of</strong> War, the<br />

compilation <strong>of</strong> the formal reports, correspondence, orders, and returns <strong>of</strong> the Union and<br />

Confederate Armies. In four Series, it consists <strong>of</strong> nearly 70 volumes, many in several parts,<br />

with most <strong>of</strong> the parts between 800 and 1200 pages. For example, Volume XXIV, published<br />

in 1889, comes in three parts, and covers “Operations in Mississippi and West Tennessee,<br />

including those in Arkansas and Louisiana connected with the Siege <strong>of</strong> Vicksburg. January<br />

20 - August 10, 1863.” Part III includes the Correspondences and is 1196 pages long. For<br />

an estimate, if we assume each volume has 2 parts, each <strong>of</strong> 1000 pages, and there are 3000<br />

characters per page, the volumes contain 420,000,000 characters in total. This is over 200,000<br />

characters for each day <strong>of</strong> the war! Now imagine the number <strong>of</strong> characters sent during WWII.<br />

Or during either <strong>of</strong> the Persian Gulf Wars!


8.5.<br />

VIGENÈRE’S AUTO KEY CIPHER 149<br />

8.5 Vigenère’s Auto Key Cipher<br />

In a conversation on that subject [unbreakable<br />

ciphers] which I had with the late Mr. Davies<br />

Gilbert, President <strong>of</strong> the Royal Society, [he and I]<br />

each maintained that he possessed a cipher which<br />

was absolutely inscrutable. On comparison, it<br />

appeared that we had both imagined the same<br />

law.<br />

Charles Babbage, discussing Auto-key ciphers<br />

Passages from the Life <strong>of</strong> a Philosopher<br />

So we hope to produce and use really long keywords. But producing good<br />

ones is hard, and exchanging them even harder. What can we do<br />

Cardano had among the first ideas along this line. In modern terminology<br />

his idea is to encipher each word with a progressive key starting with the first<br />

letter <strong>of</strong> the previous word. Of course, there must be some way <strong>of</strong> enciphering<br />

the first word, and Belaso suggested picking a key letter.<br />

Example: Encipher Lets attack them Friday using the keyletter J.<br />

So Lets is enciphered with JKLM (recall that a progressive key moves one<br />

letter forward each step), attack with LMNOPQ, and so on.<br />

plaintext l e t s a t t a c k t h e m f r i d a y<br />

key J K L M L M N O P Q A B C D T U V W X Y<br />

ciphertext U O E E L F G O R A T I G P Y L D Z X W<br />

So the ciphertext is UOEEL FGORA TIGPY LDZXW.<br />

⋄<br />

What is the security <strong>of</strong> this method It seems better than the Vigenère<br />

method since the keyword is not repeated. One possible problem is that since<br />

t starts so many words, many words much <strong>of</strong> the plaintext will be enciphered<br />

with key TUVWXY.... If word length is preserved in the ciphertext then we may<br />

simply decipher each word using the key TUVWXY... until we get lucky and find<br />

one for which this works. Since almost 16% <strong>of</strong> all words begin with T, we’ll<br />

likely only have to try 3 or 4 until we get lucky. And once we have one word<br />

we are done for it will tell us how to decipher the next word. So this is a good<br />

idea, but we need a way to make it less predictable.<br />

At this point Blaise de Vigenère (1523–1596) finally enters the picture.<br />

As a youth Vigenère received an excellent education, attending the Diet <strong>of</strong><br />

Worms as a very young secretary and traveling throughout Europe in diplomatic<br />

missions. In 1549 he was sent to Rome, where he apparently read Trithemius,<br />

Belaso, Cardano and Porta, among others, and studied with the experts <strong>of</strong> the<br />

papal curia. After a career in diplomacy (for the Duke <strong>of</strong> Nevers and King<br />

Charles IX) in 1570 he married a much younger wife, quit court life, gave his<br />

annuity to the poor, and devoted himself to writing. And he wrote about


150 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

everything, everything under the sun, including Traicté des Comètes, which<br />

helped to destroy the superstition that comets come from an angry God trying<br />

to warn a wicked world to stop sinning.<br />

In 1586 he wrote the 600 page Traicté des Chiffres which, beyond discussions<br />

<strong>of</strong> magic and the mysteries <strong>of</strong> the universe, was a comprehensive overview <strong>of</strong><br />

cryptography. Of immediate interest to us, he wanted an easily remembered<br />

but really long and non-repeating key. When enciphering a message, what is<br />

the nearest long possible key The message itself!<br />

Auto Key Algorithm: Pick a priming key <strong>of</strong> one or more letters.<br />

Encipher the plaintext as a Vigenère cipher in which the actual key is the<br />

priming key followed by the message.<br />

Examples:<br />

(1) Encipher My vengeance is at hand, key D.<br />

plaintext m y v e n g e n c e i s a t h a n d<br />

key D M Y V E N G E N C E I S A T H A N<br />

ciphertext P K T Z R T K T P G M A S T A H N Q<br />

The ciphertext is PKTZR TKTPG MASTA HNQ.<br />

(2) Encipher Beware the hand <strong>of</strong> fate with key = TO.<br />

plaintext b e w a r e t h e h a n d o f f a t e<br />

key T O B E W A R E T H E H A N D O F F A<br />

ciphertext U S X E N E K L X O E U D B I T F Y E<br />

The ciphertext is USXEN EKLXO EUDBI TFYE.<br />

(3) Decipher XZCYY INTCQ AQX, key = M.<br />

To decipher we must creep along, remembering that the next keyletter is<br />

the previous plaintext letter.<br />

ciphertext X Z C Y Y I N T C Q A Q X<br />

key M L<br />

plaintext l<br />

ciphertext X Z C Y Y I N T C Q A Q X<br />

key M L O<br />

plaintext l o<br />

ciphertext X Z C Y Y I N T C Q A Q X<br />

key M L O O<br />

plaintext l o o


8.5.<br />

VIGENÈRE’S AUTO KEY CIPHER 151<br />

ciphertext X Z C Y Y I N T C Q A Q X<br />

key M L O O K<br />

plaintext l o o k<br />

Eventually this produces look out a comet.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

The Auto Key Cipher defeats all the types <strong>of</strong> frequency analysis we’ve seen<br />

so far, making it the strongest cipher system yet. Its main disadvantage is one<br />

we haven’t seen before: even simple copying misteaks can cause havoc. Since it<br />

is easy to make a small error, and any mistake propagates through the rest <strong>of</strong> the<br />

cipher, even a single error can make an Auto Key enciphered text unreadable.<br />

Example: Unfortunately, DSAUB ARIVI FF contains a small error. If the key<br />

is D, can you find the error 14 .<br />

⋄<br />

How might we go about breaking an Auto Key cipher Consider the following<br />

message, where we assume we know the ciphertext, and have somehow<br />

guessed one plaintext letter and know that the priming key was a single letter.<br />

· · · · · · · · s · · · · · · · · · · ·<br />

· · · · · · · · · · · · · · · · · · · ·<br />

Y B C M G W R U V S N Q I T F N W R U V<br />

By working forwards and backwards we fill in some:<br />

· · · · · · · d s · · · · · · · · · · ·<br />

· · · · · · · · d s · · · · · · · · · ·<br />

Y B C M G W R U V S N Q I T F N W R U V<br />

and then more<br />

and before long 15<br />

· · · · · · r d s a · · · · · · · · · ·<br />

· · · · · · · r d s a · · · · · · · · ·<br />

Y B C M G W R U V S N Q I T F N W R U V<br />

b a c k w a r d s a n d f o r w a r d s<br />

x b a c k w a r d s a n d f o r w a r d<br />

Y B C M G W R U V S N Q I T F N W R U V<br />

If the priming key is longer, then we need to know as many consecutive letters <strong>of</strong><br />

plaintext as there were priming key letters, but the same forwards and backwards<br />

stepping will then decrypt the cipher.<br />

14 a simple error is the message. The R in the ciphertext should be a P<br />

15 This should look quite familiar to those who completed Exercise 7.19.


152 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

Using mathematics similar to that used in Friedman’s Index <strong>of</strong> Coincidence,<br />

given enough text any Auto Key cipher can be broken. To perhaps explain<br />

how, notice that the plaintext-key pairs (t,O), (n,I), (s, N) and (i, D) all give<br />

rise to the ciphertext letter V. But this is the only way <strong>of</strong> creating V from two<br />

high-frequency letters. So if we suspect that an Auto Key Cipher with priming<br />

keyword <strong>of</strong> length 1 was used, then we can try each <strong>of</strong> these as the possible<br />

plaintext–key pair on each V’s in the ciphertext. By probability, we very quickly<br />

will find one that gives the correct decipherment. Similarly, the pairs re and<br />

er will occur <strong>of</strong>ten in the plaintext, producing a large number <strong>of</strong> W’s in the<br />

ciphertext. Thus an Auto Key cipher with a priming key <strong>of</strong> length 1 is not<br />

secure.<br />

Likewise, every the in a Auto Key cipher <strong>of</strong> keylength two will give many<br />

e’s enciphered by t’s into Y’s. In general, the etaoinshr letters so frequently<br />

encipher one another they give each other away, leading to a decryption <strong>of</strong> the<br />

cipher.<br />

To summarize, we broke the Vigenère Cipher by exploiting the pattern <strong>of</strong><br />

its repeating keyword. The Auto Key Cipher can be broken by exploiting the<br />

usual frequency patterns <strong>of</strong> English. Removing all such patterns must be our<br />

next goal.<br />

8.6 Perfect Secrecy<br />

All the ciphers we’ve studied so far depend, eventually, on some sort <strong>of</strong> pattern,<br />

and this pattern eventually gives them away. What is needed is a cipher system<br />

whose keyword is both endless and and senseless. The need for endless should<br />

be clear after our work with Vigenère ciphers. Once a keyword starts to be<br />

repeated, the cipher is in danger <strong>of</strong> being broken. Hence, for perfect secrecy we<br />

can never allow the it to be repeated, i.e., it must be endless. The reason for<br />

senseless is nearly the same: an extremely long keyword that is not senseless<br />

has some pattern to it. And a pattern is not much different from a repeating<br />

keyword. As Kahn puts it, the perfect cipher must “avoid the Scylla <strong>of</strong> repetition<br />

and the Charybdis <strong>of</strong> intelligibility.”<br />

Joseph O. Mauborgne (1881–1971) had the idea <strong>of</strong> “endless”. Mauborgne<br />

had a long and very distinguished career in cryptography. In 1914 he gave the<br />

first recorded solution <strong>of</strong> a Playfair cipher. (We will study these in Chapter 9.)<br />

He eventually rose to the post <strong>of</strong> Chief Signal Officer in October 1937 and as a<br />

Major General built the cryptanalytic abilities <strong>of</strong> the Signal Corps to the extent<br />

that it was reading a flood <strong>of</strong> Japanese ciphers by his retirement in 1941.<br />

Gilbert S. Vernam (1890-1960) had the idea <strong>of</strong> “senseless”. Vernam was an<br />

employee <strong>of</strong> AT&T when in 1917 he proposed the use <strong>of</strong> “stream cipher devices”<br />

for automatic encryption and decryption <strong>of</strong> telegram messages. Vernam received<br />

65 patents in the areas <strong>of</strong> cryptography and telephone switching systems and<br />

was well known for his cleverness – supposedly he asked himself “What can I


8.6. PERFECT SECRECY 153<br />

invent now” each night while relaxing on his s<strong>of</strong>a. 16<br />

Put endless and senseless together and we have the<br />

One-time Pad: 17 Pick any random keyword <strong>of</strong> length equal to the length <strong>of</strong><br />

your message. Treat it as the key word <strong>of</strong> a Vigenère cipher. Throw it away<br />

after you use it (hence the name).<br />

A properly used one-time pad is the only unbreakable cipher, or, in fancier<br />

language, is holocryptic. Why is it unbreakable Consider the ciphertext UVAET.<br />

What is the plaintext Using this ciphertext and the ciphertext only it is impossible<br />

to tell. This is because for every 5 letter block <strong>of</strong> letters you can pick,<br />

there is a (possibly non-nonsensical) 5 letter Vigenère keyword that will turn<br />

your plaintext into UVAET. And unless you have some other knowledge, all are<br />

equally possible. So it is impossible to tell what UVAET means.<br />

This idea holds on a much larger scale. If you pick a keyword that is as<br />

long as your message, make the keyword to be a random collection <strong>of</strong> letters,<br />

and use the keyword exactly twice, once to encipher and once to decipher, then<br />

there is no way that anyone can break the message. This was a favorite method<br />

<strong>of</strong> Russian spies in the 1950’s. 18 It is also popular in movies, mainly because<br />

the one-time pads were usually written on very small pieces <strong>of</strong> paper that we<br />

hidden in false shoe bottoms, or inside fake cigarettes, fake nickels, etc.<br />

As Friedman put it in his Encyclopedia Britannica article on cryptology<br />

[Britt, pg 1059]<br />

a letter-for-letter cipher system which employs, once and only once, a<br />

keying sequence composed <strong>of</strong> characters or elements in a random and<br />

entirely unpredictable sequence may be considered holocryptic, that is,<br />

messages in such a systems cannot be read by indirect processes involving<br />

cryptanalysis, but only by direct processes involving possession <strong>of</strong> the<br />

key or keys, obtained either legitimately, by virtue <strong>of</strong> being among the<br />

intended communicators, or by stealth.<br />

Examples: Encipher and decipher using a one-time pad.<br />

(1) Encipher holocryptic using the key SLMPQOSUCFC.<br />

(2) Decipher HROJA OPMNZ using the key NEXFA LPLCV. 19<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

How much use do you think this system that allows perfect secrecy gets<br />

The answer is almost none. Consider the problems you would have if you were<br />

16 Among the things he did invent was a “Secret Signaling System” that was awarded U.S.<br />

Patent 1,310,719. This was, more or less, a teletypewriter that performed Vigenére encryption.<br />

17 Ciphers very similar to one-time pads were also discovered in Germany and Russia about<br />

this same time [Bauer, page 144].<br />

18 Unfortunately for them, the Russians made 9 copies <strong>of</strong> some <strong>of</strong> their one-time pads. Even<br />

this small lapse was enough for the NSA to break these messages. (This information was only<br />

recently declassified, and can be found in the “Verona Breaks” pages at the NSA website.)<br />

19 (1) ZZXDS FQJVN E, (2) unreadable.


154 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

the Chief Decipherer in Spy Central. For every page <strong>of</strong> text that one <strong>of</strong> your<br />

spies wishes to send you he or she (and you) must have a page <strong>of</strong> keyword. If<br />

you are collecting 1000 pages <strong>of</strong> data from your spies everyday you must make<br />

and distribute that many different pages <strong>of</strong> keywords everyday. You obviously<br />

can’t send the keyword via radio or email because they must be private. And<br />

you can’t first encipher them before sending them because the only way to safely<br />

encipher them is with a one-time pad! The only way is to somehow physically<br />

carry the key to the spy.<br />

This is a real key management problem, and it is difficult enough to<br />

overcome that one-time pads are used vary rarely. For instance, the “hot line”<br />

between Moscow and Washington used a form <strong>of</strong> one-time pads. Unfortunately,<br />

the lure <strong>of</strong> perfect encryption is so great that some still argue that the one-time<br />

pad is the future. But as Bruce Schneier recently wrote 20<br />

[It] is the only provably secure cryptosystem we know <strong>of</strong>. It’s also pretty<br />

much useless. Because the key has to be as long as the message, it doesn’t<br />

solve the security problem. One way to look at encryption is that it takes<br />

very long secrets – the message – and turns them into very short secrets:<br />

the key. With a one-time pad, you haven’t shrunk the secret any. It’s just<br />

as hard to courier the pad to the recipient as it is to courier the message<br />

itself. Modern cryptography encrypts large things – Internet connections,<br />

digital audio and video, telephone conversations, etc. – and dealing with<br />

one-time pads for those applications is just impracticable. ...<br />

One-time pads may be theoretically secure, but they are not secure in a<br />

practical sense. They replace a cryptographic problem that we know a lot<br />

about solving – how to design secure algorithms – with an implementation<br />

problem we have very little hope <strong>of</strong> solving. They’re not the future. And<br />

you should look at anyone who says otherwise with deep and pr<strong>of</strong>ound<br />

suspicion.<br />

So one-time pads do provide perfect secrecy, but they do so in a way that is<br />

nearly perfectly useless.<br />

8.7 Summary<br />

The Index <strong>of</strong> Coincidence measures the likelihood that two letters, chosen at<br />

random from some text, are the same. It is very closely related to the “roughness”<br />

<strong>of</strong> the frequency count <strong>of</strong> the text. Using this relation, Friedman was able<br />

to predict the length <strong>of</strong> a polyalphabetic cipher’s keyword from ciphertexts Index<br />

<strong>of</strong> Coincidence value. While not necessarily precise for short ciphers, when<br />

combined with Kasiski’s test, the Index <strong>of</strong> Coincidence provides an accurate and<br />

rapid method for determining the keylength used to produce that ciphertext.<br />

Hence polyalphabetic ciphers are not secure.<br />

By repeatedly enciphering a text with a variety <strong>of</strong> keywords one can produce<br />

the equivalent <strong>of</strong> a Vigenère cipher <strong>of</strong> keylength equal to the least common<br />

20 Crypto-gram, October 15, 2002


8.8. TERMS AND TOPICS 155<br />

multiple <strong>of</strong> the lengths <strong>of</strong> the individual keys. While this method may keep<br />

short texts secure, the amount <strong>of</strong> keyword needed is directly related to the<br />

amount <strong>of</strong> text one wishes to send (approximately 1 page <strong>of</strong> keyword must be<br />

used to safely encipher 20 pages <strong>of</strong> plaintext). Producing and exchanging the<br />

huge <strong>of</strong> amount keys needed by a modern business or government prevents any<br />

practical use <strong>of</strong> a repeated Vigenère system.<br />

Vigenère did not invent the Vigenère Cipher, but, rather that Auto Key<br />

Cipher. This cipher uses a priming key following by the plaintext as its key,<br />

thus producing a key without repetitions. Its security is much better than that<br />

<strong>of</strong> the Vigenère. Nonetheless, the patterns in English provide enough <strong>of</strong> an entry<br />

that Friedman was eventually able to break this system.<br />

The only unbreakable cipher system is the One-Time Pad. A random series<br />

<strong>of</strong> letters (or numbers) is used as the key. As long as each key is used exactly<br />

twice, once for enciphering and once for deciphering, and is kept secret, the<br />

system cannot be broken. But the key is as long as the message, so the problem<br />

<strong>of</strong> transmitting the message is simply replaced by that <strong>of</strong> transmitting the key.<br />

So the immense quantity <strong>of</strong> keys that must be distributed to use this system<br />

prevent it from being used except in very special circumstances.<br />

8.8 Terms and Topics<br />

1. What is a “coincidence” What is the connection between coincidences<br />

and Kasiski’s test<br />

2. What is the Index <strong>of</strong> Coincidence What does it measure<br />

3. What is the formula for Φ<br />

4. How do the frequency counts <strong>of</strong> a monoalphabetic cipher and a polyalphabetic<br />

cipher with long keylength differ<br />

5. What does M.R. stand for What does it measure<br />

6. Under what circumstances do we expect M.R. to be a larger number A<br />

smaller number<br />

7. What is the Friedman test<br />

8. How can we use Φ to estimate the keylength <strong>of</strong> a polyalphabetic cipher<br />

9. What is the Double Vigenère How does it differ from the Vigenère cipher<br />

10. Performing multiple encipherments with different keywords is equivalent<br />

to enciphering once with a keyword <strong>of</strong> what length<br />

11. Who invented the Auto Key cipher<br />

12. What is the Auto Key cipher Explain how to use it.


156 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

13. What is the key for an Auto Key cipher<br />

14. Give a strength and a weakness <strong>of</strong> the Auto Key Cipher.<br />

15. What is “Perfect Secrecy”<br />

16. How does the One-Time Pad work<br />

17. Give a strength and a weakness <strong>of</strong> the One-Time Pad system.<br />

8.9 Exercises<br />

For Problems 1 through 6, do a frequency count and use it to compute Φ. Use<br />

this value to estimate the keylength. Try to find a couple <strong>of</strong> repetitions in<br />

the ciphertext that seem to validate your keylength guess. Then decipher the<br />

message.<br />

1. COMUB XWYKU OXTIY UBXNQ AFLXC SMIYR BLXUI UFJKF ZXSLX EUKFN ASYXU<br />

BTUNA FSUFH HUFTC IKJIN TNHXL BUYTO XKFUW FNABN MIYRC YXJGI PMLJV<br />

EFNHE CLDSI IYKBH WJHLP GXDUL FMMIU MUBXZ VXFQB UBHVN LVMIJ NBPH<br />

2. ZYIBX YKXHT ZTENU KVBPX IKIDB YKLAM ZYIDX MIIEH LJICN XZXYU KXVET<br />

ZVRON MYXOW KCEYL UCYTB UEFYM NVINX SPJOK YLGHT RVRGM NFJTB SVXHT<br />

ZNLEG ZYISH RLXIH TZWFB TRPLR XVECA KUXHX OEJOK SRXIH TKLUL USXAB<br />

TVHHT YCSSM GCPIM YMELN K<br />

3. (a) QZIQU DTKUT IWCUG LJZIU MSVHO KIGNZ IDCEW KIMPG VWRHP WVWIS<br />

POIOE QSDIW NWVWI STSYS VWQAG HUDMN YLLHH MQEYJ SIFWX WYJWX<br />

HVIUY SGKEW CLMLS EYSWV GSPOU KTRMK MEFW<br />

(b) What is the meaning <strong>of</strong> the quote<br />

4. IKUQN VOCSJ MPYKA BIJFG NXGGS YOYRV RSLCK ZEKIC EEMQY JFCMF RCNTU<br />

NHVDK EEFCN MUQIF ZCDWA PADAK EEFYR PQVCY MLGVA DLVFR EIEZE KICEE<br />

ECVVD YLZEM LRFCD GQMPC QYNUM KEKTM DFRAR PBROX DYPYK GNUQB TFSMV<br />

VDLTY QAOID CSGAL DVZAE SQRWV QLDZR DEIQL TRDKY TTGEW EDOIM LUEXG<br />

MZFCD KUKE<br />

5. This one is a bit harder:<br />

MOVBA NZLIB GFLTR DWJBW YEJZU BKIXP ZVKHG SWVWA XLPDF RVZBB JUSSE<br />

FWOMU WVLTL OXRVY LOXJF NKLJB VNULL VWTZP LPEGW UNPKY OHLVT CSZBV<br />

EADSR WRIFM NSKHW VPUVR KVYAY EVLML TTWKV PGHWY LZFMW ABTVS LOKHJ<br />

HWKFL KHGBZ OKHWM TBCTD HRPET ZLBYF WFZMB GIVPM F


8.9. EXERCISES 157<br />

6. As is this one:<br />

KHVBH FXPSP NMJET MGXWF RLIEN OGMOO TRHRV ADUJH KSOGN WXKSU IFYYT<br />

XVVRR HTSTF HYNZF KZVCS FJGAC UIPIG GBAML FCZGN LEWVC HWXVV UHNWX<br />

KLCHV OUJCU HRVLV UWWER HXWGQ ENWPA GFRRH KLGVN WXJSH HBXFR VISNW<br />

ODFGF BOCEH KJVMO RPUWG LILPF PRLID TTCZR MVHCH RJWYI PUNPY DIPHV<br />

WQYME VBWYF VCBBC BVVQT GQYDX QCXYU IX<br />

7. Encipher or decipher the following texts using a Vigenére cipher with two<br />

keywords.<br />

(a) Encipher Peter Piper picked a peck using the keywords JACK and<br />

SPRATT.<br />

(b) Decipher FDUAP XNQHJ LCWOI UIOHF BEUDN C using the keywords<br />

LIZARD and CRAWL.<br />

(c) Encipher I need to laugh, and when the sun is out using the<br />

keywords Sun and shine.<br />

(d) Decipher RJQMU FJRQV HIRBS OIMEO ELUIJ PAAZ using keywords Good<br />

and day.<br />

8. Matteo Argenti used the keyword Key PIETRO and a slightly mixed alphabet<br />

to make a Vigenère cipher:<br />

cipher<br />

plain1<br />

plain2<br />

plain3<br />

plain4<br />

plain5<br />

plain6<br />

HI LMNOPRSTABCDE FGU<br />

p r s t u a b c d e f g h i l m n o<br />

i l m n o p r s t u a b c d e f g h<br />

e f g h i l mnop r s t u a b c d<br />

t u a b c d e f gh i l mn o p r s<br />

r s t u a b c d e f g h i l m n o p<br />

o p r s t u a b c d e f g h i l mn<br />

To encipher, find the first letter <strong>of</strong> plaintext in the first plaintext alphabet,<br />

and replace it by the ciphertext letter above it. The second plaintext<br />

alphabet is used for the second letter, the third for the third, etc. For<br />

example peter becomes HECPH.<br />

Decipher LHUAP AHEAN SLMNG TSUUM BPAOT PEBNC NEALP HGSAE MAGEC<br />

ANUD.<br />

9. If we are using a double Vigenère, does it matter in which order we use<br />

the keywords Explain.<br />

10. The “Double Vigenère” we discussed in the chapter used two keywords to<br />

encipher a message twice. A different and better way to do this is to use<br />

the first key to mix the cipheralphabet and the second key as a Vigenère<br />

keyword using the newly mixed cipheralphabet (much like PIETRO was<br />

used in exercise 8.8).


158 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

To do this, use the first keyword to mix the alphabet. Then under the<br />

usual alphabet copy the cipheralphabet a number <strong>of</strong> times so that the<br />

first letters <strong>of</strong> the rows spells the second keyword. Then use the alphabets<br />

cyclically.<br />

(a) Use a Keyword Mixed cipher with keyword ONCE to mix the cipheralphabet,<br />

and then a Vigenére cipher with keyword TWICE to encipher<br />

three times a lady.<br />

(b) Use a Keyword Transposed cipher with keyword AGAIN to mix the<br />

cipheralphabet, and then a Vigenére cipher with keyword REPEAT to<br />

encipher Over and out.<br />

(c) The ciphertext UIKQEYM BU TN JRBA was enciphered with a Vigenére<br />

cipher with keyword SIMPLE, using a cipheralphabet mixed via a Keyword<br />

Mixed cipher with keyword TWIST. What was the plaintext<br />

(d) The plaintext microwave oven was enciphered with a Vigenére cipher<br />

with keyword QUICK, using a cipheralphabet mixed via a simple<br />

Keyword cipher to produce the ciphertext CCYNYMUZU YFYR. What<br />

was the Keyword Cipher’s keyword<br />

11. A Vigenère Cipher with two keywords has the mathematical formulation<br />

C = P + K 1 + K 2 , where K 1 and K 2 are the first and second keywords.<br />

What if we instead used C = P ∗ K 1 + K 2 , perhaps calling this the<br />

Linear Vigenère Cipher The Linear Cipher (from Chapter 4), while not<br />

very secure, is certainly harder to break than the Caesar Cipher. Is the<br />

Linear Vigenère Cipher more secure than the Vigenère with two keywords<br />

Explain.<br />

12. Encipher or decipher the following definitions using an Auto Key cipher<br />

with the given priming key.<br />

(a) Encipher Autobiography is a story with priming key T.<br />

(b) Encipher autoclave is an oven with priming key F.<br />

(c) Decipher OUNHQ TRCAG ASGUJ ZVEZQ RG with priming key O.<br />

(d) Decipher CUNHU OZFWA SHLPT KQDIX V with priming key C.<br />

(e) Encipher autograph is a signature with priming key RI.<br />

(f) Decipher CLTIF CNWMM TWIUA T with priming key CR.<br />

(g) Decipher PYTIF OFIVO GGVSY AMBNL VGGOV LWEWA with priming key<br />

PE.<br />

(h) Decipher FLXOH HALWE GVVMC HRSIA FI with priming key FRE.<br />

(i) Decipher SNTSS OZUWM ZOSFB ABBBZ LDGVQ XF with priming key STAE.<br />

(j) Decipher ZSTIF BUFIE IEXWA PTYO with priming key ZY.


8.9. EXERCISES 159<br />

13. It has been remarked that one can detect an Auto Key Cipher (or a<br />

Vigenère Cipher with long keyword) from the large number <strong>of</strong> VAISX’s<br />

and the lack <strong>of</strong> DQNJ’s in the ciphertext. Explain this remark.<br />

14. Break the following Auto-Key Ciphers. A hint has been given.<br />

(a) KFGWW SRVVV HYDWZ PXLSR VFMFY Hint: priming key was length 1<br />

and message rhymes with “true”<br />

(b) RZDVQ BUXLR HGKXS SGSTS SHUDE SWMIY QFTZM VXSSG STSSA UWE Hint:<br />

priming key had length 2, and message contains several the’s<br />

(c) ORMMI MWIAD HTBAW I. The priming key had length 1, and ee appears<br />

somewhere in the plaintext.<br />

(d) SNGHC UDRYI MCFLS UEZAN AGUP. The priming key had length 2 and<br />

one <strong>of</strong> the letters is N.<br />

15. There are many ways <strong>of</strong> combining the several types <strong>of</strong> ciphers we have<br />

seen into new, and possibly more difficult ciphers. Here is one way. Pick a<br />

Vigenère keyword. For each letter in this keyword pick another keyword.<br />

Use these secondary keywords to form mixed alphabets using the Keyword<br />

Mixed method. Then to encipher the message use the Vigenère technique,<br />

but use the mixed alphabet corresponding to the primary keyword letter.<br />

For example, we pick Suit as our primary key, and Club, Diamond, Heart<br />

and Spade as secondary keys. Then when enciphering the 1st, 5th, 9th,<br />

etc. letters <strong>of</strong> the message we use as cipheralphabet the one formed from<br />

Club and Vigenère key S. For the 2nd, 6th, 10th, etc. letters we use as<br />

alphabet the one formed from Diamond and Vigenère key U. Similarly for<br />

the rest <strong>of</strong> the message.<br />

(a) Does this system have an increase <strong>of</strong> security over a regular Vigenère<br />

system with keyword Suit If so, where is the increase For example,<br />

is it because the Kasiski test fails Or for other reasons If the<br />

security has not increased, why not<br />

(b) What if we make five secondary keys, perhaps Wild as the fifth, and<br />

cyclically use both the Vigenère key and the five cipheralphabets<br />

16. Suppose you capture a Vigenère-enciphered text, and somehow you know<br />

that it was enciphered using a mixed cipher alphabet. Will or will not a<br />

Kasiski test still work Explain.<br />

17. How does the use <strong>of</strong> a keyword with repeated letters effect the accuracy <strong>of</strong><br />

Φ (Hint: What sort <strong>of</strong> encipherment and roughness would the keyword<br />

TTTATTT give)


160 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

18. (a) Finish the computation <strong>of</strong> Φ for a text consisting <strong>of</strong> English with the<br />

normal distribution started in section 8.3. (Use Figure 1.3. So there<br />

are 8.2 A’s, 1.5 B’s, and N = 100.)<br />

(b) Compute the value <strong>of</strong> Φ, if the plaintext consisted <strong>of</strong> English with the<br />

normal distribution that was enciphered with a Caesar cipher with<br />

key B.<br />

(c) Compute the value <strong>of</strong> Φ, if the plaintext consisted <strong>of</strong> English with<br />

the normal distribution that was enciphered with a monoalphabetic<br />

cipher.<br />

(d) Compute Φ for the ciphertext that has all 26 letters occurring an<br />

equal number <strong>of</strong> times.<br />

19. In this exercise we work out the formula for Φ given in Equation 8.3.<br />

Assume we have a ciphertext <strong>of</strong> N letters enciphered with a Vigenère<br />

cipher with keylength k. As we did in Section 7.7, lets assume we’ve<br />

written the ciphertext in an array, so there are k rows, each containing all<br />

the ciphtertext letters that were enciphered with the same keyletter.<br />

Now Φ is the probability that two letters, chosen at random from the text,<br />

are the same. Either these letters were chosen from the same row, or from<br />

different rows.<br />

Same row: There are N total letters and k rows, so about N/k letters per<br />

row. Hence there are N k ( N k<br />

− 1)/2 ways to choose two from any particular<br />

row. There are k rows and so k N k ( N k<br />

− 1)/2 ways to choose two letters a<br />

row. Finally, the likelihood that two letters are the same in any <strong>of</strong> these<br />

rows is 0.0656. So the contribution here is<br />

.0656 ∗ k<br />

N<br />

k ( N k − 1) N(N − k)<br />

= .0656<br />

2<br />

2k<br />

Different rows: There are k(k − 1)/2 ways to pick to two rows. There are<br />

N/k letters in each row, so there are N/k ∗ N/k ways to pick one letter<br />

from each. Finally, we have no way <strong>of</strong> relating the keyletters from the<br />

different rows, so we can only approximate the likelihood that these two<br />

letters are the same with 1/26. So the contribution here is<br />

1<br />

26 ∗ N N k(k − 1)<br />

∗ = 1 N 2 (k − 1)<br />

k k 2 26 k<br />

Adding the two probabilities, and simplifying,


8.9. EXERCISES 161<br />

This is Equation 8.3.<br />

N(N − k)<br />

Φ ≈ .0656 + 1 N 2 (k − 1)<br />

2k 26 k<br />

= .0656(N − k) + N(k − 1) 1 26<br />

k(N − 1)<br />

.0656(N − k) + .0385N(k − 1)<br />

=<br />

k(N − 1)<br />

(a) If our work has been correct, substituting k = 1 into 8.3 should<br />

produce the value <strong>of</strong> Φ in a monoalphabetic cipher, 0.0656. Does it<br />

(b) If k = N, then the keylength is the same as the length <strong>of</strong> the text.<br />

This should produce a very flat frequency count, resulting in a value<br />

<strong>of</strong> .0385 for Φ. Does it<br />

(c) It is sometimes <strong>of</strong> value to have a formula for k, the keylength. Multiply<br />

both sides <strong>of</strong> 8.3 by k(N − 1) and then solve for k to find one.<br />

20. (a) In section 8.3 we saw that Φ = .0656 when the language is English.<br />

Referring to Figure 1.5, compute Φ for French, German and Spanish.<br />

(b) Jeremiah 25:26 and 51:41 (taken from BibleGateway.org) are<br />

25:26: and all the kings <strong>of</strong> the north, near and far, one after the<br />

other-all the kingdoms on the face <strong>of</strong> the earth. And after all <strong>of</strong><br />

them, the king <strong>of</strong> Sheshach will drink it too.<br />

51:41: How Sheshach will be captured, the boast <strong>of</strong> the whole<br />

earth seized! What a horror Babylon will be among the nations!<br />

(Sheshach is Babel (= Babylon) written with a reversed alphabet,<br />

in Hebrew, <strong>of</strong> course.) Translating the combined verses into German<br />

and French, and then enciphering with a monoalphabetic cipher produces<br />

Text 1: FINPC DYCVN TCSPC YGIYU IVTNU GVNKL YCNPY DNTBU YCFPJ PUCYI<br />

FPJFP IVYCY IFINP CDYCV NQFPM YCSPM NUSYO PTCNU ICPVD FRFKY SYDFI<br />

YVVYY IDYVN TSYCK LYCKL FKANT VFFGV YCYPJ YLOPN TCKLY CKLFK YCIGV<br />

TCYKY DDYSN UIDFB DNTVY VYMGD TCCFT IINPI YDFIY VVYYC IKNUO PTCYY<br />

LOPNT AFAQD NUYYC ISYIV PTIYF PMTDT YPSYC UFITN UC<br />

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 total<br />

3 2 27 14 0 19 5 0 21 3 10 7 4 20 4 20 2 1 8 17 11 17 0 0 42 0 257<br />

and<br />

Text 2: PUSGD DYRMU TCYSY AUMVS YUAST YUGKY UPUSS TYEYV UYUYT UYUUG<br />

JKSYL GUSYV UPUSG DDYRM UTCVY TJKYS YVYVS YSTYG PESYV EDGJK YSYAY<br />

VSBMS YUAAT USPUS SYVRM UTCWM UAJKY AJKGJ KAMDD UGJKT KUYUH VTURY<br />

UNTYT AHAJK YAJKG JKYTU CYUML LYUPU SSYVV PKLSY VCGUX YUYVS YYVMB<br />

YVHNT YTAHB GBYDX PLYUH AYHXY UCYNM VSYUP UHYVS YUUGH TMUYU<br />

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 total<br />

13 4 6 8 3 0 13 8 0 10 13 5 11 3 0 9 0 4 25 17 40 18 1 3 51 0 265


162 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

Which text is in German, and which is in French (Compute Φ <strong>of</strong><br />

each and, remembering that monoalphabetic encipherments do not<br />

change the Φ value <strong>of</strong> the text, use part (a).)<br />

21. Here is a variant on the auto-key method. Rather than use the message<br />

as the key, which perhaps seems rather dangerous, instead use the secret<br />

message<br />

Encipher mysterious with priming key m and use your answer to help you<br />

discuss the security <strong>of</strong> this method.<br />

22. Joseph Willard Brown wrote<br />

“Ciphers are undiscoverable in proportion as their changes are frequent,<br />

and as the messages in each change are brief. When alphabetic<br />

ciphers are used, the aim should be never to allow any letter to appear<br />

twice alike. The number <strong>of</strong> letters under each key is to be as<br />

small as possible [Brown page 99].”<br />

Explain the meaning <strong>of</strong> this quote.<br />

23. On March 8, 1913, the Secretary <strong>of</strong> <strong>St</strong>ate, William Jennings Bryan, sent<br />

the following message to all American Diplomatic and Consular Officers.<br />

“Gentleman:<br />

For the purpose <strong>of</strong> affording a means <strong>of</strong> direct secret communication<br />

between <strong>of</strong>ficers <strong>of</strong> the Army and Navy and the Diplomatic and<br />

Consular Service, the respective Departments are providing the necessary<br />

<strong>of</strong>ficers with the Larrabee Cipher Code, a copy <strong>of</strong> which is<br />

transmitted herewith.<br />

The following arrangements as to key words will be observed:<br />

(1) Key words may be arranged between <strong>of</strong>ficers using code either<br />

directly or through their Departments in Washington, when more<br />

direct secret communication is not possible.<br />

(2) In the absence <strong>of</strong> other agreement, the key word is to be the name<br />

<strong>of</strong> the month in which the message is sent.<br />

The Navy Department is supplying the Larrabee Cipher to the commanding<br />

<strong>of</strong>ficers <strong>of</strong> all ships in the service.”<br />

Enclosed with this letter was a chart, Figure 8.2, and instructions:<br />

“Write down the words, message, or cipher to be converted, and write<br />

over them, letter for letter, the key word agreed upon, repeating<br />

the key word as <strong>of</strong>ten as necessary. For each letter to be converted<br />

enter the table with the letter <strong>of</strong> the key word found above it, as a<br />

marginal letter. If converting message into cipher [read] in the upper<br />

line abreast the marginal letter, the letter <strong>of</strong> the message, the letter<br />

<strong>of</strong> the cipher is [then] directly below it. If converting cipher into<br />

message [read] the lower line abreast the marginal letter [, then] the<br />

letter <strong>of</strong> the cipher the letter <strong>of</strong> the message is directly above it.


8.9. EXERCISES 163<br />

A: AB CDE FGH I J K LMNOPQRSTUVWXYZ N: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

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 n o p q r s t u vw x y z a b c d e f g h i j k l m<br />

B: AB CDE FGH I J K LMNOPQRSTUVWXYZ O: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

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 a o p q r s t u vwx y z a b c d e f g h i j k l m n<br />

C: AB CDE FGH I J K LMNOPQRSTUVWXYZ P: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

c d e f g h i j k l m n o p q r s t u vw x y z a b p q r s t u v wx y z a b c d e f g h i j k l m n o<br />

D: AB CDE FGH I J K LMNOPQRSTUVWXYZ Q: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

d e f g h i j k l m n o p q r s t u vwx y z a b c q r s t u v w x y z a b c d e f g h i j k l m n o p<br />

E: AB CDE FGH I J K LMNOPQRSTUVWXYZ R: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

e f g h i j k l m n o p q r s t u vwx y z a b c d r s t u vw x y z a b c d e f g h i j k l m n o p q<br />

F: AB CDE FGH I J K LMNOPQRSTUVWXYZ S: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

f g h i j k l m n o p q r s t u v wx y z a b c d e s t u v wx y z a b c d e f g h i j k l m n o p q r<br />

G:AB CDE FGH I J K LMNOPQRSTUVWXYZ T: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

g h i j k l m n o p q r s t u v w x y z a b c d e f t u v w x y z a b c d e f g h i j k l m n o p q r s<br />

H: AB CDE FGH I J K LMNOPQRSTUVWXYZ U: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

h i j k l m n o p q r s t u v w x y z a b c d e f g u vw x y z a b c d e f g h i j k l m n o p q r s t<br />

I: AB CDE FGH I J K LMNOPQRSTUVWXYZ V: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

i j k l m n o p q r s t u v w x y z a b c d e f g h vwx y z a b c d e f g h i j k l m n o p q r s t u<br />

J: AB CDE FGH I J K LMNOPQRSTUVWXYZ W:ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

j k l m n o p q r s t u v w x y z a b c d e f g h i wx y z a b c d e f g h i j k l m n o p q r s t u v<br />

K:AB CDE FGH I J K LMNOPQRSTUVWXYZ X: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

k l m n o p q r s t u v w x y z a b c d e f g h i j x y z a b c d e f g h i j k l m n o p q r s t u v w<br />

L: AB CDE FGH I J K LMNOPQRSTUVWXYZ Y: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

l m n o p q r s t u v w x y z a b c d e f g h i j k y z a b c d e f g h i j k l m n o p q r s t u v w x<br />

M:AB CDE FGH I J K LMNOPQRSTUVWXYZ Z: ABCDEFGH I JKLMNOPQR S TUVWXY Z<br />

m n o p q r s t u v w x y z a b c d e f g h i j k l z 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<br />

Figure 8.2: Larrabee’s Cipher Code<br />

To apply to figures<br />

let A B C D E F G H I J<br />

represent 1 2 3 4 5 6 7 8 9 0<br />

To indicate that figures are used, write the letter Q followed by the<br />

number <strong>of</strong> figures expressed in letters as above that follow: then for<br />

the figures write the letters, thus QEICDJF means 93406, Q indicating<br />

that figures follow, E 5 the number <strong>of</strong> figures, and ICDJF<br />

representing 03496.<br />

Example<br />

Key word Pekin<br />

Key words PEKI NPEKI NPE<br />

Message SEND QCCJJ MEN<br />

Cipher HIXL DRGTR ZTR<br />

Ordinarily however it is safer to send numbers in words, i.e. three<br />

hundred instead <strong>of</strong> 300.<br />

Before transmission the cipher is arranged in five letter groups. Thus,<br />

the above example would appear HIXLD RGTRZ TR etc.<br />

There were plans for a new codebook for the Departments <strong>of</strong> <strong>St</strong>ate, War<br />

and Navy, and the Larrabee Code was to be only in temporary use.


164 CHAPTER 8. POLYALPHABETIC CIPHERS<br />

(a) On November 8, 1913 The Adjutant General’s Office in the War<br />

Department, Washington sent the following to the Chief <strong>of</strong> <strong>St</strong>aff,<br />

U.S. Army.<br />

HBYID EEKRA VVOIU RROGI FUIIJ ONADJ XKRBO SKPYU VFZGF JRZBV<br />

ZYKFS WYOMV MCIVP CYIUO IOPVV RSFSW PWKLQ SQVFG VKQTF VGKZI<br />

ZHSMR FIQQO XRYRZ TMSXD RBOWM DOEBK GIPHI KYWN.<br />

AAPH.<br />

What did it say<br />

(b) The HQ <strong>of</strong> Coast Defenses <strong>of</strong> Chesapeake Bay, Fort Monroe VA,<br />

struggled with this new cipher, as they reported in a letter <strong>of</strong> Nov 9,<br />

1913. To attempt a decipherment <strong>of</strong> a Larrabee message they first<br />

crossed “out the inadmissible code letters”, and then used (probably)<br />

the Red code book to treat the remaining letters as code groups.<br />

This gave “Appropriations for the 4th quarter British Minister J. F.<br />

Reynolds Landis Henry J. Nichols Facts do not justify having party<br />

arrested” as the message. Trying a slightly different technique gave<br />

“Congress did not appropriate merited unknown unknown permanent<br />

arrangement.”<br />

They eventually realized their mistake:<br />

“It was evident that the meaning was not that which was intended.<br />

[And, after further consideration] It is thought that this<br />

message might be translated by the Larrabee Cipher Code Card<br />

which was sent to the Depot Quartermaster, Newport News, Va.,<br />

on March 10, 1913, but which has apparently been misplacedby<br />

[sic] that <strong>of</strong>ficer as he is unable to furnish it.”<br />

Then on November 12 the same HQ sent<br />

ESAID FRTRQ DTTFV CRHOI DOSCN FNENF ITBRZ GMSHI RQSMH FHYNJ<br />

ZQMEI LFSJJ AOIZA DJWEF WJVCI SRLIG BHLYM SXVLA VWFFV ERKKS<br />

DURVJ GQEDF ULRGO PMSVR OSZGU QLVLQ JHQCI WHFIM EIIU<br />

Have they figured it out What does the message say<br />

(c) How is the Larrabee cipher related to the Vignere<br />

24. (a) Two very long message have been enciphered with a Vigenère cipher<br />

using the same five letter keyword. How do the ciphertexts’ frequency<br />

charts compare (“Very long” here indicates that the plaintext’s<br />

frequencies are close to that <strong>of</strong> typical English.)<br />

(b) Continuing, how the two ciphertext’s Φ values compare<br />

(c) Two very long message have been enciphered with Vigenère ciphers<br />

using five letter keywords. If the two ciphertexts’ frequency charts<br />

are very similar, can we conclude that the keywords were the same<br />

If yes, why If no, why not, and what may we conclude<br />

25. Explain in your own words why an endless, senseless key is needed for<br />

perfect secrecy.


8.9. EXERCISES 165<br />

26. Decipher<br />

SVQYU EFNKW BHNRQ VIUZI CVSNR TVEZF WYXFA UNJYW MOADU KSVRS LUSJI<br />

JWVKC WCKYX PBVZK CDNOQ BZVGQ BMYMX QARTU G<br />

if the one-time pad key was<br />

FHEUC MFHGO JPNMM NVSRT VRBTE IRMHM PUNBC FGSYE IGIBG YDVAS KJOBV<br />

YSIEJ PGCFQ WURNG KLNIM TGDCF WXYVN MJKLB N.<br />

27. Decipher<br />

LYLWZ FDHIG AWYOE GRKTZ TJGWC OQDQK CAEOO VBXLQ ITHJL REZOI POMZT<br />

QOMQS GTABM MJRMS BVFQC CNLQD RCAJA AYZM<br />

if the one-time pad key was<br />

PRNDS BQZQN TOGUT NJYTG PHYHV KZQCR UNKBG AXGTQ XZPFK NCZUQ LAHGM<br />

MWTWD CGXNS UTXMF INMIY KZGGZ TLWTG SHVJ.


166 CHAPTER 8. POLYALPHABETIC CIPHERS


Chapter 9<br />

Digraphic Ciphers<br />

Although Hill’s cipher system itself saw almost no<br />

practical use, it had a great impact on cryptology.<br />

David Kahn<br />

What has been constant about all the cipher methods that we have tried<br />

All <strong>of</strong> the monoalphabetic ciphers had one letter replaced by a different letter<br />

as indicated in the plainalphabet–cipheralphabet chart. There were different<br />

ways to make up the cipheralphabet, but we always ended up with the pairs <strong>of</strong><br />

alphabets. The polyalphabetic ciphers differed because they didn’t use just one<br />

cipheralphabet, they used several, and sometimes very many. However, when<br />

we were enciphering any particular letter <strong>of</strong> the plaintext, there was always some<br />

plainalphabet–cipheralphabet chart that we were using.<br />

The constant pattern is this letter-for-letter replacement. A single letter has<br />

always been replaced by a single letter. The idea behind polygraphic ciphers<br />

is to replace multiple strings <strong>of</strong> letters by other multiple strings.<br />

9.1 Polygraphic Ciphers<br />

Consider first the digraphic ciphers, in which pairs <strong>of</strong> letters are replaced by<br />

other pairs. 1 Porta used these ciphers in his 1563 De furtivis literarum notis.<br />

The idea behind this is simple: replace each pair <strong>of</strong> possible plaintext letters<br />

(plain 1, plain 2) by a pair <strong>of</strong> ciphertext letters (cipher 1, cipher 2).<br />

1 Bigraphic, meaning two letters at a time, might be a more reasonable name, but, for some<br />

reason, digraphic is the word used when two letters are enciphered as a pair.<br />

167


168 CHAPTER 9. DIGRAPHIC CIPHERS<br />

Examples: The algorithm is to consider the letters two-by-two. If the letters<br />

are in alphabetical order, replace both by the letters that follow them. If they<br />

are not, replace them by the letters before them. So et→ FU and <strong>of</strong> → NE.<br />

(1) Encipher nice doggy.<br />

(2) Decipher EZSBB U. 2<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

There are a couple <strong>of</strong> problems. What do we do with double letters (Probably<br />

they are not in alphabetic order.) Or single letters at the end (Add<br />

a meaningless letter to make a pair.) But basically this is a simple digraphic<br />

cipher.<br />

What does a general digraphic cipher look like For our monoalphabetic<br />

ciphers we always ended up with a plaintext alphabet and a ciphertext alphabet.<br />

So for digraph ciphers we’ll have a (really big) chart telling which pairs <strong>of</strong> letters<br />

got replaced by which pairs <strong>of</strong> letters.<br />

To develop a very simple such system we start with a 26 × 26 array <strong>of</strong> all<br />

possible letter–letter pairs. We will use this as our ciphertext pairs. Next we<br />

use some method, say the keyword mixed method, to make two orderings <strong>of</strong><br />

the alphabet. We put these alphabets across the top and down the sides <strong>of</strong> the<br />

chart. To encipher a pair <strong>of</strong> letters, call them (α, β), find α along the top row<br />

and β down the column. The pair <strong>of</strong> letters appearing in the α-th column and<br />

β-th row is our ciphertext.<br />

Example: Using the keywords first and second gives the alphabets<br />

fagmuzibknvrcjowsdkpxtelqy and sajryebktzcfluogmvnkpwdiqx. Putting<br />

these above and along the side <strong>of</strong> the chart gives Figure 9.1.<br />

Then telephones=te-le-ph-on-es is enciphered as VFXFT TOSWA (keeping<br />

the usual 5 letter split.) LBGML OBW is deciphered as railroad. ⋄<br />

There are several drawbacks to this system. Since the chart has 676 = 26×26<br />

entries it is not something a person would like to have to repeatedly produce.<br />

Further, while deciphering is not bad, because the edges are not in order it<br />

is a bit <strong>of</strong> a pain to encipher. What would be quicker would be to rearrange<br />

the chart so that the top and side alphabets were in order. But this means<br />

rewritting the entire chart, not an attractive idea.<br />

Even if these difficulties were surmounted, this cipher is simply not a good<br />

one. For example, all plaintext pairs f* will be enciphered to A*, and all plaintext<br />

pairs *s will be enciphered to *A, with similar results for the other letters.<br />

This cipher is a monograph-digraph hybrid <strong>of</strong> some sort, and is not much more<br />

secure than a pure monographic cipher.<br />

2 (1) MHDFE NFFXY, (2) fat cat.


9.1. POLYGRAPHIC CIPHERS 169<br />

f a g m u z i b h n v r c j o w s d k p x t e l q y<br />

s AA BA CA DA EA FA GA HA IA JA KA LA MA NA OA PA QA RA SA TA UA VA WA XA YA ZA<br />

a AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB<br />

j AC BC CC DC EC FC GC HC IC JC KC LC MC NC OC PC QC RC SC TC UC VC WC XC YC ZC<br />

r AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD TD UD VD WD XD YD ZD<br />

y AE BE CE DE EE FE GE HE IE JE KE LE ME NE OE PE QE RE SE TE UE VE WE XE YE ZE<br />

e AF BF CF DF EF FF GF HF IF JF KF LF MF NF OF PF QF RF SF TF UF VF WF XF YF ZF<br />

b AG BG CG DG EG FG GG HG IG JG KG LG MG NG OG PG QG RG SG TG UG VG WG XG YG ZG<br />

k AH BH CH DH EH FH GH HH IH JH KH LH MH NH OH PH QH RH SH TH UH VH WH XH YH ZH<br />

t AI BI CI DI EI FI GI HI II JI KI LI MI NI OI PI QI RI SI TI UI VI WI XI YI ZI<br />

z AJ BJ CJ DJ EJ FJ GJ HJ IJ JJ KJ LJ MJ NJ OJ PJ QJ RJ SJ TJ UJ VJ WJ XJ YJ ZJ<br />

c AK BK CK DK EK FK GK HK IK JK KK LK MK NK OK PK QK RK SK TK UK VK WK XK YK ZK<br />

f AL BL CL DL EL FL GL HL IL JL KL LL ML NL OL PL QL RL SL TL UL VL WL XL YL ZL<br />

l AM BM CM DM EM FM GM HM IM JM KM LM MM NM OM PM QM RM SM TM UM VM WM XM YM ZM<br />

u AN BN CN DN EN FN GN HN IN JN KN LN MN NN ON PN QN RN SN TN UN VN WN XN YN ZN<br />

o AO BO CO DO EO FO GO HO IO JO KO LO MO NO OO PO QO RO SO TO UO VO WO XO YO ZO<br />

g AP BP CP DP EP FP GP HP IP JP KP LP MP NP OP PP QP RP SP TP UP VP WP XP YP ZP<br />

m AQ BQ CQ DQ EQ FQ GQ HQ IQ JQ KQ LQ MQ NQ OQ PQ QQ RQ SQ TQ UQ VQ WQ XQ YQ ZQ<br />

v AR BR CR DR ER FR GR HR IR JR KR LR MR NR OR PR QR RR SR TR UR VR WR XR YR ZR<br />

n AS BS CS DS ES FS GS HS IS JS KS LS MS NS OS PS QS RS SS TS US VS WS XS YS ZS<br />

h AT BT CT DT ET FT GT HT IT JT KT LT MT NT OT PT QT RT ST TT UT VT WT XT YT ZT<br />

p AU BU CU DU EU FU GU HU IU JU KU LU MU NU OU PU QU RU SU TU UU VU WU XU YU ZU<br />

w AV BV CV DV EV FV GV HV IV JV KV LV MV NV OV PV QV RV SV TV UV VV WV XV YV ZV<br />

d AW BW CW DW EW FW GW HW IW JW KW LW MW NW OW PW QW RW SW TW UW VW WW XW YW ZW<br />

i AX BX CX DX EX FX GX HX IX JX KX LX MX NX OX PX QX RX SX TX UX VX WX XX YX ZX<br />

q AY BY CY DY EY FY GY HY IY JY KY LY MY NY OY PY QY RY SY TY UY VY WY XY YY ZY<br />

x AZ BZ CZ DZ EZ FZ GZ HZ IZ JZ KZ LZ MZ NZ OZ PZ QZ RZ SZ TZ UZ VZ WZ XZ YZ ZZ<br />

Figure 9.1: A Simple Digraphic Substitution Chart<br />

To make a better digraph cipher we need to better scramble the ciphertext<br />

pairs. What we really need is to take the 676 main entries <strong>of</strong> the previous<br />

chart and more randomly mix them around, producing a table like Figure 9.2.<br />

Enciphering is easy: hide becomes CTOW. But now deciphering is hard: try to<br />

decipher JGPS. 3<br />

This method has some problems as well, however. First, it is a pain to construct<br />

such a chart. Second, deciphering is hideously slow. Since the ciphertext<br />

pairs are all mixed, it takes a full search to find each pair for decipering. To<br />

comfortably use this method one would be need to make an additional chart <strong>of</strong><br />

676 entries for deciphering.<br />

Nonetheless, either by hand or with the use <strong>of</strong> a computer, two such charts<br />

can certainly be created. What would the security <strong>of</strong> such a digraphic cipher<br />

be Pretty good, at least compared to our monographic ciphers. As always,<br />

this system is broken by frequency analysis, only now we are analysing the<br />

frequencies <strong>of</strong> pairs <strong>of</strong> letters, or bigrams, rather than <strong>of</strong> individual letters.<br />

Not surprising, the most common bigram is th. The top 18, according to the<br />

Brown Corpus, are listed in Figure 9.3.<br />

So when doing frequency analysis on a digraphic cipher, rather than looking<br />

3 seek


170 CHAPTER 9. DIGRAPHIC CIPHERS<br />

a<br />

b<br />

c<br />

d<br />

e<br />

f<br />

g<br />

h<br />

i<br />

j<br />

k<br />

l<br />

m<br />

n<br />

o<br />

p<br />

q<br />

r<br />

s<br />

t<br />

u<br />

v<br />

w<br />

x<br />

y<br />

z<br />

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<br />

RA XW DT JP PU VQ BN HS NO TK ZP FM LI RN XJ DG JC PH VD BA HF NB TX ZC FZ LV<br />

IB OX UT AQ GV MR SN YS EP KL QQ WM CJ IO OK UG AD GI ME SA YF EC KY QD WZ CW<br />

ZB FY LU RZ XV DS JO PT VP BM HR NN TJ ZO FL LH RM XI DF JB PG VC BZ HE NA TW<br />

QC WY CV IA OW US AP GU MQ SM YR EO KK QP WL CI IN OJ UF AC GH MD SZ YE EB KX<br />

HD NZ TV ZA FX LT RY XU DR JN PS VO BL HQ NM TI ZN FK LG RL XH DE JA PF VB BY<br />

YD EA KW QB WX CU IZ OV UR AO GT MP SL YQ EN KJ QO WK CH IM OI UE AB GG MC SY<br />

PE VA BX HC NY TU ZZ FW LS RX XT DQ JM PR VN BK HP NL TH ZM FJ LF RK XG DD JZ<br />

GF MB SX YC EZ KV QA WW CT IY OU UQ AN GS MO SK YP EM KI QN WJ CG IL OH UD AA<br />

XF DC JY PD VZ BW HB NX TT ZY FV LR RW XS DP JL PQ VM BJ HO NK TG ZL FI LE RJ<br />

OG UC AZ GE MA SW YB EY KU QZ WV CS IX OT UP AM GR MN SJ YO EL KH QM WI CF IK<br />

FH LD RI XE DB JX PC VY BV HA NW TS ZX FU LQ RV XR DO JK PP VL BI HN NJ TF ZK<br />

WH CE IJ OF UB AY GD MZ SV YA EX KT QY WU CR IW OS UO AL GQ MM SI YN EK KG QL<br />

NI TE ZJ FG LC RH XD DA JW PB VX BU HZ NV TR ZW FT LP RU XQ DN JJ PO VK BH HM<br />

EJ KF QK WG CD II OE UA AX GC MY SU YZ EW KS QX WT CQ IV OR UN AK GP ML SH YM<br />

VJ BG HL NH TD ZI FF LB RG XC DZ JV PA VW BT HY NU TQ ZV FS LO RT XP DM JI PN<br />

MK SG YL EI KE QJ WF CC IH OD UZ AW GB MX ST YY EV KR QW WS CP IU OQ UM AJ GO<br />

DL JH PM VI BF HK NG TC ZH FE LA RF XB DY JU PZ VV BS HX NT TP ZU FR LN RS XO<br />

UL AI GN MJ SF YK EH KD QI WE CB IG OC UY AV GA MW SS YX EU KQ QV WR CO IT OP<br />

LM RR XN DK JG PL VH BE HJ NF TB ZG FD LZ RE XA DX JT PY VU BR HW NS TO ZT FQ<br />

CN IS OO UK AH GM MI SE YJ EG KC QH WD CA IF OB UX AU GZ MV SR YW ET KP QU WQ<br />

TN ZS FP LL RQ XM DJ JF PK VG BD HI NE TA ZF FC LY RD XZ DW JS PX VT BQ HV NR<br />

KO QT WP CM IR ON UJ AG GL MH SD YI EF KB QG WC CZ IE OA UW AT GY MU SQ YV ES<br />

BP HU NQ TM ZR FO LK RP XL DI JE PJ VF BC HH ND TZ ZE FB LX RC XY DV JR PW VS<br />

SP YU ER KN QS WO CL IQ OM UI AF GK MG SC YH EE KA QF WB CY ID OZ UV AS GX MT<br />

JQ PV VR BO HT NP TL ZQ FN LJ RO XK DH JD PI VE BB HG NC TY ZD FA LW RB XX DU<br />

AR GW MS SO YT EQ KM QR WN CK IP OL UH AE GJ MF SB YG ED KZ QE WA CX IC OY UU<br />

Figure 9.2: A More Complicated Digraphic Substitution Chart<br />

for etaoinshr, as we would in a monographic cipher, we look for th-he-in-erre-....<br />

But the basic idea is the same: do a (very large) frequency count, guess<br />

that the top occurring pairs come from therein, and start working. So while<br />

we need more data, the techniques are very similar to the ones with which we<br />

are comfortable.<br />

How to make this system better I guess a 26 × 26 × 26 hyper-chart listing<br />

all 17576 three-letter triples. Maybe one would do this as 26 charts, where the<br />

first letter <strong>of</strong> the triple was the name <strong>of</strong> the chart, the second one was on the left<br />

<strong>of</strong> the chart and the third one was one the top The extreme cumbersomeness<br />

<strong>of</strong> a system like this would limits its use to those who have a computer to help. 4<br />

9.2 Hill Ciphers<br />

Lester S. Hill (1881-1961) was an assistant pr<strong>of</strong>essor <strong>of</strong> mathematics at Hunter<br />

<strong>College</strong> in New York when, in 1931, he published the method now named for him<br />

as “Cryptography in an Algebraic Alphabet” in The American Mathematical<br />

4 The idea <strong>of</strong> enciphering letters not individually but in groups, so-called block ciphers,<br />

reappears in almost every modern cipher system.


9.2. HILL CIPHERS 171<br />

th 2.96 es 1.34 at 1.16<br />

in 1.88 on 1.31 ed 1.14<br />

er 1.75 st 1.24 ti 1.10<br />

an 1.56 nt 1.21 nd 1.07<br />

re 1.45 en 1.20 to 1.04<br />

Figure 9.3: 18 Most Frequent Bigrams, in percent<br />

Monthly, the undergraduate journal <strong>of</strong> the American Mathematical Society. He<br />

eventually received U.S. patent 1,845,947 for an apparatus that mechanically<br />

performed his cipher. Much <strong>of</strong> Hill’s work involved the use <strong>of</strong> mathematics<br />

in communications, for example, methods for splicing telephone cables. His<br />

cipher provides us with an easy example <strong>of</strong> a polygraphic cipher, but is more<br />

important because it shows that by the middle <strong>of</strong> the first half <strong>of</strong> the 20th<br />

century cryptology was being done primarily by mathematicians.<br />

To explain the cipher we need to introduce matrices (plural <strong>of</strong> matrix).<br />

Matrices are simply rectangular arrays <strong>of</strong> numbers and are quite important<br />

in mathematics, chemistry ( ) and physics. We will deal only with two-by-two<br />

3 0<br />

matrices, such as . Matrices are very easy to add and subtract –<br />

−1 4<br />

simply perform the operation entry-by-entry. For example<br />

( ) 4 3<br />

+<br />

−2 7<br />

( ) 0 5<br />

=<br />

2 4<br />

( ) 4 8<br />

0 11<br />

and<br />

( ) 1 9<br />

−<br />

0 2<br />

( ) −2 3<br />

=<br />

5 1<br />

( ) 3 6<br />

.<br />

−5 1<br />

Multiplication is a bit more complicated as each row <strong>of</strong> the first matrix is<br />

multiplied by the column entries in the second. (Rows go across and columns<br />

go down.) For example,<br />

( ) ( ( ) ( )<br />

3 5 2 3 × 2 + 5 × 9 6 + 45<br />

× =<br />

=<br />

=<br />

14 23 9)<br />

14 × 2 + 23 × 9 28 + 209<br />

( )<br />

51<br />

,<br />

235<br />

and<br />

( ) 3 5<br />

×<br />

14 23<br />

( ) ( ) ( )<br />

15 3 × 15 + 5 × 19 45 + 95<br />

=<br />

=<br />

=<br />

19 14 × 15 + 23 × 19 210 + 437<br />

( ) a b<br />

The general form for multiplication is<br />

c d<br />

( e<br />

× =<br />

f)<br />

( ) 140<br />

.<br />

647<br />

( )<br />

a × e + b × f<br />

.<br />

c × e + d × f


172 CHAPTER 9. DIGRAPHIC CIPHERS<br />

The Hill Cipher then simply multiplies pairs <strong>of</strong> letters by a matrix.<br />

Examples:<br />

( ) 3 5<br />

(1) Encipher bios using .<br />

14 23<br />

( ( b 2<br />

First, = . Then multiplying:<br />

i)<br />

9)<br />

( ) ( 3 5 2<br />

× =<br />

14 23 9)<br />

( ) 51<br />

≡<br />

235<br />

( ) 25<br />

1<br />

(mod 26) =<br />

( Y<br />

A)<br />

.<br />

So bios is enciphered to YA.<br />

Similarly, os becomes<br />

( ) 3 5<br />

×<br />

14 23<br />

( ) 15<br />

=<br />

19<br />

( ) 140<br />

≡<br />

647<br />

( ) 10<br />

23<br />

(mod 26) =<br />

( J<br />

W)<br />

.<br />

(2) Use the same matrix to encipher math.<br />

( ) ( )<br />

13<br />

20<br />

ma= , and th= , so we have<br />

1<br />

8<br />

( ) ( )<br />

3 5 13<br />

× =<br />

14 23 1<br />

( )<br />

44<br />

≡<br />

89<br />

( ) (<br />

18 R<br />

=<br />

23 W)<br />

and<br />

( ) ( )<br />

3 5 20<br />

× =<br />

14 23 8<br />

( ) 100<br />

≡<br />

464<br />

( ) ( 22 V<br />

=<br />

22 V)<br />

So the ciphertext is RWVV.<br />

(3) Encipher hill using the same enciphering matrix.<br />

(4) Multiply by<br />

( )<br />

3 5<br />

to decipher SWBAG RERQG YV.<br />

14 23<br />

5<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

5 (3) QGJQ, (4) polygraphic.


9.2. HILL CIPHERS 173<br />

We will be using a special type <strong>of</strong> 2 × 2 matrices known as involutions.<br />

They are special in that enciphering and deciphering is done using the same<br />

matrix. 6 We need to take care in setting up these matrices.<br />

Method for using Hill Ciphers:<br />

1. Pick any number a from 0 to 25.<br />

2. Pick a number b that is relatively prime to 26. Find its multiplicative<br />

inverse β from Figure 3.2.<br />

3. Compute c = (1 − a 2 )β%26 and d = (−a)%26.<br />

4. ( The enciphering ) ( and deciphering ) matrix is<br />

a b a b<br />

=<br />

c d (1 − a 2 .<br />

) · β −a<br />

Examples: Suppose we choose a = 7 and b = 9. From Figure 3.2 b’s inverse<br />

is 3 = β. Then (1 − a 2 ) · β = (1 − 7 2 ) × 3 = −146, ( so c = ) (−146)%26 = 12.<br />

7 9<br />

Since −7 ≡ 19 (mod 26), d = 19. So the matrix is .<br />

12 19<br />

(1) To( encipher ) ( ) matrix ( ) we first convert the plaintext into numbers: matrix<br />

13 20 9<br />

=<br />

, and then compute<br />

1 18 24<br />

So matrix → VSHZSR.<br />

(2) Decipher TIDDYVKM. 7<br />

( ) ( ) ( ) ( 7 9 13 22 V<br />

× ≡ = ,<br />

12 19 1 19 S)<br />

( ) ( ) ( ) (<br />

7 9 20 8 H<br />

× ≡ = ,<br />

12 19 18 26 Z)<br />

( ) ( ( ) ( 7 9 9 19 S<br />

× ≡ =<br />

12 19 24)<br />

18 R)<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Hill ciphers may be done with matrices <strong>of</strong> any square size, like 3 × 3 or 5 × 5,<br />

and the entries in the array can be chosen with more latitude than our examples<br />

suggest. See Exercise 9.11 for consideration <strong>of</strong> the latter.<br />

6 For the use <strong>of</strong> non-involutions in Hill ciphers see Exercise 9.11.<br />

7 multiply.


174 CHAPTER 9. DIGRAPHIC CIPHERS<br />

9.3 Recognizing and Breaking Polygraphic Ciphers<br />

What makes a digraphic cipher digraphic It encipher pairs <strong>of</strong> letters, rather<br />

than single letters. For example, the word the will be broken up either as<br />

*t-he or as th-e*. In a monoalphabetic cipher each plaintext letter is always<br />

replaced by the same ciphertext letter. Don’t let the “di” in digraphic fool you –<br />

digraphic ciphers also have this one-to-one replacement. Each pair <strong>of</strong> plaintext<br />

letters is always replaced by the same pair <strong>of</strong> ciphertext letters. So there should<br />

be many copies <strong>of</strong> the ciphertext versions <strong>of</strong> th and he in our ciphertext.<br />

Further, and here is the key point, these repetitions will all occur at even<br />

distances. If there are an odd number <strong>of</strong> letters between two occurrences <strong>of</strong><br />

the, then these two occurrences will be broken differently, and so will not lead<br />

to a repetition. It is only when the is broken the same way that we will get<br />

a repetition, and this only happens when there are an even number <strong>of</strong> letters<br />

in between, that is, when the distance is even. So a cipher that is not monoalphabetic<br />

but has many many digraph repetitions occurring at even distances is<br />

almost certainly a digraphic cipher.<br />

Let’s demonstrate with an example.<br />

Example: Decrypt XCCNQ FUARE LXELM XSBUM WLKVO KTWJU EELXA NZUQJ<br />

KCWFM KSKYN QOEYR QLXFK ELRKQ FYCSK OXELZ GZHQN UPIUM NYNVQ OXBRA VQAAN<br />

IPRYJ YKOQO WXUMK JELOZ YSCII EJLXI MQAGJ FNIKO BJJMH EIURL RKQFR SLXSR<br />

KJKOW FRQLX FKELR KEZ<br />

Of course, this is a Hill cipher. But how might we determine this if we didn’t<br />

know it As always, we start with a frequency count:<br />

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 total<br />

6 3 5 0 12 8 2 2 7 9 16 13 7 8 9 2 12 11 6 1 8 3 5 11 7 5 178<br />

This is not a Caesar cipher. Nor does it really look like a monoalphabetic<br />

cipher, since the rare letters are not that rare. Is it a polyalphabetic cipher<br />

Computing, Φ = 0.04621 suggests a keylength <strong>of</strong> about 4. In particular, this is<br />

not a monoalphabetic cipher.<br />

If it is polyalphabetic, we should be able to find some repetitions. Figure<br />

9.4 contains all repetitions longer than length 2. The repetition RQLXFKELRK is<br />

too long to be ignored: if this is a polyalphabetic cipher the keylength must<br />

divide 112. But if we pick 7, 14, 28 or 56 as the keylength, we must ignore three<br />

nice repetitions (LRKQF, RLFER, and QXKLK), all <strong>of</strong> whose distance is divisible by<br />

22. This seems strange. Further, there are 57 repetitions <strong>of</strong> length 2 (which<br />

we didn’t list). This is a huge number, far more than we’ve ever seen in a<br />

polyalphabetic cipher. And almost all <strong>of</strong> them occur in lengths divisible by 2.<br />

We have ruled out any <strong>of</strong> the ciphers we have ever seen, except for digraphic


9.3. RECOGNIZING AND BREAKING POLYGRAPHIC CIPHERS 175<br />

Repetition <strong>St</strong>art Positions Distance Factors<br />

ELX 10 22 2 × 11<br />

XEL 12 60 2 × 2 × 3 × 5<br />

RQLXFKELRK 55 112 2 × 2 × 2 × 2 × 7<br />

LRKQF 62 88 2 × 2 × 2 × 11<br />

RLFER 28 56 2 × 2 × 2 × 7<br />

QXKLK 117 56 2 × 2 × 2 × 7<br />

LKF 120 44 2 × 2 × 11<br />

Figure 9.4: Repetitions in the unknown cipher.<br />

ones. And the large number <strong>of</strong> repetitions <strong>of</strong> length 2 at distances divisible by<br />

2 would lead us to digraphic ciphers anyway. So digraphic it is.<br />

Since we’ve recognized it, how do we break it To attack a digraphic cipher<br />

we start as we always did – with a frequency count – except we count pairs <strong>of</strong><br />

letters, not singletons. The only pairs appearing more than twice are EL and<br />

LX, 5 times each, and KO, QF and RK, 3 times each.<br />

Now what We will grant ourselves the knowledge that it is a Hill cipher.<br />

In many ways Hill ciphers are a fancy version <strong>of</strong> the Decimation and Linear<br />

Ciphers from Chapters 3 and 4. They do do a better job <strong>of</strong> mixing up the<br />

frequencies than those ciphers did, but, just as correctly guessing two letters <strong>of</strong><br />

a ciphertext enciphered with a Linear Cipher (and some math) leads to a decryption,<br />

correctly guessing two bigrams (and some math) leads to a decryption<br />

<strong>of</strong> a Hill cipher. (However, it is generally much harder to guess bigrams than<br />

letters.) Here, the pairs EL and LX must be very common bigrams. If we know<br />

which, we can solve for the enciphering matrix.<br />

For ease, we will make a (miraculously correct) guess, that LX=th and<br />

EL=at. This is, actually, fairly reasonable as th is the most common ( bigraph ) a b<br />

and at is the eleventh most common. So there is some matrix with<br />

c d<br />

( ( ) ( ( ( ) ( a b L t a b E a<br />

= and<br />

= . Substituting the values for<br />

c d)<br />

X h)<br />

c d)<br />

L t)<br />

( ) ( ) ( ) ( ( ) ( a b 12 20 a b 5 1<br />

the letters, and we have<br />

= and<br />

= .<br />

c d 24 8 c d)<br />

12 20)<br />

Multiplying out gives two sets <strong>of</strong> equations<br />

12a + 24b = 20 and 5c + 12d = 20<br />

12c + 24d = 8 5a + 12b = 1.<br />

These( two sets ) <strong>of</strong> two equations in two unknowns may now be solved to see<br />

9 5<br />

that<br />

is the original enciphering matrix. From here, the quote may<br />

10 17


176 CHAPTER 9. DIGRAPHIC CIPHERS<br />

be deciphered. 8<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

9.4 Playfair<br />

Sir Charles Wheatstone, like several other cipher inventors we have met, was<br />

interested in many things. His name is attached to a method for measuring electrical<br />

resistance, the “Wheatstone bridge” but he also constructed an electric<br />

telegraph, invented the concertina, and wrote about acoustics. His accomplishments<br />

led him to be elected as a fellow <strong>of</strong> the Royal Society and knighted. As the<br />

Exposition Universelle in 1867 he displayed his “Wheatstone cipher machine,”<br />

a disc cipher device <strong>of</strong> some complexity that is very simple to use.<br />

But it is the Playfair Cipher we are currently interested in. Wheatstone<br />

invented it in 1854 and showed it to his friend, Lyon Playfair, Baron <strong>of</strong> <strong>St</strong>.<br />

Andrews, and in one <strong>of</strong> the more humorous episodes in cryptologic history they<br />

brought it to the attention <strong>of</strong> British Government <strong>of</strong>ficials. As David Kahn tells<br />

the story [Kahn, page 201]<br />

Wheatstone and Playfair explained the cipher to the Under Secretary <strong>of</strong><br />

the Foreign Affairs. ... When the Under Secretary protested that the<br />

system was too complicated, Wheatstone volunteered to show that three<br />

out <strong>of</strong> four boys from the nearest elementary school could be taught it in<br />

15 minutes. The Under Secretary put him <strong>of</strong>f. “That is very possible”,<br />

he said, “but you could never teach it to attachè’s”.<br />

Playfair, reasoning that this reflected more on the diplomats than on the<br />

cipher, remained enthusiastic about it.<br />

The cipher was indeed used, perhaps first in the Crimean and Boer Wars. It<br />

is easy to use, and was popular as field cipher because it does not need tables<br />

or other equipment. The British attempted to keep it secret, but by the First<br />

World War the Germans could routinely solve Playfair ciphers.<br />

Wheatstone’s clever idea was to notice that in an rectangular arrangement<br />

<strong>of</strong> the alphabet there are many smaller rectangles, with four letters forming the<br />

corners. Exchanging two <strong>of</strong> the corners for the other two is a way to perform<br />

the (plain 1, plain 2) → (cipher 1, cipher 2) substitution at heart <strong>of</strong> a<br />

digraphic cipher.<br />

8 This is the opening quote from Chapter 3.


9.4. PLAYFAIR 177<br />

Playfair Ciphers: Pick a keyword. Using the Keyword Mixed method<br />

Section 5.2 to mix the alphabet, arrange the the alphabet in a 5 × 5 array,<br />

considering i and j to be the same letter.<br />

To encipher, the plaintext is replaced two letters at time using the following<br />

rules.<br />

1. If the letters are in the same column, replace each by the letter below<br />

it.<br />

2. If the letters are in the same row, replace each by the letter to its<br />

right.<br />

3. If the letters are in neither the same row or column, then use them to<br />

form a rectangle. The individual letters are replaced by the opposing<br />

corners <strong>of</strong> the same height, i.e., the opposing corner in the same row.<br />

(Notice that we must pretend that leaving the bottom <strong>of</strong> the array to be<br />

entering its top, and leaving the right-hand-side to be entering its left-handside.)<br />

Deciphering is simply the opposite: replace by the letters above, to the left,<br />

and by the opposing corners.<br />

For example, if we use the alphabet in its usual order (with J omitted) the<br />

array is<br />

A B C D E<br />

F G H I K<br />

L M N O P<br />

Q R S T U<br />

V W X Y Z<br />

Then examples <strong>of</strong> each <strong>of</strong> the three enciphering steps are as follows:<br />

1. bm→GR, uz→ZE<br />

2. lo→MP, gk→HF<br />

3. ls→NQ, er→BU<br />

Similarly, here are examples <strong>of</strong> the three deciphering steps.<br />

1. LA→fv, JO→dj<br />

2. QU→ut, CE→bd<br />

3. TW→ry, LI→ <strong>of</strong><br />

If there are repeated letters in a pair, insert a null, <strong>of</strong>ten x, to break them up.<br />

So balloon becomes ba lx lo on. Notice that oo is naturally broken, so no x<br />

is needed. If the message contains an odd number <strong>of</strong> letters either send the last<br />

letter un-enciphered, or add a final null letter before enciphering.


178 CHAPTER 9. DIGRAPHIC CIPHERS<br />

Examples:<br />

(1) Using keyword square, encipher rectangle<br />

The arrangement <strong>of</strong> the alphabet is<br />

S Q U A R<br />

E B C D F<br />

G H I K L<br />

M N O P T<br />

V W X Y Z<br />

Then we follow the directions. re forms corners <strong>of</strong> a rectangle with SF.<br />

Since S is on r’s row, and F is on e’s, re becomes SF. ct forms a rectangle<br />

with FO, and an with QP. gl are on the same row, so moving each one to<br />

the right g becomes H and (circling around) l becomes G. Finally, perhaps<br />

adding an x as a null, ex becomes CV. So the final ciphertext is SFFOQ<br />

PHGCV.<br />

(2) Use the same keyword to decipher RKNKQ DFM.<br />

Each <strong>of</strong> the pairs RK, NK,QD, and FM are two <strong>of</strong> the four corners <strong>of</strong> a rectangle.<br />

Replace each letter by the corner <strong>of</strong> the rectangle with the same<br />

height.<br />

(3) Encipher foreign affairs using the keyword playfair.<br />

(4) Use the same keyword to decipher QMIGH PSZQF BKKN. 9<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Of course, naming this cipher for Playfair is already unfair to Wheatstone.<br />

But further, Wheatstone recommended using the cipher with rectangular matrices,<br />

rather than only square ones, and mixing the alphabet as in the Keyword<br />

Mixed ciphers rather as in the simpler Keyword ciphers. Unfortunately, these<br />

improvements tended to be forgotten.<br />

The Playfair cipher is quick to set-up and easy to use. It is harder to break<br />

than a monoalphabetic cipher, but only somewhat so. To see why, notice that<br />

the only possible substitutes for e are the letters in its row and the one letter<br />

directly beneath it. (In the keyword SQUARE example earlier, these are the<br />

letters BCDFG.) So the letters in e’s row will be used a lot. This gives some hope<br />

<strong>of</strong> setting up an entire and row in an unknown Playfair cipher. Additionally,<br />

bigrams such as re and er will always be encoded by a reversal, for example as<br />

SF and FS. From here, with some guided guesswork and some training, anyone<br />

can be taught to break Playfair ciphers accurately and fairly quickly.<br />

9 (2) alphabet, (3 ) LTIGR EQPYZ PY, (4) three attaches.


9.5. SUMMARY 179<br />

9.5 Summary<br />

Polygraphic ciphers, or block ciphers, work by enciphering groups <strong>of</strong> letters at<br />

a time, rather than one letter at a time. In particular, digraphic ciphers treat<br />

pairs <strong>of</strong> letters, or bigrams, as units when enciphering and deciphering. Since<br />

there are 676 pairs <strong>of</strong> letters, enciphering and deciphering tables for digraphic<br />

ciphers are large and cumbersome, and hence never used (outside <strong>of</strong> introductory<br />

examples).<br />

Digraphic ciphers are the “monoalphabetic” ciphers for bigrams. That is,<br />

each plaintext bigram is replaced by the same ciphertext bigram throughout<br />

the entire message. Hence frequency analysis may be used to attack a digraphic<br />

cipher. But whereas e and t, the two most common single letters, make up<br />

nearly 20% <strong>of</strong> all letters, the two most common bigrams, th and in, make up less<br />

than 5% <strong>of</strong> bigrams. So using frequency analysis only to break digraphic ciphers<br />

is difficult unless one has a very large amount <strong>of</strong> ciphertext. In particular, a<br />

good digraphic system is much more secure than a good monoalphabetic system.<br />

The Hill Cipher System enciphers by treating the block <strong>of</strong> letters as a matrix<br />

with only one column and multiplying the column by another matrix. Using a<br />

2 × 2 involution, a matrix with 2 columns and 2 rows that is its own multiplicative<br />

inverse, is most common, but non-involutions may be used, as may 3 × 3,<br />

4 × 4 or larger matrices. Hill Ciphers can be thought <strong>of</strong> as a digraphic version<br />

<strong>of</strong> Decimation Ciphers. In particular, once one knows the plaintext equivalents<br />

<strong>of</strong> two ciphertext bigrams, then one can use some simple mathematics to determine<br />

the enciphering matrix, and hence break the message. The importance<br />

<strong>of</strong> the Hill Cipher is that it indicates that by the middle <strong>of</strong> the 20th century<br />

cryptography was almost entirely a mathematical subject.<br />

Playfair Ciphers were invented by Charles Wheatstone and are the most<br />

common digraphic ciphers, being used in both World Wars. After setting up a<br />

rectangular array <strong>of</strong> letters, enciphering proceeds by replacing pairs <strong>of</strong> letters<br />

with the pair to the right if they are in the same column, underneath if they are<br />

in the same row, or the opposite corners <strong>of</strong> the rectangle produced otherwise.<br />

The strengths <strong>of</strong> Playfair are its ease <strong>of</strong> use, its rapidity, and its use <strong>of</strong> a keyword.<br />

Conversely, each letter can be replaced by only 6 others, and this allows entries<br />

into the system.<br />

9.6 Topics and Techniques<br />

1. What is a digraphic cipher How does it differ from a mono-graphic<br />

cipher<br />

2. What does the use <strong>of</strong> “di” in digraphic refer to<br />

3. Is a digraphic cipher monoalphabetic or polyalphabetic Explain.<br />

4. What is the general appearance <strong>of</strong> a digraphic cipher That is, explain


180 CHAPTER 9. DIGRAPHIC CIPHERS<br />

how a chart for a digraphic cipher is built and used.<br />

5. Explain how to use two monoalphabetic ciphers to build a digraphic cipher.<br />

6. What is a matrix<br />

7. How are two matrices <strong>of</strong> the same size added<br />

8. What is the Hill Cipher system based on<br />

9. How does the Hill Cipher encipher How does it decipher<br />

10. Does the frequency count <strong>of</strong> a digraphic cipher have any special appearance<br />

11. What sort <strong>of</strong> frequency count is useful when trying to break a digraphic<br />

cipher<br />

12. What should the value <strong>of</strong> Φ suggest for a digraphic cipher<br />

13. What sorts <strong>of</strong> repetitions will Kasiski’s test find in a digraphic cipher<br />

Why<br />

14. Who was Playfair Who invented the Playfair cipher<br />

15. Explain the three enciphering rules for the Playfair Cipher.<br />

9.7 Exercises<br />

1. Here is a proposed digraphic cipher. To encipher a pair <strong>of</strong> letters p 1 p 2<br />

keep whichever letter is later in the alphabet and replace the other by the<br />

letter equal to the distance between p 1 and p 2 . For example, fe becomes<br />

FA, since f is later and f and e are 1 letter apart. Similarly, mr becomes<br />

ER since r is 5 letters later than m.<br />

(a) Encipher pair.<br />

(b) Encipher twosomes.<br />

(c) Decipher CRAERING.<br />

(d) Decipher KLPHABOT.<br />

(e) There is a problem with this cipher. Can you determine what it is<br />

Hint: decipher WRLZ.<br />

2. (a) Here is a candidate digraphic cipher: To encipher a pair <strong>of</strong> letters,<br />

swap them if they are alphabetical ordering, if not, leave them fixed.<br />

So pair becomes PARI. Critique this proposed cipher. (Encipher<br />

some words and try to decipher your results.)


9.7. EXERCISES 181<br />

(b) The use <strong>of</strong> “alphabetical” in part (a) didn’t work. Instead, when<br />

the letters are in alphabetical order, add 4 to each. When they are<br />

not, subtract 3. Leave doubles alone. Will this work (Again try to<br />

encipher and decipher some words.)<br />

3. A slightly fancier digraphic cipher is as follows. If the letters are both<br />

vowels, replace each by the vowels before them in the alphabet (ea become<br />

AU.) If the pair is two consonants, replace each by the next consonant in<br />

the alphabet (ns becomes PT). And if the pair is is one each, swap them<br />

(ho becomes OH).<br />

(a) Encipher vowels.<br />

(b) Encipher breakers.<br />

(c) Decipher ROEAP VLA.<br />

(d) Decipher EBUOVZ.<br />

(e) We’ve learned to recognized monoalphabetic ciphers by their odd<br />

appearance – too few good etaoinshr letters, too many bad jkvwxyz<br />

letters. What sort <strong>of</strong> appearance will this cipher produce<br />

4. To make a combination Caesar-AutoKey Digraphic cipher, encipher each<br />

pair <strong>of</strong> letters by using a Caesar cipher with key k on the first letter, and<br />

an Auto Key Cipher on the second letter, using the first letter as the key.<br />

Symbolically, for each pair p 1 p 2 <strong>of</strong> plaintext letters, the ciphertext pair is<br />

(p 1 + k)%26, (p 1 + p 2 )%26. So if k = 3, then to becomes WH, as W is three<br />

letters past t, and o enciphered with key T is H.<br />

(a) Encipher combinations with key 7.<br />

(b) Decipher JCLWH R, if the key was 12.<br />

(c) Encipher primer if the key is 21.<br />

(d) Decipher KZKVE MZAKV, if the key was 6.<br />

5. In a table-based digraph cipher, like Figure 9.2, it is best if each letter<br />

appears in each row exactly once, and similarly in each column exactly<br />

once. If we had a three letter language “ABC” or four letter language<br />

“ABCD” then examples <strong>of</strong> such tables are<br />

AB BC CA<br />

CC AA BB<br />

BA CB AC<br />

and<br />

DC AD BB CA<br />

CD BC AA DB<br />

AB CA CC BD<br />

BA CB DD AC<br />

These arrangements are called Greek-Latin Squares, and exists for every<br />

size <strong>of</strong> square, except 2 × 2 and 6 × 6.<br />

(The 6×6 case is <strong>of</strong>ten referred to as the 36 Officers Problem: Suppose we<br />

have 36 military <strong>of</strong>ficers <strong>of</strong> 6 ranks from 6 different states, no two <strong>of</strong> whom


182 CHAPTER 9. DIGRAPHIC CIPHERS<br />

have the same rank and are from the same state. Can they be arranged<br />

in rows <strong>of</strong> 6 so that each state and each rank is represented exactly once<br />

in each row and each column In 1779 Leonard Euler showed no.)<br />

(a) Explain, maybe by using examples, why AA, AB, BA, BB cannot be<br />

put into a 2 × 2 Greek-Latin Square.<br />

(b) Find, through experimentation, a 5 × 5 Greek-Latin Square.<br />

(c) Sometimes the “Greek” part <strong>of</strong> the name is reserved for those squares<br />

whose front and back diagonals also have the “Latin” property. Find<br />

a 3 × 3 square <strong>of</strong> this type.<br />

6. Given A =<br />

b =<br />

( 3 11<br />

19 4<br />

)<br />

, B =<br />

( 9<br />

2)<br />

, compute the following.<br />

(a) A + B.<br />

(b) B − C.<br />

(c) C + A.<br />

(d) Aa.<br />

(e) Ab.<br />

(f) Ba%26.<br />

(g) Bb%26.<br />

( −2 1<br />

10 21<br />

)<br />

, C =<br />

7. Given a and b, find the corresponding Hill Matrix.<br />

(a) a = 8, b = 9.<br />

(b) a = 2, b = 17.<br />

(c) a = 11, b = 5.<br />

(d) a = 21, b = 19.<br />

( ) 4 9<br />

, and a =<br />

−7 5<br />

8. Use the given matrix to encipher and decipher the following.<br />

( ) 4 21<br />

(a) , mountain and ARKTC D.<br />

3 22<br />

( )<br />

10 15<br />

(b) , valley and BXOWI N.<br />

9 16<br />

( ) 17 5<br />

(c) , desert and JULGU Y.<br />

10 9<br />

9. Complete the Hill Matrix, and then use it to encipher and decipher.<br />

(a) a = 7, b = 11, apogee and EATJU N.<br />

(b) a = 18, b = 3, escarpment and DPWWZ EOLID.<br />

(c) a = 23, b = 25, impediment and AOFTV CGD.<br />

( ) 8<br />

,<br />

12


9.7. EXERCISES 183<br />

10. Just as we combined addition and multiplication to form Linear Ciphers,<br />

we can form Linear Hill Ciphers by first multiplying by a matrix, and then<br />

adding another matrix to the result. That is, the pairs m <strong>of</strong> the message<br />

are enciphered to Am + B, where A and B are the multiplier and addend<br />

matrices, respectively.<br />

(a) Use A =<br />

( 13 5<br />

8 13<br />

)<br />

and B =<br />

( ) 8 10<br />

to encipher linear.<br />

12 14<br />

(b) Use the same matrices to decipher CSKKI SEB. (Remember to subtract<br />

before multiplying by the inverse.)<br />

11. The matrices we used for Hill Ciphers were involutions – they are their own<br />

inverses. Limiting ourselves to just( these)<br />

matrices is rather restrictive. 10<br />

a b<br />

In general, the inverse <strong>of</strong> a matrix exists only when gcd(26, ad −<br />

c d<br />

( ) ed −eb<br />

bc) = 1. If this it so, then the inverse matrix is<br />

, where e<br />

−ec ea<br />

is the inverse <strong>of</strong> ad − bc modulo 26 found from the Euclidean Algorithm.<br />

(The value ad − bc is called the determinant, since it determines whether<br />

or not the matrix has an inverse.)<br />

(a) Which <strong>of</strong> the following matrices have inverses modulo 26<br />

( ) ( ) ( )<br />

8 4 5 10 11 6<br />

(i) . (ii) . (iii) .<br />

13 9 16 23 7 4<br />

( ) 2 5<br />

(b) Find the inverse <strong>of</strong> .<br />

3 9<br />

(c) Encipher determinants with<br />

( ) 2 5<br />

.<br />

3 9<br />

(d) Decipher JWOSY QGKVO. It was enciphered with<br />

( ) 2 5<br />

.<br />

3 9<br />

12. Modern cipher systems all encipher blocks <strong>of</strong> text at a time. (The block<br />

size in this chapter has generally been two, meaning two letters at a time.)<br />

Here we look at a cipher with block size two.<br />

To do this, first, rather than converting the message blocks to 2-12-15-<br />

3-11-19 before multiplying, we convert it to 0212-1503-1119. Notice the<br />

zeros. With them aa=0101=101 is distinct from l=11; without it is not.<br />

Then performing a Decimation Cipher with a block size <strong>of</strong> two differs from<br />

our previous Decimation Cipher only in that the modulus must be chosen<br />

to be larger than 2525. That is, choose a number N larger than 2525,<br />

and an enciphering key e. Use the Euclidean Algorithm to check that<br />

gcd(e, N) = 1 and to find the deciphering key d. Encipher by multiplying<br />

10 Recall that for Decimation ciphers there are 12 proper key pairs modulo 26, but only 2 in<br />

which the enciphering and deciphering key are the same (i.e., involutions). In the Hill ciphers<br />

there are 157, 248 proper pairs <strong>of</strong> 2 × 2 matrices, but only 312 <strong>of</strong> these are involutions.


184 CHAPTER 9. DIGRAPHIC CIPHERS<br />

pairs <strong>of</strong> letters by e modulo N, and decipher by multiplying by d. (The<br />

resulting ciphertexts will be numbers, rather than letters.)<br />

(a) If the modulus N is chosen to be 2999, show that e = 100 is a proper<br />

enciphering key. Find the corresponding deciphering key d.<br />

(b) Use e = 100 and N = 2999 to encipher blocks.<br />

(c) Use the deciphering key found in part (a) to decipher 2543-1513-<br />

1460.<br />

(d) If N = 3001 and e = 29, find d.<br />

(e) Use e = 29 and N = 3001 to encipher number.<br />

(f) Use the deciphering key found in part (d) to decipher 218-2644-17-<br />

2037.<br />

13. (Continuing the ideas <strong>of</strong> Exercise 12.) A problem with the cipher from<br />

Exercise 12 is that the ciphertext is numbers not letters. If we want<br />

a bigram-decimation cipher, perhaps we should use 676 = 26 2 as the<br />

modulus, rather than 26. Here is one way to try to do this:<br />

Choose a key k with 1 ≤ k < 676, relatively prime to 26. For each pair <strong>of</strong><br />

plaintext letters p 1 p 2 , first convert the letters into their numerical equivalent,<br />

then compute the cipher-number c = ( k ∗ (p 1 ∗ 26 + p 2 ) ) %676. The<br />

ciphertext is then C 1 C 2 , where C 1 and C 2 are the quotient and remainder<br />

when c is divided by 26.<br />

For example, let k = 19. Then to = 20 15 has ciphernumber c = ( 19 ∗<br />

(20 ∗ 26 + 15) ) %676 = (19 ∗ 535)%676 = 25. Since 25 ÷ 26 = 0 = Z and<br />

25%26 = 25 = Y, to is enciphered to ZY.<br />

To decipher, first find the inverse <strong>of</strong> 19 modulo 676, which is 427. Then<br />

multiply ZY = 25 = 00225 by 427%676 to receive 535. Finally 535 ÷ 26 =<br />

20 = t and 535%26 = 15 = o.<br />

(a) Use k = 101 to encipher stat.<br />

(b) Use k = 219 to encipher data.<br />

(c) Find the inverse <strong>of</strong> k = 87 modulo 676, and use it to decipher BONO.<br />

(d) Carefully examine the ciphertexts from this Exercise. What appears<br />

to be happening What does this say about the value <strong>of</strong> this cipher<br />

In particular, how “digraphic” is this digraphic ciphers<br />

14. It was hinted in the text that Hill Ciphers are simply a fancy Decimation<br />

Cipher. In this Exercise we see why this is so.<br />

(a) Find the form the enciphering matrix takes if we choose a = 0.<br />

(b) Encipher the “message” p 1 p 2 p 3 p 4 p 5 p 6 using the matrix you found in<br />

part (a).<br />

(c) Is the cipher performed in part (b) a Decimation Cipher If not, how<br />

close is it


9.7. EXERCISES 185<br />

(d) (For those( who have ) done Exercise 11.) The general Hill matrix has<br />

a b<br />

the form . What choices do we need to make for a, b, c and<br />

c d<br />

d so that performing Hill encipherment with this matrix is the same<br />

as a Decimation Cipher with key k<br />

15. You’ve somehow capture a ciphertext sent via Hill Cipher. The signature<br />

is CVVOFY and you’ve reason to think that this is Lester. Use this<br />

information to compute the matrix used.<br />

16. Encipher or decipher the following texts using a Playfair cipher based on<br />

the normal ordering <strong>of</strong> the alphabet. Add an x if double letters need to<br />

be divided.<br />

(a) Blue Balloons<br />

(b) Pat the Bunny<br />

(c) IMYNC OKHIS NPYNSC.<br />

(d) CBSMV DTBYC CLDA.<br />

17. Encipher or decipher the following texts using a Playfair cipher based on<br />

the given keyword.<br />

(a) Keyword Northeast. Message Nine battalions will attack from<br />

the north at noon.<br />

(b) Keyword South. Message Enemy unit crossing river.<br />

(c) Keyword Western. Message ATCWS WEDDF TWSRW SCEFC HV.<br />

(d) Keyword Eastmarch. Message CPULD OHVFR QEQPH PSKPO.<br />

18. One Army Signal School used as an example <strong>of</strong> Playfair the following<br />

message enciphered with the keyword CLIQUE [SSA1].<br />

CP LE AH RZ PF IG TP NZ GA FG DG ZM PS<br />

PN TE CA MT PH CG DA FG OB OA IW CA BY<br />

What was the message<br />

19. Use a Playfair cipher with keyword Poems to decipher the following three<br />

phrases:<br />

(a) QKMSE WPQ.<br />

(b) OZCEMRHSXP.<br />

(c) XHRPGVAMEMUTZY.<br />

20. [Kahn, pg 198] The first known demonstration <strong>of</strong> the Playfair Cipher was<br />

at a dinner party in January 1854 when Baron Playfair explained “Wheatstone’s<br />

newly-discovered symmetrical cipher” to Prince Albert, Queen Victoria’s<br />

husband, and Lord Palmerston, Home Secretary and future Prime<br />

Minister, among others. The earliest remaining written description appears<br />

on page 199 <strong>of</strong> Kahn, and is transcribed as follows.


186 CHAPTER 9. DIGRAPHIC CIPHERS<br />

26 March,<br />

1854<br />

Specimen <strong>of</strong> a Rectangular Cipher<br />

m b p y a<br />

d q z g f<br />

r n h s e<br />

u t k v i<br />

l w c o x<br />

A despatch in the above cipher preserving the separation<br />

<strong>of</strong> the words.<br />

We have received the<br />

xn epis erxhgfrf knr<br />

following telegraphic despatch<br />

gxaabytet inxrdscxekp frhybipk<br />

A dispatch in the same cipher with no external<br />

indication <strong>of</strong> the separation <strong>of</strong> the words.<br />

We have received the<br />

xnznyinferxhgfrfvgeh<br />

following telegraphic despatch<br />

itmyymxtsqgvrxsfemhpkxutsexckwh<br />

The same cipher arranged in a different rectangle.<br />

m b p y a d q z g<br />

f r n h s e j u t<br />

k v i l w c o x −<br />

We have received the following telegraphic despatch<br />

cs sycr ugswbpas feh jkddapqjk fhchbtiwnly hynasgle<br />

Key to the permutated alphabet employed<br />

in the preceding ciphers<br />

mbpyadqzgfrnhsejutkvilwcox<br />

m a g n e t i c<br />

b d f h j k l o<br />

p q r s u v w x<br />

y z<br />

[signed] C. Wheatstone


9.7. EXERCISES 187<br />

The rules that Wheatstone used to encipher his messages are a bit different<br />

than the ones we use. Can you figure them out Hint: consider Playfair’s<br />

name for this cipher.<br />

21. Another way to use Playfair is construct a 6 × 6 square that consists <strong>of</strong><br />

the 26 letters followed by the 10 numbers 0, 1, ..., 9. Then encipher and<br />

decipher as usual. (Below we use z as the double-breaking letter, rather<br />

than x. I’ve also used o for the letter “O”, to prevent confusion with the<br />

number 0.)<br />

(a) Encipher 1800 Pennsylvannia Avenue.<br />

(b) Encipher The Lodge, the residence <strong>of</strong> the Australian Prime Minister.<br />

(c) Decipher INWBG RBSoM TUo0.<br />

(d) Decipher FHBCM LPVWA.<br />

(e) Decipher 76CPT QHo HTXNB 2BW.<br />

(f) Decipher Y8Y0T YWAVF oLWD.<br />

22. During World War II there was a widespread network <strong>of</strong> Australian coastwatchers<br />

spread about on the numerous island in the South Pacific. [Kahn,<br />

pages 591–3.]<br />

They observed enemy activity from the peaks and cliffs <strong>of</strong> enemy-held<br />

islands, collected bits <strong>of</strong> information from native allies, and radioed<br />

their information to Allied military commands. They frequently gave<br />

valuable early warning <strong>of</strong> Japanese bombing raids and ship movements,<br />

and they assisted in the rescue <strong>of</strong> downed Allied airmen.<br />

In the early morning hours <strong>of</strong> August 2, 1943, coast-watcher Lieutenant<br />

Arthur Reginald Evans <strong>of</strong> the Royal Australian Naval Volunteer<br />

Reserve saw a pinpoint <strong>of</strong> flame on the dark waters <strong>of</strong> Blackett<br />

<strong>St</strong>rait from his jungle ridge on Kolombangara Island, one <strong>of</strong> the<br />

Solomons. He did not know then that the Japanese destroyer Amagiri<br />

had rammed and sliced in half an American patrol torpedo boat,<br />

PT 109, lieutenant John F. Kennedy, United <strong>St</strong>ates Naval Reserve,<br />

commanding. But at 9:30 that morning he received<br />

the following message:<br />

(a) KXJEY UREBE ZWEHE WRYTU HEYFS KREHE GOYFI WTTTU OLKSY CAJPO<br />

BOTEI ZONTX BYBWT GONEY CUZWR GDSON SXBOU YWRHE BAAHY USEDQ<br />

The keyword is Royal new zealand navy. What does it say<br />

(b) Evan reported back that Object still floating between Meresu and<br />

Gizo, and was told later that there was a possibility that survivors<br />

landing either Vangavanga or islands. In fact, Kennedy had led his<br />

men to Plum Pudding Island. This was behind enemy lines, and only<br />

3 or 4 miles from Gizo Island where there was a Japanese garrison.


188 CHAPTER 9. DIGRAPHIC CIPHERS<br />

On Saturday morning, August 7th, Even received news from a native<br />

that the crew had been found and moved to Gross Island. He sent<br />

the following message:<br />

XELWA OHWUW YZMWI HOMNE OBTFW MSSPI AJLUO EAONG OOFCM FEXTT<br />

CWCFZ YIPTF EOBHM WEMOC SAWCZ SNYNW MGXEL HEZCU FNZYL NSBTB<br />

DANFK OPEWM SSHBK GCWFV EKMUE<br />

The key was Physical Examination. Decipher the message.<br />

(c) Another message reused the key Physical Examination, and began<br />

XYAWO GAOOA GPEMO HPQCW IPNLG RPIXL TXLOA NNYCS YXBOY MNBIN<br />

YOBTY QYNAI<br />

Later messages explained the rescue arrangements. The combination <strong>of</strong><br />

messages could have been easily solved in an hour by any moderately<br />

experienced cryptanalyst. If solved, the Japanese could have gotten both<br />

the shipwrecked crew and the rescue force. For whatever reason, there<br />

was no enemy action taken, and Lt. Kennedy was rescued and went on to<br />

become President.<br />

23. H.F. Gaines [page 199] proposed a cipher that uses the Saint Cyr Slide to<br />

implement a digraphic cipher, calling it, logically enough “Slidefair”. <strong>St</strong>art<br />

by setting the keyletter under a, as usual. To encipher a pair <strong>of</strong> letter,<br />

find the first letter in the plaintext strip and the second in the cipherstrip.<br />

Replace them by other corners <strong>of</strong> the rectangle then formed, first letter<br />

from the plainstrip and second from the cipherstrip. If the letters happen<br />

to occur as a horizontal pair, replace them by the letters directly to their<br />

right.<br />

Her example used the keyword HERCULES and produced the ciphertext<br />

XZ ZR RU KC TI HO KX US MZ NI JU KO TI PO SC MW PR PM XY RW GZ AT<br />

What was the plaintext


Chapter 10<br />

Transposition Ciphers<br />

In one word, the transposition methods give a<br />

nice mess [salade] <strong>of</strong> cleartext letters.<br />

Etienne Bazeries<br />

So far each <strong>of</strong> the methods <strong>of</strong> ciphering we’ve studied have been substitution<br />

methods. They obtain their secrecy by hiding the meaning <strong>of</strong> the letter. In this<br />

chapter we turn to transposition ciphers, ciphers which obtain their secrecy<br />

by hiding the location <strong>of</strong> the letter. We start with a couple <strong>of</strong> simple classics.<br />

10.1 Route Ciphers<br />

Route ciphers are also called rail fence ciphers, for an obvious reason.<br />

Examples: Decipher the route ciphers.<br />

(1) Decipher AEICL BLNON.<br />

a e i c l<br />

b l n o n<br />

(2) Decipher TEIEP NDSR.<br />

(3) Decipher OBNN LAIECL DLO. (Hint: three rows.)<br />

(4) Decipher ILE ALPITR RST.<br />

(5) Decipher ILVGI IOIAE ITSRN MANHM NG. 1<br />

(Try three rows.)<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

1 (2) Two rows, read backwards: president, (3) Old Abe Lincoln, (4) rail splitter, (5)<br />

I am leaving this morning – from [HITT, page 28].<br />

189


190 CHAPTER 10. TRANSPOSITION CIPHERS<br />

10.2 Geometrical Ciphers<br />

Traditionally, the most common way <strong>of</strong> using transposition was to arrange the<br />

plaintext letters in some sort <strong>of</strong> rectangle. When the insertion and reading <strong>of</strong><br />

the letters is done in patterns other than rows and columns, we call the ciphers<br />

Geometrical Ciphers.<br />

Examples: Decipher the geometrical ciphers.<br />

(1) Decipher ANOOR RDXOA OWEOD UNDAN. (Write in 4 rows and read <strong>of</strong>f in a<br />

spiral.)<br />

(2) Decipher IINIZ ATGDZ MTVYY GEERX.<br />

(3) Decipher MOGIN VNNOA IAGLI DAIRC ISTKY. 2<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

10.3 Turning Grilles<br />

A grille is simply a piece <strong>of</strong> paper in which holes have been cut. To encipher, lay<br />

the grille on a clean sheet <strong>of</strong> paper, write your message in the holes, and, once<br />

finished, remove the grill and fill in the leftover spaces with nulls. Deciphering<br />

is easy – lay the grille back on the ciphertext to see the meaningful letters.<br />

Giacolomo Cardano, last seen in Chapter 8.8.4 apparently invented this method<br />

in the 16th century. The problem with this method is that to be secure there<br />

must be many nulls, maybe up to half, and this makes the ciphertext long in<br />

relation to the plaintext. To reduce the number <strong>of</strong> nulls, we need to be more<br />

careful about where we put the holes. 3<br />

<strong>St</strong>art with a piece <strong>of</strong> paper that has a grid marked on it. (A grid here simply<br />

meaning a series <strong>of</strong> horizontal and vertical lines that visually divides the paper<br />

into equal sized squares.) Select some 2n × 2n collection <strong>of</strong> these small squares<br />

that forms a large square and divide it into four n × n squares. Fill up the<br />

upper left-hand sub-square with the numbers 1 through n 2 with 1 through n<br />

on the top row, etc.. Then turn your paper one-quarter <strong>of</strong> the way around and<br />

similarly fill the new upper left-hand square with 1 through n 2 . Repeat this<br />

process twice more, so that each <strong>of</strong> the numbers is repeated four times in the<br />

big square.<br />

Next, pick exactly one <strong>of</strong> the four copies <strong>of</strong> each <strong>of</strong> the numbers and highlight<br />

or circle it. It’s best if you pick about the same number <strong>of</strong> numbers from each <strong>of</strong><br />

the small squares. Take a new sheet <strong>of</strong> paper and, using the old as a reference,<br />

2 (1) around and around we go, (2) Read <strong>of</strong>f going down and up the columns: i am<br />

getting very dizzy, (3) Read <strong>of</strong>f the diagonals: moving in a diagonal is tricky.<br />

3 To be precise, the Cardano method actually produces a open cipher rather than a<br />

transposition, but we aren’t that precise.


10.3. TURNING GRILLES 191<br />

1 2 3 7 4 1<br />

4 5 6 8 5 2<br />

7 8 9 9 6 3<br />

3 6 9 9 8 7<br />

2 5 8 6 5 4<br />

1 4 7 3 2 1<br />

Figure 10.1: A 3 × 3 turning grille.<br />

cut out boxes in the new sheet that are where and <strong>of</strong> the same size as the boxes<br />

you highlighted on the first sheet. We have made a turning grille. In Figure<br />

10.1 a set <strong>of</strong> numbers has been chosen, as the bold typeface indicates.<br />

To encipher the message lay your grille onto a clean sheet <strong>of</strong> paper. Moving<br />

from left to right and top to bottom, as usual, write your text in the holes in the<br />

grille. Once you have filled the holes give your grill a quarter turn and continue<br />

with your message. If your message is quite long you may have to repeat the<br />

filling process on a second or even third sheet <strong>of</strong> paper, while if your message is<br />

short, you’ll probably want to fill the remaining spots with nulls.<br />

The deciphering process is the natural opposite <strong>of</strong> the enciphering: lay the<br />

grill over the sheet and copy the letters <strong>of</strong>f that you can see, turning the ciphersheet<br />

one quarter each time you have copied down all the letters.<br />

Examples:<br />

(1) Encipher Girolomo Cardano was a mathematician using the grille in<br />

Figure 10.1.<br />

Nine letters at a time will be entered.<br />

partial ciphertext looks like<br />

After the first nine letters, the<br />

O<br />

I<br />

O<br />

R<br />

M<br />

G<br />

L<br />

O<br />

C<br />

Now give the grill one quarter twist and enter nine more. This make<br />

A G<br />

R I D<br />

R A O<br />

N L O<br />

O W M<br />

S O A C


192 CHAPTER 10. TRANSPOSITION CIPHERS<br />

Do this twice more. Since the plaintext has only 31 letters we add five<br />

nulls letters at the end. (I chose stopt as the nulls.) Then pull <strong>of</strong>f the<br />

ciphertext in rows and regroup.<br />

(2) Decipher UTOWL MHHDE IAFTO NADOG MBIHD OEAEU CNCOS Y using the same<br />

grille. 4<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

For about four months in 1917 the German Army used Turning Grilles. (The<br />

German Army was quite lost, cryptographically, during much <strong>of</strong> World War I,<br />

and tried just about every method they could get their hands on.) ANNA was<br />

5 × 5, BERTA was 6 × 6, all the way up to FRANZ, who was 10 × 10. The<br />

French, who were crytologically far more advanced than the Germans, treated<br />

Anna, Berta and Franz as old friends, and happily read most <strong>of</strong> the messages<br />

sent in this manner.<br />

10.4 Columnar Transposition<br />

Columnar transposition is the transposition method. It was widely used,<br />

especially in World War I, and fell out <strong>of</strong> favor only because <strong>of</strong> the rise <strong>of</strong><br />

machine ciphers. 5<br />

To encipher, pick a keyword and write the message under the keyword in<br />

rows with as many columns as letters in the keyword. Number the columns<br />

alphabetically from the code word, just as in the keyword transposed ciphers<br />

from Section 1.5.3. (Remember we decided to consecutively number repeated<br />

letters, so REPEATER is numbered 62531847.) Then pull the columns out oneby-one<br />

in this numerical order. Separate the letters into groups <strong>of</strong> five and you<br />

have enciphered your message. (It is possible that your message will not make<br />

a perfect rectangle. That is fine. Either ignore the blanks, or fill them with<br />

nulls.)<br />

To decipher the message we need to know not only what the proper ordering<br />

<strong>of</strong> the the columns is (which we do, as we know the keyword), but also how<br />

many letters go into each column. Suppose we have a message N letters long,<br />

and the keyword has k letters. <strong>St</strong>art by drawing a rectangle with k columns.<br />

Next divide the columns into rows. There will be N ÷ k full rows (here N ÷ k<br />

means this integer part <strong>of</strong> division), and a final row that will contain N%k<br />

letters at its beginning and be blank at the end. Cross out these blank spaces<br />

so you won’t be tempted to put letters into them. Now put in your ciphertext<br />

4 (1) MACGA IRITA DHNER ASOMN TALOO OWMTP SOIAT C. (2) who did anything he could to<br />

become famous, (which is true about Cardano, as his biographers can attest.)<br />

5 Machine ciphers are clearly much faster than ciphering by hand. Further, since transposition<br />

generally deals with large groups <strong>of</strong> letters at one, as opposed to substitution which<br />

enciphers small groups at once, the early limits on computer memory made pure transposition<br />

machine-ciphers less secure than substitution machine-ciphers.


10.4. COLUMNAR TRANSPOSITION 193<br />

column by column, following the order given by the keyword. Reading across<br />

the rows then gives the message.<br />

Examples: Encipher or decipher using columnar transposition.<br />

(1) Encipher Here is my very clever secret message using the keyword<br />

cipher.<br />

c i p h e r<br />

H E R E I S<br />

M Y V E R Y<br />

C L E V E R<br />

S E C R E T<br />

M E S S A G<br />

E<br />

Reading down we have the c column: HMCSME, the e column: IREEA, the<br />

h column: EEVRS, the i column: EYLEE, the p column RVECS, and the r<br />

column: SYRTG. Putting these together and regrouping we obtain HMCSM<br />

EIREE AEEVR SEYLE ERVEC SSYRT G.<br />

(2) Encipher Monday morning arrives too early using the keyword simple<br />

filling last row with null m’s.<br />

(3) Decipher DKOEY TGHRT OORAE NTFSO TEIAL GE using the keyword square.<br />

There are 27 letters in the message and 6 in the keyword, so there will be<br />

27 ÷ 6 ≈ 4 full rows and 27%6 = 3 letters in a fifth row. So we will fill in<br />

S Q U A R E<br />

First we fill down the A column (putting in the first four letters <strong>of</strong> the<br />

message),<br />

S Q U A R E<br />

D<br />

K<br />

O<br />

E


194 CHAPTER 10. TRANSPOSITION CIPHERS<br />

then fill down the E column with the next four,<br />

S Q U A R E<br />

D Y<br />

K T<br />

O G<br />

E H<br />

then the Q column with the next five, etc. This gives us<br />

S Q U A R E<br />

F R I D A Y<br />

S T A K E T<br />

O O L O N G<br />

T O G E T H<br />

E R E<br />

From here we simply read <strong>of</strong>f the message (ignoring the keyword): Fridays<br />

take too long to get here.<br />

(4) Decipher VOOGH KEBWN TEEDR FEERY KOWNY SIRED with keyword daily.<br />

(5) Decipher ENMPK EAKWN TESUE VYEES SDAAN with keyword later. 6<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

There are two standard tricks to use with transposition. The first we’ve seen<br />

before – the use <strong>of</strong> nulls. As with monoalphabetic substitution, nulls are simply<br />

meaningless letters added to the plaintext before enciphering with the hope <strong>of</strong><br />

making the decrypter’s life more difficult. While nulls may appear anywhere,<br />

we will restrict ourselves to putting nulls at the beginnings and endings <strong>of</strong> messages.<br />

As we will see, nulls used in this way add only modestly to the security <strong>of</strong><br />

columnar transposition. More worthwhile is performing interrupted columnar<br />

transposition in which certain spots are skipped during the enciphering<br />

and deciphering process.<br />

6 (3) YNVEO OASRA IIONR RTLDN ROYMM GEA. (4) A completely filled rectangle with 6 rows:<br />

Everybody’s working for the weekend. (5) The te and nns are nulls: Seven days make up<br />

a week.


10.5. TRANSPOSITION VS. SUBSTITUTION 195<br />

Examples:<br />

(1) Encipher some spots are simply skipped using the keyword START with<br />

the interruptions as given:<br />

S T A R T<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

Enciphering is almost the same as before: put the message into the array,<br />

skipping the designated spots. Then when pulling out the columns,<br />

remember to forget to write down the ∗’s.<br />

(2) Decipher STPAR STEIA GPSTC NUTMN RNRIU SEENH IRSID EOUET. The keyword<br />

is EXPLODE and the interruption pattern is<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

∗<br />

7<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

10.5 Transposition vs. Substitution<br />

How do we recognize that a cipher is possibly from a columnar transposition,<br />

rather than from some form <strong>of</strong> substitution A message enciphered with a any<br />

transposition consists <strong>of</strong> exactly the same letters as the plaintext message. A<br />

frequency analysis <strong>of</strong> the ciphertext will thus result in a chart that matches the<br />

a-e-i, no, rst, and uvwxyz patterns exactly, and in their natural positions. So it<br />

is easy to detect a transposition cipher: its frequency chart will look like one from<br />

common English but the text won’t be readable. 8 Conversely, a substitution<br />

7 (1) MPAIS ORMKE STSLP OSSYP EEPID. (2) Missed interruptions cause anger eruptions.<br />

8 Since position and not identity is now what is important, we probably want to make any<br />

nulls we use to be similar to the other letters in the plaintext, in the hope that the enemy<br />

will be confused as to which letters are meaningful. So, while in a substitution cipher we use<br />

letters like jkxqz as nulls to try to make frequency analysis harder, in a transposition cipher<br />

we use etaoinshr letters to add insignificant significant-looking letters to the ciphertext.


196 CHAPTER 10. TRANSPOSITION CIPHERS<br />

cipher will generally have too many jvkxyq’s and too few etaoinshr’s. To<br />

our eyes, trained to read English, transposition ciphers will look like a salad<br />

<strong>of</strong> letters (to mis-translate Bazeries’ quote), worthwhile components but oddly<br />

mixed, whereas substitution ciphertexts look unappetizing, with too many odd<br />

letters.<br />

10.6 Letter Connections<br />

Decrypting a transposition cipher is a bit like putting Humpty Dumpty back<br />

together again – all the pieces are given, we just need to determine which goes<br />

where. When doing this, we will continually have a letter and will be wondering<br />

which letter most likely came just before it in the message, and which letter<br />

likely came just after it. These are questions <strong>of</strong> conditional probability. Notice<br />

the difference between<br />

and<br />

“This letter is a T. How likely is it that the next letter an H”<br />

“How likely is it that this letter is a T and the next letter is an H”<br />

Figure 10.2 provides the answer to the first question, in percent. 9 In the row<br />

centered by T, just to the right <strong>of</strong> T appears H 32 , which indicates that T is followed<br />

by H almost 1/3 <strong>of</strong> the time. Similarly, the appearance <strong>of</strong> U 4 E 17 O 18 A 22 I 26 just<br />

before N show that N is almost always preceded by a vowel, with that vowel<br />

being I about 1/4 <strong>of</strong> the time. And that when the rare V does appear, it is<br />

usually followed by E. 10<br />

For comparison, the answer to the section question (“how likely is it that<br />

this pair is “TH”) appears in Figure 10.3. This figure is the bigram companion<br />

to our standard frequency chart Figure 1.3, as it shows how likely each possible<br />

bigram is in standard English. 11<br />

9 These percentages were computed using “The Brown Corpus.” The Brown Corpus <strong>of</strong><br />

<strong>St</strong>andard American English was compiled by W.N. Francis and H. Kucera at Brown University,<br />

Providence, RI, from one million words <strong>of</strong> American English texts printed in 1961. The texts<br />

sampled came from fifteen different categories ranging from “Reportage” (The Philadelphia<br />

Inquirer, May 10, 1961, p.49) to “Popular Lore” (Jack Kaplan, “The Health Machine Menace:<br />

Therapy by Witchcraft”) to “Romance” (Samuel Elkin, “The Ball Player,” Nugget, October,<br />

1961). By modern standards, this corpus is considered small and dated.<br />

10 We remarked back in Chapter 6 that vowels like to combine with consonants. Look at<br />

the vowels rows to ascertain the validity <strong>of</strong> this statement. Likewise, that H is more likely to<br />

precede vowels while N and S are more likely to follow them.<br />

11 The numbers are in %%, meaning that you should divide by 100 and add % to the end.<br />

So the 13 in the BA entry means that BA appears .13% <strong>of</strong> the time, about 1/10 <strong>of</strong> 1 percent <strong>of</strong><br />

the time. Values smaller than 0.01% have been left out.


10.6. LETTER CONNECTIONS 197<br />

F 2 G 2 I 2 Y 2 P 3 D 4 C 5 L 5 W 5 M 6 N 6 S 7 T 7 R 8 H 10 E 12 A N 19 T 14 L 10 R 10 S 10 C 5 D 4 I 3 M 3 B 2 G 2 P 2 V 2 Y 2<br />

L 3 I 4 N 4 R 4 U 4 Y 4 M 5 T 5 S 7 O 9 D 10 A 13 E 13 B E 30 L 12 O 11 U 11 A 8 Y 7 I 5 R 5 S 2<br />

D 2 Y 2 T 3 R 4 U 4 O 5 S 7 N 11 A 13 I 16 E 19 C O 19 E 15 H 14 A 13 T 9 I 6 K 4 L 3 R 3 U 3<br />

D 2 O 4 R 4 L 6 I 7 A 9 N 27 E 28 D E 15 I 13 T 10 A 9 O 7 S 6 B 4 H 3 R 3 U 3 W 3 C 2 D 2 F 2 L 2 M 2<br />

G 2 I 2 P 2 W 2 B 3 C 3 E 3 D 5 L 5 M 5 N 5 S 5 V 5 T 7 R 11 H 20 E R 14 S 10 D 9 N 9 A 7 T 6 C 4 L 4 E 3 I 3 M 3 W 3 F 2 O 2 P 2<br />

Y 2 L 3 R 3 T 3 D 4 N 4 A 5 F 5 S 5 I 6 E 13 O 36 F O 17 T 15 I 11 A 9 E 8 R 7 F 5 L 3 U 3 C 2 H 2 S 2<br />

D 2 S 2 O 4 R 4 U 6 A 9 E 9 I 11 N 42 G E 15 H 12 A 10 I 8 O 8 R 8 T 7 S 4 L 3 U 3 N 2<br />

D 2 N 2 E 4 G 4 W 6 S 7 C 8 T 54 H E 48 A 16 I 13 O 8 T 4<br />

C 2 G 2 V 2 A 3 F 3 M 3 W 4 E 5 N 5 D 7 L 7 R 8 S 8 H 9 T 15 I N 25 S 12 T 12 C 7 O 7 L 5 D 3 E 3 M 3 R 3 A 2 F 2 G 2 V 2<br />

G 2 Y 4 O 5 R 5 T 5 A 6 S 6 B 7 D 8 N 10 E 14 F 15 J U 28 O 25 E 19 A 13 I 3 T 2<br />

L 4 E 7 I 7 S 7 N 8 O 11 R 12 A 14 C 20 K E 34 I 15 N 7 S 7 A 6 O 4 T 4 H 2 L 2 W 2<br />

C 2 N 2 R 2 S 2 T 3 B 4 P 4 U 6 O 7 I 8 L 12 E 13 A 19 L E 16 I 12 L 12 A 11 Y 9 O 8 D 6 S 3 T 3 U 2<br />

Y 2 D 3 M 3 N 3 T 3 U 4 S 5 R 6 A 10 I 10 E 18 O 18 M E 25 A 19 I 11 O 11 P 6 U 4 B 3 M 3 S 3 T 3<br />

R 2 U 4 E 17 O 18 A 22 I 26 N T 17 D 15 G 11 E 9 O 7 A 6 S 6 C 5 I 5<br />

B 2 G 2 W 2 D 3 M 3 O 3 P 3 Y 3 E 4 L 4 F 5 H 5 N 6 C 7 I 7 S 7 R 8 T 13 O N 17 R 13 F 11 U 10 M 6 T 6 L 4 W 4 O 3 S 3 C 2 D 2 P 2 V 2<br />

L 2 X 2 Y 2 D 3 I 3 N 3 T 3 R 4 P 5 U 5 M 8 A 9 O 10 S 11 E 17 P E 18 R 16 O 13 A 12 L 10 I 5 P 5 T 4 H 3 U 3 S 2<br />

O 2 R 2 C 3 T 3 A 4 D 4 N 5 I 8 S 12 E 43 Q U 98<br />

D 2 G 2 F 3 I 4 P 5 T 5 U 6 A 14 O 16 E 28 R E 23 A 10 O 10 I 9 S 7 T 7 D 3 Y 3 C 2 M 2 N 2<br />

L 2 Y 2 D 3 O 4 T 5 U 5 R 6 N 7 S 7 A 12 I 13 E 20 S T 18 E 11 A 9 I 9 O 8 S 7 H 6 C 3 P 3 U 3 W 3 M 2<br />

H 2 Y 2 C 3 F 3 U 3 D 4 O 5 R 5 T 5 E 8 I 9 A 12 N 13 S 13 T H 32 I 11 O 11 E 10 A 6 T 5 S 4 R 3 U 2 W 2<br />

G 2 H 2 N 2 P 2 A 3 C 3 E 3 F 3 L 3 M 3 Q 3 D 4 R 4 B 6 T 7 S 9 O 28 U R 14 S 13 T 13 N 12 L 10 C 5 G 4 P 4 A 3 E 3 I 3 M 3 B 2 D 2<br />

D 2 L 2 N 4 R 5 O 15 A 17 I 20 E 24 V E 65 I 19 A 9 O 5<br />

L 2 A 4 R 4 Y 4 N 5 D 6 T 10 S 11 O 17 E 20 W A 22 H 17 I 17 E 16 O 11 N 4<br />

O 5 I 7 A 8 E 74 X P 26 T 17 I 12 A 11 C 10 E 7 O 2<br />

H 2 M 2 O 2 D 3 S 3 N 6 B 7 E 9 T 10 R 11 A 12 L 21 Y O 13 T 11 A 10 S 9 E 7 I 6 W 5 B 4 C 3 F 3 H 3 M 3 P 3 D 2 L 2 R 2<br />

N 2 U 2 T 3 O 4 E 5 Z 7 A 14 I 51 Z E 44 A 18 I 11 Z 7 O 5 L 2 Y 2<br />

Figure 10.2: Appearances before and after the given letter, in %.<br />

To use the charts correctly, we need to carefully note the meanings <strong>of</strong> three<br />

different possible numbers:<br />

1. If we ask “I have V. How <strong>of</strong>ten is V followed by E”, look for E in the V<br />

row <strong>of</strong> Figure 10.2. The answer is 65% <strong>of</strong> the time. V is (almost) always<br />

followed by a vowel, and E is the mostly likely one.<br />

2. If we ask “How <strong>of</strong>ten is E preceded by V” the answer is much smaller, only<br />

5%, as seen also in Figure 10.2. Why smaller That is the “conditional”<br />

part <strong>of</strong> the probability. Looking at a V one feels that a vowel is probably<br />

next. Looking at an E we are somewhat surprised if the preceding letter<br />

is V.<br />

3. If we ask “Here are two letters. Are the VE” we find 64 in Figure 10.3,<br />

meaning .64% = 0.0064 <strong>of</strong> all letter pairs are VE’s. So this pair is quite<br />

uncommon, as matches our intuition.


198 CHAPTER 10. TRANSPOSITION CIPHERS<br />

.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<br />

A. 2 20 40 37 11 18 3 28 1 9 82 27 156 1 18 86 81 116 9 17 8 1 21 1<br />

B. 13 1 47 8 1 18 17 9 3 1 17 12<br />

C. 41 5 48 46 19 13 12 59 11 2 30 10 2<br />

D. 36 16 8 9 63 9 5 14 52 1 8 9 8 30 7 12 25 40 12 2 12 6<br />

E. 98 20 59 114 45 32 17 22 39 2 4 54 47 120 35 34 4 175 134 80 8 24 39 14 16<br />

F. 22 2 4 2 20 13 1 5 26 2 7 3 1 41 3 18 5 35 8 2 1<br />

G. 21 2 2 1 30 3 3 25 16 6 2 5 17 2 17 7 15 7 3 1<br />

H. 88 2 3 1 260 1 3 72 2 3 3 44 1 8 5 22 6 3 4<br />

I. 19 7 52 28 28 15 21 1 5 36 27 188 54 7 25 89 88 20 1 1 4<br />

J. 2 3 4 5<br />

K. 4 22 1 1 10 1 5 3 5 3 1 1<br />

L. 46 5 5 27 69 7 1 3 52 2 52 4 1 35 5 3 15 15 10 2 4 37<br />

M. 48 8 1 63 1 2 28 1 8 1 30 17 3 9 7 10 2 4<br />

N. 49 7 36 107 63 10 82 11 40 1 5 9 7 9 50 6 4 48 121 7 4 10 10<br />

O. 13 14 16 18 6 86 8 7 10 7 30 48 131 24 21 100 30 49 77 15 32 1 4<br />

P. 25 36 7 11 20 1 27 11 32 4 9 7<br />

Q. 10<br />

R. 64 7 14 18 145 7 9 8 60 8 11 17 15 66 8 12 43 47 11 5 8 19<br />

S. 62 11 22 7 73 13 4 40 63 1 4 11 14 9 57 23 1 6 46 124 25 1 21 5<br />

T. 61 9 10 5 95 7 2 296 110 1 13 9 4 104 6 35 38 49 20 20 18<br />

U. 10 7 13 7 10 1 11 8 27 10 33 1 11 39 36 35<br />

V. 9 64 19 5<br />

W. 41 1 30 32 33 1 1 7 20 3 3 3 1 1<br />

X. 2 2 1 2 5 3<br />

Y. 17 7 6 4 12 5 2 6 11 4 6 3 23 6 4 16 19 1 8<br />

Z. 1 4 1<br />

Figure 10.3: Bigram Frequencies (in %%), from the Brown Corpus.<br />

10.7 Breaking the Columnar Transposition Cipher<br />

Once we know we have a transposition cipher (and for us this means columnar<br />

transposition), to start trying to decrypt it first count the length <strong>of</strong> the message,<br />

and use this to find all the possible shapes. (In exchange for making your<br />

life easier by giving you only completely filled rectangles to decrypt, I may<br />

complicate things by throwing in nulls both at the beginning and end <strong>of</strong> the<br />

message.) So if there are 40 letters in the message we’d expect an 8 × 5 or 5 × 8<br />

rectangle. (Variants like 2 × 20 or 4 × 10 are possible but less likely.) And if the<br />

message is only 35 letters the rectangle must be 5 × 7 or 7 × 5. On thin strips<br />

<strong>of</strong> paper write the message in columns <strong>of</strong> the proper length. Then start flipping<br />

the pieces <strong>of</strong> paper around until a message starts to form.<br />

How does one “flip around” <strong>St</strong>art by putting the strips near one another<br />

and making a vowel count <strong>of</strong> the rows. In English, vowels make up between<br />

35% and 40% <strong>of</strong> all letters. It is uncommon to find even a ten-letter segment<br />

that has fewer than 3 or more than 5 vowels. As a quick test <strong>of</strong> your rectangle,<br />

count the number <strong>of</strong> vowels in each row. If many <strong>of</strong> the rows have much less<br />

than 40% vowels, or much more, then you may wish to instead try a rectangle<br />

<strong>of</strong> a new size.<br />

Once you have a rectangle with a good vowel count turn to any peculiarities<br />

<strong>of</strong> the message you can find, such as those coming from the appearance <strong>of</strong> low-


10.7. BREAKING THE COLUMNAR TRANSPOSITION CIPHER 199<br />

frequency letters. For example, a q in the message must be followed by a u;<br />

j, v and z are almost always followed by a vowel; x is generally preceded by a<br />

consonant.<br />

Counting the contacts will help determine which strips fit together the best.<br />

For each pair <strong>of</strong> columns that may possibly fit together, sum the values from<br />

Figure 10.3 for that pair. Often the pair <strong>of</strong> columns with the highest sum will<br />

be neighbors in the plaintext.<br />

Finally, look for words. Decrypting a transposition cipher is very similar<br />

to the final step in decrypting a complicated monoalphabetic ciphers in that<br />

you must just work hard, carefully sort through the possibilities, and let your<br />

English intuition solve it for you.<br />

Examples: Decrypt the following transposition ciphers.<br />

(1) EERHE LARGE GNEDH IWIDD OERET AIYTT SSERT.<br />

This has 35 fairly standard letters, so must be a transposition cipher, and<br />

is either 5 × 7 or 7 × 5. Let’s guess 5 rows. Then our columns are exactly<br />

those 5 letter groupings given.<br />

1 2 3 4 5 6 7<br />

1 E L G I O A S<br />

2 E A N W E I S<br />

3 R R E I R Y E<br />

4 H G D D E T R<br />

5 E E H D T T T<br />

First, there are seven letters per row, and 40% <strong>of</strong> 7 is about 3, so we’d<br />

expect each row to contain about 3 vowels. Rows 1, 2 and 3 all have<br />

exactly 3 vowels, and row 5 has 2. Only row 4, with 1 vowel, hints that<br />

this rectangle is the wrong one. On the other hand, there are only 12<br />

vowels among these 35 letters, a percentage closer to 33% than 40% so<br />

row 4 by itself is probably not a reason to discard this arrangement.<br />

Second, column 6 has a y, a very uncommon letter. In English y appears<br />

almost exclusively as the final letter <strong>of</strong> a word, so we should not worry<br />

about what letter follows it. Using Figure 10.3, y is mostly preceded by one<br />

<strong>of</strong> the letters NBETRAL. (These are they only significant non-zero entries in<br />

the .Y column <strong>of</strong> Figure 10.2.) Can we make any <strong>of</strong> these pairs Assuming<br />

that y is not the first letter <strong>of</strong> the row we can make three ry’s, with the<br />

column-pairs 16, 26 and 56, and two ey’s, with the column-pairs 36 and<br />

76. (This means five pairs to check, out <strong>of</strong> a possible (7 × 6)/2 = 21.)<br />

Next we count the total number <strong>of</strong> contacts we have for each pair <strong>of</strong>


200 CHAPTER 10. TRANSPOSITION CIPHERS<br />

columns, using the chart in Figure 10.3. 12<br />

columns 1 6 2 6 3 6 5 6 7 6<br />

E A 98 L A 46 G A 21 O A 13 S A 62<br />

E I 39 A I 28 N I 40 E I 39 S I 63<br />

R Y 19 R Y 19 E Y 16 R Y 19 E Y 16<br />

H T 22 G T 15 D T 40 E T 80 R T 47<br />

E T 80 E T 80 H T 22 T T 49 T T 49<br />

totals 258 185 139 200 237<br />

The column pairs 16 and 76 have the highest totals so one <strong>of</strong> these is<br />

probably right. The pair 16 has the largest total but this is build from<br />

two big and three small values. The pair 76, on the other hand, has four<br />

good pairs and the one given EY pair. For this reason I would probably<br />

start with 76 rather than 16, despite the slightly smaller total. 13<br />

Since y occurs almost exclusively at the end <strong>of</strong> words we next try to see<br />

which columns could come before our column pair 76.<br />

columns 1 7 6 2 7 6 3 7 6 4 7 6 5 7 6<br />

E S A L S A G S A O S A S S A<br />

E S I A S I N S I E S I S S I<br />

R E Y R E Y E E Y R E Y E E Y<br />

H R T G R T D R T E R T R R T<br />

E T T E T T H T T T T T T T T<br />

None <strong>of</strong> these look encouraging. The TTT triplets in 476 and 576 force us<br />

to reject those combinations. Similarly 276 and 376 have bad GRT and DRT<br />

triplets. Only 176 works at all, and even then the HRT is not good.<br />

We can always come back, so let’s temporarily abandon the 5 × 7 and try<br />

7 × 5. This give the columns<br />

1 2 3 4 5<br />

E R H E T<br />

E G I R T<br />

R E W E S<br />

H G I T S<br />

E N D A E<br />

L E D I R<br />

A D O Y T<br />

12 Note again the difference between Figures 10.3 and 10.2. When we knew we were working<br />

with y but didn’t know which letter came before it we used 10.2. Now that we have definite<br />

pairs <strong>of</strong> letters we use 10.3.<br />

13 Some authors advise taking the product <strong>of</strong> the contact values, rather than their sum.<br />

This prevents a column with a couple very large contact counts and the rest very small from<br />

“winning.” The product counts demonstrate much more clearly the superiority <strong>of</strong> the 76<br />

combination. For simplicity, we will stick with sums.


10.8. DOUBLE TRANSPOSITION 201<br />

Since 5 × 40% = 2 we expect about 2 vowels per row, and except for one 1<br />

and one 3, all the rows have exactly 2 vowels, so this rectangle looks good.<br />

<strong>St</strong>arting again with the y both the 14 and 54 column-pairs fit well together<br />

and should be investigated:<br />

columns 1 4 5 4<br />

E E 45 T E 95<br />

E R 175 T R 35<br />

R E 145 S E 73<br />

H T 22 S T 124<br />

E A 98 E A 98<br />

L I 52 R I 60<br />

A Y 21 T Y 18<br />

totals 548 503<br />

I’d probably continue with the pair 14, except that the word there on the<br />

top row leaps <strong>of</strong>f the page, as does the word today on the bottom row.<br />

From here we are quickly done. (This example provides a good example<br />

<strong>of</strong> why we frequently add nulls at the start and end <strong>of</strong> a message.)<br />

(2) EGONH UITES ERMON QEELI HSAII TNCVF ENATT<br />

Again we have a 5 × 7. This time, besides the v, we have a q, probably<br />

giving us an easy two-column match. Since no u’s will be near the q if we<br />

use 7 rows, there must be five rows. Since a vowel must follow the qu this<br />

gives us three columns to choose from.<br />

(3) AADOI SEEDD OGRCE TRNGE TTSES ODRSH IBMNA DGHNR ISLOA AVT (Hint:<br />

there are nulls at the beginning and/or end.) 14<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

10.8 Double Transposition<br />

A double transposition cipher is one <strong>of</strong> the most difficult simple ciphers to<br />

decrypt. It was used so extensively by the Unites <strong>St</strong>ates that it is sometimes<br />

called the US Army double transposition, and was one <strong>of</strong> the many methods<br />

used by the German Army in WWI.<br />

A double transposition is exactly what it sounds like: after using a transposition<br />

method to encipher the message same keyword is used again to reencipher<br />

the ciphertext. Deciphering is accomplished simply by deciphering<br />

twice. For example, Attack your left flank at once enciphered once with<br />

14 (1) Three tigers were sighted near Deli today. (2) The three e columns make this<br />

one a bit harder: The Queen’s reign came to a violent finish t. (3) sr diamond and<br />

gold are good. straight cash is even better. The sr are nulls.


202 CHAPTER 10. TRANSPOSITION CIPHERS<br />

keyword bombs gives AKLLT AUTKC TOFNN TYEAO CRFAE. Guessing that this was<br />

a 5×5 square would lead to almost immediate decryption. But if we re-encipher<br />

it with the same keyword we get AATTC LKNAA LTFEF KUOYR TCNOE.<br />

Suppose we try to decrypt this cipher, and for ease we grant ourselves the<br />

knowledge that it is 5 × 5. Arranging it gives<br />

1 2 3 4 5<br />

A L L K T<br />

A K T U C<br />

T N F O N<br />

T A E Y O<br />

C A F R E<br />

There are only 7 vowels out <strong>of</strong> 25 letters, or 28%, which is a smaller percentage<br />

than normal, but it still stands out that there is only one vowel in each <strong>of</strong> the<br />

first two rows. Cheating (by looking at the previous paragraph) how will we<br />

guess that AUTKC is the correct ordering <strong>of</strong> the second row<br />

The purpose <strong>of</strong> a transposition is to mix-up the position <strong>of</strong> the letters. A single<br />

columnar transposition cipher can be broken because this mixing is far from<br />

complete. The second enciphering causes many more <strong>of</strong> the letter connections to<br />

be shredded, making decryption very difficult. If the cryptanalyst has a number<br />

<strong>of</strong> messages, all enciphered with the same key, and all <strong>of</strong> exactly the same length,<br />

then, by moving from one message to another and back again, it is possible to<br />

decrypt the whole set. (This is the trick that the brilliant French cryptanalyst<br />

Georges Jean Painvin used to break the German ÜBCHI double transposition<br />

cipher <strong>of</strong> World War I.) However, even the experts cannot routinely decrypt a<br />

single message carefully enciphered with a double transposition.<br />

10.9 Transposition during the Civil War<br />

The Civil War turned out to be an interesting test <strong>of</strong> Kerckh<strong>of</strong>f’s maxim that<br />

the enemy knows the system being used. Not only did the two armies speak<br />

the same language, but most <strong>of</strong> the trained <strong>of</strong>ficers knew each other, having<br />

attended West Point together, and some even had fought together during the<br />

Mexican–American War <strong>of</strong> 1848. We have already seen that the South put their<br />

trust largely in polyalphabetic ciphers, with rather little success. The North<br />

would turn to transposition.<br />

Anton <strong>St</strong>ager was born in 1833, in New York, and worked in a printer’s <strong>of</strong>fice<br />

and as a bookkeeper before becoming a telegraph operator in Pennsylvania. He<br />

was rapidly promoted and by his early thirties he was the general superintendent<br />

<strong>of</strong> the Western Union Telegraph Company, head-quartered in Cleveland. After<br />

the outbreak <strong>of</strong> hostilities in the Civil War, Governor Denison <strong>of</strong> Ohio gave him<br />

responsibility for all telegraph lines in the Ohio military district, and asked him<br />

to prepare a cipher so that the governors <strong>of</strong> Ohio, Indiana and Illinois could


10.9. TRANSPOSITION DURING THE CIVIL WAR 203<br />

conduct secret communications with one another. This was, apparently, “the<br />

first telegraphic cipher used for war purposes” [Plum, page 44].<br />

Later George B. McClellan, a recent railroad executive who became a general<br />

<strong>of</strong> volunteers, asked <strong>St</strong>ager to prepare a cipher for use during the campaign<br />

in West Virginia. <strong>St</strong>ager based this new cipher on his previous one. It was afterwords<br />

adopted as the <strong>of</strong>ficial cipher <strong>of</strong> the War Department [<strong>Web</strong>er]. The cipher<br />

was simply a route cipher. As J.E. O’Brien, a former US Military Telegraph<br />

operator, put it [SSA3, vol 1]<br />

The principle <strong>of</strong> [this] cipher consisted in writing a message with an equal<br />

number <strong>of</strong> words in each line then copying the words up and down the<br />

columns by various routes, throwing in an extra word at the end <strong>of</strong> each<br />

column, and substituting other words for important words and meanings.<br />

The cipher information was printed on cards, about 3 by 5 inches in size.<br />

Printed on the cards were the code words, called arbitrary words, the keys,<br />

called commencement words, and the nulls, called check words or blind<br />

words. The route was also indicated on the card.<br />

Successive editions <strong>of</strong> the ciphers were aided by the practical experience <strong>of</strong><br />

the users, both in Washington and in the field. More code words, more nulls,<br />

and variations on the routes were added. Eventually the cards abandoned and<br />

pamphlets were substituted, in pocket-sized editions, the first with 16 pages,<br />

the last with 48 [SSA3].<br />

The genesis <strong>of</strong> <strong>St</strong>ager’s system can perhaps be seen in a simple example that<br />

appears in [Myers]:<br />

The enemy has changed his position during the night. Deserters say<br />

that he is retreating. Smith<br />

We put it into a rectangle in the following given order: down column 1, up<br />

column 4, down column 2 and up column 4, and then add a column <strong>of</strong> nulls.<br />

Column 1 Column 2 Column 3 Column 4 Column 5<br />

The night. Smith the attacking<br />

enemy Deserters retreating during summer<br />

has say is position unchanged<br />

changed that he his him.<br />

The ciphertext can then be read <strong>of</strong>f:<br />

The night. Smith the attacking enemy Deserters retreating during<br />

summer has say is position unchanged changed that he his him.<br />

Notice the use <strong>of</strong> significant looking insignificant check words – “attacking” and<br />

“unchanged.”


204 CHAPTER 10. TRANSPOSITION CIPHERS<br />

The early form <strong>of</strong> <strong>St</strong>ager’s ciphers was similar to the Myers example. Here<br />

is one sent at the very beginning <strong>of</strong> the war.<br />

Example: [Plum]<br />

Parkersburg, VA. June 1, 1861.<br />

To Maj. Gen. G.W. McClellan, Cincinnati, Ohio:<br />

Telegraph the have be not I hands pr<strong>of</strong>ane right hired held must start<br />

my cowardly to an responsible Crittendon to at polite ascertain engine<br />

for Colonel desiring demands curse the to success by not reputation nasty<br />

state go <strong>of</strong> superseded Crittenden past kind <strong>of</strong> up this being Colonel my<br />

just the road division since advance sir kill. (Signed) F.W. Lander<br />

With possession <strong>of</strong> the codebook we’d look up the keyword “Telegraph” to<br />

learn that this message is eight lines long, with seven columns. Further that the<br />

plaintext was inserted in the order up the 6th column, down the 1st, up the 5th,<br />

down the 2nd, up the 4th, and down the 3rd. (From now on we will abbreviate<br />

this as U6, D1, U5, D2, U4, D3.) Finally that the seventh column is filled with<br />

nulls and the message must be pulled <strong>of</strong>f row by row in the usual order.<br />

To decipher, we reverse the steps. So we first write the message in 8 rows <strong>of</strong><br />

7 columns each, and then pull <strong>of</strong>f the columns in order. 15<br />

the have be not I hands pr<strong>of</strong>ane<br />

right hired held must start my cowardly<br />

to an responsible Crittended to at polite<br />

ascertain engine for Colonel desiring demands curse<br />

the to success by not reputation nasty<br />

state go <strong>of</strong> superseded Crittenden past kind<br />

<strong>of</strong> up this being Colonel my just<br />

the road division since advance sir kill<br />

Up the 6th column and down the 1st begins the message:<br />

“Sir. My past reputation demands at my hands the right to ascertain the<br />

state <strong>of</strong> the advance. Colonel Crittendon, not desiring to start, I have<br />

hired an engine to go up road. Since being superseded by Colonel Crittendon,<br />

[I] must not be held responsible for [the] success <strong>of</strong> this division.”<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

15 We have always done transposition by putting the plaintext words or letters in rows in<br />

the usual order and pulling <strong>of</strong>f the columns via the keyword order. This is an example <strong>of</strong> the<br />

reverse process: put the plaintext message into a rectangle via some order and then pull it <strong>of</strong>f<br />

row by row, and then to decipher put the ciphertext into the rectangle in order and pull <strong>of</strong>f<br />

the plaintext by the keyword ordering.


10.9. TRANSPOSITION DURING THE CIVIL WAR 205<br />

By 1863 the ciphers had become more complicated.<br />

Example: (From [<strong>Web</strong>er, pages 114-5].) Here is the plaintext message.<br />

Headquarters Department <strong>of</strong> the Cumberland<br />

Chattanooga, October 16, 1863 - 7 p.m.<br />

Major-General Burnside,<br />

Knoxville, Tenn.;<br />

The enemy are preparing pontoons and increasing on our front. If they<br />

cross between us you will go up, and probably we too. You ought to move<br />

in the direction, at least as far as Kingston, which should be strongly<br />

fortified, and your spare stores go into it without delay. You ought to<br />

be free to oppose a crossing <strong>of</strong> the river, and with your cavalry to keep<br />

open complete and rapid communications between us, so that we can<br />

move combined on him. Let me hear from you, if possible, at once. No<br />

news from you in ten days. Our cavalry drove the rebel raid across the<br />

Tennessee at Lab’s Ferry, with loss to them <strong>of</strong> 2,000 killed, wounded,<br />

prisoners, and deserters; also five pieces <strong>of</strong> artillery.<br />

Yours,<br />

Rosecrans<br />

Answer quick.<br />

To encipher we first choose a key: Enemy. This keyword demands that we<br />

use an array with 10 rows <strong>of</strong> 6 columns each. So we enter the first 60 words <strong>of</strong><br />

the message:<br />

For Burnside The enemy are preparing<br />

Pontoons & increasing numbers on our<br />

front If they cross between us<br />

you will go up and probably<br />

we too . You ought to<br />

move in this direction at least<br />

as far as Kingston which should<br />

be strongly fortified and your spare<br />

stores go into it without delay<br />

You ought to be fee to<br />

Next, some giveaway words are replaced by their code equivalents as the<br />

code indicates: Burnside becomes BURTON and enemy becomes WILEY. The key<br />

also indicates that nulls are to be added at the tops and bottoms <strong>of</strong> certain<br />

columns. After doing this we have<br />

boy greatly<br />

For BURTON the WILEY are preparing<br />

Pontoons & increasing numbers on our<br />

front If they cross between us<br />

you will go up and probably<br />

we too . You ought to<br />

move in this direction at least<br />

as far as Kingston which should<br />

be strongly fortified and your spare<br />

stores go into it without delay<br />

You ought to be free to<br />

Not surely some<br />

Finally, the key tells how the plaintext is to be taken <strong>of</strong>f: D3, U4, D2, U5, D1


206 CHAPTER 10. TRANSPOSITION CIPHERS<br />

and U6. This gives the ciphertext<br />

the increasing they go period this as fortified into some be it<br />

and Kingston direction you up cross numbers Wiley boy Burton & If<br />

will too in far strongly go ought surely free without your which<br />

at ought and between on are greatly For Pontoons front you we move<br />

as be stores You Not to delay spare should least to probably us our<br />

preparing<br />

Since the entire message has not yet been enciphered, we proceed by choosing<br />

a new key and enciphering as the new key demands. In this case (since this was<br />

an actual message) <strong>St</strong>anton and McDowell were chosen. They each represented<br />

the same system: 6 × 6 with nulls atop columns 1, 5, and 6 and below columns<br />

1, 2 and 3.<br />

fortune the time<br />

oppose a crossing and with your<br />

RELAY to keep open complete and<br />

rapid communications between us so that<br />

we can move combined on him<br />

Let me hear from you if<br />

possible at once No news from<br />

speed this more<br />

(Relay is the code word for cavalry.) The pattern is up the diagonal from bottom<br />

right to top left, followed by D1, U6, U5, D3, U4.<br />

Putting the final portion <strong>of</strong> the message into cipher as well gives<br />

To Jaque Knoxville, Enemy the increasing they go period this as<br />

fortified into some be it and Kingston direction you up cross numbers<br />

Wiley boy Burton & if will too in far strongly go ought surely free<br />

without your which it ought and between or are greatly for pontoons<br />

front you we move as be stores you not to delay spare should least<br />

to probably us our preparing <strong>St</strong>anton from you combinedly between to<br />

oppose fortune roanoke rapid we let possible speed if him that and<br />

your time a communication can me at this news in so complete with<br />

the crossing keep move hear once3e more no from us open and McDowell<br />

julia five thousand ferry the you must drove at them prisoners<br />

artillery men pieces wounded to Godwin relay horses in Lambs <strong>of</strong> and<br />

yours truly quick killed Loss the our minds ten snow two deserters<br />

Bennet Gordon answer also with across day<br />

E.P. Alexander, the founder <strong>of</strong> the Confederate Army Signal Corps, received<br />

this ciphertext and was asked to translate it. His account (from Gary W. Gallagher<br />

Fighting for the Confederacy: The Personal Recollections <strong>of</strong> General<br />

Edward Porter Alexander, pages 302-03) <strong>of</strong> this incident is quite informative:<br />

I had never seen a cipher <strong>of</strong> this character before, but it was very clear<br />

that is was simply a disarrangement <strong>of</strong> words, what may be called, for<br />

short, a jumble. Each correspondent, <strong>of</strong> course, had what was practically<br />

a list <strong>of</strong> the natural numbers, say from one up to 50, or whatever limit<br />

was used, taken in an agreed jumble, as for instance beginning 19, 3, 41,<br />

22 &c. Then, the first word <strong>of</strong> the cipher would be the 19th <strong>of</strong> the genuine<br />

message, the 2nd cipher would be 3rd <strong>of</strong> message, the 3rd cipher the 41st,<br />

&c.


10.10. THE BATTLE OF THE CIVIL WAR CIPHERS 207<br />

If [the jumble] were used twice or three times, I could, by comparison &<br />

trial, probably decipher the whole business. But if the jumble were not<br />

repeated, I could never decipher it without getting another message in the<br />

same jumble in order to compare the two. ... I found one pair <strong>of</strong> words<br />

which certainly belonged together, ‘Lambs’ & ‘ferry’ – for there was a<br />

‘Lamb’s Ferry’ on the Tennessee River. But it only made the demonstration<br />

absolute that the jumble ws not repeated [and so I could not make<br />

sense <strong>of</strong> it.] I afterward found that the Federals made their jumbles by<br />

means <strong>of</strong> diagrams <strong>of</strong> row & columns, writing up & down in different orders<br />

& then taking the words across ... They also used some blind words<br />

to further confuse the cipher. This made, indeed, a most excellent cipher,<br />

quick & easy, both to write & to decipher, which is a very great advantage.<br />

But there is one objection to it, in that it required a book, & that<br />

book might get into the wrong hands.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

10.10 The Battle <strong>of</strong> the Civil War Ciphers<br />

The ciphers used during the Civil War give an interesting comparison. The<br />

North used relatively simple word transposition ciphers, which sends the plaintext,<br />

only jumbled. The South used what was thought to be the unbreakable<br />

Vigenére cipher. Why, then, did the North enjoy more success, cryptographically<br />

There are several reasons. The North’s use <strong>of</strong> meaningful word in their<br />

reduced the number <strong>of</strong> garbles, errors, while Vigenére ciphertexts, which have<br />

no context, had many more errors [<strong>Web</strong>er]. The extensive use <strong>of</strong> code words<br />

in <strong>St</strong>ager’s system generally prevented the South from getting any easy entries<br />

into a message. Conversely, the clumsy use <strong>of</strong> Vigenére (the failure to encipher<br />

the entire message, keeping word lengths) by the South gave the codebreakers<br />

<strong>of</strong> the North many clues about the message. Having a very few number <strong>of</strong> keys<br />

also contributed to the weakness <strong>of</strong> the South’s cryptography. “Judged by the<br />

standards <strong>of</strong> its own day, [<strong>St</strong>ager’s] cipher was adequate: it was not too complex<br />

to be practicable, and yet it delayed solution for a sufficient time.” [SSA2, page<br />

20].<br />

10.11 Summary<br />

Transposition Ciphers receive their security by the manner in which they mix<br />

the letters <strong>of</strong> the plaintext. There are many methods for providing this mixing;<br />

route ciphers, grilles and columnar transposition being the most famous, with<br />

the latter being by far the most popular.<br />

To perform a columnar transposition first select a keyword. Write the plaintext<br />

underneath the keyword, in as many columns as the keyword has letters.


208 CHAPTER 10. TRANSPOSITION CIPHERS<br />

To find the ciphertext pull out the columns <strong>of</strong> this array in the alphabetical<br />

order <strong>of</strong> the letters <strong>of</strong> the keyword. Deciphering is the reverse process, with the<br />

bit <strong>of</strong> complication that the length <strong>of</strong> the ciphertext and length <strong>of</strong> the keyword<br />

must first be used to determine how many letters each column contains.<br />

Recognizing transposition ciphers is easy – the frequency chart <strong>of</strong> a ciphertext<br />

appears to be that <strong>of</strong> normal English. Breaking transposition ciphers is,<br />

obviously, a matter <strong>of</strong> putting the letters back into their proper positions. For<br />

columnar transposition one first decides upon a guess <strong>of</strong> the size <strong>of</strong> the ciphertext<br />

rectangle and then creates the proposed columns <strong>of</strong> the plaintext. By knowing<br />

which letters are more likely to contact which one then proceeds by putting the<br />

columns next to their proper neighbors.<br />

The North used columnar transposition <strong>of</strong> words to great success during the<br />

Civil War. Keeping the words largely prevented Morse Code-based garbles, and<br />

the extensive use <strong>of</strong> code words, for proper names and locations, prevented the<br />

South from having any easy entry into the messages.<br />

10.12 Topics and Techniques<br />

1. From what do transposition cipher receive their security<br />

2. What is the main difference between transposition ciphers and substitution<br />

ciphers<br />

3. What is a route cipher What does its name mean<br />

4. What is a geometrical cipher<br />

5. What is a turning grille Explain how to construct one.<br />

6. Explain how to use a keyword to set up a columnar transposition.<br />

7. In a columnar transposition, how is the plaintext entered<br />

8. In a columnar transposition, how is the ciphertext removed<br />

9. Given the number <strong>of</strong> letters in the ciphertext and the length <strong>of</strong> the keyword,<br />

how are the lengths <strong>of</strong> the columns used that transposition determined<br />

10. How does one decipher a columnar transposition cipher<br />

11. How does one recognize that a cipher is a transposition<br />

12. How does one decide whether a ciphertext is from a substitution cipher or<br />

from a transposition cipher<br />

13. Explain how to break a columnar transposition ciphertext.


10.13. EXERCISES 209<br />

14. What is a double transposition Is it a better or a worse cipher than single<br />

transposition Why<br />

15. Explain the basics <strong>of</strong> the North’s system <strong>of</strong> transposition ciphers during<br />

the Civil War.<br />

16. Was <strong>St</strong>ager’s system more like route ciphers or more like columnar transposition<br />

ciphers Explain.<br />

10.13 Exercises<br />

1. Decipher the following geometric ciphers.<br />

(a) SIYEE OLYMS MLYTS ESOOE SQUAR.<br />

(b) ASNRE NDPUT SELZT RESPA UTCLP.<br />

(c) ARBHUN OSOQM IEUSA ASRE.<br />

2. Decipher the following rail fence ciphers.<br />

(a) RIRAS ALOD.<br />

(b) ABDIB BREWRE.<br />

(c) FET ECPSS NO.<br />

3. These ciphers are based on the 12, 3, 6 and 9 o’clock positions on a clock.<br />

Decipher them.<br />

(a) HORPCK TEMSERUHEOC EUATL.<br />

(b) OHHLL FRWOTELTLS WNBO.<br />

(c) HSUS URINESCO OMTED.<br />

4. Encipher the following short messages using a columnar transposition<br />

based on the given keyword.<br />

(a) let us hear from you at once concerning the jewels. Keyword<br />

jewels.<br />

(b) rft diamonds must be received by thursday morning ee. Keyword<br />

wealth.<br />

(c) rubies hidden in oatmeal containers in pantry floor. Keyword<br />

cereal.<br />

(d) sapphires were fake so was painting weve been setup flee. Keyword<br />

manetmonet.


210 CHAPTER 10. TRANSPOSITION CIPHERS<br />

5. Decipher the following short messages using columnar transposition based<br />

on the given keyword.<br />

(a) LTIAD IEEUU NRIER SRANI AEROR XEILO VACEE MTBOR VMUUT CO. Keyword<br />

SHARP.<br />

(b) SMAES LEHEH AUATN OIIYW CTCET RTAED SOOEK IHNOL MROGI ARGUB<br />

MS. Keyword OPENING.<br />

(c) BLWHS NNCTI EQTNF SEOET JEWRR EUIOT RTPSA HDUSE EDAEE XTOTH<br />

US. Keyword BROADWAY.<br />

(d) EWLMR RNIIH VOLEO CINLE RNAPD OGGTO CBWTT ESBHT POLIT BRSYT<br />

LE. Keyword QUICK.<br />

6. Decrypt the following short messages enciphered using columnar transposition<br />

on full rectangles.<br />

(a) OQYHN AGEYE LGAPE SEMIN OLTAF VTUCP HDIOE OUITR RUUEY SSU.<br />

(b) AEWFU HRSLO SOLTE RIENA QTETS NTN. Hint: nulls at end.<br />

(c) HHTHM HMETS GDESU MSRED DNDFE DPXRE ODOON ITENE EIHNX EOTHI<br />

LELND DAEOX TSTOR TELNH XIAJA RLPOT.<br />

(d) LTESU AAGEO NEORE OSAGG LWERN IGDSD TNLIA TRIMD ODLLR OOTND<br />

GPNE.<br />

7. [Hitt, pages 31–33] Since the ciphertext <strong>of</strong> transposition ciphers consist <strong>of</strong><br />

the same letters as the plaintext, knowledge <strong>of</strong> cribs – words suspected <strong>of</strong><br />

appearing in the plaintext – is especially helpful. Break the following 108<br />

letter transposition cipher in which the word villa appears.<br />

HIIGF TNGHI NTCVN IEIOT CYIFY LHAEA ESNBA EEEEN RWGBN YDELR OAESG<br />

RNEBO VNLDA ICAOA LCNDT IRGVA CDOIE SEREC DVPEI AFIFL RINEH ETT<br />

8. [HITT, pages 34-35] A weak form <strong>of</strong> double transposition uses two keywords<br />

in the following way. As usual, put the plaintext into a rectangle<br />

under the (first) keyword. The put the (second) keyword alongside the<br />

first column. Mix the plaintext by reordering the columns according the<br />

first keyword and then reordering the rows according to the second keyword.<br />

For example, to encipher radios may now be used xx with keywords<br />

S I G N S<br />

S r a d i o<br />

SIGNS and SEND, first set up the rectangle E s m a y n<br />

N o w b e u<br />

D s e d x x<br />

The first rearrangement gives<br />

I G N S S<br />

S a d i r o<br />

E m a y s n<br />

N w b e o u<br />

D e d x s x


10.13. EXERCISES 211<br />

and the second gives<br />

I G N S S<br />

E m a y s n<br />

D e d x s x<br />

N w b e o u<br />

S a d i r o<br />

So the ciphertext is maysn edxsx wbeou adiro.<br />

The following message was enciphered using this technique. Decrypt it.<br />

Hint: The size is 7 × 10.<br />

WVGAE EGENL TFTOH TEIEF RBTSE INENG ONWRM GXIXN GOITN ROMRO ESPAL<br />

HNEAC UDNNH DERME<br />

9. [HITT PAGE 47] Hitt considers the following slightly tricky example.<br />

LT. J. B. SMITH, Royal Flying Corps, Calais, France.<br />

DACFT RRBHA MOOUE AENOI ZTIET ASMOS EOHIE YOCKF NOHOE NOUTH OMEAH<br />

NILGO OSAHU OHOUE APCHS TLNDA CFTEN INTWN BAFOH GROHT AEIOH ABRIS<br />

ODACF TRREN OSTSM AYBIS DFTEN EFAPH OSMNI ZTIEA HLILL TWSOU GDENO<br />

UTHOM EAHBH AMOOU EAYOE QISUU OLEHA DENOE NHOOQ OBBOR TSLHO BAHEO<br />

UBHOB IHTSW ENOHO PAHIH ITUAS BIHTL<br />

Graham-White<br />

Is this a transposition or substitution cipher Explain your answer.<br />

For help, here is the frequency count.<br />

22 11 5 6 23 7 3 26 16 0 1 8 7 15 37 3 2 7 14 18 11 0 3 0 3 2<br />

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<br />

10. [Plum, page 51] General Halleck wished the following cipher to be sent.<br />

Washington, 10:30am, July 15, 1863<br />

For Genl S.A. Hurlbut, Memphis:<br />

If Gen. W.T. Sherman’s movements have sufficiently occupied the<br />

enemy to render your line safe, send all the forces you can spare to<br />

Brig.-Gen. Prentiss to operate on Price’s rear if he advances toward<br />

Missouri.<br />

H.W. Halleck, Maj.-Gen’l.<br />

His clerk, T. T. Eckert, chose McClellan as the indicator. This specifies<br />

the codewords specified in Figure 10.4.<br />

The message is to be pulled <strong>of</strong>f by first starting at the bottom right-hand<br />

corner and moving up the diagonal, followed by D1, U6, D2, U5, D3, U4.<br />

In addition, there is be a null added after every six words. That is, after<br />

the diagonal, after D1, after U6, after D2, etc..<br />

Please encipher the message.


212 CHAPTER 10. TRANSPOSITION CIPHERS<br />

Plain<br />

Hurlbut<br />

Sherman<br />

movements<br />

enemy<br />

Prentiss<br />

Price<br />

rear<br />

advances<br />

Missouri<br />

10:30am<br />

Halleck<br />

Code<br />

bear<br />

Blubber<br />

zebras<br />

wiley<br />

valley<br />

query<br />

world<br />

wafers<br />

chorus<br />

Clara<br />

applause<br />

Figure 10.4: Codewords for keyword McClellan.<br />

11. Cipher No. 7 was used early in the Civil War.<br />

To Louisville, Ky. Sept 29, 1862<br />

Colonel Anson <strong>St</strong>ager, Washington 16<br />

Austria await I in over to requiring orders olden rapture blissful for<br />

your instant command turned and instructions and rough looking further<br />

shall further the Camden me <strong>of</strong> ocean September poker twenty I<br />

the to I command obedience repair orders quickly pretty Indianapolis<br />

your him accordingly my fourth received 1862 wounded nine have<br />

twenty turn have to to to alvord hasty.<br />

(signed) William H. Drake<br />

The keyword Austria indicates that this has nine lines, and is to be read<br />

U1, D6, U2, D3, U5, D4. The only codeword in this message is “Camden,”<br />

Major General G. H. Thomas. By this time <strong>St</strong>ager had regularized the<br />

location <strong>of</strong> the blind words: always insert one at the end <strong>of</strong> a column being<br />

pulled <strong>of</strong>f.<br />

Decipher the message.<br />

12. [Antonucci] <strong>St</strong>ager’s Cipher No. 12 was used from September 1862 until<br />

August 1864. It had many code words, for times <strong>of</strong> days, prominent<br />

<strong>of</strong>ficers, place names, and even commonly used words and phrases. For<br />

example, in the following message Arabia is Major General Don Carlos<br />

Buell, Adam is Major General Henry Halleck, and Lincoln is Louisville,<br />

KY.<br />

Louisville, Ky. Sept 30, 1862 To George C. Maynard, Washington<br />

Regulars ordered <strong>of</strong> my to public out suspending received 1862 spoiled<br />

thirty I dispatch command <strong>of</strong> continue <strong>of</strong> best otherwise worst Arabia<br />

my command discharge duty <strong>of</strong> my last for Lincoln September period<br />

your from sense shall duties the until Seward ability to the I a removal<br />

16 Since <strong>St</strong>ager was the head <strong>of</strong> the Military Telegraph Office in Washington, during some<br />

years most messages to Washington were sent to his name. Likewise, Drake must be the<br />

telegraph operator stationed with the commander the message is for, Major General D.C.<br />

Buell in this case.


10.13. EXERCISES 213<br />

evening Adam herald tribune.<br />

(signed) Philip Bruner<br />

This response to Exercise 11 uses the keyword Regulars to specify a<br />

rectangle <strong>of</strong> nine lines and five columns. The ordering is U4, D3, U5, D2,<br />

U1. Decipher the message. (Hint: remember that each column ends with<br />

an extra check word that is then ignored.)<br />

13. [Plum] Cipher No. 4 was the last one <strong>of</strong> the war, only going into service<br />

on March 23, 1865. By now the codesheets were really code books. This<br />

one had 1608 codewords, many key words and routes, and even it was in<br />

code. Page seven in its entirety is:<br />

3 7 4 2<br />

8 10 14 12<br />

13 11 9<br />

6 5 1<br />

Bedroom. 1. Lazy. — Blonde. 11. Liniment.<br />

Bedstead. 2. League. — Bloody. 12. Lion.<br />

Beverage. 3. Leather. — Bosom. 13. Liquid.<br />

Beyond. 4. Legacy. — Boy. 14. Loafer.<br />

Big. 5. Lemon. — Bread. 15. Log.<br />

Bill. 6. Lesson. — Bride. 16. Lomax.<br />

Billiards. 7. Let. — Brush. 17. Long.<br />

Bilious. 8. Library. — Bulk. 18. Lucky.<br />

Blanket. 9. Life. — Bushel. 19. Luscious.<br />

Bliss. 10. Linen. — Buxom. 20. Luxury.<br />

Words are the line indicators, only one was used (unless the message was<br />

more than 20 lines, in which case others were added.) The route was<br />

given, reading left-to-right, using only the top and bottom lines. So here<br />

the route is up the 6th, down the 3rd, up the 5th, down the 7th, up the<br />

1st, down the 4th, down the 2nd. The middle lines are only to confuse<br />

the enemy. (Remember that there is an extra word at the end <strong>of</strong> each<br />

column.)<br />

Word Code Word Code<br />

. flea, hound battle knit<br />

, ass, bat commander locust<br />

, bear, bitch corps Madrid<br />

, cat the enemy village<br />

3 Madison fight optic<br />

15th Brown fighting oppressing<br />

18 Norris in the quail<br />

60 Knox <strong>of</strong> the serenade<br />

July <strong>St</strong>eward one Harry<br />

Sunday Tyler over skeleton<br />

Couch ax night Rustle<br />

A. Lincoln Adrian relieved trammeled<br />

Meade Bunyan the river turnip<br />

Smith children signature upright<br />

Washington, D.C. Incubus


214 CHAPTER 10. TRANSPOSITION CIPHERS<br />

Washington, D.C.<br />

To A. Harper Caldwell,<br />

Cipher Operator, Army <strong>of</strong> the Potomac:<br />

Blonde bless <strong>of</strong> who no optic to get and impression I Madison square<br />

Brown cammer Toby ax the have turnip me Harry bitch rustle silk<br />

Adrian counsel locust you another only <strong>of</strong> children serenade flea Knox<br />

County for wood that awl ties get hound who was war him suicide<br />

on for was please village large bat Bunyan give sigh incubus heavy<br />

Norris on trammeled cat knit striven without if Madrid quail upright<br />

martyr <strong>St</strong>ewart man much bear since ass skeleton tell the oppressing<br />

Tyler monkey.<br />

(signed) D. Homer Bates 17<br />

Please decipher.<br />

14. (a) [Bates] In November 1862 David Homer Bates, one <strong>of</strong> Lincoln’s telegraph<br />

operators in Washinton, was worried that a Confederate operator<br />

had tapped the telegraph line leading from Washington to Major<br />

General Burnside’s location in Virginia. So rather than using one <strong>of</strong><br />

their usual cipher systems he sent the following message.<br />

Washington, D.C. November 25, 1862.<br />

BURNSIDE, Falmouth, Virginia;<br />

Can Inn Ale me withe 2 oar our Ann pas Ann me flesh ends N.V.<br />

Corn Inn out with U cud Inn heave day nest Wed roe Moore Tom<br />

Darkey hat Greek Why Hawk <strong>of</strong> Abbott Inn B Chewed I if.<br />

BATES<br />

Can you make sense <strong>of</strong> it Hint: read it backwards.<br />

(b) The same technique was used in this message from the very end <strong>of</strong><br />

the war, supposedly to conceal the news from the cipher operators<br />

who might happen to see it while relaying it to Washington.<br />

City Point, Va., 8:30 A.M., April 3, 1865<br />

TINKER, War Department:<br />

A Lincoln its in fume a in hymn to start I army treating there<br />

possible if <strong>of</strong> cut too forward pushing is He is so all Richmond aunt<br />

confide is Andy evacuated Petersburg reports Grant morning this<br />

Washington Secretary War.<br />

BECKWITH<br />

What does the message say<br />

15. On June 1, 1863 President Lincoln sent the following message<br />

GUARD ADAM THEM THEY AT WAYLAND BROWN FOR KISSING VENUS CORRE-<br />

SPONDENTS AT NEPTUNE ARE OFF NELLY TURNING UP CAN GET WHY DETAINED<br />

TRIBUNE AND TIMES RICHARDSON THE ARE ASCERTAIN AND YOU FILLS BELLY<br />

THIS IF DETAINED PLEASE ODOR OF LUDLOW COMMISSIONER<br />

17 David Homer Bates, died 1926, was from 1861–1866 a telegrapher and cipher clerk in the<br />

telegraph <strong>of</strong>fice in the old War Department Building [SSA, vol 1]. His war remembrances,<br />

Lincoln in the Telegraph Office, make for interesting reading.


10.13. EXERCISES 215<br />

Several codewords were in use: VENUS for colonel, WAYLAND for captured,<br />

ODOR for Vicksburg, NEPTUNE for Richmond, ADAM for President, NELLY for<br />

4:30pm. The message was also enciphered as a complete rectangle.<br />

With these hints (that the South didn’t have), can you decrypt the message<br />

16. Break the double transposition UELOB DARES RNIOI STOBE LIYVA APSRN<br />

TALWY ALE Hint: the word double appears in it.<br />

17. [Hassard] One <strong>of</strong> the favorite enciphering techniques during the controversy<br />

following the presidential election <strong>of</strong> 1876 was transposition ciphers<br />

on words with the important tell-tale words (people’s names, state names,<br />

etc.) being replaced by (<strong>of</strong>ten) proper nouns, usually geographical names.<br />

(In the messages below, however, the names <strong>of</strong> the states in question –<br />

Florida, Louisiana and Oregon – are un-encrypted.) Then the entire message<br />

was transposed, using words as units.<br />

Fortunately for the decrypters, there were a very large number <strong>of</strong> dispatches.<br />

A very common word was Warsaw, and a lucky guess confirmed<br />

this stood for telegram. The short ciphertext<br />

Warsaw they read all unchanged last are idiots cant situation<br />

is then fairly easily seen to read<br />

Cant read last telegram. Situation unchanged. They are all idiots.<br />

This provides the key (47296381015), meaning, take the 4th work <strong>of</strong> the<br />

plaintext, put it first in the cipher, followed by the 7th word or the plaintext,<br />

then the 2nd word, and so on.<br />

This ordering helped decrypt most messages <strong>of</strong> ten words, but not others.<br />

However, it was noticed that the telegrams always came in word lengths<br />

that were multiples <strong>of</strong> five. Perhaps each length had its own key If so,<br />

multiple anagramming on a selection <strong>of</strong> ciphers <strong>of</strong> the same length should<br />

lead to their decryption.<br />

In Figure 10.5 are five messages, written in column form, with their words<br />

numbered. Dispatch 1 has adjourned until to-morrow. The only possible<br />

noun is London, so 29, 27, 19, 28 must be part <strong>of</strong> the key. Using<br />

this order in Dispatch 2 gives us out if a. Looking at the words in Dispatch<br />

2, intend to count us out if a seems reasonable. So now the<br />

key must contain 25, 5, 10, 29, 27, 19, 28.<br />

This is an example <strong>of</strong> multiple anagramming – using a reasonable<br />

ordering <strong>of</strong> one text to help understand the ordering <strong>of</strong> another, and visa<br />

versa. Use multiple anagramming to decrypt this message.


216 CHAPTER 10. TRANSPOSITION CIPHERS<br />

Num Dispatch 1 Dispatch 2 Dispatch 3 Dispatch 4 Dispatch 5<br />

1 Me Very Figure To Rochester<br />

2 you news France situation <strong>of</strong><br />

3 do say capture prospects answer<br />

4 to Copenhagen and ans America<br />

5 did to over Africa yesterday<br />

6 to from what desperate to-day<br />

7 question can see intend understands<br />

8 when Florida answer Thames Thomas<br />

9 you you Europe soon my<br />

10 you count Moselle Europe Africa<br />

11 to much Russia report about<br />

12 morning in shall every but<br />

13 asked behe little mischief it<br />

14 want give and the first<br />

15 where what appearances Warsaw avail<br />

16 go Louisiana about in at<br />

17 supposed am best dispatch my<br />

18 this placed hope in nothing<br />

19 until if Glasgow acting Bavaria<br />

20 come mixed will this as<br />

21 to-night insure up will will<br />

22 important London keep stall Copenhagen<br />

23 and Oregon Oregon all once<br />

24 answer few America concert fear<br />

25 here intend be morning reported<br />

26 Warsawed things can parties small<br />

27 adjourned out Potomac France by<br />

28 to-morrow a behind in and<br />

29 London us Edinburgh and satisfied<br />

30 you here I received hope<br />

Figure 10.5: Five similar dispatches from 1876.<br />

18. Robert Patterson was an immigrant to the United <strong>St</strong>ates from Ireland,<br />

eventually becoming pr<strong>of</strong>essor <strong>of</strong> mathematics and vice-provost <strong>of</strong> the<br />

newly established University <strong>of</strong> Pennsylvania. At some point he made the<br />

acquaintance <strong>of</strong> Thomas Jefferson, becoming vice-president <strong>of</strong> the American<br />

Philosophical Society while Jefferson was its president. In 1805 Jefferson<br />

appointed him the Director <strong>of</strong> the US Mint.<br />

On 19 December 1801 he wrote to Jefferson<br />

“A perfect cypher should possess the following properties:<br />

1. It should be equally adapted to all languages.<br />

2. It should be easily learned & retained in memory.<br />

3. It should be written and read with facility & dispatch.


10.13. EXERCISES 217<br />

4. (which is the most essential property) It should be absolutely<br />

inscrutable to all unacquainted with the particular key or secret for<br />

decyphering<br />

Patterson believed he had discovered one method that satisfied his first<br />

three requirements and was “absolutely impossible, even for one perfectly<br />

acquainted with the general system, ever to decypher the writing <strong>of</strong> another<br />

without his key.”<br />

In the same letter he sent what we will call Patterson’s Cipher. As revised<br />

by Jefferson and himself, and slightly modified to fit our manner <strong>of</strong> doing<br />

things, the cipher works as follows.<br />

(a) Choose two keywords <strong>of</strong> the same number <strong>of</strong> letters.<br />

letters alphabetically:<br />

B e n j a m i n<br />

2 3 7 5 2 6 4 8<br />

Number the<br />

F r a n k l i n<br />

2 7 1 6 4 5 3 8<br />

(Repeated letters are thought <strong>of</strong> as occurring in a “second” alphabet.)<br />

(b) Write the message (ignoring non-alphabetic characters and spaces)<br />

in rows, using a consistent number <strong>of</strong> letters per row (the last row<br />

may have fewer).<br />

(c) Cyclically number the columns in order, with the largest number<br />

being the number <strong>of</strong> letters in the keyword.<br />

(d) Take the columns <strong>of</strong>f in the numerical order indicated by the line<br />

keyword. Before transcribing them in rows insert as many nulls as<br />

the letter keyword indicates. Add some number <strong>of</strong> nulls at the end.<br />

As Patterson further explained<br />

It will be proper that the supplementary letters used at the beginning<br />

and end <strong>of</strong> the lies, should be nearly in the same relative proportion<br />

to each other in which they occur in the cypher itself, so that no clue<br />

may be afforded for distinguishing between them and the significant<br />

letters.<br />

On calculating the number <strong>of</strong> changes, and combinations, <strong>of</strong> which the<br />

above cypher is susceptible even supposing that neither the number <strong>of</strong><br />

lines in a section, nore the number <strong>of</strong> arbitrary letters at the beginning<br />

<strong>of</strong> the lines, should ever exceed nine, it will be found to amount to<br />

upwards <strong>of</strong> ninety millions <strong>of</strong> millions ... nearly equal to the number<br />

<strong>of</strong> seconds in three millions <strong>of</strong> years! Hence I presume the utter<br />

impossibility <strong>of</strong> decyphering will be readily acknowledged.<br />

Jefferson responded on 22 March, 1802 that<br />

I have thoroughly considered your cypher, and find it is much more<br />

convenient in practice than my wheel cypher, that I am proposing it<br />

to the secretary <strong>of</strong> state for use in his <strong>of</strong>fice


218 CHAPTER 10. TRANSPOSITION CIPHERS<br />

and on 18 April 1802 that although the cypher was difficult to understand,<br />

once understood it would be “the easiest to use, the most indecypherable,<br />

and varied by a new key with the greatest facility <strong>of</strong> any one I have ever<br />

known.”<br />

Although the method did <strong>of</strong>fer splendid security, it was extremely time<br />

consuming, and there is no evidence it was ever actually used.<br />

The example given by the Franco-phile Jefferson is about the success <strong>of</strong><br />

Napoleon.<br />

w s a t a i s p a p s e v h h r n t p v n t u t a n o<br />

e a a o o b c e u t e r d h e c e b n s b s a b d e p d n o<br />

e h n o e e t h h n p a l a e r n n o t n t u t i o h<br />

n e m e y e e s a n n i h a t t o a a t i e e o n d o i<br />

r t l r c w r e h e g u r i l j n e s y d o t h d s e a r<br />

s e e o b i n l e i h t s h e e e n a e e a r t a n r m<br />

a r p e n w e e r t d t a e c e n h y a n o a b i<br />

u v c l s t i h i e d c f i n s x n a h e n y t e n r f<br />

s d t r o d i e s u a u n o s i a h r i a e h e i r p<br />

s t o e t l s o a o a d h s e t t i e u a h r d e i u y<br />

f t s h o p f c f e b e i n t r t t t e h o x e o y p u<br />

p e r t e r s p i a e e o o c k r y c f n n h t e f e y o<br />

t l r l p w r u u w i p s a t t w h h n m e n t<br />

e r r e t e a l e i w a r w s a o t d i t o f n g e<br />

w h a r c r c n t t c w i g l n e n r d h f o w s h<br />

e t t d n e e l k h o s u h a x h t j o r u i y i<br />

s a n t r h t d i w u f g e t h a t d f s l t m<br />

a d t r o d i i e g a a i w t i s t n r h e s r n c t<br />

n o n o a e i e d l i n y s y i o s e a g o d l l a n n<br />

s f t a e w t r o i w n t w a n o n x y o u r e h<br />

The keys are keylines 57328162 and keyletters 81393420. To decipher –<br />

(1) cross out the known nulls at the start <strong>of</strong> each line.<br />

(2) Number the lines using the numbers <strong>of</strong> the line key.<br />

(3) Pull out the lines in order <strong>of</strong> key, putting them into columns.<br />

(4) Read the message (the ending nulls will be clear).


Chapter 11<br />

Knapsack Ciphers<br />

Merkle had great confidence in even the single<br />

iteration knapsack system and posted a note on<br />

his <strong>of</strong>fice <strong>of</strong>fering a $100 reward to anyone who<br />

could break it. ...[After Shamir broke it,] Merkle,<br />

always one to put his money where his mouth<br />

was ... paid Shamir the $100 is prize money.<br />

... Merkle’s enthusiasm [wasn’t] dampened. He<br />

promptly raised his bet and <strong>of</strong>fered $1000 to anyone<br />

who could break a multiple iteration knapsack.<br />

It took two years, but in the end, Merkle<br />

had to pay.<br />

Whitfield Diffie<br />

The First Ten Years <strong>of</strong><br />

Public-Key Cryptography<br />

In cryptography one takes plaintext (that is easy to read) and attempts turn it<br />

into ciphertext (that is apparently hard to read). In other words, cryptography<br />

involves an easy and hard version <strong>of</strong> the same problem. There are several<br />

mathematical problems that also have both an easy version and a hard version.<br />

Can the parallel between an easy/hard math problem and the easy/hard to read<br />

text be made useful As it will turn out, yes.<br />

11.1 The Knapsack Problem<br />

One day, whilst out hiking, you discover a cave containing many gold bars.<br />

Being ethically challenged, you wish to carry out as much gold as possible.<br />

Unfortunately the owner <strong>of</strong> the gold, a dragon, will probably return soon and<br />

your backpack (knapsack) can only carry so much weight without breaking.<br />

How can you decide which gold bars to take This is the Knapsack problem.<br />

(To fit the knapsack problem into the cave-gold-dragon analogy, you can carry<br />

however much your knapsack can hold, you have time to make one trip, and,<br />

since the dragon will not the mistake <strong>of</strong> leaving his/her cave unguarded again,<br />

one trip only.)<br />

219


220 CHAPTER 11. KNAPSACK CIPHERS<br />

Example: There are 8 piles <strong>of</strong> gold bars. Every bar in a given pile weighs<br />

the same. Each in pile 1 weighs 18oz. In pile 2 each weighs 29oz. Pile 3: 34oz,<br />

Pile 4: 41oz, Pile 5: 67oz, Pile 6: 88oz, Pile 7: 101oz and Pile 8: 119oz. Your<br />

backpack can carry a maximum <strong>of</strong> 300 oz (about 19 lbs). Which bars and how<br />

many should you pick 1<br />

⋄<br />

11.2 A Related Knapsack Problem<br />

An apparent simplification is to assume the cave contains exactly one bar <strong>of</strong><br />

any particular weight. So you only need to decide “yes” or “no” to each bar,<br />

rather than deciding how many bars from each pile to take. We also modify the<br />

problem to demand an exact amount <strong>of</strong> gold.<br />

Examples:<br />

(1) The weights <strong>of</strong> the bars are 4, 7, 12, 19, 22, and 25 lbs. If the total amount<br />

demanded is 55 lbs., this weight can be supplied: 4 + 7 + 19 + 25 = 55.<br />

However, there is no way to choose bars <strong>of</strong> total weight exactly 50 pounds.<br />

(2) The weights <strong>of</strong> the bars are 27, 31, 41, 48, 55, 59, 62, 65, 73, and 77. Total<br />

amount wanted is 257. Is this weight possible What about 364 2<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

This problem may seem easier than the first, but it is still quite hard. Why<br />

Think <strong>of</strong> the number <strong>of</strong> possibilities that must be considered. For each bar we<br />

must decide whether we want it or not:<br />

For one weight, say 27 lbs.: Do we want it yes or no (2 = 2 1 choices).<br />

For 27 and 31: yes/no and yes/no, or yy, yn, ny or nn (4 = 2 2 choices).<br />

For 27, 31, and 41: y/n and y/n and y/n gives yyy, yyn, yny, nyy, ynn,<br />

nyn, nny, and nnn (8 = 2 3 choices).<br />

By the time we have 5 weights we must make 2 5 = 32 choices, 8 weights demand<br />

2 8 = 256, and 10 weights, as in the last example, leads to 2 10 = 1024<br />

possibilities, too many for a quick answer if checking by hand. In fact, if there<br />

were 100 bars to choose from (a moderately rich dragon, in other words), there<br />

would be<br />

2 100 ≈ 1, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000<br />

1 I can make 295 as 2 × 18 + 2 × 34 + 3 × 41 + 67. Can you do better<br />

2 255 is possible (in seven different ways!) but 364 is not.


11.3. AN EASY KNAPSACK PROBLEM 221<br />

possible choices, far too many to check even by computer. And maybe none <strong>of</strong><br />

them give the correct total anyway!! This is a real needle-in-a-haystack problem:<br />

there are lots <strong>of</strong> easily found potential answers, it is simple to determine whether<br />

a potential solution is indeed correct, but there is no apparent way to focus in<br />

on a solution except to try all the possibilities.<br />

11.3 An Easy Knapsack Problem<br />

We have now seen a “hard” mathematical problem. What is the easy version<br />

Assume the numbers (or weights) are super-increasing, which means that<br />

when put into increasing order, the next number on the list is always larger<br />

than the sum <strong>of</strong> all the previous ones.<br />

Example: Numbers are 2, 3, 6, 13, 27, and 55.<br />

3 > 2<br />

6 > 5 = 2 + 3<br />

13 > 11 = 2 + 3 + 6<br />

27 > 24 = 2 + 3 + 6 + 13<br />

55 > 51 = 2 + 3 + 6 + 13 + 27.<br />

So these numbers form a super-increasing set <strong>of</strong> numbers.<br />

⋄<br />

Why does the numbers being super-increasing make the knapsack problem<br />

easy Because now the greedy algorithm will work – look over the bars (or<br />

weights, or numbers), starting with the largest and work toward the smallest,<br />

always taking the largest one that will fit into your knapsack.<br />

Examples:<br />

(1) Can the total 90 be made using {2, 3, 6, 13, 27, 55}<br />

We put the amount that is still needed in parentheses.<br />

90 = (90). <strong>St</strong>ill need 90, so we will use 55.<br />

90 = (35) + 55. Used 55, still need 35 more. So we will use 27.<br />

90 = (8) + 27 + 55. Used 27, still need 8 more. 13 > 8 so don’t use 13.<br />

90 = (8) + 27 + 55. Didn’t use 13, still need 8. Use 6.<br />

90 = (2) + 6 + 27 + 55. Used 6, still need 2. 3 > 2 so don’t use 3.<br />

90 = (2) + 6 + 27 + 55. Didn’t use 3, still need 2. Use 2.<br />

90 = 2 + 6 + 27 + 55. Done.<br />

(2) Same weights. Demand is for 77.<br />

77 = (77). Yes to 55.<br />

77 = (22) + 55. No to 27. Yes to 13<br />

77 = (9) + 13 + 55. Yes to 6.


222 CHAPTER 11. KNAPSACK CIPHERS<br />

77 = (3) + 6 + 13 + 55. Yes to 3.<br />

77 = 3 + 6 + 13 + 55. Done. Found a total that works.<br />

(3) Same weights. Demand is for 81.<br />

81 = (81). Yes to 55.<br />

81 = (26) + 55. No to 27. Yes to 13.<br />

81 = (13) + 13 + 55. Yes to 6.<br />

81 = (7) + 6 + 13 + 55. Yes to 3.<br />

81 = (4) + 3 + 6 + 13 + 55. Yes to 2.<br />

81 = (2) + 2 + 3 + 6 + 13 + 55.<br />

Done. We didn’t find a total that was correct, and since we can only use<br />

each weight once, this means there is no solution.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

In general, when the numbers or weights are super-increasing, the greedy<br />

method will find a solution when there is one, and will indicate that no solution<br />

is possible when it is impossible.<br />

Example: Weights 3, 7, 12, 24, 49, 104, and 215. Which <strong>of</strong> the totals 298,<br />

421, 358 and 311 can be found 3 ⋄<br />

Thus, if the weights are super-increasing the knapsack problem is very easy.<br />

If they are not, it can be very very difficult. Next we transform the easy knapsack<br />

problem into (apparently) a hard one.<br />

Example: Consider the five weights W 1 = 3, W 2 = 7, W 3 = 12, W 4 = 24<br />

and W 5 = 49. These are in super-increasing order and so form the weights <strong>of</strong><br />

an easy knapsack problem. For example, can these weights produce the total <strong>of</strong><br />

80 Yes: 80 = 49 + 24 + 7.<br />

Now let e = 39 and P = 101. e is our “enciphering” multiplier. If we<br />

multiply the W ’s by e modulo P we obtain new weights, U 1 through U 5 :<br />

W 1 × e = 3 × 39 ≡ 16 ≡ U 1 (mod 101)<br />

W 2 × e = 7 × 39 ≡ 71 ≡ U 2 (mod 101)<br />

W 3 × e = 12 × 39 ≡ 64 ≡ U 3 (mod 101)<br />

W 4 × e = 24 × 39 ≡ 27 ≡ U 4 (mod 101)<br />

W 5 × e = 49 × 39 ≡ 93 ≡ U 5 (mod 101)<br />

The weights 16, 71, 64, 27 and 93 are not in super-increasing order! Can the<br />

total 90 (= (80 × 39)%101) be produced from them 4 We have succeeded in<br />

3 Only 298 and 358 are possible.<br />

4 Yes, but only modulo 101: 90 = (93 + 27 + 71)%101.


11.4. THE KNAPSACK CIPHER SYSTEM 223<br />

turning the easy knapsack problem into a hard one. Further, if we use the<br />

Euclidean Algorithm to solve 39 × d ≡ 1 (mod 101) for d = 57, then we can<br />

turn the hard problem back into the easy one, for then multiplying the U’s by<br />

d will give us the W ’s back.<br />

⋄<br />

This example suggests somehow using the total weight to send messages. To<br />

produce 80 we used W 2 , W 4 and W 5 , hinting at the pattern no-yes-no-yes-yes<br />

or nynyy or 01011. What can 01011 mean<br />

a = 00001 g = 00111 m = 01101 s = 10011 y = 11001<br />

b = 00010 h = 01000 n = 01110 t = 10100 z = 11010<br />

c = 00011 i = 01001 o = 01111 u = 10101<br />

d = 00100 j = 01010 p = 10000 v = 10110<br />

e = 00101 k = 01011 q = 10001 w = 10111<br />

f = 00110 l = 01100 r = 10010 x = 11000<br />

Figure 11.1: Binary Equivalents for the Alphabet<br />

11.4 The Knapsack Cipher System<br />

Many modern ciphers are built around a mathematical problem that is (hopefully)<br />

impossible to solve unless you have some special information that makes<br />

the problem very simple. One <strong>of</strong> the first was the suitably named Knapsack<br />

Cipher System. It was invented by Ralph Merkle and Martin Hellman [MH]. 5<br />

In this cipher the intractable problem is the general knapsack problem, and the<br />

simple version is the super-increasing knapsack problem. The Knapsack Cipher<br />

attempts to exploit this method for turning the simple problem into an<br />

apparently impossible one.<br />

The first four steps <strong>of</strong> the set-up we’ve already seen. The final two make<br />

this into what was then a radically new type <strong>of</strong> cipher.<br />

5 M. E. Hellman and R. C. Merkle, received U.S. Patent 4,218,582, filed October 6 1977,<br />

issued August 19 1980 for “Public Key Cryptographic Apparatus and Method.” It expired in<br />

1997.


224 CHAPTER 11. KNAPSACK CIPHERS<br />

Knapsack Cipher Setup:<br />

1. Pick a set <strong>of</strong> super-increasing numbers: W 1 , W 2 , W 3 , W 4 , W 5 and P .<br />

2. Pick e < P with gcd(P, e) = 1. Use the Euclidean Algorithm to find<br />

d such that e × d ≡ 1 (mod P ).<br />

3. Compute the U’s: U i = e × W i %P .<br />

4. Make the U’s public. Keep the W ’s, e, d and P secret.<br />

To Encipher:<br />

1. Turn each letter <strong>of</strong> the message into its binary equivalent<br />

(a 1 , a 2 , a 3 , a 4 , a 5 ).<br />

2. Use the U’s to find the enciphered number M, <strong>of</strong> each letter:<br />

To Decipher:<br />

M = a 1 · U 1 + a 2 · U 2 + a 3 · U 3 + a 4 · U 4 + a 5 · U 5 .<br />

1. For each received cipher number M, compute N = (d · M)%P .<br />

2. Solve N = x 1 · W 1 + x 2 · W 2 + x 3 · W 3 + x 4 · W 4 + x 5 · W 5 for the x’s.<br />

3. Convert (x 1 , x 2 , x 3 , x 4 , x 5 ) into its letter equivalent.<br />

Examples:<br />

(1) Use the weights U 1 = 16, U 2 = 72, U 3 = 64, U 4 = 27 and U 5 = 93 to<br />

encipher swim.<br />

s = 10011 → 1 · U 1 + 0 · U 2 + 0 · U 3 + 1 · U 4 + 1 · U 5<br />

= 16 + 27 + 93 = 136.<br />

w = 10111 → 1 · U 1 + 0 · U 2 + 1 · U 3 + 1 · U 4 + 1 · U 5<br />

= 16 + 64 + 27 + 93 = 200.<br />

i = 01001 → 0 · U 1 + 1 · U 2 + 0 · U 3 + 0 · U 4 + 1 · U 5<br />

= 72 + 93 = 165.<br />

m = 01101 → 0 · U 1 + 1 · U 2 + 1 · U 3 + 0 · U 4 + 1 · U 5<br />

= 72 + 64 + 93 = 229.<br />

The ciphertext message is 136, 200, 165, 229.<br />

(2) Decipher 136, 200, 165, 229.<br />

Of course, we know the answer. But how could we find it if we didn’t<br />

already know it First, if we didn’t know e and P (the private key) but


11.4. THE KNAPSACK CIPHER SYSTEM 225<br />

did know the W ’s, we would be stuck solving a hard knapsack problem.<br />

This hints that this cipher is a good one.<br />

However, if we do know e = 39 and P = 101 we may use the Euclidean<br />

Algorithm to find that d = 57 is solution to 39 × d ≡ 1 (mod 101). Then,<br />

as in Decimation Ciphers, since multiplying by e enciphered, multiplying<br />

by d must (mostly) decipher.<br />

<strong>St</strong>arting with 136, first multiply by d: (d × 136 = 57 × 136)%101 = 76.<br />

Then write 76 as a sum <strong>of</strong> the original W ’s:<br />

76 = 3 + 24 + 49<br />

= 1 · W 1 + 0 · W 2 + 0 · W 3 + 1 · W 4 + 1 · W 5<br />

→ 10011 = s.<br />

So 136 → s. For the other letters we do the same. First, 190 → d · 190 =<br />

(57 · 190)%101 = 88, and then<br />

88 = 3 + 12 + 24 + 49<br />

= 1 · W 1 + 0 · W 2 + 1 · W 3 + 1 · W 4 + 1 · W 5<br />

→ 10111 = w.<br />

So 88 → w. Similarly, 43 → i and 45 → m.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

This cipher system (also known as the Merkle–Hellman knapsack to differentiate<br />

it from other knapsack systems is a public key cipher. We haven’t seen<br />

any public key ciphers since Section 3.6, so let us briefly remind ourselves <strong>of</strong> the<br />

advantage <strong>of</strong> such a cipher. Each person who wishes to be part <strong>of</strong> a conversation<br />

may compute and make public a set <strong>of</strong> U’s, as in the Knapsack Cipher Setup.<br />

As we will see, this allows anyone to send them a secret message, even though<br />

they have never before communicated. There is no need to somehow pass a<br />

secret private key: just look up the person’s public key and start enciphering!<br />

Examples: Using the values W={5, 7, 15, 30, 59}, P = 179, e = 33:<br />

(1) Encipher dark cave.<br />

(2) Decipher 302, 260, 294, 157, 417, 459, 260, 294, 252, 52, 294,<br />

417, 302. 6<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Now with five weights the hard knapsack problem only has 2 5 = 32 possible<br />

answers to check, and so it is not really very hard. (In the previous example,<br />

we could have determined that 136 consisted <strong>of</strong> U 1 , U 4 and U 5 with only a little<br />

6 (1) 137, 157, 260, 304, 252, 157, 397, 294. (2) treasure chest.


226 CHAPTER 11. KNAPSACK CIPHERS<br />

trial-and-error.) But it is easy to use the Knapsack System as a polygraphic<br />

cipher.<br />

Examples:<br />

(1) Use the weights {3, 4, 7, 15, 30, 47, 93, 279, 466, 749}, and the values e =<br />

211 and P = 1507 to encipher swim as pairs <strong>of</strong> letters.<br />

First, we compute the U’s:<br />

U 1 = (3 · 211)%1507 = 633<br />

U 2 = (4 · 211)%1507 = 844<br />

U 3 = (7 · 211)%1507 = 1477<br />

U 4 = (15 · 211)%1507 = 151<br />

U 5 = (30 · 211)%1507 = 302<br />

U 6 = (47 · 211)%1507 = 875<br />

U 7 = (93 · 211)%1507 = 32<br />

U 8 = (279 · 211)%1507 = 96<br />

U 9 = (466 · 211)%1507 = 371<br />

U 10 = (749 · 211)%1507 = 1311<br />

Then we encipher as before, just with more weights:<br />

sw = {10011}{10111} = 1001110111<br />

→ 1 · U 1 + 1 · U 4 + 1 · U 5 + 1 · U 6 + 1 · U 8 + 1 · U 9 + 1 · U 10<br />

= 633 + 151 + 302 + 875 + 96 + 371 + 1311<br />

= 3739<br />

Similarly, im becomes 2585.<br />

(2) Decipher 2585.<br />

We first need the deciphering number. From the Euclidean algorithm<br />

d = 50 is the solution to (d × 211)%1507 = 1. Next, 2585 becomes<br />

(d × 2585)%1507 = 1155. Finally, write 1155 as a sum <strong>of</strong> the original<br />

weights:<br />

1155 = 4 + 30 + 93 + 279 + 749<br />

= U 2 + U 5 + U 7 + U 8 + U + 10<br />

= 0100101101 = {01001}{01101}<br />

→ im<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄


11.5. PUBLIC KEY CIPHER 227<br />

Even with 10 weights our adversary needs to check at most 2 10 = 1024<br />

possible combinations to determine each piece <strong>of</strong> plaintext, long by hand but<br />

quick by computer. Suppose, however, we used 100 weights. We could then<br />

encipher and decipher 20 = 100/5 letters at a time. Further, once we have<br />

computed the disguised weights, each block <strong>of</strong> 20 letters is enciphered with<br />

only 20 quick additions. Likewise, deciphering involves only one modular multiplication<br />

and then a quick greedy algorithm, per block <strong>of</strong> letters. So enciphering<br />

and deciphering are very quick. On the other hand, there are 2 100 =<br />

1267650600228229401496703205376 ways for the 100 weights to be combined.<br />

Even with the use <strong>of</strong> a a supercomputer, our adversary will be unable to determine<br />

the meanings <strong>of</strong> the blocks <strong>of</strong> letters by brute force.<br />

11.5 Public Key Cipher<br />

This is our first real example <strong>of</strong> a Public Key Cipher. 7 Modern companies<br />

and governments must strive to overcome not only the breakability <strong>of</strong> their ciphersystems<br />

but also the key-management problem: there are just too many<br />

people and to whom they’d like to send messages that doing all <strong>of</strong> (1) meeting<br />

with everyone who you’d like to send messages to and agreeing upon a ciphersystem<br />

and a private key, (2) keeping all <strong>of</strong> that information very secret (so no<br />

one who shouldn’t learns it), and (3) keeping all that information easily accessible<br />

(so you can send messages back and forth), is very difficult. “It’d sure<br />

be nice”, someone thought one day, “if there was a secret message system that<br />

worked just like the phone book: you just look up someone’s cipher information<br />

and send them a message.” 8 It seems contradictory, making public the very<br />

information used to send secret messages. But if it were possible, difficulties (1)<br />

and (3) would vanish. 9<br />

The knapsack cipher method was the first example that seemed plausible<br />

to use. Once everyone made their U’s public, anyone could send anyone else a<br />

message and the only items needed to be kept secret were the individual’s W ’s,<br />

e, d and P .<br />

Unfortunately, what made this method into a viable method didn’t work.<br />

Multiplying by e is meant to destroy the super-increasing nature <strong>of</strong> the W ’s<br />

but doesn’t completely do it. Using some fancy Linear Algebra [Shamir] it is<br />

possible to recover the original weights even without knowing e, d or P . The<br />

knapsack ciphers seemed the wave <strong>of</strong> the future, but suddenly became merely<br />

an interesting relic from the past.<br />

7 In Chapter 3 we discussed Koblitz’s Kid-RSA. It is only a toy system, never used. The<br />

Knapsack Ciphers, however, were (nearly) very important.<br />

8 The someones were Martin Hellman, a <strong>St</strong>anford pr<strong>of</strong>essor <strong>of</strong> Electrical Engineering, and<br />

Whitfield Diffie, then (1976) an undergraduate.<br />

9 As a very simple example (due to Saloma), think <strong>of</strong> a telephone book. To call someone<br />

on the phone all you need to know is their name: their telephone number you can always look<br />

up. Similarly, once you’ve gotten a telephone number anyone, including people you’ve never<br />

met, can call you up.


228 CHAPTER 11. KNAPSACK CIPHERS<br />

11.6 Summary<br />

In the past 25 years it has become fashionable to take “intractable” mathematical<br />

problems and try to turn them into cryptosystems. One <strong>of</strong> the first examples<br />

<strong>of</strong> a problem put to such use was the Knapsack Problem. In its full generality<br />

(from a large set <strong>of</strong> items choose some subset that maximizes value while<br />

keeping the total weight under some given bound) the Knapsack Problem, also<br />

known as the Subset Sum Problem, is known to be such an intractable problem.<br />

In 1977 Merkle and Hellman announced a cipher system based on a version<br />

<strong>of</strong> the Knapsack problem. It had the advantage <strong>of</strong> being a public key system,<br />

plus was relatively fast. This system starts with a set <strong>of</strong> super-increasing weights<br />

(each successive weight is larger than the sum <strong>of</strong> all the previously chosen ones).<br />

After a modular multiplication (and a permutation <strong>of</strong> their order) the weights<br />

are made public. To send a binary message send the sum <strong>of</strong> the weights corresponding<br />

to the 1’s in the message. The creator <strong>of</strong> the system can undo the<br />

modular multiplication, and so to read the message needs only to solve the<br />

sum-subset problem for a super-increasing set, which is easy.<br />

It was quickly suspected that hiding the super-increasing nature <strong>of</strong> the<br />

weights by a modular multiplication and permutation was not really sufficient,<br />

and this proved to be the case. By 1984 most forms <strong>of</strong> the Knapsack Ciphers<br />

had been shown to be insecure. Nonetheless, they provide a lovely case study<br />

<strong>of</strong> a modern cryptosystem.<br />

11.7 Topics and Techniques<br />

1. What is the general Knapsack Problem What is the meaning <strong>of</strong> “knapsack”<br />

in the name<br />

2. What is super-increasing<br />

3. Why is a Knapsack Problem with super-increasing weights easy to solve<br />

How to solve it<br />

4. How can a set <strong>of</strong> super-increasing weights be modified into a set <strong>of</strong> not<br />

super-increasing weights<br />

5. Explain the setup <strong>of</strong> a Knapsack Cipher.<br />

6. How does a Knapsack Cipher encipher What steps are involved<br />

11.8 Exercises<br />

1. Given the weights 41, 28, 39, 57, 49 and 31, and being allowed to use them<br />

possibly multiple times, can the weight 782 be achieved, and how


11.8. EXERCISES 229<br />

2. Given the weights 63, 39, 81, 57, 48 and 30, and being allowed to use them<br />

possibly multiple times, can the weight 283 be achieved. If so, how<br />

3. Given the weights 3, 7, 12, 23, 47, 95 and 190, and using each weight<br />

at most once, which <strong>of</strong> the following amounts can be realized, and how<br />

T = 323, T = 310, T = 117, T = 270.<br />

4. Given the weights 3, 8, 13, 29 and 60, and P = 129, e = 10:<br />

(a) Encipher gold.<br />

(b) Decipher 32, 84, 62, 146.<br />

5. Given the weights are 5, 8, 14, 29 and 58, and P = 127, e = 17. Decipher<br />

111, 70, 97, 66, 75, 105.<br />

6. Given the weights 6, 8, 17, 35, 81, 200, 403, 800, 1589, 3223 and e = 322,<br />

P = 6551:<br />

(a) Find the corresponding U’s.<br />

(b) Encipher stalactite.<br />

(c) Decipher 20632, 13837, 11968, 22524, 12265.<br />

the next word in the dictionary.<br />

Hint: it’s <strong>of</strong>ten<br />

7. [Hellman] Hellman’s 1979 Scientific American article, The Mathematics <strong>of</strong><br />

Public-Key Cryptography, was one <strong>of</strong> the very first public announcement<br />

<strong>of</strong> this new kind <strong>of</strong> cipher. Included in this article is an overview <strong>of</strong> public<br />

vs. private key, and an introduction to the Knapsack Ciphers and RSA.<br />

Here we look at his knapsack example.<br />

(a) Show that 3, 5, 11, 20, 41, 83, 169, 340, 679, 1358 forms a superincreasing<br />

sequence.<br />

(b) Use P = 2731 and e = 764 to find the corresponding U ′ s.<br />

(c) Hellman’s sample message was enciphered as pairs <strong>of</strong> letters (we<br />

have 10 weights), with the binary starting at 00000, so a=00000<br />

and z=11001. He also used the binary equivalent for 26 to represent<br />

a space, and 29 to represent .<br />

Encipher Hellman’s message: How are you.<br />

(d) Find d.<br />

(e) Decipher 2908, 7643, 9799.<br />

8. The public key codes tend to be slower on a computer than the traditional<br />

“private key” codes are. So they are most frequently used only to send<br />

the key for a traditional method.<br />

Decipher DNTFG EASCN HAFAO NNSBH SIOAI HEPTA CBROE EGFSR RBTGE<br />

ISIOT LAIEM C. It was enciphered using the double transposition method<br />

with keyword 94, 240, 155, 46, 197, 188, 151, 131.<br />

Hint: the W’s are 2, 7, 13, 31, 55, with P = 157 and e = 23.


230 CHAPTER 11. KNAPSACK CIPHERS<br />

9. A different way to hide the super-increasing nature <strong>of</strong> the weights would<br />

be to put the “superincreasingness” inside the numbers. For example<br />

W 1 = 2900104<br />

W 2 = 3200209<br />

W 3 = 5500401<br />

W 4 = 1300810<br />

W 5 = 2401604.<br />

(The boldness only serves to show where the super-increasing is hidden.)<br />

The modulus would be correspondingly large, say P = 200785471.<br />

(a) Use e = 41233 to find the corresponding U’s.<br />

(b) Encipher huge.<br />

(c) Which <strong>of</strong> the following may be written as a sum <strong>of</strong> the W ’s<br />

a) 36902109 b) 33501123 c) 10001420 d) 9705114 (Hint: only<br />

three digits really matter. Which three.<br />

(d) Decipher 195046101, 76263779, 175978897, 160072206.


Chapter 12<br />

RSA<br />

Take two large prime numbers, q and p.<br />

Find the product n, and the totient φ.<br />

If e and φ have GCD one<br />

and d is d’s inverse, then you’re done!<br />

For sending m raised to the e reduced mod n gives<br />

secre-c.<br />

Daniel G. Treat<br />

We have now reached our final chapter. So it is natural that we have reached<br />

the more difficult and useful cipher in the book. Fortunately, our cipher also<br />

brings us back around to the beginning <strong>of</strong> the book.<br />

We started out, in Chapter 1, with the Caesar Cipher: translate letters into<br />

numbers and add three. This was too easy to decrypt, so Chapters 3 and 4 we<br />

turned to Decimation Ciphers: translate letters into numbers and multiply by<br />

three. This also turned out to be easy to decrypt. After several other stops along<br />

the way, we now complete the triple: having used addition and multiplication<br />

how about exponentiation<br />

Example: Encipher power by raising to the 3-rd power modulo 26.<br />

plaintext p o w e r<br />

plainnumbers 16 15 23 5 18<br />

cubed 4096 2275 12167 125 5832<br />

ciphernumbers %26 14 13 25 21 8<br />

ciphertext N M Y U H<br />

The ciphertext is NMYUH<br />

⋄<br />

231


232 CHAPTER 12. RSA<br />

At this point in discussing a new cipher there are always two questions we<br />

ask: “How to decipher” and, “What is the security” Answering the first, if<br />

you think about it for a bit, will be difficult. To undo cubing we must take the<br />

cube root, But what we want to take the cube root <strong>of</strong> is not the ciphernumber<br />

but the cube <strong>of</strong> the plainnumber. So we have the problem <strong>of</strong> trying to determine<br />

the cubed plainnumber from the ciphernumber.<br />

As for the security, just as always adding 3 or always multiplying by 3 is<br />

insecure, always raising to the 3rd power is insecure. We should choose as our<br />

key some integer to take powers with. And large integers would have to be<br />

a possibility if we are to prevent the enemy from simply trying each possible<br />

power. But this leads to a new problem: what letter does the power 33 encipher<br />

S to<br />

19 33 = 1580770532156861979997149793605296459437459<br />

consists <strong>of</strong> 42 digits, and so is far too big for a calculator to handle. Similarly,<br />

19 125 has 159 digits, and 125 is not a very large number. Or how can we<br />

determine the remainder when 26 divides 19 392 , a number <strong>of</strong> over 500 digits!<br />

There is a third, more devious, problem. 1 3 = 1 so a is enciphered to A,<br />

but 3 3 = 27 ≡ 1 (mod 26) so c is also enciphered to A. Similarly, d and f both<br />

become L. Why is this, and how can we prevent this<br />

Despite these difficulties, the idea <strong>of</strong> developing a cryptosystem around the<br />

raising <strong>of</strong> numbers to powers is a very good one. It will lead us to one <strong>of</strong> the<br />

most popular cryptosystem <strong>of</strong> all time. But before we get there we need to<br />

surmount the difficulties we’ve just discussed.<br />

12.1 Fermat’s Theorem<br />

Our first need is to learn how to compute values like 133 719 %101. As you know,<br />

the “mod” just is shorthand for “find the remainder when divided by”, so in<br />

some sense we are not learning anything new. All one has to do is to compute<br />

133 719 , divide by 101, and find the remainder. However, 133 719 is galactically<br />

far too large for you calculator to directly compute. 1 How then to do this<br />

Some help is provided by a 360 year-old theorem.<br />

Theorem 3 Fermat’s Little Theorem 2 (1640). If p is a prime number and<br />

p does not divide a, then a p−1 ≡ 1 (mod p).<br />

1 It has over 1500 digits in it. For comparison, the traditional estimate for the number <strong>of</strong><br />

elementary particles in the universe is 10 80 , i.e., a number <strong>of</strong> 80 digits.<br />

2 Pierre (de) Fermat, 1601-1665, was one <strong>of</strong> the last truly great amateur mathematicians.<br />

During the day he was a lawyer/councilor for his local parliament. At night he read famous<br />

math books and added his thoughts and comments to the margins. It took over 350 years<br />

before one <strong>of</strong> these notes, Fermat’s Last Theorem, was determined to actually be true. Another,<br />

Fermat’s Little Theorem (to differentiate it from the Last Theorem) is what interests<br />

us here.


12.1. FERMAT’S THEOREM 233<br />

Example: Since 13 is prime and doesn’t divide 5, we have (5 12 )%13 = 1.<br />

Similarly, 37 and 101 are primes, and they don’t divide 52 and 133, respectively,<br />

so (52 36 )%37 = 1, and (133 100 )%101 = 1.<br />

⋄<br />

This is a beautiful, deep and powerful theorem. The beauty lies in its simplicity:<br />

Choose any prime number and any other number that is not a multiple<br />

<strong>of</strong> that prime. Then, the second number, when raised to the prime minus first<br />

power, will be one less than a multiple <strong>of</strong> the prime. In other words, the remainder<br />

upon division is always 1. No special conditions, no separate cases, just a<br />

1.<br />

OK, there is one condition: that p doesn’t divide the number. But if p<br />

does divide a, then a ≡ 0 (mod p) so a p−1 ≡ 0 (mod p). Thus, we perfectly<br />

understand a p−1 %p for all a’s: If a is a multiple <strong>of</strong> p then the answer is 0,<br />

otherwise it is 1.<br />

Since 1 ∗ a ≡ a (mod p) we may multiply a p−1 ≡ 1 by a to see that a p ≡ a<br />

(mod p) when a is not a multiple <strong>of</strong> p. And, since both sides <strong>of</strong> this equivalence<br />

are 0 when a is a multiple <strong>of</strong> p we have the following corollary:<br />

Corollary 1 If p is a prime number and a is any integer, then a p ≡ a (mod p).<br />

The depth <strong>of</strong> this theorem is what it tells us about arithmetic. One might<br />

think that raising integers to powers leads to somewhat arbitrary results. But<br />

Fermat’s Theorem says otherwise: raising to powers modulo a prime number<br />

produces a definite structure. 3<br />

The power <strong>of</strong> the theorem lies our application <strong>of</strong> it. Suppose we wish to<br />

compute 33 125 %41. Since 41 does not divide 33, by Fermat’s Theorem we<br />

know that 33 40 ≡ 1 (mod 41). So ( 33 40) 2<br />

≡ 1 2 ≡ 1 (mod 41) and, likewise,<br />

( ) 33<br />

40 3<br />

≡ 1 3 ≡ 1 (mod 41). Because 125 = 3 ∗ 40 + 5, we then have<br />

33 125 = 33 3∗40+5 = 33 3∗40 · 33 5 = ( 33 40) 3<br />

· 33 5 ≡ 1 3 · 33 5 ≡ 33 5 (mod 41).<br />

So 33 125 is the same as 33 5 modulo 41. Because 33 5 %41 = 32 is small enough to<br />

compute on a calculator, we conclude that 33 125 %41 = 32. Fermat’s Theorem<br />

has turned the seemingly impossible 33 125 (mod 41) into a calculation that is<br />

easy.<br />

Example: Compute 20 236 %59.<br />

Since 59 − 1 = 58 and 236 = 4 ∗ 58 + 4, we have 20 236 = 20 4∗58+4 =<br />

20 4∗58 · 20 4 = ( 20 58) 4<br />

· 20 4 ≡ 1 4 · 20 4 ≡ 20 4 ≡ 51 (mod 59). ⋄<br />

3 In fact, it can be said that Fermat’s Little Theorem is the first important result in the<br />

subject <strong>of</strong> Abstract Algebra, a subject that, along with Analysis, constitutes most <strong>of</strong> modern<br />

mathematics.


234 CHAPTER 12. RSA<br />

In both <strong>of</strong> these examples the quotient played an insignificant role. What,<br />

then, <strong>of</strong> the old exponent remains The remainder. Both 125 and 236 were<br />

replaced by their remainder when divided by p − 1. But “replacing by the<br />

remainder” is just another way <strong>of</strong> saying that we are doing modular arithmetic!<br />

We can summarize this as the following:<br />

Theorem 4 Fermat’s Theorem Restated: If p is a prime number and p does<br />

not divide a, then a b ≡ a b′ (mod p), where b%(p − 1) = b ′ .<br />

Less formally, when doing powers modulo p, we may work on the exponent<br />

modulo p − 1.<br />

Examples:<br />

(1) Compute 6 191 %19.<br />

Since 19 doesn’t divide 6 we can use Fermat’s theorem. Since 191%18 =<br />

11, we know that 6 191 ≡ 6 11 (mod 19). This last is easily computed to be<br />

17, which is our answer.<br />

(2) Compute 12 360 (mod 17).<br />

17 doesn’t divide 12, and 360%16 = 8, so 12 360 ≡ 12 8 ≡ 15 (mod 17). So<br />

the answer is 15.<br />

(3) Compute 23 465 (mod 43).<br />

23 465 ≡ 23 3 ≡ 41 (mod 43). The answer is 41.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

12.2 Complication I: a small one<br />

The examples we’ve done were carefully chosen so that we ended up with a fairly<br />

small number raised to a fairly small number. What if the base was too large for<br />

a calculator to handle this computation For example, what if we wanted 233 125<br />

(mod 41) By Fermat’s Theorem this is the same as 233 5 (mod 41). But 233 5<br />

is still too large for most calculators. What can we do Easy: we are doing<br />

modular arithmetic, and 233%41 = 28. We then have the string <strong>of</strong> equivalences<br />

233 125 ≡ 233 5 ≡ 28 5 ≡ 3 (mod 41).<br />

We are now doing “double modular arithmetic”, modulo p on the base and<br />

modulo p − 1 on the exponent.


12.3. COMPLICATION II: A SUBSTANTIAL ONE 235<br />

Examples:<br />

(1) Compute 130 97 %31.<br />

First, 130%31 = 6. Next, 97%30 = 7. Putting them together we have<br />

130 97 ≡ 6 7 ≡ 6 (mod 31). The answer is 6.<br />

(2) Compute 220 136 %67.<br />

220%67 = 19 and 136%66 = 4. So 220 136 ≡ 19 4 ≡ 6 (mod 67).<br />

(3) Compute 5891 213 %53.<br />

5891%53 = 8 and 213%52 = 5. So 5891 212 ≡ 8 5 ≡ 14 (mod 53).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

12.3 Complication II: a substantial one<br />

The examples we have seen have been carefully chosen so that after (at most)<br />

two reductions we end up with a small base and small exponent. What if even<br />

after both <strong>of</strong> the reduction steps are taken the numbers are still too big<br />

Examples:<br />

(1) Compute 13 27 %37.<br />

13 is already reduced modulo 37, as is 27 modulo 36. But 13 27 has some<br />

38 digits in it, far too many to work with.<br />

Now what Clearly 27 = 16 + 8 + 2 + 1. So 13 27 = 13 16+8+2+1 =<br />

13 16 · 13 8 · 13 2 · 13. Several <strong>of</strong> these powers are small and computable but<br />

13 16 is too big. To find it we start with the smaller powers.<br />

Of course 13 ≡ 13 (mod 37) and 13 2 ≡ 21 (mod 37).<br />

Next, instead <strong>of</strong> directly computing 13 4 , we use that 13 4<br />

13 4 ≡ (13 2 ) 2 ≡ 21 2 ≡ 34 (mod 37).<br />

= (13 2 ) 2 , so<br />

Similarly, 13 8 ≡ (13 4 ) 2 ≡ 34 2 ≡ 9 (mod 37). Finally, 13 16 ≡ (13 8 ) 2 ≡<br />

9 2 ≡ 7 (mod 37).<br />

The last step is to put it all together: 13 27 = 13 16 · 13 8 · 13 2 · 13 ≡<br />

7 · 9 · 21 · 13 ≡ 31. So the final answer is 31.


236 CHAPTER 12. RSA<br />

(2) Compute 22 57 %61 (with fewer explanations).<br />

We have 57 = 32 + 16 + 8 + 1. Computing the powers,<br />

22 2 ≡ 15 (mod 61),<br />

22 4 = (22 2 ) 2 ≡ 15 2 ≡ 42 (mod 61),<br />

22 8 = (22 4 ) 2 ≡ (42) 2 ≡ 56 (mod 61),<br />

22 16 = (22 8 ) 2 ≡ (56) 2 ≡ 25 (mod 61), and<br />

22 32 = (22 16 ) 2 ≡ (25) 2 ≡ 15 (mod 61).<br />

Using the powers that we need gives<br />

22 57 = 22 32 · 22 16 · 22 8 · 22 ≡ 15 · 25 · 56 · 22 ≡ 47 (mod 61).<br />

Therefore 22 57 %61 = 47.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

In each <strong>of</strong> these examples we broke down the exponent into a sum <strong>of</strong> power<br />

<strong>of</strong> 2. 4 To make this process easier we need to find a way <strong>of</strong> determining which<br />

powers <strong>of</strong> 2 are needed. A simple on is as follows. At each step divide by 2. If<br />

this division has a remainder (the quotient has a .5 as a decimal) then indicate<br />

this with a 1, otherwise indicate this with a 0. Then repeat starting with the<br />

integer part <strong>of</strong> the quotient. End when the final quotient is .5, as it has no<br />

integer part to continue with.<br />

Examples: Find the needed powers for an exponent <strong>of</strong> 27 and 57.<br />

(1) For 27:<br />

exponent quotient remainder power <strong>of</strong> 2<br />

27 ÷2 = 13.5 1 1<br />

13 ÷2 = 6.5 1 2<br />

6 ÷2 = 3 0 4<br />

3 ÷2 = 1.5 1 8<br />

1 ÷2 = .5 1 16<br />

So 27 as a 16, 8, 2 and 1 in it (that is 27 = 16 + 8 + 2 + 1).<br />

4 Why 2 and not, say, 3 Because every number can be expressed as a sum <strong>of</strong> powers <strong>of</strong> 2,<br />

allowing us to compute 22 57 %61 by performing simply a number <strong>of</strong> squarings. If we had used<br />

3 instead we would have needed to write 57 = 2 · 27 + 3, a sum <strong>of</strong> multiples <strong>of</strong> powers <strong>of</strong> 3.<br />

Using 2 means we don’t need multiples, which makes the calculations a bit easier.


12.3. COMPLICATION II: A SUBSTANTIAL ONE 237<br />

(2) For 57:<br />

So 57 = 32 + 16 + 8 = +1.<br />

remainder power <strong>of</strong> 2<br />

57 ÷2 = 28.5 1 1<br />

28 ÷2 = 14 0 2<br />

14 ÷2 = 7 0 4<br />

7 ÷2 = 3.5 1 8<br />

3 ÷2 = 1.5 1 16<br />

1 ÷2 = .5 1 32<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

In fact, every positive integer can be written as a sum <strong>of</strong> the powers <strong>of</strong> 2: 1,<br />

2, 4, 8, ..., using each power at most once. This is the binary expansion <strong>of</strong><br />

the number, and the process we have just described finds this expansion.<br />

We can use the two processes, squaring using the powers <strong>of</strong> two, and the<br />

binary expansion process, together.<br />

Example: Find the binary expansion <strong>of</strong> 159. Use it to compute 23 159 %171.<br />

159 ÷ 2 = 79.5 1 1<br />

79 ÷ 2 = 39.54 1 2<br />

39 ÷ 2 = 19.5 1 4<br />

19 ÷ 2 = 9.5 1 8<br />

9 ÷ 2 = 4.5 1 16<br />

4 ÷ 2 = 2 0 32<br />

2 ÷ 2 = 1 0 64<br />

1 ÷ 2 = .5 1 128<br />

Thus 159 = 128 + 16 + 8 + 4 + 2 + 1. Next, compute the required powers <strong>of</strong> 23:<br />

23 ≡ 23 (mod 171),<br />

23 2 = 23 2 ≡ 16 (mod 171),<br />

23 4 = (23 2 ) 2 ≡ (16) 2 ≡ 85 (mod 171),<br />

23 8 = (23 4 ) 2 ≡ (85) 2 ≡ 43 (mod 171),<br />

23 16 = (23 8 ) 2 ≡ (43) 2 ≡ 139 (mod 171),<br />

23 32 = (23 16 ) 2 ≡ (139) 2 ≡ 169 (mod 171),<br />

23 64 = (23 32 ) 2 ≡ (169) 2 ≡ 4 (mod 171), and<br />

23 128 = (23 64 ) 2 ≡ (4) 2 ≡ 16 (mod 171).<br />

Using the powers that we need gives<br />

23 159 = 23 128 · 23 16 · 23 8 · 23 4 · 23 2 · 23 ≡ 16 · 43 · 85 · 16 · 23 ≡ 163 (mod 171).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄


238 CHAPTER 12. RSA<br />

Neither <strong>of</strong> these processes is very hard, but each is a bit time-consuming,<br />

especially because there are several things we wrote again and again, like ÷2<br />

and (mod 171). Fortunately, we can combine the two steps and cut out much<br />

<strong>of</strong> the unnecessary writing. As a first example we redo the previous one.<br />

Example: Compute 23 159 %171.<br />

exponent quotient remainder power <strong>of</strong> 2 modulo 171<br />

159 ÷2 79.5 1 1 23 ≡ 23<br />

79 ÷2 39.54 1 2 23 2 ≡ 16<br />

39 ÷2 19.5 1 4 16 2 ≡ 85<br />

19 ÷2 9.5 1 8 85 2 ≡ 43<br />

9 ÷2 4.5 1 16 43 2 ≡ 139<br />

4 ÷2 2 0 32 139 2 ≡ 169<br />

2 ÷2 1 0 64 169 2 ≡ 4<br />

1 ÷2 .5 1 128 4 2 ≡ 16<br />

Thus 23 159 ≡ 16 · 43 · 85 · 16 · 23 ≡ 163 (mod 171).<br />

⋄<br />

From now on we will abbreviate by not writing the “÷2 =” or “power”<br />

columns. 5<br />

Example: Compute 45 61 %79.<br />

First, 45 < 79 and 61 < 70 so the base and the power are already reduced.<br />

Since 45 61 is far too big we must build we will call the binary chart.<br />

exponent quotient remainder mod 79<br />

61 30.5 1 45 ≡ 45<br />

30 15 0 45 2 ≡ 50<br />

15 7.5 1 50 2 ≡ 51<br />

7 3.5 1 51 2 ≡ 73<br />

3 1.5 1 73 3 ≡ 36<br />

1 .5 1 36 2 ≡ 32<br />

Thus 45 61 ≡ 45 · 51 · 73 · 36 · 32 ≡ 2 (mod 79).<br />

⋄<br />

12.4 Complication III: a mini one<br />

The computation we just did, 45 · 51 · 73 · 36 · 32 ≡ 2 (mod 79), almost is too<br />

much for many calculators. It certainly can happen that the final computation’s<br />

product is too big. Then what If there are too many factors, or if they are too<br />

5 In fact, one <strong>of</strong> the interesting results <strong>of</strong> this method is that we don’t need to explicitly<br />

find the proper powers <strong>of</strong> 2.


12.5. COMPLICATION IV: THE LAST ONE 239<br />

large to multiply together all at once, simply group them into a families <strong>of</strong> two<br />

or three, multiply and reduce them, and then multiply and reduce the results.<br />

Example: Compute 372 · 361 · 19 · 281 · 107 · 81 · 239 · 301 (mod 401)<br />

372 · 361 · 19 · 281 · 107 · 81 · 239 · 301 (mod 401)<br />

≡ (372 · 361 · 19) · (281 · 107 · 81) · (239 · 301) (mod 401)<br />

≡ 386 · 154 · 160 (mod 401)<br />

≡ 122 (mod 401).<br />

⋄<br />

12.5 Complication IV: the last one<br />

The reason we are interested in computations like 133 172 %323 in the first place<br />

is that they form the heart <strong>of</strong> the most popular public key cryptography system<br />

in use today. The final complication is that the computations in this system<br />

are not <strong>of</strong> the form a b %p, where p is prime, but like a b %pq, where p and q are<br />

different primes. How does the change from a prime as the modulus to two<br />

prime affect what we’ve done so far<br />

We know that 12 6 ≡ 1 (mod 7) and 12 10 ≡ 1 (mod 11). How should we<br />

complete 12 □ ≡ 1 (mod 77) It turns out this is equivalent 6 to finding a value<br />

k so that 12 k ≡ 1 (mod 7) and 12 k ≡ 1 (mod 11). From Fermat’s theorem<br />

12 6 ≡ 1 (mod 7) and 12 10 ≡ 1 (mod 11). In fact, any exponent that is a<br />

multiple <strong>of</strong> 6 or 10, respectively, produces the same result: 12 6n ≡ ( 12 6) n<br />

≡<br />

1 n ≡ 1 (mod 7) and 12 10m ≡ ( 12 10) m<br />

≡ 1 m ≡ 1 (mod 11). The simplest such<br />

multiple 7 is the product, (7 − 1)(11 − 1) = 60 in this case. So 12 60 ≡ 1 (mod 7)<br />

and 12 60 ≡ 1 (mod 11), hence 12 60 ≡ 1 (mod 77).<br />

Now there is nothing special about 7 and 11. If p and q are distinct prime<br />

numbers, neither <strong>of</strong> which divides a, then a k ≡ 1 (mod p) and a k ≡ 1 (mod q)<br />

whenever k is a multiple <strong>of</strong> both p − 1 and q − 1. In particular, this is true when<br />

k = (p − 1)(q − 1). This gives us<br />

6 From Theorem 1 way back in Chapter 3, a ≡ b (mod pq) is the same as pq dividing a − b.<br />

But when p and q are relatively prime, this needs both p and q to divide a − b. That is, a ≡ b<br />

modulo both p and q.<br />

7 The smallest such multiple is the least common multiple, which we recall from Section<br />

8.4. For simplicity we will use the product.


240 CHAPTER 12. RSA<br />

Theorem 5 Euler’s Theorem 8 (1760): If p and q are two distinct primes and<br />

neither one <strong>of</strong> them divides a, then<br />

a (p−1)(q−1) ≡ 1<br />

(mod pq).<br />

Leonard Euler (1707–1783) is history’s most prolific mathematician. Except<br />

for 1741–1766 when he was at the Royal Academy in Berlin, from 1727 until his<br />

death Euler lived in <strong>St</strong>. Petersburg and worked at the Imperial Academy there.<br />

His contributed to most fields <strong>of</strong> mathematics, in particular geometry, calculus<br />

and number theory, as well as to physics, especially acoustics, hydraulics and<br />

the theory <strong>of</strong> light. As if more is needed, he became blind in 1766 at age<br />

59 but, despite this, continued his work on optics, algebra and lunar motion,<br />

producing almost half <strong>of</strong> his total works while blind. Euler wrote over 700 books<br />

and papers, piling new papers atop older ones. The Imperial Academy, which<br />

published the papers, published the top ones first, cause later, more advanced<br />

results to appear before the ones they superseded or depended upon!<br />

Examples: Of Euler’s Theorem.<br />

(1) 12 60 ≡ 1 (mod 77), since 77 = 11 · 7 and (11 − 1)(7 − 1) = 60.<br />

(2) 19 252 ≡ 1 (mod 301), since 301 = 43 · 7 and (43 − 1)(7 − 1) = 252.<br />

(3) 23 24 ≡ 1 (mod 35) and 49 64 ≡ 1 (mod 85).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

Where will these theorems affect our work Only in one place. The only<br />

times we’ve used “p − 1” so far is when doing modular arithmetic on the exponent.<br />

So when the modulus is the produce <strong>of</strong> two prime pq, then we must<br />

simply be careful to consider the exponent modulo (p − 1)(q − 1).<br />

Examples:<br />

(1) Compute 17 1803 %671.<br />

671 factors as 61 · 11. Since (61 − 1, 11 − 1) = 600, we must reduce 1803<br />

modulo 600. Since this is 3, we have 17 1803 ≡ 7 3 ≡ 35 (mod 77).<br />

(2) Compute 25 448 %253.<br />

253 = 11 · 23, and 10 · 22 = 220. 448%220 = 8, so 25 448 ≡ 25 8 ≡ 49<br />

(mod 253).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

8 Euler actually proved his theorem for any modulus, rather than for the much simpler case<br />

were are concerned with here. In general it takes the form a φ(n) ≡ 1 (mod n), where φ(n) is<br />

an easily computed value. This φ is called “Euler’s phi function” and is not to be confused<br />

with Friedman’s Φ.


12.6. PUTTING IT ALL TOGETHER 241<br />

12.6 Putting It All Together<br />

We summarize the steps we’ve taken and then do one final example.<br />

To compute a b (mod p) or a b (mod pq).<br />

1. Reduce the base a either modulo p or modulo pq.<br />

2. Reduce the exponent b either modulo p − 1 or modulo (p − 1)(q − 1).<br />

3. If the numbers involved are still too large for your calculator, build<br />

and complete the binary chart modulo p or modulo pq.<br />

4. If the final product contains too many or too large <strong>of</strong> numbers, groups<br />

them, multiply and reduce the groups, then multiply and reduce again<br />

to get the final answer.<br />

Example: Compute 1971 1149 %391. Hint: 391 = 17 · 23.<br />

(1) Reduce the base: 1971%391 = 20.<br />

(2) Reduce the exponent: (17 − 1)(23 − 1) = 352. 1149%352 = 93.<br />

(3) The binary chart:<br />

93 46.5 1 20 ≡ 20<br />

46 23 0 20 2 ≡ 9<br />

23 11.5 1 9 2 ≡ 81<br />

11 5.5 1 81 2 ≡ 305<br />

5 2.5 1 305 2 ≡ 358<br />

2 1 0 358 2 ≡ 307<br />

1 .5 1 307 2 ≡ 18<br />

(4) Group and multiply: 1971 1149 ≡ (20·81·305)·(358·18) ≡ 148 (mod 391).<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄<br />

12.7 Exponential Problems (and answers)<br />

At the beginning this chapter we hinted at a new cryptosystem, one based on<br />

taking the power <strong>of</strong> the message. To use it we would choose as key an integer e<br />

and encipher our message m as m e (mod 26). There were, however, a number<br />

<strong>of</strong> difficulties with this idea. First, there was the question <strong>of</strong> decryption: what<br />

reverses raising to the e-th power in modular arithmetic Second, to prevent<br />

a possible enemy from simply trying all possible exponents we need to be able<br />

to choose arbitrarily large e’s. Finally, it is possible for this system to encipher<br />

different letters to the same cipherletter (both d and f become L if e = 3),<br />

making deciphering rather problematic.


242 CHAPTER 12. RSA<br />

Perhaps not surprisingly, given the last several sections, the solution to all<br />

three <strong>of</strong> these difficulties will come from the same modification: instead <strong>of</strong> working<br />

modulo 26 we will work modulo P Q, where P and Q are two (large) primes.<br />

From Euler’s generalization <strong>of</strong> Fermat’s Theorem, we know that a (P −1)(Q−1) ≡ 1<br />

(mod P Q) whenever neither P nor Q divides a. So if we cleverly pick d (using<br />

the Euclidean Algorithm) to be the solution to ed ≡ 1 (mod (P − 1)(Q − 1)),<br />

then we have<br />

(<br />

a<br />

e ) d<br />

≡ a ed ≡ a (mod P Q).<br />

That is, raising to the d-th power will reverse the effect <strong>of</strong> raising the e-th<br />

power. 9 We will be able to decipher messages.<br />

Further, having two letters that become the same when enciphered will be<br />

impossible: if m e ≡ n e (mod P Q), then<br />

m ≡ m ed ≡ (m e ) d ≡ (n e ) d ≡ n ed ≡ n<br />

(mod P Q).<br />

So two letters (or messages) that are enciphered to the same letter (or message)<br />

were actually the same to start. That is, different letters are enciphered<br />

differently.<br />

Finally, there is the question <strong>of</strong> choices <strong>of</strong> e and d: are there enough so that<br />

our supposed enemy cannot stumble upon d simply by trying all the possibilities.<br />

Notice first that different choices <strong>of</strong> e can lead to the same actual encryption.<br />

We pointed this out in the case <strong>of</strong> prime moduli: if e ≡ e ′ (mod P − 1) then<br />

m e ≡ m e′ (mod P ). The same is true modulo (P − 1)(Q − 1): if if e ≡ e ′<br />

(mod (P − 1)(Q − 1)) then m e ≡ m e′ (mod P Q). So it doesn’t actually add<br />

more choices to allow e and d to be larger than (P − 1)(Q − 1), and so there<br />

are at most (P − 1)(Q − 1) different choices for e and d. To provide for a large<br />

number <strong>of</strong> choices for e, then, we will use very large P ’s and Q’s.<br />

12.8 RSA<br />

The RSA 10 crypto-system was invented by Ronald L. Rivest, Adi Shamir and<br />

Leonard Adelman in 1977. We have given the basics <strong>of</strong> the system. The<br />

only thing left to add is that if we are going to work modulo a large modulus,<br />

there is no need to encipher one letter at a time. We can instead use this as a<br />

polygraphic cipher.<br />

9 This statement is the “trick” behind the cipher system we are about to explain. Make<br />

sure you understand it, looking back at Theorems 12.1 and , if necessary.<br />

10 U.S. Patent No. 4, 405, 829, September 20, 1983, expired on September 20, 2000.


12.8. RSA 243<br />

The RSA Algorithm<br />

Setup:<br />

Pick two prime numbers P and Q, and let N = P Q.<br />

Choose e so that 1 < e < (P − 1)(Q − 1) with gcd ( e, (P − 1)(Q − 1) ) = 1.<br />

Find d such that ed ≡ 1 (mod (P −1)(Q−1)) via the Euclidean Algorithm.<br />

To encipher:<br />

Split the message into segments M each <strong>of</strong> which is smaller than N.<br />

Compute and send the numbers M e %N.<br />

To decipher:<br />

To decipher a message block E, compute E d %N.<br />

Before we do examples there are a couple comments we need to make. Notice<br />

that when converting the plaintext into numbers we need to translate letters<br />

like a into 01 rather than simply 1. This way we can tell concatenations like<br />

11 12<br />

sab = 190102 and sl = 1912 apart.<br />

Next, people tend to pick P and Q to be massively large primes, one having<br />

300 digits or a bit less, and one having 300 digits or a bit more. This makes<br />

N = P · Q to be about 600 digits long. It’s certainly not any trouble for a<br />

computer to store a 600 digit number (in a text file this is only about eight lines<br />

<strong>of</strong> numbers). Conversely, it is quite common choose P and Q so that 3 does not<br />

divide either P − 1 or Q − 1, and then simply use e = 3 for enciphering. 13<br />

Finally, the RSA code seems quite difficult to break (for reasons we will see<br />

in a moment) as long as P and Q are this large. However, RSA is very slow<br />

compared to the popular private key codes available today. So most messages<br />

are sent in two parts. The first part <strong>of</strong> the message would say something like<br />

“Use DES with key key” and be enciphered using RSA, while the second part,<br />

the much longer portion, would contain the actual message enciphered using<br />

DES with the key sent in part one.<br />

Examples:<br />

(1) Use P = 19, Q = 13, e = 23.<br />

1. Encipher code as a monographic cipher (i.e., one letter at a time).<br />

First N = P ·Q = 247. Then, performing the necessary computations<br />

(but not writing the details, such as the binary charts), we have<br />

11 This translation means that the largest two-letter block is 2626, the largest three-letter<br />

block is 262626, etc. We need to make sure to pick N so it is larger than the largest block in<br />

whatever block size we pick.<br />

12 There are more compact ways to translate letter blocks into numbers. For example,<br />

setting z=0 rather than 26, and then using (p1, p2) → 26 ∗ p1 + p2 for two-letter blocks and<br />

(p1, p2, p3) → 676 ∗ p1 + 26 ∗ p2 + p3 for three-letter blocks provides for more compact usage.<br />

But we will stick with concatenation.<br />

13 2 16 + 1 is another popular choice for e, due to its simple binary expansion.


244 CHAPTER 12. RSA<br />

c = 3 → 3 23 %247 = 243.<br />

o = 15 → 15 23 %247 = 59.<br />

d = 4 → 4 23 %247 = 36.<br />

e = 5 → 5 23 %247 = 47.<br />

So code is send as 243, 59, 36, 47.<br />

2. Decipher 47, 123, 61, 59.<br />

To decipher we must find d. First, (P −1)(Q−1) = 18·12 = 216, and<br />

then from the Euclidean algorithm d = 47 is the solution 23x ≡ 1<br />

(mod 216). Then<br />

47 → 47 47 %247 = e → e.<br />

123 → 123 47 %247 = 24 → x.<br />

61 → 61 47 %247 = 16 → p.<br />

59 → 59 47 %247 = 15 → o.<br />

So the deciphered message is expo.<br />

(2) Use N = 2747 and e = 19 to encipher exponentiation in two-letter pairs.<br />

ex = 0524 → 0514 19 %2747 = 1567.<br />

po = 1615 → 1615 19 %2747 = 1084.<br />

ne = 1405 → 1405 19 %2747 = 1461.<br />

nt = 1420 → 1420 19 %2747 = 1323.<br />

ia = 0901 → 901 19 %2747 = 901.<br />

ti = 2009 → 2009 19 %2747 = 2009.<br />

on = 1514 → 2009 19 %2747 = 1818.<br />

So 1567, 1084, 1461, 1323, 901, 2009, 1818 is the ciphertext.<br />

(3) Use that 2747 = 67 · 41 to to decipher 1032, 1469, 1821, 1551, 2020<br />

into two-letter pairs.<br />

After finding (P − 1)(Q − 1) = 2640 and d = 139, we decipher:<br />

The answer is superpower.<br />

1032 → 1032 139 %2747 = 1921 → su.<br />

1469 → 1469 139 %2747 = 1605 → pe.<br />

1821 → 1821 139 %2747 = 1816 → rp.<br />

1551 → 1551 139 %2747 = 1523 → ow.<br />

2020 → 2020 139 %2747 = 518 → er.<br />

⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄ ⋄


12.9. RSA AND PUBLIC KEYS 245<br />

There are at least two interesting things about these examples. First, because<br />

<strong>of</strong> the choice <strong>of</strong> small numbers for P and Q in Example (1), the RSA<br />

cipher became a complicated mono-graphic cipher. Frequency analysis <strong>of</strong> the<br />

type we practiced in Chapter 6 would easily break this cipher. However, by<br />

choosing P and Q so that N was larger than 2626 in Examples (2) and (3) we<br />

used RSA as a digraphic cipher. And if we had chosen P = 487, Q = 541 then<br />

N = 263467 would have let us use RSA as trigraphic cipher.<br />

The second thing was how encryption and decryption, while very similar<br />

processes, involve very different amounts <strong>of</strong> knowledge. To encipher we only<br />

need to know e and N, for the only thing we must do is to compute M e %N. In<br />

particular, we do not need either P or Q. To decipher, however, we do need to<br />

know P and Q, because to find d we must use (P −1)(Q−1). The application <strong>of</strong><br />

this differential knowledge is what allows RSA to be public key cipher system.<br />

12.9 RSA and Public Keys<br />

The information needed to use any particular RSA cipher is very different for<br />

the encryptor than it is for the decryptor. To encipher a message one only<br />

needs the power e and the modulus N. The values <strong>of</strong> d and (P − 1)(Q − 1)<br />

are unnecessary. When deciphering we need N, but also need d, and need e<br />

and (P − 1)(Q − 1) to determine d. That is, the decipherer needs P and Q to<br />

determine d.<br />

This allows RSA to be used as a public key code. Alice chooses the two<br />

primes P and Q and computes their product N. Then she chooses e and uses<br />

P and Q to compute d. Alice then makes public the values N and e. Since<br />

all that is needed to encipher a message is e and N, anyone can send Alice a<br />

message using her system.<br />

Alice Anderson<br />

Phone: 1-800-CALL-ALC<br />

Email: alice a○mymail.com<br />

I use RSA. My public keys are<br />

e = 17 and N = 549992441.<br />

Conversely, Alice keeps P , Q, (P − 1)(Q − 1) and d all secret. Since she<br />

knows d she can decipher any message sent to her. 14<br />

12.10 How to break RSA<br />

Suppose we capture an enciphered message E that is intended for our enemy.<br />

How can we read the message<br />

14 Since to decipher she only need to raise to the d-th power modulo N, she should throw P ,<br />

Q and (P − 1)(Q − 1) away, erase them from any computers they are on and burn any papers<br />

they are written on.


246 CHAPTER 12. RSA<br />

First, what about our old standby – frequency analysis If N consists <strong>of</strong><br />

around 600 decimal digits, then our ciphertext segments will also be about 600<br />

digits long. How many possible 600 digit segments are there Lots: 10 600 .<br />

Recall that a traditional estimate for the number <strong>of</strong> elementary particles in the<br />

universe is 10 80 . So even if we wanted to perform frequency analysis, there<br />

wouldn’t be enough room in the universe to write down our frequency count!<br />

So we must try another method to break a message. As usual, once we have<br />

tried the brute force method <strong>of</strong> frequency analysis, we then turn to the specifics<br />

<strong>of</strong> the system itself. Again, how to decrypt an RSA-enciphered message<br />

Well, we can look up our enemy’s e and N, since these are public information.<br />

We want M, the true message, we know the value <strong>of</strong> N and we know that<br />

E d %N = M. The only thing we don’t know is d. So we only need to discover<br />

d.<br />

Well, we know that e and d are chosen so that e·d ≡ 1 (mod (P −1)(Q−1)),<br />

and we know e. The only thing we don’t have is (P − 1)(Q − 1). So we only<br />

need to discover (P − 1)(Q − 1).<br />

Well, we know N, and we know that P · Q = N. Also,<br />

(P − 1)(Q − 1) = P · Q − P − Q + 1 = N − P − Q + 1.<br />

We know the N and 1 parts <strong>of</strong> this, but don’t know the P or Q. So we only<br />

need to discover P or Q.<br />

Well, N/P = Q and N/Q = P , so if we know either P or Q then we know<br />

the other and so know them both. But N has only two factors, P and Q. So<br />

we only need to factor N.<br />

Thus the entire security <strong>of</strong> the RSA system apparently comes down to the<br />

ease or difficulty <strong>of</strong> factoring N. If we can factor N we can easily decrypt any<br />

message enciphered modulo N. And the chain <strong>of</strong> “well”s above is meant to<br />

convince you that factor N is the only way to break RSA. 15 How hard can this<br />

be After all, we all spent several weeks in 5th or 7th grade talking about primes<br />

and factors and breaking down numbers into their prime factors. So why can’t<br />

smart people using fast machines just factor N In fact, why not just set up<br />

a really fast computer and do the obvious thing: see if 2 divides N, then see<br />

if 3 divides N, then see if 5 divides N, and so on, working your way along the<br />

primes until you find either P or Q<br />

Remember that N is about 600 digits long. An important theorem, called,<br />

logically enough, the Prime Number Theorem, says that less that N there are<br />

about N/ ln(N) primes. That means that to find up to P or Q, which means<br />

checking up to about 10 300 , we must check about 10 300 / ln(10 300 ) ≈ 10 298<br />

primes. But, again, there are only 10 80 particles in the whole universe! Imagine<br />

that I said I hid one specially marked atom somewhere in the universe and you<br />

15 Of course there are other ways to break any particular RSA system. Perhaps our enemy<br />

will make some grievous mistake in enciphering, like leaving part <strong>of</strong> the message unenciphered.<br />

Or will allow us to time his/her computer while it is deciphering as many messages as we wish.<br />

But, for most practical purposes, the security <strong>of</strong> RSA comes down to the factoring problem.


12.10. HOW TO BREAK RSA 247<br />

had to find it. This task is almost infinitely easier than the factoring N using a<br />

brute force factoring method!<br />

OK, perhaps you say that we know that none <strong>of</strong> the small prime numbers<br />

divide N, so let’s not waste our time with those. In fact, let’s only check the<br />

primes that have between 299 and 301 digits. This can’t be so many, right<br />

Well, the Prime Number Theorem, again, tells us there are<br />

10 301 / ln(10 301 ) − 10 299 / ln(10 299 ) > 10 298<br />

primes in this region. We haven’t eliminated too many! 16<br />

OK, perhaps you will argue that somebody will someday figure out how to<br />

factor such big numbers. Really, it is a very simple idea: just factor the darned<br />

thing. There are indeed many many people working on exactly this question,<br />

developing fancy methods with exotic names like “Pollard’s ρ-method” and the<br />

“Number Field Sieve”, and these method have been shown to have the ability<br />

to factor numbers <strong>of</strong> up to 155 digits. 17 So it is possible that in the future 18<br />

people will be able to quickly factor 600 digit numbers. I guess our hope is that<br />

by then whatever messages we send today will be so outdated that no one will<br />

care to go back and break them. And by then we will have switched so that P<br />

and Q are about 300 digits each.<br />

The final “OK”. OK, perhaps you will say but isn’t there this thing called<br />

the “National Security Agency” and isn’t the US government spending billions<br />

<strong>of</strong> dollars to fund them every year to do cryptographic work for the FBI and<br />

CIA and weren’t they smart enough to break the Russians one-time pads when<br />

the Russians didn’t use them properly and don’t they hire many many really<br />

smart mathematicians that they swear to secrecy Might not they have figured<br />

out a way to break RSA ciphers and not be telling us Huh Hey smart guy,<br />

what’s your answer to this And I’d have to answer, “dunno”. Maybe they<br />

have. No one seems to have any real evidence that they did, but we just don’t<br />

know since they aren’t telling.<br />

The upshot is that, outside <strong>of</strong> possibly the NSA (or its equivalents in other<br />

countries), as far as I know no one is currently able to break a carefully constructed<br />

and properly used RSA cipher in any reasonable amount <strong>of</strong> time. This<br />

is an area <strong>of</strong> much research in mathematics, so I’m making no promises about<br />

the future. But for the time being a well-constructed RSA system appears to<br />

be quite secure.<br />

16 In fact, intuitively this makes sense. $10, 000 is a lot <strong>of</strong> money, but removing that much<br />

from $1, 000, 000 still leaves a whole lot left over. Those two extra 0’s are a big deal!<br />

17 See the rsasecurity.com homepage.<br />

18 Two big shots in the field, Arjen Lenstra and Eric Verheul, have guessed that in another<br />

5 or so years (2009) it will be possible to build a computer that can break a 1024-bit RSA<br />

key in about a day for $250 million. The National Institute <strong>of</strong> <strong>St</strong>andards and Technology<br />

recommends that to protect information until 2015 one should use primes <strong>of</strong> roughly 300<br />

digits.


248 CHAPTER 12. RSA<br />

12.11 Authenticity – Pro<strong>of</strong> <strong>of</strong> Authorship<br />

An important disadvantage <strong>of</strong> all private key cipher systems is that they do<br />

nothing to help solve the key management problem. How can we secretly exchange<br />

secret keys with people we’ve never met And how can we keep all these<br />

secret keys straight, let alone secret As we have discussed, a Public Key cipher<br />

takes care <strong>of</strong> these difficulties. To send someone a private message we don’t<br />

have to know them, or have met them, or have agreed on a key or a method.<br />

We just look up and use their RSA information from their Internet site.<br />

This leads to a problem: If anyone can send you a message, there is no direct<br />

way <strong>of</strong> knowing who sent you that message! It means little for an email to be<br />

signed “Bob” as anyone can type B-o-b. How can we be sure that the person<br />

whose name is at the bottom <strong>of</strong> the message really sent it With the knapsack<br />

ciphers this is a fairly difficult problem to overcome but with the RSA it’s easy.<br />

As usual, we’ll refer to the two parties exchanging messages as Alice and<br />

Bob. We will use a subscript A to denote “Alice’s”, so N A is the value <strong>of</strong> N in<br />

Alice’s system. Similarly, e B is the enciphering exponent in Bob’s system. Alice<br />

knows her d A but no one else does. Similarly only Bob knows d B . However,<br />

they both know e A , N A , e B and N B . When Alice sends a message to Bob she<br />

wants to make sure that only he can decipher it, and that he knows it is actually<br />

from her. So she writes her message M and then computes<br />

(<br />

M d A<br />

%N A<br />

) eB<br />

%N B , if N A < N B ,<br />

or (<br />

M e B<br />

%N B<br />

) dA<br />

%N A , if N B < N A ,<br />

and sends this ciphertext to Bob. (Unfortunately, while ( )<br />

M d eB<br />

( )<br />

A and M<br />

e dA B<br />

are equal, they may not be equivalent, that is, when working modulo N A and<br />

N B the order <strong>of</strong> the moduli matters.)<br />

Bob needs to be similarly careful when deciphering. If N A < N B , he undoes<br />

the e B exponentiation (using d B ) and then undoes the d A exponentiation (with<br />

e A ). When N A > N B , the order must be reversed.<br />

This is quite clever, and so let’s take a moment to see what each party now<br />

knows. Bob receives a ciphertext supposedly from Alice. Since he can look<br />

up her modulus N A he knows which order to apply d B and e A to decipher<br />

the message. So he can read it. Further, since only he knows d B , Bob is the<br />

only person that can decipher this message. Finally, since applying e A led to a<br />

readable message, d A must have been applied to the plaintext, and since Alice<br />

is the only person that knows d A , it really must have been her that sent the<br />

message. Alice can come to quite similar conclusions: Bob is the only person<br />

who can read the message she sent, and she knows he will know it was she who<br />

sent it. (Make sure you understand why she knows these things.) Finally, Ed<br />

the Adversary, even though he knows all <strong>of</strong> Alice and Bob’s public information,


12.12. SUMMARY 249<br />

cannot read the message; in fact, he cannot even determine if it is actually from<br />

Alice!<br />

This process is called sending a digital signature. In fact, it is a bit like a<br />

person’s signature in that your signature is something that you can easily make<br />

and that anyone can compare with others <strong>of</strong> yours to convince themselves that<br />

you are you, but it is something that is hard for other people to fake. Similarly,<br />

it is easy for Alice to compute the number (Alice) d A<br />

after which anyone else<br />

can compute ( (Alice) A) d eA<br />

to convince themselves she is really who she says<br />

she is. 19<br />

Example: We receive 277763, 165924, 169282 from someone who claims<br />

to be David. We know that N David = 273487 and e David = 3. Our values are<br />

N = 279827, e = 297 and d = 4757. Did this message come from him and what<br />

did it say<br />

First, since N David = 273487 < 279827, if it was David who sent this message<br />

he would first have computed E = M d D<br />

%N D and sent us E e %N. So we must<br />

first compute E d %N, and then raise this to the e D modulo N D .<br />

Raising the message to the d = 47577-th power modulo 279827 produces<br />

198427, 240953, 178426. Raising these numbers to the e D = 3-rd power<br />

modulo N D = 273487 gives 23, 5, 5, 11, 5, 14, 4 or weekend. This message<br />

makes sense, so yes, David actually send the message.<br />

⋄<br />

With the idea <strong>of</strong> digital signatures understood we should modify one <strong>of</strong> our<br />

earlier sections. When one is using the RSA one really sends a message in<br />

several parts. Part 1 is a quick note saying who you are and what private key<br />

method and what key you will use to encipher part 2 <strong>of</strong> the message. Part 1 is<br />

double enciphered using your d and your recipient’s e as just indicated, which<br />

both keeps it secure and proves you sent it. Part 2 is the true message and is<br />

enciphered using the method and key you just indicated. Finally, Part 0 is a<br />

cover letter saying who you are and where you are sending the message.<br />

12.12 Summary<br />

After trying addition (Caesar Ciphers) and multiplication (Decimation Ciphers),<br />

it is natural to try exponentiation to create a cipher system, and RSA is exactly<br />

that. It enciphers messages by raising them to a power modulo the product <strong>of</strong><br />

19 There is a subtlety here. If Alice simply sends Alice d A as her signature for each <strong>of</strong> her<br />

messages, Ed can steal this number and pretend to be her.<br />

In practice, Alice would apply a hash function to the message, producing a very short<br />

version <strong>of</strong> it, and it is this that she “signs.” Since Bob can apply the same hash function to<br />

the un-deciphered message, he can compare these “digital fingerprints” to see if they are the<br />

same, and will then know if it was indeed Alice who sent the message.<br />

For our purposes, you can instead think that Alice uses as her name Alice coupled with<br />

some nulls that change from message to message – xAliceet or mnAliceW.


250 CHAPTER 12. RSA<br />

two large primes. Euler’s Theorem allows us to decipher messages by raising<br />

the ciphertext to a power modulo the same product. The deciphering power<br />

is the multiplicative inverse <strong>of</strong> the enciphering power modulo a number easily<br />

computed from the two original primes.<br />

When dealing with large primes, and here large means approximately 300<br />

digits each, exponentiation must be done carefully so that the size <strong>of</strong> the numbers<br />

does not overwhelm the computer or calculator being used. In general,<br />

to compute the value (a b )%n, where a, b and n could all be sizable values and<br />

n is either prime or the product <strong>of</strong> two primes, first reduce a modulo n, then<br />

reduce b modulo n − 1 (if n is prime) or modulo (p − 1)(q − 1) (if n = pq is a<br />

product <strong>of</strong> primes). Next, a “binary chart” is used to simultaneously write the<br />

remainder <strong>of</strong> b in binary and compute the powers <strong>of</strong> the remainder <strong>of</strong> a. Finally,<br />

the necessary powers <strong>of</strong> the remainder <strong>of</strong> a are combined to produce the final<br />

value.<br />

The RSA system has become the world’s most widely-known Public Key<br />

cryptosystem. The private information is the deciphering key and the two<br />

primes, and the public information is the product <strong>of</strong> the primes and the enciphering<br />

exponent. RSA also provides for digital signatures, a method by which<br />

the sender can prove their identity. Although RSA is slow when compared with<br />

popular private key systems, it pairs easily with any such system: encipher your<br />

message with a private key system, encipher the key with RSA and then send<br />

the enciphered key and the ciphertext as a two-part message.<br />

Outside <strong>of</strong> poor uses <strong>of</strong> the system (e.g., a bad choice <strong>of</strong> parameters), which<br />

are generally easy to avoid, the RSA system seems very difficult to break. Its<br />

security seems to depend on the difficulty <strong>of</strong> factoring the product <strong>of</strong> the two<br />

large primes. While factoring has been studied for many, many years, there no<br />

publicly-known general method that will factor the product <strong>of</strong> two well-chosen<br />

primes in any realistically small amount <strong>of</strong> time. So, for the time being at least,<br />

RSA is one <strong>of</strong> the most secure ciphersystems known.<br />

12.13 Topics and Techniques<br />

1. What is Fermat’s Theorem How to use it Under what conditions does<br />

it apply<br />

2. Is raising a number to a large power modulo a prime ever the same as<br />

raising that same number to a smaller power modulo the same prime<br />

Explain.<br />

3. What is “double modular arithmetic”<br />

4. If I have a large number raised to a large number that I want to reduce<br />

modulo a smaller prime, how do I go about making this problem more<br />

manageable<br />

5. What is the binary expansion <strong>of</strong> a number How to find it


12.14. EXERCISES 251<br />

6. What is a “binary chart” How is it used<br />

7. Outline the steps involved in computing a b %p, where p is a prime number<br />

and a and b both might be quite large.<br />

8. What is Euler’s Theorem How does it differ from Fermat’s Theorem<br />

9. Outline the steps involved in computing a b %n, where n = pq is the product<br />

<strong>of</strong> two prime numbers and a and b both might be quite large.<br />

10. Explain the basics <strong>of</strong> the RSA algorithm.<br />

11. Can RSA be used as a polyalphabetic cipher How When<br />

12. Is RSA a public key system What is public What is private<br />

13. What is involved in breaking the RSA system What knowledge must the<br />

enemy obtain to break an RSA-enciphered message<br />

14. What size <strong>of</strong> numbers are used in an RSA system Why does size matter<br />

15. How can the author <strong>of</strong> a message sign the message How does the recipient<br />

<strong>of</strong> a message become convinced the author is who he/she says he/she is<br />

12.14 Exercises<br />

1. Find the following numbers. The numbers in the modulus are all primes.<br />

(a) 340 187 (mod 37).<br />

(b) 19 195 (mod 5 · 17).<br />

(c) 541 330 (mod 7 · 19).<br />

(d) 184 144 (mod 59).<br />

(e) 24 67 (mod 5 · 23).<br />

(f) 5404 2203 (mod 29 · 37).<br />

2. Encipher large in one-letter blocks using P = 7, Q = 19 and e = 5.<br />

3. Decipher 1108, 494 if it was enciphered with parameters P = 31, Q = 41<br />

and e = 7.<br />

4. Using the parameters P = 31, Q = 13, e = 7:<br />

(a) Encipher primes in one-letter pieces.<br />

(b) Compute d and decipher 391, 135, 208, 128, 346, 164.<br />

5. Using the parameters P = 71, Q = 37, and e = 13:<br />

(a) Encipher arithmetic in two-letter segments.


252 CHAPTER 12. RSA<br />

(b) Compute d and decipher 2024, 1553, 469, 299.<br />

6. Decipher 498, 1, 280, 248, 143, 37, if the RSA system used P = 19,<br />

Q = 29 and e = 13.<br />

7. Encipher composite in three-letter blocks using the parameters P = 1223,<br />

Q = 563 and e = 23.<br />

8. (a) [RSA] The “Small Example” given in the original description <strong>of</strong> RSA<br />

uses p = 27, q = 59 and d = 157. (This paper chooses d first and<br />

then computes e.) Compute e.<br />

(b) Using the usual translation <strong>of</strong> letters to two-digit numbers, with 00<br />

representing a space, translate Its all greek to me into numbers.<br />

(c) Encipher the message.<br />

9. [Hellman] In his Scientific American paper about Knapsack Ciphers and<br />

RSA, Hellman uses the letter-to-number translation in which a to z are 0<br />

to 25, A to Z are 26 to 51, a space is represented by 62, and is 66.<br />

(a) Hellman’s example message is How are you What is the numerical<br />

equivalent<br />

(b) Use e = 11 and N = 11023 to encipher the message in two-letter<br />

pairs. (Hellman called these E and n.) Hint: 73 divides 11023.<br />

(c) Find the deciphering exponent.<br />

10. In the following examples, the sender has tried to prove his identity by<br />

signing the message, as described in the text. Decipher the message.<br />

(a) The message is 54, 135, 112, 112. It is to Andy (parameters P =<br />

17, Q = 11, e = 7) from Bridget (parameters P = 19, Q = 13,<br />

e = 5).<br />

(b) The message is 14756, 9105, 191. It is to Alice (parameters P =<br />

137, Q = 191, e = 7) from Bob (parameters P = 173, Q = 127,<br />

e = 5).<br />

11. We started the chapter by considering raising a message to the 3rd power.<br />

That is translating letters to numbers and raising each number to the 3rd<br />

power modulo 26. Why didn’t we instead raise 3 to the letter’s power<br />

So, for example, e would encipher to 3 5 = 243 ≡ 9 (mod 26) = I. Would<br />

this method produce a good cipher (Hint: encipher a couple <strong>of</strong> words<br />

and study the outcome.)<br />

12. Your RSA parameters are P = 67, Q = 97, e = 59 and d = 179. One day<br />

you receive the message<br />

5689, 3415, 347.


12.14. EXERCISES 253<br />

Bob is going to be sending you the name <strong>of</strong> a new business contact. But<br />

so is Carley. If Bob’s RSA parameters are N = 7979 and e = 47 and<br />

Carley’s are N = 3569 and e = 53, who sent the message and what does<br />

it say<br />

13. The statement <strong>of</strong> Euler’s Theorem begins “If p and q are two distinct<br />

primes.” Why is the distinctness needed In other words, what happens<br />

if p = q<br />

14. By some amazing coincidence Alice and Bob independently chose the same<br />

primes P and Q when making their RSA parameters. Fortunately they<br />

chose different encryption and decryption keys e A and e B . Show that<br />

given the ciphertexts C A = (M e A<br />

)%N and C B = (M e B<br />

)%N if e A and e B<br />

are relatively prime then M can be recovered.<br />

15. Show that P +Q = N −(P −1)(Q−1)+1 and P −Q = √ (P + Q) 2 − 4N.<br />

Thus by adding or subtracting P and Q can be found directly.<br />

This shows that knowledge <strong>of</strong> N and (P − 1)(Q − 1) suffices to break<br />

RSA.<br />

16. Shamir, Rivest and Adelman suggested that their RSA method could be<br />

used to play poker over the phone [SRA]. Explain how using techniques<br />

similar to signing a message, two players may use RSA to play poker.<br />

Hint: Have one player begin by encrypting the fifty-two messages ace<br />

<strong>of</strong> clubs, two <strong>of</strong> clubs, three <strong>of</strong> clubs, ..., king <strong>of</strong> spades, sending<br />

them to the other player. There will need to be a lot <strong>of</strong> messages sent.


254 CHAPTER 12. RSA


Bibliography<br />

[Antonucci] Michael Antonucci, Code-Crackers Civil war Times Illustrated,<br />

July August 1995.<br />

[Abeles]<br />

[Abeles2]<br />

[Abelels3]<br />

[Bates]<br />

[Bauer]<br />

[Belaso]<br />

[Brown]<br />

[Elements]<br />

Francine F. Abeles, The Mathematical Pamplets <strong>of</strong> Charles Luttwidge<br />

Dodgson and Related Pieces, 1994, page 326.<br />

Francine Abeles and <strong>St</strong>anley H. Lipson, Some Victorian Periodic<br />

Polyalphabetic Ciphers, Cryptologia, April 1990, Vol XIV No. 2,<br />

page 128–134.<br />

Francine Abeles and <strong>St</strong>anley H. Lipson, The Matrix Cipher <strong>of</strong> C.L.<br />

Dodgson, Cryptologia, January 1990, Vol XIV No. 1, page 28-36.<br />

David Homer Bates, Lincoln in the Telegraph Office.<br />

Bauer’s Book.<br />

Giovan Batista Belaso, La Cifra del. Sig. Giovan Batista Belaso,<br />

1553 (see page 137, Kahn).<br />

Joseph Willard Brown, The Signal Corps, U.S.A. in the War <strong>of</strong> the<br />

Rebelions, Boston, U.S. Veteran Signal Corps Association, 1896.<br />

United <strong>St</strong>ates <strong>of</strong> America War Office, Elements <strong>of</strong> Cryptanalysis,<br />

Training Pamphlet No. 3, May 1923 .<br />

[Friedman] William Friedman, Cryptography and Cryptanalysis, Vol 2, 1937.<br />

[Gaddy]<br />

[Gaines]<br />

[Glasby]<br />

David Winfred Gaddy,Signals and Ciphers, C.S.A. A <strong>St</strong>udy in Confederate<br />

<strong>Cryptology</strong>.<br />

Helen Fouche Gaines, Cryptanalysis.<br />

S.P. Glasby, Extended Euclid’s Algorithm vi Backward Recurrence<br />

Relations, Math. Mag., Vo. 72, No. 3, Pages 228–230.<br />

[Graves] Robert Graves, I, Claudius, page 212, Random House, 1934.<br />

[Gray]<br />

Jacques B. M. Gray, Vowel identification: an old (but good) algorithm.<br />

Crytologia, July 1991 VOl XV, Number 3, pages 258–61.<br />

255


256 BIBLIOGRAPHY<br />

[Hassard] John R. G. Hassard, Cryptography in Politics, pp 315–26, 1879,<br />

The North American Review.<br />

[Hellman]<br />

[Kahn]<br />

[Kasiski]<br />

Martin Hellman, The Mathematics <strong>of</strong> Public-Key Cryptography,<br />

Scientific American, 1979. Vol 241, pages 146–57.<br />

David Kahn, The Codebreakers.<br />

Friedrich Kasiski, Die Geheimschriften und die Dechiffrir-kunst<br />

[Koblitz] Neal Koblitz, Crytography as a teaching tool, Cryptologia, Vol. 21,<br />

No. 4 (1977), pp. 317–326.<br />

[Merkle]<br />

[Morris]<br />

[Myers]<br />

R. C. Merkle, M. E. Hellman, Hiding Information and Signatures<br />

in Trapdoor Knapsacks, IEEE Transactions on Information Theory,<br />

Vol. 24, No. 5, pp. 525-530, September 1978.<br />

Richard Morris, John Jay: The Making <strong>of</strong> a Revolutionary, Unpublished<br />

papers 1745–1780, Edited by Richard B. Morris, Harper &<br />

Row, page 656-666<br />

General Albert James Myer, A Manual <strong>of</strong> Signals: for the use <strong>of</strong><br />

Signal Officers in the field<br />

[Nichols] Randall K. Nichols, ICSA Guide to Cryptography, page 70.<br />

[Schooling] John Holt Schooling, The Pall Mall Magazine Vol VIII, 1896 I.<br />

page 119–D<br />

[Peckham]<br />

[Plum]<br />

[Pratt]<br />

[RSA]<br />

[Sinkov]<br />

[SSA1]<br />

[SSA2]<br />

[SSA3]<br />

Howard H. Peckham, British Secret Writing in the Revolution, The<br />

Quarterly Review, pages 125–130. (Michigan Alumnus Quarterly<br />

Review, 9 November 1938, winter 1938 VF 25-43 )<br />

William Rattle Plum The Military Telegraph during the Civil War<br />

in the United <strong>St</strong>ates, Arno Press, New York, 1974<br />

Fletcher Pratt, Secret and Urgent<br />

Rivest, Shamir, Adleman A Method for Obtaining Digital Signatures<br />

and Public-Key Cryptosystems, Communications <strong>of</strong> the ACM,<br />

February 1978, Volume 21, Number 2, pages 120–126.<br />

Abraham Sinkov, Elementary Crytanalysis.<br />

SSA, The History <strong>of</strong> Codes and Ciphers in the United <strong>St</strong>ates Prior<br />

to World War I, page 132.<br />

Codes and Ciphers during the Civil War Prepared under the Direction<br />

<strong>of</strong> the Chief Signal Officer, 20 April 1945.<br />

Historical Background <strong>of</strong> the Signal Security Agency Army Security<br />

Agency, Washington, D.C, 12 April 1946 Volume I


BIBLIOGRAPHY 257<br />

[Shamir]<br />

[SRA]<br />

A. Shamir, A Polynomial-Time Algorithm for Breaking the Basic<br />

Merkle-Hellman Cryptosystem, Advances in <strong>Cryptology</strong> - CRYPTO<br />

’82 Proceedings, pp. 279-288, Plenum Press, 1983. IEEE Transactions<br />

on Information Theory, Vol. IT-30, pp. 699-704, 1984.<br />

A. Shamir, R. Rivest, L. Adleman, Mental Poker, The Mathematical<br />

Gardner, pgs 37-43.<br />

[Treat] Daniel G. Treat RSA: A Limerick, Mathematics Magazine, Vol 75,<br />

No. 4, October 2002, page 255.<br />

[Vigenere]<br />

[<strong>Web</strong>er]<br />

[Yardleyb]<br />

[Yardleya]<br />

Vigenerè, Traicte’ des Chiffres.<br />

Ralph E. <strong>Web</strong>er Masked Dispatches: Cryptograms and <strong>Cryptology</strong><br />

in American Hisotyr, 1775–1900, Series I Pre-World War I Volume<br />

I MSA, CSS 1992.<br />

Yardley book<br />

Herbert Yardley, Are we giving away our state secrets, Liberty<br />

Magazine, Dec 19, 1931, pages 8–13.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!