Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

3.
1. Cryptography
 Cryptography, a word with Greek origins, means "secret
writing."
 However, we use the term to refer to the science and art of
transforming messages to make them secure and immune to
attacks.
 Figure 1 shows the components involved in cryptography.
3
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

4.
 Plaintext and Ciphertext-The original message, before being transformed, is called plaintext.
After the message is transformed, it is called ciphertext. An encryption algorithm transforms
the plaintext into ciphertext; a decryption algorithm transforms the ciphertext back into
plaintext. The sender uses an encryption algorithm, and the receiver uses a decryption
algorithm.
 Cipher -We refer to encryption and decryption algorithms as ciphers. The term cipher is also
used to refer to different categories of algorithms in cryptography. This is not to say that every
sender-receiver pair needs their very own unique cipher for a secure communication. On the
contrary, one cipher can serve millions of communicating pairs.
 Key- A key is a number (or a set of numbers) that the cipher, as an algorithm, operates on. To
encrypt a message, we need an encryption algorithm, an encryption key, and the plaintext.
These create the ciphertext.
 To decrypt a message, we need a decryption algorithm, a decryption key, and the ciphertext.
These reveal the original plaintext.
 Alice, Bob, and Eve- In cryptography, it is customary to use three characters in an information
exchange scenario; we use Alice, Bob, and Eve. Alice is the person who needs to send secure
data. Bob is the recipient of the data. Eve is the person who somehow disturbs the
communication between Alice and Bob by intercepting messages to uncover the data or by
sending her own disguised messages. These three names represent computers or processes that
actually send or receive data, or intercept or change data.
4
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

6.
 1. Symmetric Key Cryptography- In symmetric-key cryptography,
the same key is used by both parties.
 The sender uses this key and an encryption algorithm to encrypt data;
 The receiver uses the same key and the corresponding decryption
algorithm to decrypt the data.
 Note-In symmetric key cryptography, the same key is used by the sender
(for encryption) and the receiver (for decryption). The key is shared.
6
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

7.
 2. Asymmetric-Key Cryptography- In asymmetric or public-key
cryptography, there are two keys: a private key and a public key.
 The private key is kept by the receiver. The public key is announced to
the public.
 In Figure, imagine Alice wants to send a message to Bob. Alice uses
the public key to encrypt the message. When the message is received
by Bob, the private key is used to decrypt the message.
7
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

8.
 In public-key encryption/decryption, the public key that is used for
encryption is different from the private key that is used for
decryption. The public key is available to the public; the private key is
available only to an individual.
 Three Types of Keys-The reader may have noticed that we are dealing
with three types of keys in cryptography: the secret key, the public
key, and the private key.
 The first, the secret key, is the shared key used in symmetric-key
cryptography. The second and the third are the public and private keys
used in asymmetric-key cryptography. We will use three different
icons for these keys throughout the book to distinguish one from the
others, as shown in Figure.
8
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

9.
 Let us compare symmetric-key and asymmetric-key cryptography.
Encryption can be thought of as electronic locking; decryption as
electronic unlocking. The sender puts the message in a box and locks
the box by using a key; the receiver unlocks the box with a key and
takes out the message. The difference lies in the mechanism of the
locking and unlocking and the type of keys used.
 In symmetric-key cryptography, the same key locks and unlocks the
box. In asymmetric-key cryptography, one key locks the box, but
another key is needed to unlock it. Figure shows the difference.
9
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

10.
1. SYMMETRIC-KEY CRYPTOGRAPHY
 Symmetric-key cryptography started thousands of years ago when
people needed to exchange secrets (for example, in a war).
 We still mainly use symmetric-key cryptography in our network
security.
 However, today's ciphers are much more complex.
 Traditional Ciphers-
10
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

11.
 (i)Substitution Cipher-A substitution cipher substitutes one symbol
with another. If the symbols in the plaintext are alphabetic characters,
we replace one character with another. For example, we can replace
character A with D, and character T with Z. If the symbols are digits
(0 to 9), we can replace 3 with 7, and 2 with 6. Substitution ciphers
can be categorized as either monoalphabetic or polyalphabetic
ciphers.
 Note - A substitution cipher replaces one symbol with another.
 In a monoalphabetic cipher- A character (or a symbol) in the
