Can You Keep a Secret?
Total Page:16
File Type:pdf, Size:1020Kb
Codes and Ciphers 20 Can You Keep a Secret? Codes and ciphers have been around just about as long as there has been written language. The ability to communicate in secret – as well as the ability to peer into the secret communications of others – has been central to a surprising number of major world events throughout history, often with nations as well as lives hanging in the balance. A word first about the difference between a code and a cipher: • A code is a secret language used to disguise the meaning of a message. The simplest form is a “jargon code,” where a particular phrase corresponds to a previously defined message. “The milkman comes in the morning,” for example, could mean “the invasion begins at dawn.” • A cipher conceals what is referred to as a “plaintext” message by substituting (a “substitu- tion cipher”) and/or scrambling (a “transposition cipher”) the letters. As we shall see later, a simple substitution cipher may encrypt the message “Call me tomorrow morning” as “FDO OPH WRP RUU RZP RUQ LQJ.” For our purposes, we will use such general terms as “code,” Cryptography, sometimes called “cryptology,” is “code breaker,” “encryp- tion” and “decryption” to from the Greek, meaning “hidden writing,” and its refer both to codes and ci- use has been documented for over 2,000 years. phers, rather than repeatedly drawing the distinction between the two. Hidden Writing Cryptography, sometimes called “cryptology,” is from the Greek, meaning “hidden writing” and its use has been documented for over 2,000 years. From the beginning, codes have always been of greatest use in matters of war and diplomacy. The reasons for this are pretty obvious: no general would want his strengths, weaknesses or plans revealed to his enemy, as no ambassador would want his goals or strategies available to his competitor sitting across the negotiat- ing table. At first, written messages were simply hidden to keep their meaning secret, in a practice called steganography. In his chronicle of the wars between Greece and Persia, the Greek historian Herodotus described how an act of cryptography had saved Greece from con- quest by Xerxes, left, the king of Persia and pharaoh of Egypt who ruled from 485 to 465 B.C. Codes and Ciphers 21 In an effort to expand his rule, Xerxes secretly began amassing a great army and navy several years before launching a surprise attack on Athens. The build-up was witnessed, however, by Demaratus, a Greek exile living in the Persia at the time. Demaratus, determined to alert his homeland, scraped the dark wax off a pair of wooden folding tablets, wrote the news onto them, then covered the message over with wax again. When the tablets reached their destination, the wax was removed and the message read. On receiving the news, the Greeks, who at that time had no navy, commissioned the construction of 200 warships. When the Persian fleet finally arrived in 480 B.C., without the element of surprise, Xerxes found himself lured into a trap, and his forces were defeated in a day. Around this same time, Spartan military leaders used a scytale, at right, (rhymes with Italy), which was simply a wooden staff, to encode their communications. A strip of parchment or leather was wrapped around it, and the writer would write his message along the length of the scytale. When finished, the strip would be unwound and seem to contain only a series of meaningless letters. In order to read the message, the receiver would wind the leather around another scytale of the same diameter as the one used by the sender. Herodotus also documented the tale of Histaiaeus, who was anxious to encourage Aristagoras of Miletus to revolt against the Persian king. To keep his message hidden, he shaved the head of his messenger, wrote the message on his scalp, then waited for the hair to grow back before sending him off. The weakness of this second method should be pretty obvious. If the message remains hidden until its intended recipient receives it, then all is well and good, but if it is found, it is plain for all to see. As the demand for secrecy increased, a more foolproof solution was needed. The Caesar Cipher In his historic quest to expand the Roman Republic into a vast empire a little more than 2,000 years ago, Julius Caesar, commemorized in a bust at right, by all accounts a man of exceptional brilliance, energy and vision, embarked on a series of military campaigns in such countries as Gaul (modern-day France), Hispania (Spain), Egypt, Britannia (Eng- land) and Germania (Germany). Communications on the battlefield in Caesar’s time consisted only of written messages delivered on foot by runners, whose ability to accomplish their mission (and live to report back to their commander) depended entirely on their ingenuity, bravery and speed. Most often, several runners were dispatched to deliver the same message to one of Caesar’s of- ficers in the hopes that one would complete the mission. Since the enemy’s officers, at least, were usually literate, there was always the danger that Caesar’s orders would fall into enemy hands. To prevent the enemy from learning his plans, Caesar devised one of the earli- est known encryption techniques, which is today known as the “Caesar Cipher.” The Roman historian Suetonius, best known for his The Lives of the First Twelve Caesars, refers to Julius Caesar’s use of the Caesar Cipher in this excerpt: Codes and Ciphers 22 “If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the let- ters of the alphabet, that not a word could be made out. If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others.” As described by Suetonius, the Caesar Cipher is a simple shift of the alphabet by a specified number of characters to the right. The number of character shifts is referred to as the key. By replacing each character in a message with the character that corresponds to the key number of charac- ters further down the alphabet – in this case, three – anyone can create a Caesar-Ciphered message. Codes and Ciphers Lessons In Unit 2, Codes & Ciphers, you will create a software program capable of encoding a plaintext message and decoding an encrypted message, using the Caesar Cipher described in the previous narrative. After modeling the Caesar Cipher on a simple message using a pencil and paper in order to get a basic idea of how it works, you will: 1. Create the Cryptography Project 2. Ask the User to Choose Encipher, Decipher or Exit 3. Ask the User to Choose Caesar Cipher, Vigenere Cipher or Exit 4. Implement the Caesar Cipher method to Encode a plaintext message For an explanation of the Vigenere Cipher, read on. Codes and Ciphers 23 Encoded Court Intrigue During the Middle Ages, thick with intrigue and secret plots, the royal courts of Europe always sought to employ the finest code makers and breakers in order to help rulers guard against as well as uncover the plots of their enemies. When Mary Queen of Scots, right, was tried for plotting the assassination of Queen Elizabeth in 1586 in a failed attempt to seize the British throne, for ex- ample, Sir Francis Walsingham, Elizabeth’s ruthless spymaster, knew that he would have to prove beyond a doubt that she was behind the infamous plot before Eliza- beth would agree to her cousin’s execution. Fortunately, Thomas Phelippes, the court’s resident expert on code breaking, was up to the task and cracked the code Mary had used to communicate with her co- conspirators. In the end, Mary was condemned and Elizabeth herself signed the death warrant. As Mary learned the hard way, just as important as the ability to create a cipher that will keep your communications safe from the prying eyes of your enemies is the ability to crack your enemies’ ciphers and reveal the thoughts and plans of those who wish you or your allies harm. As long as there have been ciphers, there have been cryptanalysts. Cryptanalysis is the science of deci- phering a message without knowledge of the key. The science of crypt- analysis was invented Frequency analysis is the study of the frequency of let- by an Arab in the ninth century, during the ters or groups of letters in an encoded message and has Golden Age of Islamic come to be the first step in breaking classical codes. Civilization. One of the many schol- ars who worked in Baghdad’s House of Wisdom at that time was the noted philosopher and mathematician Yaqub ibn Ishaq al-Kindi, pictured below in a Syrian postage stamp. During his career, Al-Kindi wrote nearly 300 books on a wide range of subjects, and his On Deciphering Cryptographic Messages was the first treatise to describe the science of letter frequency analysis. Frequency analysis is the study of the frequency of letters or groups of letters in an encoded message and has come to be the first step in breaking classical codes. Meanwhile, the West was still mired in the Dark Ages and the only places where the study of secret writing was encouraged were the monasteries, where monks strug- gled in search of hidden meanings in the Bible. Monks noticed deliberate instances of cryptography in the Old Testament. There are, for example, sections of text encrypted with atbash, a traditional form of Hebrew substitution cipher.