Encryption Discrete Math March 7, 2006 Harding University Jonathan White Outline Terms Types of Attacks Classical Techniques Substitution: Caesar Monoalphabetic Playfair Shifting: Rail Fence Cipher Rotor Machines (Enigma) Outline (2) Data Encryption Standard (DES) Triple DES Blowfish MD5, SHA-1 RSA Quantum Computers Terms Plaintext Ciphertext Cipher Key Cryptography Symmetric Encryption Asymmetric Encryption Terms Security by Obscurity Brute Force Search Attack Dictionary Attack Man in the Middle Attack Cipher Attacks Plaintext Attacks Steganography Unconditional security Computational security Brute Force Attacks Brute Force Searches: Simply try every possible key Effort required is proportionate to the key size You must recognize the plaintext once you see it! Typically uses no knowledge about the cipher, the cipher text, or the plaintext, so it is very easy to do. Dictionary Attacks For this attack, you have already encrypted a large amount of plaintext. You simply search what you’ve already encrypted for a match. This is how most password crackers work. Is your password something common like: An English word? A variation of your username? Numbers or letters at the beginning or end appended to the above? Blank? Guessing, along with dictionary attacks, have proven to break ~50% of all passwords. Older Unix systems only allow 8 character passwords Plaintext Attacks Plaintext Attacks Attack the language the plaintext was written in Human languages are very redundant Ever seen Wheel of Fortune? ASCII characters are also very predictable C++/Java/Lisp code is very redundant Military communications are very redundant Most ciphers overcome this by appending a bit of random characters to the end of the message Called padding. Cipher Attacks Attack something that is known about the cipher For example, if you encrypt 0 and 1 in RSA, the ciphertext is the exact same Ciphers typically have periodic behavior, which can be attacked. However, most modern ciphers have been extensively studied and have very few potential attacks. No “Security by Obscurity” In fact, you want people to try and crack your cipher – it just makes you look better when they can’t crack it. Unconditional Security Very difficult to provide. One of the only known unconditional secure algorithms is a random, one time pad, key that is as long as the message. Since the key is completely random, you can just add the letters in the key and the message together and send them. The cipher text bears no statistical relationship between the plaintext. You can only use the key once though. However, how do you distribute the key? Russian nuclear crisis. Classical Substitution Ciphers Where letters of the plaintext are replaced by other letters or symbols. Or, if viewed as bit patterns, a sequence of bits in the plaintext is replaced with a sequence of bits in the plaintext. Very easy to use. They’ve been around the longest. The key is the mapping that you used from the plaintext to the cipher text. Caesar Cipher Earliest known substitution cipher. Used in military affairs. Replaces each letter in the plaintext by the nth letter down in the alphabet, wrapping back around. In this case, the key is just the shift number that you chose. To unencrypt, you just subtract the n from the ciphertext to get the original. Caesar Example Encrypt this message with a shift of 5: The brown fox ate the sheep Plaintext Shift 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 MEQEWXYHIRX LDPDVWXGHQW KCOCUVWFGPV JBNBTUVEFOU IAMASTUDENT HZLZRSTCDMS GYKYQRSBCLR FXJXPQRABKQ EWIWOPQZAJP DVHVNOPYZIO CUGUMNOXYHN BTFTLMNWXGM ASESKLMVWFL ZRDRJKLUVEK YQCQIJKTUDJ XPBPHIJSTCI WOAOGHIRSBH VNZNFGHQRAG UMYMEFGPQZF TLXLDEFOPYE SKWKCDENOXD RJVJBCDMNWC QIUIABCLMVB PHTHZABKLUA OGSGYZAJKTZ Cryptanalysis of Caesar Only have 26 possible orders. Very easy to defeat using brute force. You do need to recognize when you have the plaintext, however. Monoalphabetic Cipher Rather than just shifting the alphabet, you could just jumble the letters arbitrarily. Each plaintext letter then maps to a different ciphertext letter. The key is then 26 characters long. So, we have 26! possible keys. But, this does not conceal the language characteristics. Also, tables exist for double and triple letter frequencies such as “ing”, “th”, “ou”, etc… These ciphers don’t change the relative letter frequencies. Monoalphabetic Example Let the key and plaintext be : QWERTYUIOPASDFGHJKLZXCVBNM If we wish to replace these letters GO TO THE MALL The ciphertext is: Playfair Cipher A 5 x 5 matrix of letters based on a keyword. Fill in letters of keyword without duplicates Then, just fill in the rest of the matrix with the rest of the alphabet going in order. J and I are the same letter in the playfair cipher; so, there are only 25 letters in the alphabet. Playfair Encrypting/Decrypting Plaintext is encrypted 2 letters at a time: If a pair is a repeated letter, insert a filler letter like “x” If both letters fall in the same row, replace ach with the letter to the right (wrapping back to start from the end) Exp: “ar” encrypts as “rm” If both letters fall in the same column, replace each with the letter below it, wrapping bottom to top. Exp: balloon becomes ba lx lo on Exp: “mu” encrypts as “cm” Otherwise, each letter is replaced by the one in its row in the column of the other letter of the pair. Exp: “hs” encrypts to “bp”, “ea” encrypts to “im” Playfair Security We have 25 x 25 potential combinations = 625! potential ways to encrypt. Widely used for many years, including WW1. But, it can be broken, given a few hundred letters. With a computer, this is quite simple, because some of the plaintext structure still remains. Transposition Ciphers These hide the message by rearranging the letter order. The actual letters aren’t altered. However, the ciphertext will still have the same relative frequency as the original text. These are typically incredibly quick. Rail Fence Cipher Write your message horizontally across a narrow sheet of paper. Wrap the paper around a circular post that both you and the person you wish to send the message to both posses one of. Then, just write down the letters you see starting at the top of the post. Very insecure. The Enigma Machine Used by the Germans in WW2 to encrypt and decrypt messages. Used a series of rotors connected to a complex electrical circuit and some initial letter swaps to encrypt messages. Produced incredibly strong encryption for its time. Decryption was exactly the same as encryption – provided you knew the starting position. http://www.enigmaco.de/enigma.sw f Enigma Machine 2 The interesting thing about the Enigma is that the substitution pattern changes after every keystroke. No longer just a simple substitution cipher. There are 263 possible start positions for the rotors. This would be relatively easy to solve. But, this does remove a lot of the letter frequencies apparent in the German language. There are still 26! ways to substitute the original letters. Altogether, (if a few mishaps hadn’t occurred), this cipher can’t be beat by humans. Enigma Machine 3 Mishaps: Letters couldn’t encrypt to themselves. Repeating the same greeting in every message. Mother/Father/Girlfriend’s name, city, favorite soccer team… Stolen codebooks Please Respond, Dear, weather reports… Always using “X” for the space key. Letting operators always choose their passphrase. Sometimes test messages were sent by lazy operators that only used one letter. Helps for a little while… Stolen machines What really allowed the Polish and British intelligence agencies to crack the Enigma. Only around 15 machines were ever captured. Enigma Machine 4 In order to test potential codes, the Americans designed one of the first computers. This was aided by Alan Turing, a British citizen. By the end of the war, all Enigma communications could be broken in under 3 days. However, the Allies didn’t always use this information. Battle of the Bulge. Many officials have estimated that by cracking the Enigma, WW2 ended 1 year earlier than it would have.