# An Introduction To Cryptography Computer Science Essay

**Published:** **Last Edited:**

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Cryptography is the art of writing in hidden characters. Encrypting is the act of converting a normal message to a message written with hidden characters also known as the encrypted message. Decrypting is the inverse of encrypting act of converting a message written with hidden characters into an understandable message the unencrypted message. It is one of the most important parts in computer security, since modern encryption algorithms can ensure all secure conversation: privacy, authentication and integrity

The goal of cryptography is to make it possible to exchange a text in such a way that others cannot understand the text. There are number of ways this can be done, but here we will be concerned with methods of altering the message in such a way that the receiver can undo the alteration and discover the original message. The initial text is usually called "clear text" and the encoded text is called "cipher text". The conversation from cleartext to ciphertext is called encoding, and the inverse operation is called decoding. If you are trying to read a hidden message that was not intended for you and you initially don't know the encoding method, it is called cracking the code .The more ciphertext you have, the easier it is to crack the code. So typical it is a good idea to change the coding mechanism regularly. Let's consider an example; if a coding scheme has a keyword, if a different keyword is used each and every day, there may never be enough ciphertext to decode the text. But if you change the encoding each and every day, you need to have some method of getting the new keyword to the intended receives in a secure way. The easiest way to crack a code is to know the code!

C:\Users\sekhar\Desktop\CRYPT.png

Encryption: Encryption is a method to hide message to protect integrity

Decryption: Decryption is a method of getting the hidden message

Decryption: Figure 9.1 encryption Figure 9.2 decryption Key-based encryption Key-based decryption

RSA:

The RSA was devised by Ronald Rivest, Adi Shamir, and Leonard Adleman, .

It is the most important and use method of encryption in the world today especially common on the internet. It is essentially unbreakable. The maths behind the encryption is relatively elementary, using results from classical number theory: Chinese Remainder Theorem and the Fermat's Little Theorem. The main principle behind RSA, is that it is relatively easy to multiply two prime numbers together, but almost impossible to factorise their product back to the two constituent primes. This is the idea of a one way function.

1. Find two large primes p and q.

