<<

Cryptography

Joshua Pankau

1. INTRODUCTION TO CRYPTOGRAPHY

Communicating via messages has become a major part of society; be it sending letters, text messages or e-mails. In today’s world, when we send a message we are confident that its intended recipient will be the one to read it. When you send an e-mail the recipient has a user name and that is usually known only to him/her. In other words, there are safeguards in place to stop others from viewing the message you sent. This is the basic idea behind Cryptography, and it has been around for a long time.

The definition of Cryptography is simple: Cryptography is the art and science of , and decryption. Cryptography is a science because it uses to encode messages so that their contents are not seen by unwanted eyes, and it is an art because one has to use clever techniques in an attempt to insure that their message is well coded. The science and art goes both ways though, because one can be just as clever in their use of mathematics to decode a message. The encryption and decryption aspect of Cryptography splits it into two Categories: Cryptographers and Cryptanylists, or more simply, encoders and decoders.

In todays society Cryptographers spend there time using mathematics to come up with new ways to secure . Cryptographers work on a new encoding method, and when they are finished

Cryptanylists use mathematics to try and break the and expose any weaknesses so that the

Cryptographers can improve the security of the encoding.

The discussion of Cryptography so far has been a vague, so now we will define some termi- nology and in the next section we will define a few mathematical ideas that will help us in our exploration of Crytography. First, the message, or data, that will be coded is called the .

The act of coding the message, as we have seen above, is called Encryption. On the same token, 6ACM Journal Name, Vol. 1, No. 1, November 2010, Pages 1–0??. 2 · Joshua Pankau the act of decoding a message is called Decryption. In order to code a message you require an

Algorithm that defines the steps that will be taken to conceal the message or data. In Cryptogra- phy, such an is called a . The Cipher depends on a chosen , which could be a word or a string of numbers that determines how to encode the message. Any holders of the key will be able to decode all messages that were coded using that cipher. Once a message is encoded using a cipher it is called .

2. MATHEMATICS

Mathematics is flowing through every aspect of Cryptography, so now we will establish some impor- tant ideas that give us the tools we need to journey through the world of Cryptography. Following each definition will be an example that shows these tools in action.

Our first definition establishes the mathematical notion of the Function.

Definition 1. Let X and Y be sets. A rule that is defined by F is called a function between X and Y, denoted F: X → Y, if F takes an element x ∈ X(the Domain), to exactly one element y ∈

Y(the Codomain); (i.e. if x ∈ X, then F(x)=y for some y ∈ Y).

Example 1. Let f : R → R be a function given by:

f(x) = x2

Then f is a function that takes a real number x and maps it to exactly one other real number, namely the of x.

Next we need the notions of One-to-One and Onto so that we can establish a very special function that will play a key role in our exploration of Cryptography; The Bijection.

Definition 2. Let X and Y be sets, then a function f : X → Y is said to be One-to-One(or Injective) if for any elements x, z ∈ X, f(x) = f(z), then x = z. The function f is said to be

Onto(or Surjective) if for every element y ∈ Y, there exists an x ∈ X such that f(x) = y.

Example 2. Let X be the set {1, 2, 3} and Y be the set {4, 5, 6, 7}. Then define f: X → Y to be a function such that f(1) = 4, f(2) = 5, and f(3) = 6. Then f is clearly One-to-One but not Onto. If we define g: Y → X such that g(4) = 1, g(5) = 2, g(6) = 3, and g(7) = 1. Then g is clearly Onto, but not One-to-One.

ACM Journal Name, Vol. 1, No. 1, November 2010. Cryptography · 3

In the past example we saw two functions f and g, where f was one One-to-One but not Onto, and g was Onto but not One-to-One. It is possible for a function to be both Injective and Surjective which leads to following definition:

Definition 3. A function f: X → Y is said to be a Bijection between X and Y if f is both Injective and Surjective. If two sets have a Bijection between them, then they are said to be the same size, i.e. they have the same number of elements. Furthermore, since f is a bijection, then there exists a function g: Y → X such that g(f(x)) = x, that is g is called the inverse of f, denoted f −1.

The inverse of f is also a Bijection.

Example 3. Let X be the set {1, 2, 3} and Y be the set {4, 5, 6}, then the function f: X → Y defined by f(1) = 4, f(2) = 5, and f(3) = 6 is clearly One-to-One and Onto, therefore f is a