plaintext is always changed to the same character (or symbol) in the
ciphertext regardless of its position in the text. For example, if the
algorithm says that character A in the plaintext is changed to
character D, every character A is changed to character D. In other
words, the relationship between characters in the plaintext and the
ciphertext is a one-to-one relationship.
11
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

12.
 Polyalphabetic cipher- Each occurrence of a character can
have a different substitute. The relationship between a character
in the plaintext to a character in the ciphertext is a one-tomany relationship. For example, character A could be changed
to D in the beginning of the text, but it could be changed to N
at the middle. It is obvious that if the relationship between
plaintext characters and ciphertext characters is one-tomany,
the key must tell us which of the many possible characters can
be chosen for encryption. To achieve this goal, we need to
divide the text into groups of characters and use a set of keys.
For example, we can divide the text "THISISANEASYTASK“
into groups of 3 characters and then apply the encryption using
a set of 3 keys. We then repeat the procedure for the next 3
characters.
12
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

13.
 Shift Cipher- The simplest monoalphabetic cipher is probably the
shift cipher. We assume that the plaintext and ciphertext consist of
uppercase letters (A to Z) only.
 In this cipher, the encryption algorithm is "shift key characters down,"
with key equal to some number. The decryption algorithm is "shift key
characters up." For example, if the key is 5, the encryption algorithm is
"shift 5 characters down" (toward the end of the alphabet). The
decryption algorithm is "shift 5 characters up" (toward the beginning
of the alphabet). Of course, if we reach the end or beginning of the
alphabet, we wrap around. Julius Caesar used the shift cipher to
communicate with his officers. For this reason, the shift cipher is
sometimes referred to as the Caesar cipher. Caesar used a key of 3 for
his communications.
 Note- The shift cipher is sometimes referred to as the Caesar cipher.
13
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

14.
 (ii)Transposition Ciphers- In a transposition cipher, there is no





14
substitution of characters; instead, their locations change. A character
in the first position of the plaintext may appear in the tenth position of
the ciphertext. A character in the eighth position may appear in the
first position. In other words, a transposition cipher reorders the
symbols in a block of symbols.
Key In a transposition cipher, the key is a mapping between the
position of the symbols in the plaintext and cipher text. For example,
the following shows the key using a block of four characters:
Plaintext:2 4 1 3
Ciphertext:123 4
In encryption, we move the character at position 2 to position 1, the
character at position 4 to position 2, and so on.
In decryption, we do the reverse.
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

15.
 Note- To be more effective, the key should be long, which means
encryption and decryption of long blocks of data.
Figure: shows encryption and decryption for our four-character
block using the above key. The figure shows that the encryption and decryption use
the same key.
The encryption applies it from downward while decryption applies it upward.
15
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

16.
3. Simple Modern Ciphers
 The traditional ciphers we have studied so far are character-oriented.
 The computer, ciphers need to be bit-oriented.
 This is so because the information to be encrypted is not just text; it
can also consist of numbers, graphics, audio, and video data.
 It is convenient to convert these types of data into a stream of bits,
encrypt the stream, and then send the encrypted stream.
16
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

17.
 1. XOR Cipher- Modern ciphers today are normally made of a set of
simple ciphers, which are simple predefined functions in
mathematics or computer science. The first one discussed here is called the
XOR cipher because it uses the exclusive-or operation as
defined in computer science.
An XOR operation needs two data inputs plaintext, as the first and a key as the
second.
In other words, one of the inputs is the block to be the encrypted, the other input is a
key; the result is the encrypted block.
Note that in an XOR cipher, the size of the key, the plaintext, and the ciphertext are
all the same. XOR ciphers have a very interesting property: the encryption and
decryption are the same.
17
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

18.
 2. Rotation Cipher- Another common cipher is the rotation cipher,




18
in which the input bits are rotated to the left or right.
The rotation cipher can be keyed or keyless.
In keyed rotation, the value of the key defines the number of
rotations;
In keyless rotation the number of rotations is fixed.
Note that- The rotation cipher can be considered a special case of
the transpositional cipher using bits instead of characters.
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

19.
 Interesting property- If the length of the original stream is N, after