Select p = 11 and q = 5. (Obviously these aren't large)

Define,

n = pq = 55 and k = (p âˆ’ 1)(q âˆ’ 1) = 40.

2. Find a large random integer e which is co prime with k

As k = 40 = 23 Ã- 5 we can choose e = 7.

3. Take your text M and encode it as a whole number in the range 0 6 M < n.

If your text is long cut the message into blocks.

4. The text M is encrypted into the cryptogram C in the range 0 6 C < n

Under the rule

C = Me (mod n).

5. Compute the unique whole number d such that

de = 1 (mod k) and d is in the range 1 6 d < k

Because e and k are co prime, we can make sense of d = 1e .

In this example, where e = 7 and k = 40, we can do this by trial and error,

7 Ã- 23 = 161 = 1 (mod k).

So d = 23.

6. Given the encrypted text C, this can be decrypted back into the text

M by takingG:\crypt\1111.png

M = Cd (mod n).

Wireless Access Point:

RC4 Algorithm:

RC4 is a stream cipher, symmetric key algorithm. The same algorithm is used foR encryption and decryption as the data stream is simply XORed with the generated key sequence. The key stream is solely independent of the plaintext used. It uses a variable length key from 1 to 256 bit to initialize a 256-bit state table. The state table is used for Subsequent generation of pseudo-random bits and then to generate a pseudo-random stream which is XORed with the plaintext to give the cipher text. The steps for RC4 encryption algorithm are

Get the data to be encrypted and the selected key.

Create two string arrays.

Initiate on array with numbers from 0 to 255.

Fill the other array with the selected key.

Randomize the intial array depending on the array of the key.

Randomize the intial array within itself to generate the end key stream.

7- XOR the final key stream with the data to be encrypted to give cipher text. The RC4 encryption algorithm is shown in Figure.

RC4: Algorithm:

An 8 * 8 S-Box (S0 S255), each of the entries is a permutation for the numbers 0 to 255, and the permutation is a function of the variable key length.

function cipher= rcfour

format compact;

szplain = size(plain);

szplain = szplain(2);

szkey = size(key);

szkey = szkey(2);S = [0:255];

i = 0;

j = 0;

for k = 1: szplain

k

i = i + 1

modk = mod(k,szkey) + 1;

Kc = key(modk);

j = mod((S(i) + j + Kc), 256) + 1 t = S(i);

S(i) = S(j); S(j) = t;

Sc = mod((S(i)+S(j)), 256)

Ck = S( Sc )

Cipher (k) = bitxor(Ck, plain(k)+0)end

end;

RC4 Encryption:

Integrity checksum- CRC 32

c(M) M = Message or Text

Plan text: P = (M, c(M))

Encryption

C =P XOR RC4(v,k)

Transmitted Data:

[v, C]

RC4 Encryption and Decryption View:

I:\encrypt nd decrypt in rc4.png

RC4 Strengths:

â€¢ A particular RC4 key can be used only once.

â€¢ The difficulty of knowing which location is used to select each value in the sequence.

â€¢ The difficulty of knowing where any value is.

â€¢ Encryption is about 10 times faster than DES.

RC4 Weakness:

â€¢ The RC4 algorithm is vulnerable to analytic attacks.

â€¢ One in every 256 keys can be a weak key. These keys are identified by cryptanalysis that is able to know circumstances under which one of more generated bytes are strongly correlated with a few bytes of the key.

â€¢ Weak keys are keys identified by cryptanalysis that is able to know circumstances under which one or more generated bytes are strongly correlated with small subset of the key bytes. These keys can happen in one out of keys generated.

RC4 Terminology:

â€¢ RC4: Rivets or Ron's code # 4

â€¢ Cipher: a cryptographic algorithm used for both encryption and decryption.

â€¢ Symmetric key algorithm: an algorithm that uses the same key to encrypt and decrypt

â€¢ Stream cipher: algorithm that encrypts data one byte

â€¢ Anonymous remailer: distribution system that strips off all of the sender information and remains the message as unknown name.

â€¢ Cyberpunk: computer users that believe that privacy from government and large business institutions must be protected. These users generally have expertise in cryptography.

â€¢ State table: is a table initialized from 1 to 256 bytes. The bytes in the table are used for subsequent generation of Pseudo-Random bytes. The Pseudo-Random stream extracted is XORed with the plaintext to give the ciphertext.

The Advanced Encryption Standard (AES)

The Advanced Encryption Standard algorithm also known as Rijndael after its inventors Vincent Rijmen and Joan Daemen. This algorithm acts on 128-bit blocks and can use a key of 128, 192 or 256 bits as lengths. It is an SP network in order to specify, we need to fix the S-boxes, the linear transformation between the rounds, and the way in which the key is joined into the computation. Rijndael uses a single S-box which acts on a byte input to give a byte output. For implementation it simply as a lookup table of 256 bytes; it is actually defined by the equation S(x) = M(1/x) + b over the field GF(28) where b is a constant and M is a suitably chosen matrix. This construction gives linear and differential bounds. The linear transformation is depends on arranging the 16 bytes of the value being enciphered and then doing byte wise mixing and shuffling operations. The intial step in the linear transformation is the mixing in which the first row of four bytes is left are unchanged, while the second row is moved one place to the left, the third row shifted by two places and the fourth row moved three places. The next step is a column mixing step, the four bytes in a column are mixed using a matrix multiplication. An example: how a change in the value of the third byte in the first column is sent. The effect of this is a change in the input to the cipher can potentially affect all of the output after just couple of rounds.

AES Encryption:

AES vs. RC4

Advanced Encryption Standard and RC4 are two encryption ciphers that are used in a multiple applications. A common example where we would find both ciphers employed is in wireless routers. Although you would not explicitly see RC4 as an encryption mechanism there, both TKIP and WEP implement the RC4 cipher. Where AES is relatively new and complex, RC4 is old and is simple. The difference between the two would probably be their type. AES is a block cipher that handles on discrete blocks of data using a fixed key and a formula where as RC4 is a stream cipher that don't have a discrete block size. it uses a key stream of pseudo random bits that is combined to the data using an exclusive OR operation. You can use block ciphers as stream ciphers and inversely, so the separation is not distinct. It is known that RC4 is not effective when used as a block cipher.A good example of the weaknesses of RC4 is the using of WEP. WEP has been completely rendered insecure and can be broken within a minutes with tools that you can find readily available. Although TKIP addresses the issues that have plagued WEP, it is not considered to be as secure as AES. so it is advisable to use AES in any situation. The primary reason why RC4 is popular is the fact that it is simple and very fast. This is already being mitigated since AES implementations in hardware are becoming popular as it provides speed advantages over software implementations.

Wired Communication:

RC2 Algorithms:I:\use1111.png

RC2 is developed by the request of Lotus, for their Lotus Notes software. This RC4 algorithm was kept hidden but in 1996 source code leaked. RC 2 Algorithm is 64 bit block cipher with a variable size key.

Algorithm description:

We use the "word" to denote a 16-bit quantity. The symbol "+" will denote twos-complement addition. The symbol "&" will denote the bitwise "and" operation. The term XOR will denote the "exclusive-or" operation. The symbol "~" will denote bitwise complement. The symbol "^" will denote the exponentiation operation. The term "MOD" will denote the modulo operation.

There are three algorithms involved:

Key expansion: This takes a input key and produces an expanded key consisting of 64 words K[0],......,K[63]. Encryption: This takes a 64-bit input quantity stored in words R[0], ......, R[3] and encrypts it "in place". Decryption: It is the inverse operation to encryption.

Encryption Algorithm:

The encryption operation is defined in terms of "mix" and "mash" operations. Here the expression "x rol k" denotes the 16-bit word and x rotated left by k bits, with the bits shifted out the top end entering the bottom end.

3.1 Mix up R[i]

The primitive "Mix up R[i]" operation is where s[0] is 1, s[1] is 2, s[2] is 3, and s[3] is 5, and where the indices of the array R are always to be considered "modulo 4," so that R[i-1] refers to R[3] if i is 0

R[i] = R[i] + K[j] + (R[i-1] & R[i-2]) + ((~R[i-1]) & R[i-3]);

j = j + 1;

R[i] = R[i] rol s[i];

The next key word K[j] is added to R[i], and j is advanced. Then R[i-1] is used to create a composite word which is added to R[i]. The composite word is identical with R[i-2] where R[i-1] is one, and identical to R[i-3] where R[i-1] is zero. Then R[i] is rotated left by s[i] bits. Here j is a "global" variable so that K[j] is always the first key word in the expanded key which has not yet been used in a "mix" operation.

3.2 Mixing round

A "mixing round" consists operations:

Mix up R[0]

Mix up R[1]

Mix up R[2]

Mix up R[3]

3.3 Mash R[i]

The primitive "Mash R[i]" operation is defined as: R[i] = R[i] + K[R[i-1] & 63]; R[i] is "mashed" by adding to it one of the words of the expanded key. The key word to be used is determined by looking at the low-order six bits of R[i-1], and using that as an index into the key array K.

3.4 Mashing round

A "mashing round" consists of Mash R[0] Mash R[1] Mash R[2] Mash R[3]

3.5 Encryption operation

In the entire encryption operation j is a global integer variable which is affected by the mixing operations. 1. Initialize words R[0], ..., R[3] to contain the 64-bit input value. 2. Expand the key, so that words K[0], ..., K[63] become defined. 3. Initialize j to zero. 4. Conduct five mixing rounds. 5. Conduct one mashing round. 6. Conduct six mixing rounds. 7. Conduct one mashing round. 8. Conduct five mixing rounds.

The each mixing round uses four key words, and that there are 16 mixing rounds altogether, so that each key word is used exactly once in a mixing round. The mashing rounds will refer to up to eight of the key words in a data-dependent manner.

4. Decryption Algorithm:

The decryption operation is defined in terms of primitive operations that undo the "mix" and "mash" operations of the encryption algorithm. They are named "r-mix" and "r-mash".Here the expression "x ror k" denotes the 16-bit word x rotated right by k bits, with the bits shifted out the bottom end entering the top end.

4.1 R-Mix up R[i]

The primitive "R-Mix up R[i]" operation is defined as follows, where s[0] is 1, s[1] is 2, s[2] is 3, and s[3] is 5, and where the indices of the array R are always to be considered "modulo 4," so that R[i-1] refers to R[3] if i is 0

R[i] = R[i] ror s[i]; R[i] = R[i] - K[j] - (R[i-1] & R[i-2]) - ((~R[i-1]) & R[i-3]); j = j - 1;

In words: R[i] is rotated right by s[i] bits. Here j is a "global" variable so that K[j] is always the key word with highest index in the expanded key which has not been used in a "r-mix" operation. The key word K[j] is deducted from R[i], and j is decremented. R[i-1] is used to make a "composite" word which is deducted fom R[i]. The composite word is identical with R[i-2] in those positions where R[i-1] is one, and identical to R[i-3] in those positions where R[i-1] is zero.

4.2 R-Mixing round

An "r-mixing round" consists of following operations: R-Mix up R[3]

R-Mix up R[2]

R-Mix up R[1]

R-Mix up R[0]

4.3 R-Mash R[i]

The primitive "R-Mash R[i]" operation is defined as follows:R[i] = R[i] - K[R[i-1] & 63];

R[i] is "r-mashed" by deducting from it one of the words of the expanded key. The key word to be used is determined by looking at the low-order six bits of R[i-1], and using that as an index into the key array K.

4.4 R-Mashing round An "r-mashing round" consists of: R-Mash R[3]

R-Mash R[2]

R-Mash R[1]

R-Mash R[0]

4.5 Decryption operation

The whole decryption operation j is a global integer variable which is affected by the mixing operations.

1. Initialize words R[0], .........., R[3] to contain the 64-bit cipher text value 2. Expand the key, so that words K[0], ..........., K[63] become defined. 3. Initialize j to 63. 4. Perform five r-mixing rounds. 5. Perform one r-mashing round. 6. Perform six r-mixing rounds. 7. Perform one r-mashing round. 8. Perform five r-mixing rounds.G:\useee 111 3des.png

Triple DES:

Triple DES is an another mode of DES operation. It takes three 64-bit keys, for an key length of 192 bits. In Private Encrypt you simply type in the entire 192-bit key rather than entering all the three keys individually. The Triple DES DLL then breaks the user provided key into three sub keys, padding the keys if necessary so they are each 64 bits long. The process for encryption is exactly the same as regular DES, but it is repeated three times. so the name Triple DES. The data is encrypted with the first key, decrypted with the second key, and again encrypted again with the third key.

DES Encryption Decryption Algorithm:

G:\3des 11111111111111.png

G:\3des 222222222222.png