Introduction to Cryptography

Size: px
Start display at page:

Download "Introduction to Cryptography"

Transcription

1 Introduction to Cryptography Brian Veitch July 2, 2013 Contents 1 Introduction Alice, Bob, and Eve Basic Terminology Brief History of Cryptography Kerckhoff s Principles of Cryptographic Secuity Substitution Cipher Caesar Cipher Activity Keyword Cipher Activity Vigenere Cipher Activity Transposition Easy Example Railfence Cipher Transposition Activity Modular Arithmetic Examples of Congruences Arithmetic with Congruences Multipication Tables Finding the Inverse Solving Equations (mod n) The Extended Euclidean Algorithm

2 CONTENTS 2 5 Diffie-Hellman Key Exhange What is it? The Algorithm Example of a Key Exhange Why is Cracking this Exchange Difficult Key Exhange Activity RSA Encryption Introduction Example of RSA Encryption RSA Algorithm Using The Extended Euclidean Algorithm ASCII Table Cracking RSA by finding the private key d Your turn to crack an RSA encrypted message Using RSA for Authentication Algorithm Authentication Activity Important Information Caesar Shift Wheel Letter Frequency Tables Vigenere s Table ASCII Table Useful Websites

3 1 INTRODUCTION 3 1 Introduction You don t have to be an expert in cryptogrphy to appreciate the field. Cryptography is all around us. We use it to store senstive data, send secret messages, send financial information over the internet, hide messages from parents, etc. The methods we will cover in this paper can be easily picked up with some knowledge of basic arithmetic and some modular algebra. There are two basic types of encryption: substitution and transposition. We will cover the basics of each with some easy examples. Since this is an introduction, the techniques will be easier. After reading a section, try to improve on the method by coming up with your own versions. 1.1 Alice, Bob, and Eve Suppose Alice wants to send Bob a message. She doesn t want Eve to intercept it and read it, so she decides to disguise it. Here s a diagram that outlines the what s happening. Your hope is that Eve doesn t know how to figure out your message or alter it in some way.

4 1 INTRODUCTION Basic Terminology 1. Plaintext - this is the original message to be sent. It can letters, numbers, characters, symbols, etc. 2. Encryption - disgusing the plaintext using some method. These methods usually have a key or algorithm to generate the ciphertext. 3. Ciphertext - the result of the encryption. It can be letters, numbers, characters, etc., but unreadable. 4. Decryption - the process of undoing the encryption. You should get the original plaintext when finished. 5. Key - something that is used to encrypt the message. Think of it as a password that disguises and un-disguises your message. 6. Keyspace - the set of all possible keys. For example, a four digit lock has possible keys. (0000, 0001, 0002,..., 9998, 9999) 7. Cryptography - the science of the enciphering and deciphering of messages in secret code or cipher. Also referred to as cryptology. 8. Cryptosystem - a system for encrypting information. 9. Cryptanalysis - the science (and art) of recovering information from ciphers without knowledge of the key. 1.3 Brief History of Cryptography Cryptography is an ancient science. The term comes from the Greek language meaning the study of hidden or secret writing. Ever since there were multiple tribes (or countries), we needed a way to communicate to one another without the other tribe (country) understanding it. Today it s vital to communicatations, authentication, sending sensative data over the internet, purchasing items from

5 1 INTRODUCTION 5 ebay, Amazon, and more. One of the earliest examples of cryptography was in Egypt around 2000 B.C. where they used hieroglyphics to decorate their tombs. Even though they weren t trying to completely hide the meaning, it still wasn t easy to interpret. The Greek writer Polybius used a 5x5 or a 6x6 (with out alphabet) to disguise the message. Below is an example of how it would work, If you wanted to write the message SAVE ME, it would be disguised as S - A - V - E - M - E Another Greek tool for disguising a message was called the Scytale. It is a tool used to perform a transposition cipher, consisting of a cylinder with a strip of parchment wound around it on which is written a message. In other words, it was a way to rearrange the letters. You would wrap a long thin parchment around a rod. You then write your message across the rod, SEND HELP!

6 1 INTRODUCTION 6 When you unwrap the parchment the letters appear rearranged. To understand the message, the receiver would need a rod of the same size. Julius Caesar used his own way of disguising messages to send to his military. We know call it the Caesar Cipher. If he had anything important to send, he would write out his message and then replace each letter of his message with another letter down the alphabet. So A = D, B = E, C = F, D = G, etc. When it needed to be read, the receiver of the message would reverse this process, changing D back to A, E back to B, F back to C. We will go over this method in great detail in the next chapter. The tool we will use will look something like this,

7 1 INTRODUCTION 7 This method is a form of substitution, where you replace one letter for another. Over the years, the substitution method evolved. In this next chapter, we discuss the Keyword Cipher, which is another form of substitution. The Vigenere cipher was a substitution cipher where each letter of the message used its own caesar shift. This means the first letter might be shifted by 3 letters, the second letter of the message could be shifted by 5 letters, the third letter by 3, the fourth letter by 5, the fifth letter by 3, and so on. This particular pattern would be two Caesar shifts with 3 and 5. For 300 years it was believed to be indecipherable. It can now be broken by determining the number of different caesar shifts and then do a frequency analysis on the letters that use the same Caesar shift. To give you an idea, suppose your keyword is DOG and you want to disguise the message HELP ME, you use the Vigenere Table below to determine the ciphertext.

8 1 INTRODUCTION 8 Message: H E L P M E Keyword: D O G D O G Cipher: K S R S A K Why was this cipher so strong? Consider the ciphertext. There are two K s but each corresonds to a different letter in the plaintext. One K decrypts back to H while the other K decrypts to E. In 1917 U.S. Army Major Joseph Mauborgne developed a technique known as the One-Time Pad. It works the same way as a Vigenere Cipher. The only

9 1 INTRODUCTION 9 difference is the keyword is a random string of letters that is the same length as the message. That way the keyword never repeats which makes frequency analysis useless. If this method is done correctly, it is the only provably unbreakable encryption algorithm. Here s an example. Suppose the ciphertext is KNEXYLTCOW. Now suppose you used two different one-time pad keys, AFTMRDARKF and DJWMRDARKF. Let s see what happens. Use the Vigenere Table to convert back to plaintext. Cipher: K N E X Y L T C O W Key: D J W M R D A R K F Plaintext: H E I L H I T L E R Cipher: K N E X Y L T C O W Key: A F T M R D A R K F Plaintext: K I L L H I T L E R This means you can make the plaintext say anything you want. But there are two main weaknessess to this method. 1. Making sure the key is random and of sufficient length. 2. Distributing the keys. How is the receiver suppose to know which key to use? One way to accompish the distribution of keys is to have an agreed upon book. Each day the random key starts with the first letter of a page in that book. Keep reading the letters from the page until it s the same length as the message. Another interesting use of crytography was to send messages through newspapers. Before the telegraph, people needed to send messages through the mail. Postage could be expensive, plus someone could intercept the letter. Newspapers traveled freely and without charge. So someone could publish an article in the newspaper and put a dot above the letter that was part of the plaintext. For example,

10 1 INTRODUCTION 10 I ȧm exciṫed ṫo ȧnnounce the wedding of my brother. He is baċ k from his journey overseas and is looking forward to a new life with his beautiful bride. Excluding i s, which would have two dots, the letters with dots above them spell World War II attack The Germans adopted the use of a family of electro-mechanical encryption devices invented by the German engineer Arthur Scherbuis. They became known as the Enigma Machines, and were extremely effective during the war. The details about how the Engima machine works is a bit complicated. The Enigma looks roughly like a typewriter. Here s an excerpt from Enigma allowed an operator to type in a message, then scramble it by using three to five notched wheels, which displayed different letters of the alphabet. The receiver needed to know the exact settings of these rotors in order to reconstitute the coded text. Over the years the basic machines became more complicated as German code experts added plugs with electronic circuits. When a key was pressed, a set of electrical contacts in the disks would complete a circuit lighting up the ciphertext letter. The disks would rotate after each letter is pressed providing a different encryption. In 1932, Polish cryptologists broke the Enigma by reverse engineering the machine. As Germany added more complexity to their machine, the initial

11 1 INTRODUCTION 11 decryption techniques became unsuccessful. Poland presented their initial decryption technqiues to the British military intelligence. The cryptanalysts at Bletchley Park used this information to greatly increase their success of decrypting Enigma. Modern Era In 1972, the U.S. identified a need for a government-wide data encryption standard. They went with the encryption technique designed by cryptographers from IBM. It became known as DES. AES, the advanced encrpytion standard replaced DES in In 1977, the RSA algorithm was presented by its creators Ron Rivest, Adi Shamir, and Leonard Adleman from MIT. With many of the classical cryptosystems, the key used to encrypt a message was also used to decrypt the message. Suppose 300 people send financial information to a bank. Each person could encrypt it and have the bank decrypt it. This would, however, require the bank to know 300 separate keys. Not only is it inefficient, how would the bank know each person s key? RSA is called public key encrpytion (asymmetric key encription). To encrypt a message, someone uses a public key known to everyone to encrypt their data. Only the receiver of the message knows the private key to decipher the message. This means 300 people can send their personal info using the bank s public key to encrypt it. Only the bank can decrypt it with their private key. We will discuss more of RSA later on. Now this was only a taste of the more famous works in cryptography. More information can be found through reserach in your libraries or online. 1.4 Kerckhoff s Principles of Cryptographic Secuity You might think that the power behind an encryption technique is keeping the technique secret. This is not true. Kerckhoff s principles (some of them) state 1. The system must be practically indecipherable. In other words, if the data can be deciphered, it must take a very long time.