Bijection. Also, by the above definition, f −1 exists and is defined as f −1(4) = 1, f −1(5) = 2, and f −1(6) = 3.

It should be noted that the Bijections have played a pivotal role in Symmetric Cryptography. Imagine if you had a message you wanted to encode using a function/algorithm f. If the function is a bijection then it will have an inverse, so whatever f did to convert the message from plaintext to ciphertext, f −1 could be used to decode the ciphertext back into plaintext. So if two people wanted to securely communicate with each other, and they both know the encrypting function f and the decrypting fuction f −1, then they can continously send each other secret messages by encoding them using f, and decoding them using f −1. You can guess that the more complex the functions f and f −1 are the harder it would be for an outside observer to discover the contents of the messages. This notion of functions that are difficult to solve leads to two very important types of functions that will play a prominent role ahead. The One Way Function and the Trap Door Function.

Definition 4. A function f: X → Y is called One Way if given the image of an element in X, it is implausible to find the pre-image.

In loose terms, a One Way function is easy to compute but hard to invert. A good One Way function should be next to impossible to invert. It is hard to classify a function as One Way because it may just be that someone has not yet thought of a clever way of finding a pre-image yet.

Example 4. Suppose we chose two large primes p and and took their product say p = 55, 021 and q = 5, 783. Then n = 318, 186, 443. Say if you gave n to someone and asked them to find the

ACM Journal Name, Vol. 1, No. 1, November 2010. 4 · Joshua Pankau factorization of n, then more than likely it will take them a very long time to compute p and q. So given the product of larger and larger primes, the task of finding the factorization grows exponentially.

[Welsh2006]

Definition 5. A is a One Way function that is easy to compute the inverse given an extra piece of information.

Example 5. An easy example of a Trapdoor function can be seen in our last example. Knowing the Product of the two primes and one of the primes it become instantly easy to determine the other prime.

The final mathematical concept that we will need to start our journey through the world of Cryp- tography is the notion of .

Definition 6. Two integers a and b are said to be Congruent Modulo N if and only if N|(a− b), i.e. if and only if their difference is exactly divisible by N. Denoted a ≡ b(modN)

Modular Arithmetic gives, in a sense, a wrap around point. This is related to the idea of the remainder which is shown in the next example:

Example 6. Consider the days of week. Assign values to each day of the week, i.e., Sunday = 1, Monday = 2, ... , Saturday = 7. So, if you start on Sunday and add 1 repeatedly you would get Monday, then you would get Tuesday, and so on. What happens when you get to Saturday?

You would add 1 to 7 but end up back to 1. This is because when you add 1 to 7 you get 8, but

1 + 7 ≡ 1mod7 because 8 − 1 = 7 which is divisible by 7. So in modular arithmetic 1 is equivalent to any element x such that 7|x − 1. To see the idea of remainders in Modular Arithmetic, say your friend told you he was having a birthday 15 days from Monday. If you wanted to know what day of the week you can just add 15 to 2 and get 17,and divide 17 by 7 to obtain 2 with remainder 3.

Notice that 7|17 − 3, so 17 ≡ 3mod7 which implies that 15 days from Monday is a Tuesday.

We now begin our tour of Cryptography with the age old Symmetric Key .

3. SYMMETRIC KEY CRYPTOGRAPHY

A Symmetric is a system where both parties who wish to communicate confiden- tially share a secret key which the encryption and decryption depends. Generally in Symmetric Key

Cryptography the encryption functions e(x) and decryption function d(x) are inverses.

ACM Journal Name, Vol. 1, No. 1, November 2010. Cryptography · 5

3.1 Shift Cipher

One of the most basic type of Symmetric Cryptosystem is the Shift Cipher. This is an ancient method of encrypting a message. One of the most popular Shift in history was the Caesar

Cipher, named after Julius Caeser. Julius Caeser’s method of encrypting his messages was to shift every letter of his message down three letters; hence the name Shift Cipher. We can see how this works by the following picture, and the example following the picture will show the in action.

Image from http://donpiorsuerte.wordpress.com/

Example 7. Consider the message ATTACKATDAYBREAK. Using the Caesar Cipher, the mes- sage becomes DWWDFNDWGDBEUHDN.