N rotations, we get the original input stream. This means that it is useless to
apply more than N - 1 rotations. In other words, the number of rotations
must be between 1 and N-1.
 The decryption algorithm for the rotation cipher uses the same key
and the opposite rotation direction. If we use a right rotation in the
encryption, we use a left rotation in decryption and vice versa.
3.Substitution Cipher: S-box- An S-box (substitution box) parallels
the traditional substitution cipher for characters.
 The input to an S-box is a stream of bits with length N; the result is
another stream of bits with length M. And Nand M are not necessarily the
same.
 The S-box is normally keyless and is used as an intermediate stage of
encryption or decryption. The function that matches the input to th
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013
19 output may be defined mathematically or by a table.

20.
4. Transposition Cipher: P-box P-box (permutation box) for bits parallels the
traditional transposition cipher for characters.
It performs a transposition at the bit level; it transposes
bits.
 It can be implemented in software or hardware, but hardware is
faster.
 P-boxes, like S-boxes, are nonnally keyless.
 We can have three types of pennutations in P-boxes: the straight
permutation, expansion permutation, and compression
permutation
20
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

21.
A straight permutation cipher or a straight P-box has the same number of inputs as outputs.
In other words, if the number of inputs is N, the number of outputs is also N.
In an expansion pennutation cipher, the number of output ports is greater than the number
of input ports.
In a compression pennutation cipher, the number of output ports is less than the number of
input ports.
21
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

22.
4. Modern Round Ciphers
 The ciphers of today are called round ciphers because they
involve multiple rounds, where each round is a complex cipher
made up of the simple ciphers.
 The key used in each round is a subset or variation of the general key
called the round key.
 If the cipher has N rounds, a key generator produces N keys, Kb Kz, ..., KN,
where K1 is used in round 1, K2 in round 2, and so on.
22
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

23.
4.1 Data Encryption Standard (DES)(Symmetrickey ciphers)
 DES was designed by IBM and adopted by the U.S. government as
the standard encryption method for nonmilitary and nonclassified
use.
 The algorithm encrypts a 64-bit plaintext block using a 64-bit key
23
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

24.
 DES has two transposition blocks (P-boxes) and 16 complex round
ciphers (they are repeated). Although the 16 iteration round ciphers
are conceptually the same, each uses a different key derived from the
original key. The initial and final permutations are keyless straight
permutations that are the inverse of each other. The permutation
takes a 64-bit input and permutes them according DES has two
transposition blocks (P-boxes) and 16 complex round ciphers.
 The 16 iteration round ciphers are conceptually the same, each uses a
different key derived from the original key.
24
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

25.
DES Function
 The heart of DES is the DES function. The DES function applies a 48-
bit key to the rightmost 32 bits Ri to produce a 32-bit output.
 This function is made up of four operations: an XOR, an expansion
permutation, a group of S-boxes, and a straight permutation.
25
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

26.
Triple DES
 Note- The encrypting block uses an encryption-decryption-encryption
combination of DESs, while the decryption block uses a decryptionencryption-decryption combination.
 Two different versions of 3DES are in use: 3DES with two keys and 3DES
with three keys. To make the key size 112 bits and at the same time protect
DES from attacks such as the man-in-the-middle attack, 3DES with two
keys was designed.
26
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

28.
 1. Electronic Code Book- The electronic code book (ECB) mode is a
purely block cipher technique.
 The plaintext is divided into blocks of N bits.
 The ciphertext is made of blocks of N bits.
 The value of N depends on the type of cipher used.
28
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

29.
 Characteristics of this mode:
1. Because the key and the encryption/decryption algorithm are the
same, equal blocks in the plaintext become equal blocks in the
ciphertext. For example, if plaintext blocks 1, 5, and 9 are the
same, ciphertext blocks I, 5, and 9 are also the same.
 This can be a security problem; the adversary can guess that the
plaintext blocks are the same if the corresponding ciphertext blocks
are the same.
2. If we reorder the plaintext block, the ciphertext is also reordered.
3. Blocks are independent of each other. Each block is encrypted or
decrypted independently. A problem in encryption or decryption of
a block does not affect other blocks.
29
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