12 1 INTRODUCTION The system must not be secret. If you encrypted a message using Caesar s cipher, then your evesdropper Eve must also know that. 3. Any evesdroppers or attackers must be able to get their hands on the ciphertext. 4. The security of the system should depend solely on the secrecy of the key. To summarize, a good cryptosystem is one where everyone knows what it is and how it works, everyone can get their hands on the ciphertext, and its strength lies in the secrecy of the key.

13 2 SUBSTITUTION CIPHER 13 2 Substitution Cipher 2.1 Caesar Cipher Activity With a Caesar Cipher, you replace each letter in a message with a letter along the alphabet. A Caesar cipher shifts the alphabet and is therefore also called a shift cipher. The key is the number of letters you shift. The Caesar Cipher is named after Julius Caesar, who is said to have used it to send messages to his generals over 2,000 years ago. You should have a pdf of a Caesar Shift Wheel. Follow the directions to create the wheel. Example: Key: Shift 3 Message: M A T H E Q U A L S M O N E Y Cipher: P D W K H T X D O V P R Q H B 1. Use a key shift of 7, encrypt the following message: Message: W E L C O M E T O M A T H C A M P Cipher: 2. Use a key shift of 13, encrypt the following message: Message: B O W L I N G T O U R N A M E N T T O N I G H T Cipher:

14 2 SUBSTITUTION CIPHER Use a key shift of 20, encrypt the following message: Message: T H E S E C R E T P A S S W O R D I S B O O G E R Cipher: 4. A KEY SPACE is the set of all possible keys. What is the size of the KEY SPACE for the shift cipher?

15 2 SUBSTITUTION CIPHER 15 To decrypt a shift cipher, you just reverse the shift. If you shifted RIGHT 3, then to decrypt the message we shift LEFT 3. Example: Key shift: -3 Cipher: P D W K H T X D O V P R Q H B Plaintext : M A T H E Q U A L S M O N E Y 1. Use a key shift of 4, decrypt the following ciphertext: Ciphertext: G S H I R E Q I: K S S R M I W Plaintext: 2. Choose your own key shift. Encrypt your name and high school grade level Plaintext: Ciphertext: 3. Pass your ciphertext to your neighbor. DO NOT TELL THEM YOUR KEY. Have your neighbor decrypt your message. 4. Go to Use this page to figure out the answer to this riddle. What did the one eye say to the other? Ciphertext: TWLOWWF QGM SFV EW Plaintext: Ciphertext: KGEWLZAFY KEWDDK! Plaintext:

16 2 SUBSTITUTION CIPHER Why can t you tell an egg a joke? Key = 23 Ciphertext: FQ JFDEQ ZOXZH RM. Plaintext: 6. Now that you got a chance to play around with the shift cipher, can you think of any weaknesses in this encryption technique?

17 2 SUBSTITUTION CIPHER Keyword Cipher Activity With a Keyword Shift, you place a word underneath the original alphabet. The Keyletter is the letter where you start your keyword. In this example below, the keyword is KINGDOM and the keyletter is G Starting after the letter M, you fill in the rest of the alphabet. If the letter was already used in the keyword, then you skip it. Also, your keyword cannot have repeated letters. Example: With the keyword: KINGDOM and keyletter M Message: G R A V I T Y I S A D O W N E R! Cipher: K F U P N J S N H U X B Q A Y F! 1. Use the keyword: BACON, keyletter: C

18 2 SUBSTITUTION CIPHER 18 Message: C R Y P T O I S C O O L Ciphertext: 2. Use the keyword: BACON, keyletter A to decrypt the following ciphertext. Ciphertext: T R Y S T B P J G L E H N J J M T M B T R N N Plaintext: 3. Go to Use this page to decrypt the following statement. Keyword: THUNDERCLAP, Keyletter: E ZPA J SPK NWJT DJ ONTA SPK GT JTQJDAU WAZ CSDAU PA SPKG XWYR ONTA SPKG BNPAT ZTYDZTI JP XT W ADAEW, ICDBI JNGPKUN SPKG HDAUTGI, WAZ WJJWYRI SPKG HWYT!

19 2 SUBSTITUTION CIPHER The following are quotes from famous movies. Each quote has been encrypted with the same keyword and keyletter. Your job is to decrypt them and determine its origin. Identify the keyword and keyletter. Use the letter frequency calculator at to help determine the plaintext. WSC ZE RCVMTD, IV VEFVC M ISCOR FYMF ZD VEFZCVOK SGC SIE. TMK FYV WSCPV NV IZFY KSG. FYVCV D ES AOMPV OZUV YSTV. KSG PME F YMEROV FYV FCGFY! KSG CV XSEEM EVVR M NZXXVC NSMF. YVCV D QSYEEK! TK ACVPZSGD. KSGC TSFYVC IMD M YMTDFVC MER KSGC WMFYVC DTVOF SW VORVCNVCCZVD. Z DYMOO PMOO YZT DBGZDYK. MER YV DYMOO NV TZEV. MER YV DYMOO NV TK DBGZDYK. FYVKHV RSEV DFGRZVD, KSG UESI. DZJFK AVCPVEF SW FYV FZTV, ZF ISCUD VHVCK FZTV. CMK, EVJF FZTV DSTVSEV MDUD KSG ZW KSGCV M XSR, KSG DMK KVD!

20 2 SUBSTITUTION CIPHER Vigenere Cipher Activity The Vigenre Cipher is a method of encrypting alphabetic text by using a series of different Caesar ciphers based on the letters of a keyword. Instead of shifting every letter of your plaintext by C = 2, each letter of the plaintext will have a different shift. Though the cipher is easy to understand and implement, for three centuries it resisted all attempts to break it; this earned it the description le chiffre indchiffrable (French for the indecipherable cipher ) (wikipedia). Each letter of the alphabet represents a shift. For example, A = 0 (no shift), B = 1 (shift 1 to the right), C = 2 (shift 2 to the right), D = 3 (shift 3 to the right), E = 4 (shift 4 to the right),... If the keyword is BED, it means you shift the first letter of your cipher by B = 1, the second letter of the cipher by E = 4, third letter by D = 3. Repeat this pattern. The keyword BED converts to the numeric key 143. Consider the following example. You can use your Caesar Shift Wheel to do this. Since you will have to keep changing the shift for each letter, the wheel will help you do it quickly. Example: Using the keyword: NEMO, encrypt the following message. NEMO = (corresponding numeric key)

21 2 SUBSTITUTION CIPHER 21 Example: Using the keyword: CRYPTO, encrypt the following message. CRYPTO = (corresponding numeric key) Decrypting the Ciphertext Decrypting a Vigenere message requires you to reverse the shift from the keyword. You would line up your ciphertext with the numeric key and reverse the shift, just like you reversed the shift with the Caesar Cipher. Example: Using the keyword: AVENGERS, decrypt the following message. Decryping by hand can be tedious. Go to This allows you to encrypt a message with the Vigenere keyword and also decrypt messages very quickly.

22 3 TRANSPOSITION 22 3 Transposition There are two basic ways of encrypting a message. One way is through some sort of substitution, which was covered in the previous section. The other way is through transposition. Transposition ciphers are formed by changing the normal position of the letters that make up the message. 3.1 Easy Example A common transposition can be simply writing out the letters of a word backwards. translates into ATTACK AT DAWN KCATTA TA NWAD You could also read the entire message right to left, which would encrypt to NWAD TA KCATTA 3.2 Railfence Cipher Suppose you have the message STOP THE ATTACK WE ARE OUTNUMBERED 1. Write the message vertical. You must choose how many letters you go down. When you reach the bottom of the column, you start the next column. Some examples, (a) Vertical: 5 S H A A T E T E C R N R O A K E U E P T W O M D T T E U B

23 3 TRANSPOSITION 23 (b) Vertical: 2 S O T E T A K E R O T U B R D T P H A T C W A E U N M E E 2. Next, you would write out the message from left to right like you were reading a book. The cipher text would be (a) Vertical 5 by Horizontal 6: or (without spaces) SHAATE TECRNR OAKEUE PTWOMD TTEUB SHAATETECRNROAKEUEPTWOMDTTEUB (b) Vertical 2 by Horizontal 15: SOTETAKEROTUBRD TPHATCWAEUNMEE or (without spaces) SOTETAKEROTUBRDTPHATCWAEUNMEE 3. You can keep changing the vertical length to get a new cipher for the exact same message. You just need to agree upon a length with the receiver beforehand. 4. To decrypt this message, you ll need the vertical and horizontal length. It s possible to do it without, but it will take a lot of trial and error. 3.3 Transposition Activity Choose a vertical length and encrypt a message. Give your encrypted message to your partner. Try to decipher your partner s message without knowledge of the vertical and horizontal length. After 5 minutes, if you have not deciphered the message, have your partner tell you the vertical and horizontal lengths.