Obviously the Caesar Cipher does not have to be a shift of just 3 spaces; we can extend this to a more general result. Notice that when we shifted Y down three letters it became B. This wrap around implies Modular Arithmetic is being used. If we assigned every letter of the alphabet a number, that is, A = 0 , B = 1 , ... , Z = 25 and use Modulo 26 then we see that when we add 3 to Y, where Y = 24, we obtain 27. Since we are using Modulo 26, then 27 ≡ 1mod26, thus Y → B.

Say we shifted each letter by some positive integer α, then the inverse would be to shift each letter back by α, so we can express the encryption and decryption functions as follows:

e(X) = (X + α) ≡ Y mod26

d(Y ) = (Y − α) ≡ Xmod26

Where 0 ≤ α ≤ 25, since if α was 26 then A would go to A, B to B and so on. We are back to where we started, and if α was 27 we would have the same case that we had when we shifted by 1 since

1 ≡ 27mod26.

ACM Journal Name, Vol. 1, No. 1, November 2010. 6 · Joshua Pankau

3.2 The One Time Pad

The One Time Pad is one of the most powerful and highly secure Symmetric Cryptosystems around, in fact it said to be used in even the highest forms of Government[?, Welsh2006] The idea behind the One Time Pad is as follows: Every letter in the alphabet has its own binary representation, so a message written in the English alphabet can be converted into its binary form.

Now the message will be a string of N amount 1’s and 0’s, so an encrypting and decrypting key can be created by generating another string of length N consisting of 1’s and 0’s. Then the encryption is done by adding the Message string to the Key string Mod2, that is, 1 + 1 ≡ 0mod2. So the resulting

Encrypted message will be another string of length N consisting of 0’s and 1’s.

Example 8. Suppose the binary form of your message M was 1010011, and you randomly gen- erated the Key 1100101. To get the encrypted form of the message you add these strings together, and remember that 1 + 1 ≡ 0mod2. So the resulting encrypted form C looks like 0110110. In order to invert the encrypted form back to the binary form of the message, one would just have to subtract the Key from C. Notice that 0 − 1 = −1 where −1 ≡ 1mod2 since 2 divides −1 − 1 = −2. Thus the subtraction yields 1010011, which is the original message.

The previous example does not quite do justice to the strength of The One-Time Pad. To put the power of The One Time Pad into perspective, think about what it would take for someone to discover the original message if they were given only the Encrypted form. If one was given the encrypted form 0110110 from the above example and set out to discover the binary form of the message then they would have a rather difficult task. Consider how the encryption/decryption key was formed to turn message M into encrypted form C. It was randomly generated by choosing either a 0 or 1 for each component of the string. So each component has 2 choices, thus the total number of Keys possible for a message string whose length is 7 is 27 = 128. Notice though that only one of those keys can turn M into C. Thus, if someone was trying to recover M then they would never truly know if they succeeded because, according to Welsh, ”with the One-Time Pad any ciphertext could be the encryption of any message”.[Welsh2006] This shows that the encryption here is a One Way function. It is very easy to compute the encrypted form but very difficult to discover the message.

Though the One-Time Pad is certainly secure it does have a few drawbacks. Notice that the secret key must be as long as the message, so the only practical uses are when the key is transported in total

ACM Journal Name, Vol. 1, No. 1, November 2010. Cryptography · 7 and kept very secure. Another weakness of the One Time Pad is if the same encrypting key is used multiple times, since the more often a key is used to encrypt messages, the more information one will be able to discern about the key from the ciphertext.

3.3 Attacks

Above we saw a few drawbacks of the One-Time Pad that an attacker could exploit to try and gain some information about the Key and Message. In general these kinds of drawbacks are things that every Symmetric Cryptosystem is concerned about. Now lets take a look at a few other attacks that threaten any Symmetric Cryptosystem.

3.3.1 Brute Force Attack. A Brute Force Attack is exactly what it sounds like. It is an attack in which one tries every singly possible Key in an attempt to decipher the code. In theory, Brute

Force Attacks could work against almost any Symmetric Cryptosystem, but in reality they are not very practical. Brute Force attacks quickly become ineffective as the grows. If the attacker knew you had a key that was only 10 binary digits long, then there would be 210 possible Keys that he could check. If the key length was 256 binary digits, then there would be 2256 possible keys to check. Even a performing billions of calculations per second would take Billions of years to check every key.[Ferguson, 2003].