30.
4. An error in one block is not propagated to other blocks. If one or
more bits are corrupted during transmission, it only affects the bits in
the corresponding plaintext after decryption.
 Other plaintext blocks are not affected. This is a real advantage if the
channel is not noise-free.
2. Cipher Block Chaining
30
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

31.
 Some characteristics of CBC:
 1. Even though the key and the encryption/decryption algorithm are
the same, equal blocks in the plaintext do not become equal blocks in
the ciphertext. For example,
 if plaintext blocks 1, 5, and 9 are the same, ciphertext blocks I, 5,
and 9 will not be the same. An adversary will not be able to guess
from the ciphertext that two blocks are the same.
 2. Blocks are dependent on each other. Each block is encrypted or
decrypted based on a previous block. A problem in encryption or
decryption of a block affects other blocks.
 3. The error in one block is propagated to the other blocks. If one or
more bits are corrupted during the transmission, it affects the bits in
the next blocks of the plaintext after decryption.
31
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

32.
3. Cipher Feedback Mode (CFM)
 Some characteristics of the CFB mode:
1. If we change the IV from one encryption to another using the same
plaintext, the ciphertext is different.
2. The ciphertext Ci depends on both Pi and the preceding ciphertext block.
3. Errors in one or more bits of the ciphertext block affect the next
ciphertext blocks.
32
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

33.
4. Output feedback mode(OFM)
 The following are some of the characteristics of the OFB
mode
1. If we change the IV from one encryption to another using the same
plaintext, the ciphertext will be different.
2. The ciphertext Ci depends on the plaintext Pi‘
3. Errors in one or more bits of the ciphertext do not affect future
ciphertext blocks.
33
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

34.
2. ASYMMETRIC-KEY CRYPTOGRAPHY(Public-Key)
 Cipher uses two keys: one private and one public. We discuss two
algorithms: RSA and Diffie-Hellman.
 1. RSA
 The most common public key algorithm is RSA, named for its
inventors Rivest, Shamir, and Adleman (RSA).
 It uses two numbers, e and d, as the public and private keys, as shown
in Figure.
34
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

35.
Selecting Keys:
 Bob use the following steps to select the private and public keys:
1. Bob chooses two very large prime numbers p and q. Remember that a
prime number is one that can be divided evenly only by 1 and itself.
2. Bob multiplies the above two primes to find n, the modulus for
encryption and decryption. In other words, n = p X q.
3. Bob calculates another number F = (p -1) X (q - 1).
4. Bob chooses a random integer e. He then calculates d so that d x e =1
mod F.
5. Bob announces e and n to the public; he keeps F and d secret.
 NOTE- In RSA, e and n are announced to the public; d and F are kept
secret.
35
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

36.
 Encryption
 Anyone who needs to send a message to Bob can use n and e.
 For example- if Alice needs to send a message to Bob, she can change
the message, usually a short one, to an integer. This is the plaintext.
She then calculates the ciphertext, using e and n.
 C=pe(mod n)
 Alice sends C, the ciphertext, to Bob.
 Decryption
 Bob keeps F and d private. When he receives the ciphertext, he uses his
private key d to decrypt the message: P= Cd(mod n)
 Restriction
 For RSA to work, the value of P must be less than the value of n. If P is a
large number, the plaintext needs to be divided into blocks to make P
less than n.
36
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

37.
Applications of RSA
 RSA can be used to encrypt and decrypt actual messages, it is very
slow if the message is long.
 It is useful for short messages such as a small message digest or a
symmetric key to be used for a symmetric-key cryptosystem.
 RSA is also used for authentication.
37
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013

38.
2. Diffie-Hellman
 RSA is a public-key cryptosystem that is often used to encrypt and decrypt




38
symmetric keys.
Diffie-Hellman, on the other hand, was originally designed for key
exchange.
In the Diffie-Hellman cryptosystem, two parties create a
symmetric session key to exchange data without having to remember
or store the key for future use.
They do not have to meet to agree on the key; it can be done through the
Internet.
The first number, p, is a large prime number on the order of 300 decimal
digits (1024 bits). The second number is a random number. These two
numbers need not be confidential. They can be sent through the Internet;
they can be public.
ER.ANUPAM KUMAR,A.I.T.M.,U.P
10/12/2013