24 4 MODULAR ARITHMETIC 24 4 Modular Arithmetic Clock Example What if we kept counting after 12 o clock? Where would 13 o clock be? Turn the time back into our normal 12 hour time. 13 = o clock 17 = o clock 23 = o clock 24 = o clock The 24 hour clock face:

25 4 MODULAR ARITHMETIC 25 With modular arithmetic, we would use the following notation, 13 1 (mod 12) 17 5 (mod 12) (mod 12) 24 0 (mod 12) Formal Definition of a b (mod n) means congruent a is congruent to b mod n if b a is a integer multiple of n That s great for a math class, but a bit confusing for your first exposure to mod. Another way to look at it is, Informal Definition of a b (mod n) Examples: b is the remainder when you divide a by n = 1 R = 1 R = 1 R = 2 R 0

26 4 MODULAR ARITHMETIC 26 So when we talk about (mod n), we really only care about the remainder when you divide by n. Your answer must be a number between 0 and n Examples of Congruences (mod 12) - answer must be between 0 and (mod 12) (mod 12) (mod 5) - answer must be between 0 and (mod 3) (mod 27) (mod 101) - answer must be between 0 and (mod 27) If the number is negative, you must add multiples of n until you get a number between 0 and n 3 5 (mod 8) because = (mod 8) because = (mod 12) (mod 4) (mod 18) (mod 13)

27 4 MODULAR ARITHMETIC 27 We can do addition, subtraction, multipication, and exponentiation exactly the same way. Give them a try, 4.2 Arithmetic with Congruences (mod 12) (mod 12) (mod 12) (mod 5) (mod 3) (mod 27) (mod 27) (mod 13) (mod 7) (mod 5) 4.3 Multipication Tables Suppose you multiply each number (mod 5) with another number from (mod 5). We can create a table to keep track of the results. * mod Notice how (mod 5). This will be important very soon.

28 4 MODULAR ARITHMETIC 28 Example: Now you try creating a multiplication table for (mod 4), (mod 7) and (mod 11). * mod 4 * mod 7 * mod 11

29 4 MODULAR ARITHMETIC 29 Division is very different. What is 4/3 (mod 7)? Division like this doesn t make sense. When we added, subtracted, and multiplied we still got an integer. We then divided that integer by n. But 4/3 is not an integer! You might recall that 4/3 is the same thing as And 1 3 if we want to compute 4/3 we need to do, is the inverse of 3. So, 4/3 = So what s the inverse of 3 (mod 7)? Recall that the inverse of 3 is a number than when you multiply it to 3 you get 1. Let s look at an example. 3 x = Finding the Inverse (mod 7) We need to solve 3x 1 (mod 7) There are three ways we can do this. Let s first do it by trial and error, (mod 7) (mod 7) (mod 7) (mod 7) (mod 7)

30 4 MODULAR ARITHMETIC 30 From the multiplication table, you should have (mod 7) So if an inverse exists, you can find it from the multiplication table. The third way will be covered in the section The Extended Euclidean Algorithm. So when we are in (mod 7), 3 1 is 5 (mod 7). So 4/3 (mod 7) can be calculated as (mod 4) = 20 6 (mod 7) (mod 11)

31 4 MODULAR ARITHMETIC 31 Please note that some inverses and divisions do not exist. For example, 2 1 (mod 4) did not exist. Therefore, you cannot divide by 2 in (mod 4). However, every number (except 0) in (mod 7) and (mod 11) did have inverses. There is a reason for this. Take some time to think about it. Try creating a multipication table for (mod 12) and see what happens. * mod 12 Example: Find 11 5 (mod 12)

32 4 MODULAR ARITHMETIC Solving Equations (mod n) How did we solve an equation like 3x = 5 from basic algebra? We divided both sides by 3. 3x = 5 3x 3 = 5 3 x = 5 3 So how would we solve the equation 3x 5 (mod 11) Instead of dividing both sides by 3 (we don t do division like this in (mod n)), we multiply both sides by the inverse of 3, x 5 (mod 11) 3 1 3x (mod 11) So what s 3 1 (mod 11)? x (mod 11) From the multiplication table, (mod 11) since (mod 11). Therefore, our solution to 3x 5 (mod 11) is x (mod 11) x 4 5 (mod 11)

33 4 MODULAR ARITHMETIC 33 Now let s verify. Your turn. x 9 mod = 27 5 (mod 11) 1. 5x 7 (mod 12) 2. 7x 9 (mod 12) 3. x 2 1 (mod 12) - use the multiplication table for (mod 12)

34 4 MODULAR ARITHMETIC The Extended Euclidean Algorithm A very useful tool to use when trying to find the inverse of a number (mod n) is called the Extended Euclidean Algorithm. As you probably figured out by now, a number will have an inverse (mod n) as long as that number is relativly prime to n. This method requires the division algorithm on the left hand side, and a recursive formula on the right. Please follow the example below. We need the recursive formula: p i = p i 2 p i 1 q i 2 where p 0 = 0 and p 1 = 1. When you move onto the next step, you use a i = b i 1 and b i = r i 1 3 d 1 (mod 20) a i = q i b i + r i p i = p i 2 p i 1 q i 2 Step 0: 20 = (6) p 0 = 0 Step 1: 3 = (1) p 1 = 1 Step 2: 2 = (2) p 2 = p 0 p 1 q 0 = 0 1(6) = 6 p 3 = p 1 p 2 q 1 = 1 ( 6) 1 = 7 Therefore, the solution to 3 d 1 (mod 20) is d = 7 (mod 20). This means (mod 20) Here s another example: 7 d 1 (mod 40) Remember, a i = b i 1 and b i = r i 1

35 4 MODULAR ARITHMETIC 35 a i = q i b i + r i p i = p i 2 p i 1 q i 2 Step 0: 40 = (5) p 0 = 0 Step 1: 7 = (1) p 1 = 1 Step 2: 5 = (2) p 2 = p 0 p 1 q 0 = 0 1(5) = 5 Step 3: 2 = (2) p 3 = p 1 p 2 q 1 = 1 ( 5)(1) = 6 p 4 = p 2 p 3 q 2 = = 17 Therefore, the solution to 7 d 1 (mod 40) is Just to check, d = (mod 40) 7 23 = (mod 40) Therefore, (mod 40). Your turn! Find 9 1 (mod 16) by solving the following equation. 9 d 1 (mod 16) You ll find a table on the next page to complete the Extended Euclidean Algorithm.

36 4 MODULAR ARITHMETIC 36 a i = q i b i + r i p i = p i 2 p i 1 q i 2 Step 0: Step 1: Step 2: Step 3: Step 4: Step 5: Your inverse is the last p i value in the table. Make sure it s (mod n). The inverse of 9 1 (mod 16) is 9 1 (mod 16) Use the website to confirm the inverse.

37 5 DIFFIE-HELLMAN KEY EXHANGE 37 5 Diffie-Hellman Key Exhange 5.1 What is it? Suppose Alice sends Bob an encrypted message using the Vigenere Cipher. Bob and Alice need to also agree upon the key, otherwise Bob would have to decipher Alice s message the hard way. If Eve, our evesdropper, is aware of the key then she can decipher all of Alice s messages to Bob. Diffie-Hellman Key Exchange allows the sender, Alice, and the receiver, Bob, to come up with a key with public information. The upside to this method is Eve, our evesdropper, is aware of the exchange the whole time but will have a difficult time cracking it and finding the secret key. Here s how it works. 5.2 The Algorithm 1. Alice and Bob agree, publicly, on a prime number P, and another number N, where N < P. Everyone, including Eve, will know these two numbers. 2. Alice chooses her own personal (private) number A. She does not tell anyone this number. This number should be relatively prime to N. 3. Bob chooses his own personal (private) number B. He does not tell anyone this number. This number should be relatively prime to N. 4. Alice calculates the number and sends this number S to Bob. 5. Bob calculates S = N A (mod P ) and sends this number R to Alice. R = N B (mod P ) 6. So now Bob and Alice have two numbers. Eve, who is watching this exchange, is fully aware of the numbers S and R. But since she doesn t know A and B, she doesn t know how Alice and Bob calculated the R and S.

38 5 DIFFIE-HELLMAN KEY EXHANGE Alice takes the number she received from Bob and calculates C = R A (mod P ) and Bob takes the number he received from Alice and calculates C = S B (mod P ) 8. C is their shared key. Since the last step is done in private, Eve does not know C. 5.3 Example of a Key Exhange Alice wants to send the message ATTACK AT DAWN to Bob. Before encrypting it with the Vigenere Cipher, her and Bob need to agree upon the keyword (in numeric form). Alice calls Bob, with Eve evesdropping on this conversation, and come up with a public key P = 983 and N = 20 You ll probably want to use the exponentiation calculator at 1. Alice chooses the number A = 7 and Bob chooses the number B = 9. Remember, these must be relatively prime to N = Alice calculates and sends this number to Bob. 3. Bob calculates S = 20 7 = (mod 983) and sends this number to Alice. R = 20 9 = (mod 983)