3.3.2 . Frequency Analysis is the method of looking for values or symbols that repeat more often than others and attempting to discern what letters they represent. The reason why this works is because of the fact that some letters appear in words far more often than others, as shown in the picture below.

Image from http://www.exothermix.com/062807.html

ACM Journal Name, Vol. 1, No. 1, November 2010. 8 · Joshua Pankau

As you can see E, T, A, O, I, N, and S are the letters that appear the most in the English , with E being the most common. If you take our example above of the Caesar Cipher whose ciphertext was DWWDFNDWGDBEUHDN. D repeats the most often in this message, and W repeats the second most often, but with just this one message it would be difficult to discern what D represents.

Say if someone had intercepted one hundred of these messages and looked at which letters appeared the most often amongst all the messages, statistically speaking H should appear more than any other. He would then be able to deduce that H is E, then move to the one that appears second most often which is T and deduce that W is T. Then he would see that D is A, and so on until he had enough of the letters to deduce the remaining letters and get the message. It should be noted that this method is only really effective when one has intercepted many messages and has a lot of ciphertext to work with. Of course the are many other examples of Symmetric Cryptosystems, but each shares the problem that if two people want to secretly communicate they must both share the Key in order to read each others messages. We now turn our attention to Asymmetric Key

Cryptography that solves this pesky problem.

4. ASYMMETRIC KEY CRYPTOGRAPHY

Asymmetric Key Cryptography, also known as Public Key Cryptography, is a method of encryption in which both parties do not have to share a common encryption/decryption key like they do in a Symmetric Cryptosystem. So if one wanted to let people securely communicate with him, then he would have to generate two keys P and S using an algorithm. He then publishes P, which is the Public Key that people will use to encrypt their messages with, and he keeps S as his Secret key. He will use S to decrypt any messages he receives that were encrypted with P. The obvious benefit is that both parties no longer have to agree on a common key ahead of time and both keep it secret. This makes secret much more versatile because both parties can come up with their own public and private keys and they can communicate by encrypting messages using the others Public Key and the recipient will use their secret key to decrypt them. The thing that makes this whole idea of Public and Private keys work is the Trap Door function. We will illustrate the

Trap Door Function by the Cocks-Ellis non-secret Cryptosystem.

4.1 Cocks-Ellis non-secret Cryptosystem

Suppose Alice wants to send Bob a secret message, then the Cocks-Ellis cryptosystem works as follows:

ACM Journal Name, Vol. 1, No. 1, November 2010. Cryptography · 9

(1) The Setup:

(a) Bob secretly chooses two large distinct primes(like in Example 4) p, q such that p does not

divide q − 1 and q does not divide p − 1. Bob then publishes his public key n = pq.

(b) In order for Bob to be able to decrypt he uses Euclid’s algorithm for finding greatest common

divisors to find numbers r, s such that pr ≡ 1mod(q − 1) and qs ≡ 1mod(p − 1).

(c) Bob then uses Euclid’s algorithm one more time to find u, v satisfying up ≡ 1modq and

vq ≡ 1modp. The values (p, q, r, s, u, v) are his Trap Door information that Bob will use in

order to decrypt the messages he receives from Alice.

(2) Encryption Alice takes her message M and splits it into numbers M1, M2,...,Mt where each Mi

satisfies 0 ≤ Mi ≤ n. Alice then encrypts each number as

n Ci ≡ (Mi) modn

where Ci is the encrypted form of each number that she will send to Bob.

(3) Decryption:

(a) Bob calculates numbers ai and bi that will allow him to find the numbers that Alice split her message into by

s r ai ≡ (Ci) modp and bi ≡ (Ci) modq.

(b) Bob can then recover each Mi with

upbi + vqai ≡ Mimodn

The following example from Welsh, [Welsh2006], shows that decryption in the Cocks-Ellis cryptosys- tem actually works.

Example 9. Suppose Bob chooses p = 5 and q = 7. Notice 5 does not divide 7 − 1 and 7 does not divide 5 − 1, thus 5 and 7 satisfy the conditions from (1)(i). Bob then publishes his public key n = 35. Suppose Alice wishes to send the message M = 10, she then calculates

1035 ≡ 5mod35 and sends C = 5 to Bob. Bob then calculates (using Euclid’s algorithm) r = 5 and s = 3. It is

