Introduction to cryptography (CSCI 2824, Spring 2015)In this note, we study a few key topics in cryptography:
CryptographyWhat is cryptography? And why is it important? Crypto: Secret and graphy: writing. So cryptography is the study of techniques for encrypting and decrypting secrets. With the advent of internet and the need to keep communications across networks secret, cryptography has emerged as an important discipline of computer science and a great application of advanced mathematical techniques to the field. Example 1: Secrecy/PrivacyImagine Alice and Bob wish to share a secret message between themselves. However, they cannot meet in person in a safe place to do so. Let us suppose the secret message is Party 6:00 p.m, Friday at Zolo's. – Alice. Let us suppose the secret society (or the government) is quite interested in crashing AliceBob's party. Therefore, it is important for AliceBob to code up their message so that the secret society does not get wind of their party. Example 2: AuthenticationIn this scenario, let us say that Mr. Ty Coon would like to buy
an oil rig in the middle of campus for Dear President, I intend to purchase mining rights to the oil reserves underneath your campus for $100000.56 . Students and faculty can be hired to work in this rig for a generous salary of minimum wage. I remains yours truly, Mr. Ty Coon How is the president to know that this important message is from Ty Coon himself as opposed to some student playing a prank? In other words, is there a way that Ty Coon can sign the message so that everyone can authenticate the message as a genuine message from him? WebAs commerce over www is widespread, people send money over the internet in the form of credit card numbers and payment instructions to banks. Agreements are digitally signed over the network and people log in to secret networks over VPN. All of these nice things are powered by cryptography. There are two basic types of cryptography:
Private Key cryptosystemsPrivate key cryptography consists of encrypting a message Let us take look at some simple private key algorithms, using (1) shift ciphers, and (2) XOR. Warning: The schemes below can be broken very easily. So do not attempt this. Shift ciphersOne of the oldest cryptosystems uses the shift ciphers,
which make use of simple modular arithmetic.
Suppose we assign a number to each of the 26 English alphabets
(e.g. A simple way to encrypt a message is to use the shift cipher, i.e., a function of the form ![]() where the encryption key For example, the message HELP could be encrypted as KHOS. Here the encryption key is 3. It is very easy to crack a shift cipher and guess the encryption key. One slightly more sophisticated cipher is to incorporate a prime multiple: ![]() where XORLet us encode the message into Example: Show me da money. The ascii codes are S = 83, h = 104,….
Therefore, the message can be represented as: For simplicity, we can choose the password as a 8 bit string. Example: Each where Example: Using password Similarly, other letters can be encoded in the same way. To decode, we then XOR the encoded message with the same password Example (decryption): The main property of XOR that is being used here is
Drawbacks of the above cryptosystems.Both of the cryptosystems are very easy to crack.
DESDES stands for Data Encryption Standard. It was proposed by IBM researchers in the early 70s with the help of NSA. At a high level, you can think of DES replacing the XOR bitwise operator for a much more complicated looking function. In fact, the function is specified at its core using lookup tables called S-Boxes. DES uses many tricks to guarantee good security. Yet, it is not unbreakable. For instance, DES uses a 56 bit password (recently upgraded to 64 bits). It can be broken if someone is willing to invest very large amount of computation to brute force the password or use a more intelligent scheme. Public Key CryptographyPublic key cryptography is very interesting idea that was first invented by British intelligence in the late 60s but kept a secret. It was rediscovered and publicized by Rivest, Shamir and Adleman (RSA) in 1975. Since then it has been a key achievement of number theory in computer science. Basic idea behind public key cryptographyOne can imagine a cryptosystem as a lock that protects a secret. Private key cryptography can be thought of as a traditional lock and key system. The key is the password and if one has the key or can forge one, then one can break into the contents of the box by opening the lock. Public key cryptosystems are much more interesting. Imagine a lock with two types of keys: a private key that only one person has access to (ideally) and a public key that anyone can obtain. Imagine the lock as operating in one of two ways:
How can such a scheme help? Example 3: Secrecy/PrivacyRecall the secret message Alice wishes to send Bob: Party 6:00 p.m, Friday at Zolo's. – Alice. Imagine that every person has a private and a public key to their own box. Then Alice can send the secret message to Bob using the following procedure.
Example 4: AuthenticationSuppose Ty Coon writes the letter: Dear President, I intend to purchase mining rights to the oil rig in your campus for $100000.56 . I remains yours truly, Mr. Ty Coon Is there a way that Ty Coon can sign the message so that everyone can authenticate the message as a genuine message from him? Let us say that TyCoon has a private and a public key. How can TyCoon convince the president of his message's authenticity? Hint Use public/private keys. RSACan we really simulate private/public keys in practice? Yes. This is where number theory comes to the rescue in the form of the RSA cryptosystem. Here is the basic idea:
Encryption
We can send an encrypted message
Decryption
For Alice to read our encryped message ![]() The fact that Alice can actually read the encrypted message is due to the following result: Proposition
Let ![]() Then for any ![]() This proposition follows from Fermat's little theorem and the Chinese remainder theorem. Example 5: encryptionLet us illustrate this:
Using public key To decrypt, we have to compute
Example 6: authenticationThe proposition above can be used not only for encrypting messages, but also for authentication. Let's say Alice, equipped with a public key For simplicity, let's assume that To assure Bob that the message is from Alice, the following procedure can be taken:
Fast modular exponentiationIn practice, we do not compute the exponentiation
The key is to note that if if ![]() so ![]() As a simple example: if ![]() Noting that fast modular exponentiation algorithm
int modexp( unsigned int b, unsigned int n, unsigned int m ){ int out = 1; int power = b % m; int i; /* insert routine computing the binary representation of n stored in some array a[0], ... a[k-1]*/ for ( i=0; i<k; i++ ){ if ( a[i]==1 ) { x = ( x*p ) % m; } p = ( p^2 ) % m; } return x; } Breaking RSALet us assume that some one has access to the public key After all, Problem (Factoring) Given a number In order to convince you that factoring a large number say Combinatorially Hard ProblemsThere are problems in CS which do not have any known algorithms. The class of problems is called NP standing for Non-Deterministic Polynomial Time. Claim Factoring a number Naive Algorithm
int factor(int n){ int i; for (i = 0; i < n;++i) if (Divides(i,n)) return i; return NO_FACTOR; } Time taken to factor by best known algorithm is roughly The best known factoring algorithm is the general number field sieve. Even though
it is worst case exponential, it has been used to factor large number of upto a |