39 5 DIFFIE-HELLMAN KEY EXHANGE Alice takes 942 (mod 983) and raises it to her number A = (mod 983) 5. Bob takes 312 (mod 983) and raises it to his number B = (mod 983) 6. So Alice encrypts the message ATTACK AT DAWN with the Vigenere numeric key 101, or its equivalent alphabetic key BAB. The cipher text is 5.4 Why is Cracking this Exchange Difficult In the previous example, here is all the information Eve has during this key exchange. P = 983, N = 20,, S = 312, and R = 942 In order for Eve, our evesdropper, to determine the keyword, she needs to solve the following equations or A (mod 983) B (mod 983) This is difficult to do, especially when P and N are extremely large. Our example, they aren t large. But even for us, our best bet is probably trial and error. We would try to plug in all the values (mod 983) for A and B and see which work.

40 5 DIFFIE-HELLMAN KEY EXHANGE Key Exhange Activity Get in groups of 3. One of you will be Alice, another will be Bob, and the third will be Alice. In this activity, Alice and Bob will come up with their Vigenere Cipher key right in front of Eve. 1. Alice writes a message. It doesn t matter how long since you will be using the online Vigenere Cipher. You want to send this message to Bob. Do not show this message to anyone. 2. Alice and Bob now speak to each other publicly. Eve is there listening and taking notes. Alice and Bob agree on two numbers. Choose a prime number P and another number N less than P. You may use the website to generate the prime number. P = and N = 3. Alice and Bob choose their private number. If you re Alice write it below and calculate A = If you are Bob, write it below N A (mod P) and calculate B = N B (mod P) 4. Alice and Bob exchange numbers. Eve receives these numbers as well. 5. Alice and Bob finish the calculations to come with the key. Alice uses the Vigenere Cipher at to create the ciphertext.

41 5 DIFFIE-HELLMAN KEY EXHANGE Alice sends the message to Bob for him to decipher. 7. Eve should write down the equations she must solve in order to calculate their private key. She may try to crack it by using trial and error. Change positions and redo this until everyone gets a chance to be Alice.

42 6 RSA ENCRYPTION 42 6 RSA Encryption 6.1 Introduction I can think of two uses for RSA encryption that should make sense to us. In the last chapter, we discussed a key exhange. This is a method for Alice and Bob to commuicate publicly to create a secret key. If done correctly, Eve should have a very hard time figuring this key out. RSA encryption can also be used to send the key. It s very similar to the Diffie-Hellman Key Exhange. RSA is called public key encryption (or asymmetric-key encryption). It means that there is a public key to encrypt the data and a secret key (only the receiver of the message knows) that will decrypt the data. So Alice chooses the keyword for the Vigenere Cipher. She uses the public key to encrypt her keyword and sends the ciphertext to Bob. Bob uses his secret key, known only to him, to decrypt it. With the keyword now agreed upon, Alice can use a different method to encrypt the data and send it to Bob. Another use of RSA encryption is called Authentication. Suppose Bob recevies a message, supposedly from Alice. How does he actually know this message is from Alice? It s possible Eve intercepted the message and created her own to send to Bob. 6.2 Example of RSA Encryption Let s do an example using RSA. Public key is (e, n) = (3, 33) Message: A T T A C K N O W First, let s convert the letters to numbers using A = 0, B = 1, C = 2, D = 3,..., X = 23, Y = 24, Z = 25. Later on we will convert letters to their ASCII number. Message: A T T A C K N O W Pre-Cipher: e = 3 is called the encryption key. Raise each number in the pre-cipher to e = 3, (mod 33).

43 6 RSA ENCRYPTION 43 A: (mod 33) T: 19 3 = (mod 33) T: 19 3 = (mod 33) A: (mod 33) C: (mod 33) K: 10 3 = (mod 33) N: 13 3 = (mod 33) O: 14 3 = (mod 33) W: 22 3 = (mod 33) Message: A T T A C K N O W Cipher: Everyone has access to the public key. Only the receiver of the encrypted data has the private key. This is called asymmetric key encryption. It means there is one key to encrypt and a completely different key to decrypt. The private key for our example is d = 7. Let s see what happens when we raise our ciphertext numbers to the power of d = (mod 33) (mod 33) (mod 33) (mod 33) (mod 33) (mod 33) (mod 33) (mod 33) (mod 33)

44 6 RSA ENCRYPTION 44 We get back the original set of numbers Plaintext: Message: A T T A C K N O W Suppose you want to send the number M. The ciphertext is C M 3 (mod 33) To decrypt the ciphertext, you compute M C 7 (mod 33) So to encrypt a number, we raised it to the 3rd power. To undo it, we raise it to the 7th power. The question now is how do you come up with the private key d = 7? Warning: Notice the same letter encrypted to the same number. Those numbers carry the same statistical information as the Ceasar method. Once I figure out T = 28, I can replace all 28s with T. This is no good to us. So let s go back to Message: A T T A C K N O W Cipher: Instead of enrypting 0, 19, 19, 0, 2, 10, 13, 14, and 22, we can regroup the numbers. One example would be, 01, 91, 90, 21, 01, 31, 42, 2

45 6 RSA ENCRYPTION 45 The problem is our modulus is 33, which is too small (since we have numbers larger than 33-91, 90, 42) We need to choose a larger modulus and figure out a new public and private key. Let s figure out how to do this now. 6.3 RSA Algorithm Suppose Alice wants to send Bob a message. She uses Bob s public key (e, n). Let s see how Bob came up with his public/private key by coming up with our own public and private key. 1. Bob chooses two large primes. Call them p and q. He must keep these secret! Now you choose two primes (preferably between 10 and 20). p = q = 2. He then computes n = p q. This is part of the public key. n = 3. Bob computes φ(n) = (p 1) (q 1) φ(n) = 4. Bob chooses an integer e, 1 < e < φ(n) where e does not share any factors with φ(n). This is called copime (or relatively prime). Example: 8 and 15 are coprime because they share no factors. Example: 9 and 24 are NOT coprime because they share a common factor 3.

46 6 RSA ENCRYPTION 46 e = 5. Bob now has his public key (e, n). Your public key is (e, n) = (, ) 6. Bob then computes his private key d. To find d, you must solve the following equation e d 1 (mod n) Your equation is d 1 (mod ) Let s go over how Bob found d to the following equation. Then follow the pattern. This may take a few tries to get right. 6.4 Using The Extended Euclidean Algorithm We need the recursive formula: p i = p i 2 p i 1 q i 2 where p 0 = 0 and p 1 = 1. When you move onto the next step, you use a i = b i 1 and b i = r i 1 3 d 1 (mod 20)

47 6 RSA ENCRYPTION 47 a i = q i b i + r i p i = p i 2 p i 1 q i 2 Step 0: 20 = (6) p 0 = 0 Step 1: 3 = (1) p 1 = 1 Step 2: 2 = (2) p 2 = p 0 p 1 q 0 = 0 1(6) = 6 p 3 = p 1 p 2 q 1 = 1 ( 6) 1 = 7 Therefore, the solution to 3 d 1 (mod 20) is d = 7 (mod 20). This is how Bob got his private key. To view another example, please check out the Extended Euclidean Algorithm section in Modular Arithmetic. Your turn! d 1 (mod ) a i = q i b i + r i p i = p i 2 p i 1 q i 2 Step 0: Step 1: Step 2: Step 3: Step 4: Step 5:

48 6 RSA ENCRYPTION 48 Your d is the last p i value in the table. Make sure it s (mod n). Your private key is d = Use the website to confirm the inverse. Example: Use your public key to encrypt the following. First, convert the letters to numbers. Message: M A T H E Q U A L S M O N E Y Pre-Cipher: To encrypt each number N into the cipher C C N e (mod n) Use my expontentiation calculator at

49 6 RSA ENCRYPTION 49 M: (mod ) A: (mod ) T: (mod ) H: (mod ) E: (mod ) Q: (mod ) U: (mod ) A: (mod ) L: (mod ) S: (mod ) M: (mod ) O: (mod ) N: (mod ) E: (mod ) Y: (mod ) To practice RSA encryption, work with a partner. Write a short message (no more than 20 letters) and encrypt it using your partner s public key. Do not tell your partner your plaintext message. Give them only the ciphertext. Your partner then decrypts the ciphertext using his or her private key to reveal your message. Remember, to decrypt the message do the following N C d (mod n) Using the website genereate your own public and private key. Exchange public keys with your partner. Use your partner s public key to encrypt a word (at most 7 letters). Have your partner decrypt the word. Since the modular exponentiation will be large, use the following websites to help

50 6 RSA ENCRYPTION 50 and How do we make this harder to crack? Let me return to our previous example of encrypting ATTACK NOW Use the ASCII table provided below to convert every character (including the space, periods, etc.) into its correponding ASCII number. 6.5 ASCII Table

51 6 RSA ENCRYPTION 51 After converting the characters to their corresponding ASCII numbers, we get the following, Message: A T T A C K N O W Plaintext: Let s use the public key (e = 709, n = 923). To make this harder to crack, we regroup the numbers into blocks of 3. There is nothing special about the size of the block. You just have to make sure the numbers you re encrypting are less than n = Since the numbers will get large, use the calculator at (mod 923) (mod 923) (mod 923) (mod 923) (mod 923) (mod 923) (mod 923) Therefore, the message ATTACK NOW encrypts to