ACM Journal Name, Vol. 1, No. 1, November 2010. 10 · Joshua Pankau obvious that pr = 5 × 5 = 25 ≡ 1mod6 and qs = 3 × 7 = 21 ≡ 1mod4. Bob then calculates

a = C3 = 53 ≡ 0mod5 and b = C5 = 55 ≡ 3mod7.

Next Bob uses Euclid’s algorithm one last time to find that u = v = 3. (Again notice that 3 × 5 =

15 ≡ 1mod7 and 3 × 7 = 21 ≡ 1mod5. So every condition of the Cocks-Ellis cryptosystem has been satisfied.) Bob then recovers the message as

upb + vqa = (3 × 5 × 3) + (3 × 7 × 0) = 45 ≡ 10mod35

Thus Bob recovers the message of 10.

The security of the Cocks-Ellis system depends on an adversary not discovering p and q. Bob makes the product of p and q public so the security of the system depends on how easy it would be to find p and q knowing their product. Well according to Nash, ”Factorization is a well-studied problem that is widely believed to be difficult”[Nash, 2001]. So if very large prime numbers are chosen for p and q then it is believed to be implausible for one to be able to find p and q given their product, so under this assumption the Cocks-Ellis cryptosystem is secure.

5. REAL WORLD EXAMPLES

So far we have talked about a lot of different cryptosystems and how they can be used to encrypt data, but now we will briefly discuss some real world examples of how these things are used in everyday society.

5.0.1 Public Key Infrastructure. Public Key Infrastructure(also called a PKI for short) is a sys- tem that allows you to recognize which public key belongs to whom. In a PKI there is a central

Authority called the Certificate Authority, or CA. The CA has a public/private key pair(e.g., a

Cocks-Ellis key pair) and publishes the public key. If someone wants to join the PKI, then they generate their own public/private key pair and takes their public key to the CA who will verify that person is who he/she says they are and signs a statement called the certificate. Suppose want to communicate. Then they both get their public keys certified by the CA and then they exchange public keys. ”These keys in turn can be used to establish a for secret .”[Ferguson, 2003].

Example 10. Companies have a (VPN) that allows its employees to ACM Journal Name, Vol. 1, No. 1, November 2010. Cryptography · 11 access the corporate network from home or from their hotel rooms when traveling. ”The VPN access points must be able to recognize the people who have access and exactly what level of access they have. The IT department of the company acts as the CA and gives every employee a certificate that allows the VPN access points to recognize the employee.”[Ferguson, 2003]

Example 11. Electronic banking is a luxury we all enjoy today because it allows us to manage our accounts from home, and it is in the Bank’s best interest to be able to identify who is accessing the account. In this case, ”the bank itself can act as the CA and certify the public keys of its customers.”[Ferguson, 2003]

Example 12. ”A credit card organization is a cooperative venture between a few thousand banks spread out all over the world.”[Ferguson, 2003] All the banks in the organization must be able to securely communicate with each other. ”A PKI allows all banks to identify each other and perform secure transactions. In this situation, the credit card organization can act as the CA that certifies the keys of each bank.”[Ferguson, 2003]

In summary we have seen that Cryptography is vital part of our every day world. The goal of Cryptography is to establish secure communications and can be achieved either through Symmetric or Asymmetric Cryptosystems. Symmetric Key cryptosystems use only a single private key that is used for both encryption and decryption, while Asymmetric Key cryptosystems use a public key for encryption and a private key for decryption. We saw the power of the One-Time pad cryptosystem and how it achieves almost complete security, and we saw the Cocks-Ellis Cryptosystem, which uses the product of primes to achieve its secrecy. We see that Cryptography touches everything from private networks, to online shopping, to our credit cards. It is important to see that in our every growing technological world, where we use the to do more and more, the need for the security brought on by Cryptography becomes paramount. 8

8REFERENCES

Ferguson N, Schneier B. Practical Cryptography. Pages: 26 - 33, 316 - 319. Kippenhahn, R. Code Breaking: A History and Exploration. Pages: 67 - 69 Nash A, Duane W, Joseph C, Brink D. PKI: Implementing and Managing E-Security. Pages: 18 - 19 Welsh D, Talbot J. Complexity and Cryptography. Pages: 2 - 7, 99 - 102, 125 - 130, 141 - 144

ACM Journal Name, Vol. 1, No. 1, November 2010.