52 6 RSA ENCRYPTION 52 Suppose you re Eve and you come across this encrypted message. You know the method used and you know Bob s public key (709, 923). How do we crack it? 6.6 Cracking RSA by finding the private key d. To decrypt the ciphertext, we need the private key d. So let s try to crack it. 1. Factor n = 923 into two prime numbers p and q. 2. Calculte φ(n) = (p 1) (q 1) n = φ(923) = 3. Now solve the equation using the Extended Euclidean Algorithm. 709 d 1 (mod 840) q i p i = p i 2 p i 1 q i 2 Step 0: Step 1: Step 2: Step 3: Step 4: Step 5: Step 6:

53 6 RSA ENCRYPTION 53 Good! You now have the private key d = Use to complete the exponentiation. Raise each block of the ciphertext by the power of d. (mod 923) (mod 923) (mod 923) (mod 923 (mod 923) (mod 923) (mod 923) 4. After decrypting the numbers, you should have Regroup the numbers back into blocks of 2 (starting from the left) 6. Finally rewrite the ASCII number back into its characters. 6.7 Your turn to crack an RSA encrypted message You are Eve and you intercept a message sent from Alice to Bob. It was encrypted using Bob s public key (n = , e = ). The ciphertext is

54 7 USING RSA FOR AUTHENTICATION 54 To crack the code, find the private key d. Follow the method we used to crack the RSA example from before. Start by factoring n. You can decrypt it using the private key d using the website If you re doing it by hand, the original block size (before encryption) was 4. or the website Use a block size of 2 on this website. There you go. This is the general idea behind the RSA encryption. Now before we finish with our RSA introduction, I d like to show you the size of a typical modulus n Can you see why trying to factor n to crack RSA is hard? Even if you can factor it, you still need to find the private key d. 7 Using RSA for Authentication 7.1 Algorithm As noted earlier, how does Bob actually know the message is sent from Alice. Here s what she does. 1. Alice pubicly announces her RSA public key, say (n = 2263, e = 917). 2. She converts her name to ASCII numbers: She then encrypts her name with her private key d = Remember that only Alice knows the private key. You may need the calculator at

55 7 USING RSA FOR AUTHENTICATION (mod 2263) (mod 2263) (mod 2263) (mod 2263) (mod 2263) 3. She sends her encrypted name along with the encrypted message meant for Bob. ALICE Encrypted: Bob receives two ciphers. One is Alice s encrypted name. The other is the actual encrypted message. Bob decrypts her message, but isn t convinced it was sent from Alice. 5. Bob uses Alice s public key, which is accessible by everyone, to decrypt the name (mod 2263) (mod 2263) (mod 2263) (mod 2263) (mod 2263) ALICE 6. Since Alice sent her name by encrypting it with her private key, no one can fake this. The only way Eve can fake her name is by encrypting ALICE with her private key. And the only way Eve can do that is by cracking her RSA public key.

56 7 USING RSA FOR AUTHENTICATION Authentication Activity 1. Get in groups of 3. One person is Alice, another is Bob, and the third is Alice. 2. Alice needs to generate a public key. She also needs her find her private key. She can do this by hand or use the RSA Key Generator at Alice will create a message and encrypt it. She may use any method she wants. 3. Eve will create her own message (something that may contradict Alice s message). Example: (a) Alice may encrypt the message ATTACK AT DAWN using the Caesar Cipher. (b) Eve may encrypt DO NOT ATTACK AT DAWN using the Caesar Cipher. 4. Using Alice s public key, she encrypts her name by using her private key. 5. Eve will also encrypt Alice s name, but she must guess on the private key. 6. Both Alice and Eve send Bob their messages with the encrypted name. 7. Bob decrypts both message. Not sure which message came from Alice, use Alice s public key to decrypt the names. 8. Unless Eve guessed correctly on Alice s private key, Alice s encrypted name should decrypt back to Alice and Eve s should decrypt to jibberish.

57 8 IMPORTANT INFORMATION 57 8 Important Information 8.1 Caesar Shift Wheel

58 8 IMPORTANT INFORMATION Letter Frequency Tables

59 8 IMPORTANT INFORMATION Vigenere s Table

60 8 IMPORTANT INFORMATION ASCII Table 8.5 Useful Websites Random Substitution Generator Easier Caesar Cipher Caesar Cipher Keyword Substitution Cipher

61 8 IMPORTANT INFORMATION 61 Vigenere Ciphere Letter Frequency Modular Exponentiation Modular Inverse String to ASCII ASCII to String Easier RSA - No Blocking Before Encrypting RSA - Blocking Before Encrypting Generate RSA Public and Private Keys Generate Prime Numbers

The number theory behind cryptography

The number theory behind cryptography The University of Vermont May 16, 2017 What is cryptography? Cryptography is the practice and study of techniques for secure communication in the presence of adverse third parties. What is cryptography?

More information

MA 111, Topic 2: Cryptography

MA 111, Topic 2: Cryptography MA 111, Topic 2: Cryptography Our next topic is something called Cryptography, the mathematics of making and breaking Codes! In the most general sense, Cryptography is the mathematical ideas behind changing

More information

B. Substitution Ciphers, continued. 3. Polyalphabetic: Use multiple maps from the plaintext alphabet to the ciphertext alphabet.

B. Substitution Ciphers, continued. 3. Polyalphabetic: Use multiple maps from the plaintext alphabet to the ciphertext alphabet. B. Substitution Ciphers, continued 3. Polyalphabetic: Use multiple maps from the plaintext alphabet to the ciphertext alphabet. Non-periodic case: Running key substitution ciphers use a known text (in

More information

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography

Mathematics Explorers Club Fall 2012 Number Theory and Cryptography Mathematics Explorers Club Fall 2012 Number Theory and Cryptography Chapter 0: Introduction Number Theory enjoys a very long history in short, number theory is a study of integers. Mathematicians over

More information

Diffie-Hellman key-exchange protocol

Diffie-Hellman key-exchange protocol Diffie-Hellman key-exchange protocol This protocol allows two users to choose a common secret key, for DES or AES, say, while communicating over an insecure channel (with eavesdroppers). The two users

More information

Classical Cryptography

Classical Cryptography Classical Cryptography CS 6750 Lecture 1 September 10, 2009 Riccardo Pucella Goals of Classical Cryptography Alice wants to send message X to Bob Oscar is on the wire, listening to all communications Alice

More information

Linear Congruences. The solutions to a linear congruence ax b (mod m) are all integers x that satisfy the congruence.

Linear Congruences. The solutions to a linear congruence ax b (mod m) are all integers x that satisfy the congruence. Section 4.4 Linear Congruences Definition: A congruence of the form ax b (mod m), where m is a positive integer, a and b are integers, and x is a variable, is called a linear congruence. The solutions

More information

Cryptography Made Easy. Stuart Reges Principal Lecturer University of Washington

Cryptography Made Easy. Stuart Reges Principal Lecturer University of Washington Cryptography Made Easy Stuart Reges Principal Lecturer University of Washington Why Study Cryptography? Secrets are intrinsically interesting So much real-life drama: Mary Queen of Scots executed for treason

More information

Lecture 32. Handout or Document Camera or Class Exercise. Which of the following is equal to [53] [5] 1 in Z 7? (Do not use a calculator.

Lecture 32. Handout or Document Camera or Class Exercise. Which of the following is equal to [53] [5] 1 in Z 7? (Do not use a calculator. Lecture 32 Instructor s Comments: This is a make up lecture. You can choose to cover many extra problems if you wish or head towards cryptography. I will probably include the square and multiply algorithm

More information

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext Cryptography Codes Lecture 3: The Times Cipher, Factors, Zero Divisors, and Multiplicative Inverses Spring 2015 Morgan Schreffler Office: POT 902 http://www.ms.uky.edu/~mschreffler New Cipher Times Enemy

More information

1 Introduction to Cryptology

1 Introduction to Cryptology U R a Scientist (CWSF-ESPC 2017) Mathematics and Cryptology Patrick Maidorn and Michael Kozdron (Department of Mathematics & Statistics) 1 Introduction to Cryptology While the phrase making and breaking

More information

Public Key Cryptography Great Ideas in Theoretical Computer Science Saarland University, Summer 2014

Public Key Cryptography Great Ideas in Theoretical Computer Science Saarland University, Summer 2014 7 Public Key Cryptography Great Ideas in Theoretical Computer Science Saarland University, Summer 2014 Cryptography studies techniques for secure communication in the presence of third parties. A typical

More information

Cryptography. Module in Autumn Term 2016 University of Birmingham. Lecturers: Mark D. Ryan and David Galindo

Cryptography. Module in Autumn Term 2016 University of Birmingham. Lecturers: Mark D. Ryan and David Galindo Lecturers: Mark D. Ryan and David Galindo. Cryptography 2017. Slide: 1 Cryptography Module in Autumn Term 2016 University of Birmingham Lecturers: Mark D. Ryan and David Galindo Slides originally written

More information

EE 418: Network Security and Cryptography

EE 418: Network Security and Cryptography EE 418: Network Security and Cryptography Homework 3 Solutions Assigned: Wednesday, November 2, 2016, Due: Thursday, November 10, 2016 Instructor: Tamara Bonaci Department of Electrical Engineering University

More information

Number Theory and Public Key Cryptography Kathryn Sommers

Number Theory and Public Key Cryptography Kathryn Sommers Page!1 Math 409H Fall 2016 Texas A&M University Professor: David Larson Introduction Number Theory and Public Key Cryptography Kathryn Sommers Number theory is a very broad and encompassing subject. At

More information

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext Cryptography Codes Lecture 4: The Times Cipher, Factors, Zero Divisors, and Multiplicative Inverses Spring 2014 Morgan Schreffler Office: POT 902 http://www.ms.uky.edu/~mschreffler New Cipher Times Enemy

More information

Drill Time: Remainders from Long Division

Drill Time: Remainders from Long Division Drill Time: Remainders from Long Division Example (Drill Time: Remainders from Long Division) Get some practice finding remainders. Use your calculator (if you want) then check your answers with a neighbor.

More information

Number Theory and Security in the Digital Age

Number Theory and Security in the Digital Age Number Theory and Security in the Digital Age Lola Thompson Ross Program July 21, 2010 Lola Thompson (Ross Program) Number Theory and Security in the Digital Age July 21, 2010 1 / 37 Introduction I have

More information

DUBLIN CITY UNIVERSITY

DUBLIN CITY UNIVERSITY DUBLIN CITY UNIVERSITY SEMESTER ONE EXAMINATIONS 2013 MODULE: (Title & Code) CA642 Cryptography and Number Theory COURSE: M.Sc. in Security and Forensic Computing YEAR: 1 EXAMINERS: (Including Telephone

More information

Keeping secrets secret

Keeping secrets secret Keeping s One of the most important concerns with using modern technology is how to keep your s. For instance, you wouldn t want anyone to intercept your emails and read them or to listen to your mobile

More information

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography

Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography Discrete Mathematics & Mathematical Reasoning Multiplicative Inverses and Some Cryptography Colin Stirling Informatics Some slides based on ones by Myrto Arapinis Colin Stirling (Informatics) Discrete

More information

Data security (Cryptography) exercise book

Data security (Cryptography) exercise book University of Debrecen Faculty of Informatics Data security (Cryptography) exercise book 1 Contents 1 RSA 4 1.1 RSA in general.................................. 4 1.2 RSA background.................................

More information

Public Key Cryptography

Public Key Cryptography Public Key Cryptography How mathematics allows us to send our most secret messages quite openly without revealing their contents - except only to those who are supposed to read them The mathematical ideas

More information

Grade 7 and 8 Math Circles March 19th/20th/21st. Cryptography

Grade 7 and 8 Math Circles March 19th/20th/21st. Cryptography Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 7 and 8 Math Circles March 19th/20th/21st Cryptography Introduction Before we begin, it s important

More information

Public Key Encryption

Public Key Encryption Math 210 Jerry L. Kazdan Public Key Encryption The essence of this procedure is that as far as we currently know, it is difficult to factor a number that is the product of two primes each having many,

More information

Math 1111 Math Exam Study Guide

Math 1111 Math Exam Study Guide Math 1111 Math Exam Study Guide The math exam will cover the mathematical concepts and techniques we ve explored this semester. The exam will not involve any codebreaking, although some questions on the

More information

Chapter 4 The Data Encryption Standard

Chapter 4 The Data Encryption Standard Chapter 4 The Data Encryption Standard History of DES Most widely used encryption scheme is based on DES adopted by National Bureau of Standards (now National Institute of Standards and Technology) in

More information

The Chinese Remainder Theorem

The Chinese Remainder Theorem The Chinese Remainder Theorem Theorem. Let m and n be two relatively prime positive integers. Let a and b be any two integers. Then the two congruences x a (mod m) x b (mod n) have common solutions. Any

More information

CPSC 467: Cryptography and Computer Security

CPSC 467: Cryptography and Computer Security CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 5b September 11, 2013 CPSC 467, Lecture 5b 1/11 Stream ciphers CPSC 467, Lecture 5b 2/11 Manual stream ciphers Classical stream ciphers

More information

The Chinese Remainder Theorem

The Chinese Remainder Theorem The Chinese Remainder Theorem Theorem. Let n 1,..., n r be r positive integers relatively prime in pairs. (That is, gcd(n i, n j ) = 1 whenever 1 i < j r.) Let a 1,..., a r be any r integers. Then the

More information

Cryptography. 2. decoding is extremely difficult (for protection against eavesdroppers);

Cryptography. 2. decoding is extremely difficult (for protection against eavesdroppers); 18.310 lecture notes September 2, 2013 Cryptography Lecturer: Michel Goemans 1 Public Key Cryptosystems In these notes, we will be concerned with constructing secret codes. A sender would like to encrypt

More information

CHAPTER 2. Modular Arithmetic

CHAPTER 2. Modular Arithmetic CHAPTER 2 Modular Arithmetic In studying the integers we have seen that is useful to write a = qb + r. Often we can solve problems by considering only the remainder, r. This throws away some of the information,

More information

Purple. Used by Japanese government. Not used for tactical military info. Used to send infamous 14-part message

Purple. Used by Japanese government. Not used for tactical military info. Used to send infamous 14-part message Purple Purple 1 Purple Used by Japanese government o Diplomatic communications o Named for color of binder cryptanalysts used o Other Japanese ciphers: Red, Coral, Jade, etc. Not used for tactical military

More information

Cryptography CS 555. Topic 20: Other Public Key Encryption Schemes. CS555 Topic 20 1

Cryptography CS 555. Topic 20: Other Public Key Encryption Schemes. CS555 Topic 20 1 Cryptography CS 555 Topic 20: Other Public Key Encryption Schemes Topic 20 1 Outline and Readings Outline Quadratic Residue Rabin encryption Goldwasser-Micali Commutative encryption Homomorphic encryption

More information

Xor. Isomorphisms. CS70: Lecture 9. Outline. Is public key crypto possible? Cryptography... Public key crypography.

Xor. Isomorphisms. CS70: Lecture 9. Outline. Is public key crypto possible? Cryptography... Public key crypography. CS70: Lecture 9. Outline. 1. Public Key Cryptography 2. RSA system 2.1 Efficiency: Repeated Squaring. 2.2 Correctness: Fermat s Theorem. 2.3 Construction. 3. Warnings. Cryptography... m = D(E(m,s),s) Alice

More information

Lecture 1: Introduction

Lecture 1: Introduction Lecture 1: Introduction Instructor: Omkant Pandey Spring 2018 (CSE390) Instructor: Omkant Pandey Lecture 1: Introduction Spring 2018 (CSE390) 1 / 13 Cryptography Most of us rely on cryptography everyday

More information

Distribution of Primes

Distribution of Primes Distribution of Primes Definition. For positive real numbers x, let π(x) be the number of prime numbers less than or equal to x. For example, π(1) = 0, π(10) = 4 and π(100) = 25. To use some ciphers, we

More information

Assignment 2. Due: Monday Oct. 15, :59pm

Assignment 2. Due: Monday Oct. 15, :59pm Introduction To Discrete Math Due: Monday Oct. 15, 2012. 11:59pm Assignment 2 Instructor: Mohamed Omar Math 6a For all problems on assignments, you are allowed to use the textbook, class notes, and other

More information

Block Ciphers Security of block ciphers. Symmetric Ciphers

Block Ciphers Security of block ciphers. Symmetric Ciphers Lecturers: Mark D. Ryan and David Galindo. Cryptography 2016. Slide: 26 Assume encryption and decryption use the same key. Will discuss how to distribute key to all parties later Symmetric ciphers unusable

More information

Cryptography, Number Theory, and RSA

Cryptography, Number Theory, and RSA Cryptography, Number Theory, and RSA Joan Boyar, IMADA, University of Southern Denmark November 2015 Outline Symmetric key cryptography Public key cryptography Introduction to number theory RSA Modular

More information

Sheet 1: Introduction to prime numbers.

Sheet 1: Introduction to prime numbers. Option A Hand in at least one question from at least three sheets Sheet 1: Introduction to prime numbers. [provisional date for handing in: class 2.] 1. Use Sieve of Eratosthenes to find all prime numbers

More information

CS70: Lecture 8. Outline.

CS70: Lecture 8. Outline. CS70: Lecture 8. Outline. 1. Finish Up Extended Euclid. 2. Cryptography 3. Public Key Cryptography 4. RSA system 4.1 Efficiency: Repeated Squaring. 4.2 Correctness: Fermat s Theorem. 4.3 Construction.

More information

Related Ideas: DHM Key Mechanics

Related Ideas: DHM Key Mechanics Related Ideas: DHM Key Mechanics Example (DHM Key Mechanics) Two parties, Alice and Bob, calculate a key that a third person Carl will never know, even if Carl intercepts all communication between Alice

More information

EE 418 Network Security and Cryptography Lecture #3

EE 418 Network Security and Cryptography Lecture #3 EE 418 Network Security and Cryptography Lecture #3 October 6, 2016 Classical cryptosystems. Lecture notes prepared by Professor Radha Poovendran. Tamara Bonaci Department of Electrical Engineering University

More information

Solutions for the Practice Final

Solutions for the Practice Final Solutions for the Practice Final 1. Ian and Nai play the game of todo, where at each stage one of them flips a coin and then rolls a die. The person who played gets as many points as the number rolled

More information

Overview. The Big Picture... CSC 580 Cryptography and Computer Security. January 25, Math Basics for Cryptography

Overview. The Big Picture... CSC 580 Cryptography and Computer Security. January 25, Math Basics for Cryptography CSC 580 Cryptography and Computer Security Math Basics for Cryptography January 25, 2018 Overview Today: Math basics (Sections 2.1-2.3) To do before Tuesday: Complete HW1 problems Read Sections 3.1, 3.2

More information

Math 1111 Math Exam Study Guide

Math 1111 Math Exam Study Guide Math 1111 Math Exam Study Guide The math exam will cover the mathematical concepts and techniques we ve explored this semester. The exam will not involve any codebreaking, although some questions on the

More information

Algorithmic Number Theory and Cryptography (CS 303)

Algorithmic Number Theory and Cryptography (CS 303) Algorithmic Number Theory and Cryptography (CS 303) Modular Arithmetic and the RSA Public Key Cryptosystem Jeremy R. Johnson 1 Introduction Objective: To understand what a public key cryptosystem is and

More information

#27: Number Theory, Part II: Modular Arithmetic and Cryptography May 1, 2009

#27: Number Theory, Part II: Modular Arithmetic and Cryptography May 1, 2009 #27: Number Theory, Part II: Modular Arithmetic and Cryptography May 1, 2009 This week you will study modular arithmetic arithmetic where we make the natural numbers wrap around by only considering their

More information

Fermat s little theorem. RSA.

Fermat s little theorem. RSA. .. Computing large numbers modulo n (a) In modulo arithmetic, you can always reduce a large number to its remainder a a rem n (mod n). (b) Addition, subtraction, and multiplication preserve congruence:

More information

Codes and Nomenclators

Codes and Nomenclators Spring 2011 Chris Christensen Codes and Nomenclators In common usage, there is often no distinction made between codes and ciphers, but in cryptology there is an important distinction. Recall that a cipher

More information

Grade 7 & 8 Math Circles October 12, 2011 Modular Arithmetic

Grade 7 & 8 Math Circles October 12, 2011 Modular Arithmetic 1 University of Waterloo Faculty of Mathematics Centre for Education in Mathematics and Computing Grade 7 & 8 Math Circles October 12, 2011 Modular Arithmetic To begin: Before learning about modular arithmetic

More information

MA/CSSE 473 Day 9. The algorithm (modified) N 1

MA/CSSE 473 Day 9. The algorithm (modified) N 1 MA/CSSE 473 Day 9 Primality Testing Encryption Intro The algorithm (modified) To test N for primality Pick positive integers a 1, a 2,, a k < N at random For each a i, check for a N 1 i 1 (mod N) Use the

More information

6.2 Modular Arithmetic

6.2 Modular Arithmetic 6.2 Modular Arithmetic Every reader is familiar with arithmetic from the time they are three or four years old. It is the study of numbers and various ways in which we can combine them, such as through

More information

Cryptography Lecture 1: Remainders and Modular Arithmetic Spring 2014 Morgan Schreffler Office: POT 902

Cryptography Lecture 1: Remainders and Modular Arithmetic Spring 2014 Morgan Schreffler Office: POT 902 Cryptography Lecture 1: Remainders and Modular Arithmetic Spring 2014 Morgan Schreffler Office: POT 902 http://www.ms.uky.edu/~mschreffler Topic Idea: Cryptography Our next topic is something called Cryptography,

More information

DUBLIN CITY UNIVERSITY

DUBLIN CITY UNIVERSITY DUBLIN CITY UNIVERSITY SEMESTER ONE EXAMINATIONS 2013/2014 MODULE: CA642/A Cryptography and Number Theory PROGRAMME(S): MSSF MCM ECSA ECSAO MSc in Security & Forensic Computing M.Sc. in Computing Study

More information

Cryptography Math 1580 Silverman First Hour Exam Mon Oct 2, 2017

Cryptography Math 1580 Silverman First Hour Exam Mon Oct 2, 2017 Name: Cryptography Math 1580 Silverman First Hour Exam Mon Oct 2, 2017 INSTRUCTIONS Read Carefully Time: 50 minutes There are 5 problems. Write your name legibly at the top of this page. No calculators

More information

Journal of Discrete Mathematical Sciences & Cryptography Vol. ( ), No., pp. 1 10

Journal of Discrete Mathematical Sciences & Cryptography Vol. ( ), No., pp. 1 10 Dynamic extended DES Yi-Shiung Yeh 1, I-Te Chen 2, Ting-Yu Huang 1, Chan-Chi Wang 1, 1 Department of Computer Science and Information Engineering National Chiao-Tung University 1001 Ta-Hsueh Road, HsinChu

More information

Introduction. and Z r1 Z rn. This lecture aims to provide techniques. CRT during the decription process in RSA is explained.

Introduction. and Z r1 Z rn. This lecture aims to provide techniques. CRT during the decription process in RSA is explained. THE CHINESE REMAINDER THEOREM INTRODUCED IN A GENERAL KONTEXT Introduction The rst Chinese problem in indeterminate analysis is encountered in a book written by the Chinese mathematician Sun Tzi. The problem

More information

Classification of Ciphers

Classification of Ciphers Classification of Ciphers A Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master of Technology by Pooja Maheshwari to the Department of Computer Science & Engineering Indian

More information

Cryptography s Application in Numbers Station

Cryptography s Application in Numbers Station Cryptography s Application in Numbers Station Jacqueline - 13512074 1 Program Studi Teknik Informatika Sekolah Teknik Elektro dan Informatika Institut Teknologi Bandung, Jl. Ganesha 10 Bandung 40132, Indonesia

More information

Alan Turing: Codebreaker

Alan Turing: Codebreaker 1 CLOSE READING Alan Turing: Codebreaker Invisible ink, cipher wheels, and hidden messages these are the spy gadgets of the past. Modern spy devices include unmanned aircraft and other spy planes. But

More information

Practice Midterm 2 Solutions

Practice Midterm 2 Solutions Practice Midterm 2 Solutions May 30, 2013 (1) We want to show that for any odd integer a coprime to 7, a 3 is congruent to 1 or 1 mod 7. In fact, we don t need the assumption that a is odd. By Fermat s

More information

An Introduction to Traditional Cryptography and Cryptanalysis for Amateurs. Chris Spackman

An Introduction to Traditional Cryptography and Cryptanalysis for Amateurs. Chris Spackman An Introduction to Traditional Cryptography and Cryptanalysis for Amateurs Chris Spackman 10 Feb. 2003 Contents 1 Preface 2 1.1 Conventions Used in this Book................... 2 1.2 Warning: Randomness.......................

More information

A STENO HIDING USING CAMOUFLAGE BASED VISUAL CRYPTOGRAPHY SCHEME

A STENO HIDING USING CAMOUFLAGE BASED VISUAL CRYPTOGRAPHY SCHEME International Journal of Power Control Signal and Computation (IJPCSC) Vol. 2 No. 1 ISSN : 0976-268X A STENO HIDING USING CAMOUFLAGE BASED VISUAL CRYPTOGRAPHY SCHEME 1 P. Arunagiri, 2 B.Rajeswary, 3 S.Arunmozhi

More information

A Quick Introduction to Modular Arithmetic

A Quick Introduction to Modular Arithmetic A Quick Introduction to Modular Arithmetic Art Duval University of Texas at El Paso November 16, 2004 1 Idea Here are a few quick motivations for modular arithmetic: 1.1 Sorting integers Recall how you

More information

Solution: Alice tosses a coin and conveys the result to Bob. Problem: Alice can choose any result.

Solution: Alice tosses a coin and conveys the result to Bob. Problem: Alice can choose any result. Example - Coin Toss Coin Toss: Alice and Bob want to toss a coin. Easy to do when they are in the same room. How can they toss a coin over the phone? Mutual Commitments Solution: Alice tosses a coin and

More information

MAT199: Math Alive Cryptography Part 2

MAT199: Math Alive Cryptography Part 2 MAT199: Math Alive Cryptography Part 2 1 Public key cryptography: The RSA algorithm After seeing several examples of classical cryptography, where the encoding procedure has to be kept secret (because

More information

ElGamal Public-Key Encryption and Signature

ElGamal Public-Key Encryption and Signature ElGamal Public-Key Encryption and Signature Çetin Kaya Koç koc@cs.ucsb.edu Çetin Kaya Koç http://koclab.org Winter 2017 1 / 10 ElGamal Cryptosystem and Signature Scheme Taher ElGamal, originally from Egypt,

More information

Workbook. Janet Beissinger and Vera Pless

Workbook. Janet Beissinger and Vera Pless Workbook The Cryptoclub Using Mathematics to Make and Break Secret Codes Janet Beissinger and Vera Pless Workbook to accompany The Cryptoclub Using Mathematics to Make and Break Secret Codes Janet Beissinger

More information

La Storia dei Messaggi Segreti fino alle Macchine Crittografiche

La Storia dei Messaggi Segreti fino alle Macchine Crittografiche La Storia dei Messaggi Segreti fino alle Macchine Crittografiche Wolfgang J. Irler The Story from Secret Messages to Cryptographic Machines Wolfgang J. Irler Problem Comunicate without being understood

More information

TMA4155 Cryptography, Intro

TMA4155 Cryptography, Intro Trondheim, December 12, 2006. TMA4155 Cryptography, Intro 2006-12-02 Problem 1 a. We need to find an inverse of 403 modulo (19 1)(31 1) = 540: 540 = 1 403 + 137 = 17 403 50 540 + 50 403 = 67 403 50 540

More information

Primitive Roots. Chapter Orders and Primitive Roots

Primitive Roots. Chapter Orders and Primitive Roots Chapter 5 Primitive Roots The name primitive root applies to a number a whose powers can be used to represent a reduced residue system modulo n. Primitive roots are therefore generators in that sense,

More information

Groups, Modular Arithmetic and Geometry

Groups, Modular Arithmetic and Geometry Groups, Modular Arithmetic and Geometry Pupil Booklet 2012 The Maths Zone www.themathszone.co.uk Modular Arithmetic Modular arithmetic was developed by Euler and then Gauss in the late 18th century and

More information

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION

MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION MODULAR ARITHMETIC II: CONGRUENCES AND DIVISION MATH CIRCLE (BEGINNERS) 02/05/2012 Modular arithmetic. Two whole numbers a and b are said to be congruent modulo n, often written a b (mod n), if they give

More information

DIY Pencil-and-Paper Encryption

DIY Pencil-and-Paper Encryption DIY Pencil-and-Paper Encryption Today we re surrounded by massive computational power and vast communication systems. When you visit your bank s site, you don t think about negotiating cryptographic keys

More information

Introduction to Modular Arithmetic

Introduction to Modular Arithmetic 1 Integers modulo n 1.1 Preliminaries Introduction to Modular Arithmetic Definition 1.1.1 (Equivalence relation). Let R be a relation on the set A. Recall that a relation R is a subset of the cartesian

More information

Cryptanalysis on short messages encrypted with M-138 cipher machine

Cryptanalysis on short messages encrypted with M-138 cipher machine Cryptanalysis on short messages encrypted with M-138 cipher machine Tsonka Baicheva Miroslav Dimitrov Institute of Mathematics and Informatics Bulgarian Academy of Sciences 10-14 July, 2017 Sofia Introduction

More information

Historical cryptography 2. CSCI 470: Web Science Keith Vertanen

Historical cryptography 2. CSCI 470: Web Science Keith Vertanen Historical cryptography 2 CSCI 470: Web Science Keith Vertanen Overview Historical cryptography WWI Zimmerman telegram WWII Rise of the cipher machines Engima Allied encryption 2 WWI: Zimmermann Telegram

More information

Public-key Cryptography: Theory and Practice

Public-key Cryptography: Theory and Practice Public-key Cryptography Theory and Practice Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Chapter 5: Cryptographic Algorithms Common Encryption Algorithms RSA

More information

V.Sorge/E.Ritter, Handout 2

V.Sorge/E.Ritter, Handout 2 06-20008 Cryptography The University of Birmingham Autumn Semester 2015 School of Computer Science V.Sorge/E.Ritter, 2015 Handout 2 Summary of this handout: Symmetric Ciphers Overview Block Ciphers Feistel

More information

Application: Public Key Cryptography. Public Key Cryptography

Application: Public Key Cryptography. Public Key Cryptography Application: Public Key Cryptography Suppose I wanted people to send me secret messages by snail mail Method 0. I send a padlock, that only I have the key to, to everyone who might want to send me a message.

More information

Colored Image Ciphering with Key Image

Colored Image Ciphering with Key Image EUROPEAN ACADEMIC RESEARCH Vol. IV, Issue 5/ August 2016 ISSN 2286-4822 www.euacademic.org Impact Factor: 3.4546 (UIF) DRJI Value: 5.9 (B+) Colored Image Ciphering with Key Image ZAINALABIDEEN ABDULLASAMD

More information

Merkle s Puzzles. c Eli Biham - May 3, Merkle s Puzzles (8)

Merkle s Puzzles. c Eli Biham - May 3, Merkle s Puzzles (8) Merkle s Puzzles See: Merkle, Secrecy, Authentication, and Public Key Systems, UMI Research press, 1982 Merkle, Secure Communications Over Insecure Channels, CACM, Vol. 21, No. 4, pp. 294-299, April 1978

More information

A Secure Image Encryption Algorithm Based on Hill Cipher System

A Secure Image Encryption Algorithm Based on Hill Cipher System Buletin Teknik Elektro dan Informatika (Bulletin of Electrical Engineering and Informatics) Vol.1, No.1, March 212, pp. 51~6 ISSN: 289-3191 51 A Secure Image Encryption Algorithm Based on Hill Cipher System

More information

Solutions to Problem Set 6 - Fall 2008 Due Tuesday, Oct. 21 at 1:00

Solutions to Problem Set 6 - Fall 2008 Due Tuesday, Oct. 21 at 1:00 18.781 Solutions to Problem Set 6 - Fall 008 Due Tuesday, Oct. 1 at 1:00 1. (Niven.8.7) If p 3 is prime, how many solutions are there to x p 1 1 (mod p)? How many solutions are there to x p 1 (mod p)?

More information

Modular Arithmetic. claserken. July 2016

Modular Arithmetic. claserken. July 2016 Modular Arithmetic claserken July 2016 Contents 1 Introduction 2 2 Modular Arithmetic 2 2.1 Modular Arithmetic Terminology.................. 2 2.2 Properties of Modular Arithmetic.................. 2 2.3

More information

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague 7 November, CS1800 Discrete Structures Midterm Version C

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague 7 November, CS1800 Discrete Structures Midterm Version C CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague 7 November, 2016 CS1800 Discrete Structures Midterm Version C Instructions: 1. The exam is closed book and closed notes.

More information

CRYPTANALYSIS OF THE PERMUTATION CIPHER OVER COMPOSITION MAPPINGS OF BLOCK CIPHER

CRYPTANALYSIS OF THE PERMUTATION CIPHER OVER COMPOSITION MAPPINGS OF BLOCK CIPHER CRYPTANALYSIS OF THE PERMUTATION CIPHER OVER COMPOSITION MAPPINGS OF BLOCK CIPHER P.Sundarayya 1, M.M.Sandeep Kumar 2, M.G.Vara Prasad 3 1,2 Department of Mathematics, GITAM, University, (India) 3 Department

More information

Answer Key to accompany

Answer Key to accompany to accompany The Cryptoclub Using Mathematics to Make and Break Secret Codes Janet Beissinger Vera Pless A K Peters Wellesley, Massachusetts Editorial, Sales, and Customer Service Office A K Peters, Ltd.

More information

Network Security: Secret Key Cryptography

Network Security: Secret Key Cryptography 1 Network Security: Secret Key Cryptography Henning Schulzrinne Columbia University, New York schulzrinne@cs.columbia.edu Columbia University, Fall 2000 cfl1999-2000, Henning Schulzrinne Last modified

More information

Introduction to Cryptography CS 355

Introduction to Cryptography CS 355 Introduction to Cryptography CS 355 Lecture 25 Mental Poker And Semantic Security CS 355 Fall 2005 / Lecture 25 1 Lecture Outline Review of number theory The Mental Poker Protocol Semantic security Semantic

More information

Towards a Cryptanalysis of Scrambled Spectral-Phase Encoded OCDMA

Towards a Cryptanalysis of Scrambled Spectral-Phase Encoded OCDMA Towards a Cryptanalysis of Scrambled Spectral-Phase Encoded OCDMA Sharon Goldberg* Ron Menendez **, Paul R. Prucnal* *, **Telcordia Technologies OFC 27, Anaheim, CA, March 29, 27 Secret key Security for

More information

Modular arithmetic Math 2320

Modular arithmetic Math 2320 Modular arithmetic Math 220 Fix an integer m 2, called the modulus. For any other integer a, we can use the division algorithm to write a = qm + r. The reduction of a modulo m is the remainder r resulting

More information

University of British Columbia. Math 312, Midterm, 6th of June 2017

University of British Columbia. Math 312, Midterm, 6th of June 2017 University of British Columbia Math 312, Midterm, 6th of June 2017 Name (please be legible) Signature Student number Duration: 90 minutes INSTRUCTIONS This test has 7 problems for a total of 100 points.

More information

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013

CMPSCI 250: Introduction to Computation. Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013 CMPSCI 250: Introduction to Computation Lecture #14: The Chinese Remainder Theorem David Mix Barrington 4 October 2013 The Chinese Remainder Theorem Infinitely Many Primes Reviewing Inverses and the Inverse

More information

DES Data Encryption standard

DES Data Encryption standard DES Data Encryption standard DES was developed by IBM as a modification of an earlier system Lucifer DES was adopted as a standard in 1977 Was replaced only in 2001 with AES (Advanced Encryption Standard)

More information

MITOCW watch?v=3v5von-onug

MITOCW watch?v=3v5von-onug MITOCW watch?v=3v5von-onug The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

UNIT 19 Lesson Plan 1

UNIT 19 Lesson Plan 1 UNIT 19 Lesson Plan 1 1 Introduction T: In this first lesson we'll look at the principles of the Lorenz cipher; in the next lesson we'll learn how the Lorenz cipher machine was used to break the code.

More information

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand.

Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating by hand. Midterm #2: practice MATH 311 Intro to Number Theory midterm: Thursday, Oct 20 Please print your name: Calculators will not be permitted on the exam. The numbers on the exam will be suitable for calculating

More information