ch 3 cryptography and network security Computer Network
ch 3 cryptography and network security Computer Network
3
Cryptography and
Network Security
Objectives…
To understand Concept of Network Security
To learn Concept of Cryptography
To study Security Services
3.0 INTRODUCTION
• Today, the use of computer with Internet is increasing rapidly. At the same time
security challenges are also increasing.
• A number of software tools are available which help the attackers/interceptors to
attack computers easily.
• Therefore, security becomes an important issue in computer field, when
data/information is transmitted on a computer network. No one can deny the
importance of security in computer networks.
• Network security is an emerging field which helps to protect the computer from
various attacks.
• Computer security means to protect information. Network security means protection
of data on the network during data transmission.
• Computer security deals with prevention and detection of unauthorized actions by
users of a computer.
• Network security issues include protecting data from unauthorized access, protecting
data from damage and development and implementing policies and procedures for
recovery from breaches and data losses.
• Security in networking is based on cryptography. Cryptography is the science and art
of achieving security by encoding messages to make them non-readable.
• The art and science of concealing the messages to introduce secrecy in information
security is recognized as cryptography.
• Network security consists of the policies and practices adopted to prevent and monitor
unauthorized access, misuse, modification, or denial of a computer network and
network-accessible resources.
3.1
Computer Networks - II Cryptography and Network Security
• Today, we are living in the information age. We need to keep information about every
aspect of our lives.
• In other words, information is an asset that has a value like any other asset. As an
asset, information needs to be secured from attacks.
• An attack is any kind of malicious activity that attempts to collect, disrupt, deny,
degrade, or destroy information system resources or the information itself.
• An attacker is a person or process that attempts to access data, functions or other
restricted areas of the system without authorization, potentially with malicious intent.
• To be secured, information needs to be hidden from unauthorized access
(confidentiality), protected from unauthorized change (integrity), and available to an
authorized entity when it is needed (avaliability).
• Cryptography is technique of securing information through use of codes so that only
those users for whom the information is intended can understand it and process it.
Thus preventing unauthorized access to information.
• The word ‘cryptography’ was coined by combining two Greek words, ‘krypto’ meaning
hidden or secret and ‘graphene’ meaning writing. So, Cryptography, a word with
Greek origins, means “secret writing.”
• Cryptography is an art and science of transforming messages so as to make them
secure and immune to attacks.
• Cryptography involves the process of encryption and decryption of messages using
secret keys. The process of cryptography is shown in Fig. 3.1.
• Encryption is a process which transforms the original message into an unrecognizable
or unreadable form.
• The sender requires an encryption algorithm and a key to transform the plaintext
(original message) into a ciphertext (encrypted message),
• Decryption is a process of converting encoded/encrypted message to its original form.
The receiver uses a decryption algorithm and a key to transform the ciphertext back to
original plaintext.
3.2
Computer Networks - II Cryptography and Network Security
3.3
Computer Networks - II Cryptography and Network Security
• Both sender and receiver agree upon a secrete key to be used in encrypting and
decrypting. Usually the secrete key is transmitted via public key encryption methods.
• In the traditional encryption model, there should be at least two parties to perform
secure communication.
• Let us take the sender name as Yogita and the receiver name as Amar. Yogita wants to
communicate a message with Amar in a secure way.
• In order to do that, the original intelligible message called plaintext is converted into
an unintelligible message by Yogita and is sent to Amar.
• To convert the plain-text into ciphertext, the encryption operation takes two
parameters as input. They are the original intelligible message (P) and a key (K).
• The key is some bits of information which is generated from a source called key
generator.
• The key is generated independently of the plaintext and is used to convert intelligible
message from the original unintelligible message (vice versa).
• The encryption algorithm uses an encryption function which will produce different
ciphertext values for the same plaintext value using different key values.
• Fig. 3.2 shows a conventional encryption model that consists of three components,
namely the sender (Yogita), the receiver (Amar) and the attacker (Eavesdropper).
• The main objective of this model is to enable Yogita and Amar to communicate over an
insecure channel in such a way that the attacker (Eavesdropper) should not
understand the original plaintext.
• Initially, Yogita is generating the plaintext P and sends it to the encryption algorithm.
The encryption algorithm uses an encryption function to convert the plaintext P into
the ciphertext C using a key value K.
• After computing the ciphertext, Yogita transmits it through insecure channel. At the
receiver side (Amar), the ciphertext is converted back into the original plaintext using
the same key with the help of a decryption algorithm.
• According to Kerckhoffs principle, the encryption method is assumed to be known to
the attacker (Eavesdropper). However, both the sender and receiver keeps the key as
secret.
• As shown in Fig. 3.2, the plaintext P and the key K are given as input to the encryption
algorithm to produce the ciphertext C and it can be represented as given below:
C = EK(P)
where, P = plaintext, K = encryption and decryption key, E = encryption algorithm,
C = ciphertext.
• At the receiver side, the ciphertext C and the key K are given as input to the decryption
algorithm to produce the plaintext P and it can be represented as given below:
P = DK (C) = (DK (EK(P))) = P
where, D = decryption algorithm
3.4
Computer Networks - II Cryptography and Network Security
• During the transmission of the ciphertext, an attacker can capture the ciphertext and
tries to perform the following actions:
1. The attacker can find the original plaintext.
2. The attacker can find the key from which he/she can read all messages that are
encrypted with the same key in the future.
3. Once the key is found, the attacker can modify the original plaintext into another
message in such a way that Amar will believe that the message is coming from
Yogita.
4. The attacker makes Amar to believe that Amar is communicating with Yogita.
Eavesdropper K
P Encryption C Decryption P
Yogita Amar
algorithm algorithm
Secure channel
Key
generator
Hi Amar
Rohan
3.6
Computer Networks - II Cryptography and Network Security
• Some critical information used in the cipher, known only to sender and receiver is
called as key.
• The process of converting plaintext to ciphertext using a cipher and a key is called as
encryption. The process of converting ciphertext back into plaintext using a cipher
and a key is called as description.
• Fig. 3.6 shows a sender who wants to transfer some sensitive data to a receiver in such
a way that any party intercepting or eavesdropping on the communication channel
cannot extract the data.
• The objective of this simple crypto-system is that at the end of the process, only the
sender and the receiver will know the plaintext.
• Encryption algorithm is a crypto-graphic algorithm that takes plaintext and an
encryption key as input and produces a ciphertext.
• Decryption algorithm is a crypto-graphic algorithm that takes a ciphertext and a
decryption key as input, and outputs a plaintext.
• The decryption algorithm essentially reverses the encryption algorithm and is thus
closely related to it.
Encryption
Message in Message in
key
plaintext plaintext
Encrypt Decrypt
Decryption
Message key Message
in ciphertext in ciphertext
Insecure
network
Fig. 3.6
• Encryption key is a value that is known to the sender. The sender inputs the
encryption key into the encryption algorithm along with the plaintext in order to
compute the ciphertext.
• Decryption key is a value that is known to the receiver. The decryption key is related
to the encryption key, but is not always identical to it.
• The receiver inputs the decryption key into the decryption algorithm along with the
ciphertext in order to compute the plaintext.
• Fundamentally, there are two types of cryptosystems based on the manner in which
encryption-decryption is carried out in the system Symmetric Key Encryption and
Asymmetric Key Encryption.
3.7
Computer Networks - II Cryptography and Network Security
ciphertext
Plain Encrypt Decrypt Plain
text Insecure text
communication
channel
Reliable
Host 1 (Sender) distribution Host 2 (Receiver)
Private key Public key channel Private key
(Host 1) (Host 2) (Host 2)
Fig. 3.9
7. Decryption: (April 19)
• It is the process of converting cipher text into plain text using key.
• Decryption is a technique of translation of decoded data (ciphertext) into original data
(plaintext). A secret key is used for decryption.
Decryption
Ciphertext Plaintext
Fig. 3.10
• Fig. 3.11 shows the process of encryption and decryption.
• Encryption is a process of converting normal data or message into an
unreadable/encrypted form whereas Decryption is a method of converting the
unreadable/encrypted data into its original form.
Network
Plaintext Plaintext
Encryption Decryption
Ciphertext
Sender Receiver
Fig. 3.11
8. Keys:
• A key in cryptography is a piece of information, usually a string of numbers or letters
that are stored in a file, which, when processed through a cryptographic algorithm,
can encode or decode cryptographic data.
3.9
Computer Networks - II Cryptography and Network Security
• Hence, symmetric key cryptography also called as single key/secret key/shared key
cryptography.
• This key is shared between sender and receiver and known to only sender and
receiver and no one else.
• In symmetric encryption the plaintext gets encrypted and then converted to the
ciphertext using an encryption algorithm and a key.
• On reaching the intended receiver, the ciphertext gets converted back to plain text
utilizing the same key that was applied for encryption and a decryption algorithm.
The key used can be as easy as a secret number or just a string of letters.
Advantages:
1. Simple: This type of encryption is easy to carry out. All users have to do is specify
and share the secret key and then begin to encrypt and decrypt messages.
2. Fast: Symmetric key encryption is much faster than asymmetric key encryption.
3. Uses Less Computer Resources: Single-key encryption does not require a lot of
computer resources when compared to public key encryption.
4. Prevents Widespread Message Security Compromise: A different secret key is
used for communication with every different party. If a key is compromised, only
the messages between a particular pair of sender and receiver are affected.
Communications with other people are still secure.
Disadvantages:
1. Need for Secure Communication Channel for Secret Key Exchange: Sharing the
secret key in the beginning is a problem in symmetric key encryption. It has to be
exchanged in a way that ensures it remains secret.
2. Too Many Keys: A new shared key has to be generated for communication with
every different party. This creates a problem with managing and ensuring the
security of all these keys.
3. Origin and Authenticity of Message Cannot be Guaranteed: Since, both sender
and receiver use the same key, messages cannot be verified to have come from a
particular user. This may be a problem if there is a dispute.
• The original message from Yogita to Amar is called plaintext; the message that is sent
through the channel is called the ciphertext.
• To create the ciphertext from the plaintext, Yogita uses an encryption algorithm and a
shared secret key.
• To create the plaintext from ciphertext, Amar uses a decryption algorithm and the
same secret key.
• We refer to encryption and decryption algorithms as ciphers. A key is a set of values
(numbers) that the cipher, as an algorithm, operates on.
• We can divide traditional symmetric key ciphers into two broad categories namely,
substitution ciphers and transposition ciphers.
1. Substitution Cipher: (April 16. Oct. 17)
• In a substitution cipher, each letter or group of letters are replaced by another letter or
group of letters to disguise it.
• A substitution cipher replaces one symbol with another. If the symbols in the plaintext
are alphabetic characters, we replace one character with another.
• For example, we can replace letter X with letter Y, and letter A with letter Z. If the
symbols are digits (0 to 9), we can replace 3 with 6, and 2 with 7.
• Substitution ciphers can be categorized as either monoalphabetic ciphers or
polyalphabetic ciphers.
Monoalphabetic Cipher:
• Monoalphabetic cipher is a substitution cipher. 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 letter A in the plaintext is changed to letter D,
every letter A is changed to letter D.
3.12
Computer Networks - II Cryptography and Network Security
• In monoalphabetic cipher, the relationship between letters in the plaintext and the
ciphertext is one-to-one.
• The simplest monoalphabetic cipher is the additive cipher (or shift cipher). In
cryptography, a shift cipher, also known as Caesar cipher (proposed by Julius Caesar).
The name ‘Caesar Cipher’ is occasionally used to describe the Shift Cipher when the
‘shift of three’ is used.
• In additive cipher, the plaintext, ciphertext, and key are integers in modulo 26.
Assume that the plaintext consists of lowercase letters (a to z), and that the ciphertext
consists of uppercase letters (A to Z). To be able to apply mathematical operations on
the plaintext and ciphertext, we assign numerical values to each letter (lower or
uppercase), as shown in Fig. 3.14.
• In Fig. each character (lowercase or uppercase) is assigned an integer in modulo 26.
The secret key between Yogita and Amar is also an integer in modulo 26.
• The encryption algorithm adds the key to the plaintext character; the decryption
algorithm subtracts the key from the ciphertext character. All operations are done in
modulo 26.
• The concept of shift cipher is to replace each alphabet by another alphabet which is
‘shifted’ by some fixed number between 0 and 25.
Plaintext a b c d e f g h i j k l m n o p q r s t u v w x y z
Ciphertext A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Value 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Fig. 3.14
Process of Shift Cipher:
• In order to encrypt a plaintext letter, the sender positions the sliding ruler underneath
the first set of plaintext letters and slides it to LEFT by the number of positions of the
secret shift.
• The plaintext letter is then encrypted to the ciphertext letter on the sliding ruler
underneath.
• The result of this process is depicted in the following illustration for an agreed shift of
three positions. In this case, the plaintext ‘tutorial’ is encrypted to the ciphertext
‘WXWRULDO’.
• Here, is the ciphertext alphabet for a Shift of 3.
Plaintext
a b c d e f g h i j k l m n o p q r s t u v w x y z
Alphabet
Ciphertext
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Alphabet
Fig. 3.15
3.13
Computer Networks - II Cryptography and Network Security
• On receiving the ciphertext, the receiver who also knows the secret shift, positions his
sliding ruler underneath the ciphertext alphabet and slides it to RIGHT by the agreed
shift number, 3 in this case.
• He then replaces the ciphertext letter by the plaintext letter on the sliding ruler
underneath. Hence, the ciphertext ‘WXWRULDO’ is decrypted to ‘tutorial’.
• To decrypt a message encoded with a Shift of 3, generate the plaintext alphabet using a
shift of ‘-3’ as shown in Fig. 3.16.
Ciphertext
a b c d e f g h i j k l m n o p q r s t u v w x y z
Alphabet
Plaintext
x y z a b c d e f g h i j k l m n o p q r s t u v w
Alphabet
Fig. 3.16
• Caesar Cipher is not a secure cryptosystem because there are only 26 possible keys to
try out. An attacker can carry out an exhaustive key search with available limited
computing resources.
Example: By using Caesar cipher, transform the message ‘Happy birthday to you’.
Solution:
Plaintext: Happy birthday to you
Key: Character + 3
Caesar cipher: kdssb eluwkgdb wr brx
Polyalphabetic Cipher:
• Polyalphabetic cipher is a substitution cipher in which the cipher alphabet for the
plain alphabet may be different at different places during the encryption process.
• In polyalphabetic substitution, each occurrence of a character may have a different
substitute. The relationship between a character in the plaintext to a character in the
ciphertext is one-to-many.
• For example, “a” could be enciphered as “D” in the beginning of the text, but as “N” at
the middle. Polyalphabetic ciphers have the advantage of hiding the letter frequency
of the underlying language.
• To create a polyalphabetic cipher, we need to make each ciphertext character
dependent on both the corresponding plaintext character and the position of the
plaintext character in the message.
• This implies that our key should be a stream of subkeys, in which each subkey
depends somehow on the position of the plaintext character that uses that subkey for
encipherment.
3.14
Computer Networks - II Cryptography and Network Security
Example: Consider a plaintext : “How are you when you arrived ?” By using a key
NCBTZQARX, use transposition cipher on the plaintext.
Solution: Use transposition cipher on the plaintext.
N C B T Z Q A R X
4 3 2 7 9 5 1 6 8
H o w a R e y o u
w h e n Y o u a r
r i v e D a b c d
Ciphertext: YUBWEVOHIHWREOAOACAHEURD
• The literature divides the symmetric ciphers into two broad categories namely, stream
ciphers and block ciphers.
• In a stream cipher, encryption and decryption are done one symbol (such as a
character or a bit) at a time.
• In stream cipher, the plaintext is processed one bit at a time i.e. one bit of plaintext is
taken, and a series of operations is performed on it to generate one bit of ciphertext.
• In a block cipher, a group of plaintext symbols of size m (m > 1) are encrypted
together, creating a group of ciphertext of the same size.
• Based on the definition, in a block cipher, a single key is used to encrypt the whole
block even if the key is made of multiple values. In a block cipher, a ciphertext block
depends on the whole plaintext block.
3.16
Computer Networks - II Cryptography and Network Security
• A symmetric key modern block cipher encrypts an n-bit block of plaintext or decrypts
an n-bit block of ciphertext. The encryption or decryption algorithm uses a k-bit key.
• The decryption algorithm must be the inverse of the encryption algorithm, and both
operations must use the same secret key so that Amar can retrieve the message sent by
Yogita.
• Fig. 3.17 (a) shows the general idea of encryption and decryption in a modern block
cipher.
• If the message has fewer than n bits, padding must be added to make it an n-bit block;
if the message has more than n bits, it should be divided into n-bit blocks and the
appropriate padding must be added to the last block if necessary. The common values
for n are 64, 128, 256, and 512 bits.
• Modern block ciphers normally are keyed substitution ciphers in which the key allows
only partial mappings from the possible inputs to the possible outputs.
• Modern block ciphers are substitution ciphers when seen as a whole block. However,
modern block ciphers are not designed as a single unit.
• To provide an attack-resistant cipher, a modern block cipher is made of a combination
of transposition units (sometimes called P-boxes), substitution units (sometimes called
S-boxes) and exclusive-or (XOR) operations, shifting elements, swapping elements,
splitting elements and combining elements.
• Fig. 3.17 (b) shows the components of a modern block cipher.
• A P-box (permutation box) parallels the traditional transposition cipher for
characters, but it transposes bits.
• We can find three types of P-boxes in modern block cipher namely, straight P-boxes,
expansion P-boxes, and compression P-boxes.
• An S-box (substitution box) can be thought of as a miniature substitution cipher, but
it substitutes bits.
• Unlike the traditional substitution cipher, an S-box can have a different number of
inputs and outputs.
3.17
Computer Networks - II Cryptography and Network Security
3.18
Computer Networks - II Cryptography and Network Security
• The Data Encryption Standard (DES) is a symmetric-key algorithm for the encryption
of electronic data.
• General structure of DES is shown in Fig. 3.19. DES uses 16 rounds. The block size is
64-bit. DES is also called as Data Encryption Algorithm (DEA).
• At the encryption site, DES takes a 64-bit plaintext and creates a 64-bit ciphertext; at
the decryption site, DES takes a 64-bit ciphertext and creates a 64-bit block of plaintext.
The same 56-bit cipher key is used for both encryption and decryption.
64-bit plaintext
DES
Initial permutation
K1
Round 1
48-bit
Round-key generator
K2
Round 2
48-bit 56-bit cipher key
K16
Round 16
48-bit
Final permutation
64-bit ciphertext
• DES contains Round function, Key schedule and any additional processing − initial and
final permutation.
Initial and Final Permutation:
• The initial and final permutations are straight Permutation boxes (P-boxes) that are
inverses of each other. They have no cryptography significance in DES.
• The initial permutations takes a 64-bit input and permutes them according to a
predefined rule. The final permutation is the inverse of the initial permutation.
• The initial and final permutations are shown in Fig. 3.20.
3.20
Computer Networks - II Cryptography and Network Security
1 2 8 25 40 58 64
Initial
Permutation
1 2 8 25 40 58 64
16 Round
1 2 8 25 40 58 64
Final
Permutation
1 2 8 25 40 58 64
Fig. 3.20
DES Rounds:
• DES uses 16 rounds and each round of
DES is an invertible transformation, as
shown in Fig. 3.21.
• The round takes LI−1 and RI−1 from the
previous round (or the initial
permutation box) and creates LI and RI,
which go to the next round (or final
permutation box).
• Each round can have up to two cipher
elements (mixer and swapper). Each of
these elements is invertible. The
swapper is obviously invertible. It
swaps the left half of the text with the
right half. Fig. 3.21
3.21
Computer Networks - II Cryptography and Network Security
Fig. 3.22
Fig. 3.23
• The graphically depicted permutation logic is generally described as table in DES
specification illustrated as shown in Fig. 3.24.
32 01 02 03 04 05
04 05 06 07 08 09
08 09 10 11 12 13
12 13 14 15 16 17
16 17 18 19 20 21
20 21 22 23 24 25
24 25 26 27 28 29
28 29 31 31 32 01
Fig. 3.24
3.22
Computer Networks - II Cryptography and Network Security
• XOR (Whitener): After the expansion permutation, DES does XOR operation on the
expanded right section and the round key. The round key is used only in this
operation.
• Substitution Boxes: The S-boxes carry out the real mixing (confusion). DES uses 8 S-
boxes, each with a 6-bit input and a 4-bit output, (See Fig. 3.25).
48-bit input
Array of S-Boxes
32-bit output
Fig. 3.25
01 2 3 15
0
1
2
3
Table
entry
S-box
Fig. 3.26
• There are a total of eight S-box tables. The output of all eight s-boxes is then combined
in to 32 bit section.
• Straight Permutation: The 32 bit output of S-boxes is then subjected to the straight
permutation with rule shown in Fig. 3.27.
3.23
Computer Networks - II Cryptography and Network Security
16 07 20 21 29 12 28 17
01 15 23 26 05 18 31 10
02 08 24 14 32 27 03 09
19 13 30 06 22 11 04 25
Fig. 3.27
Key Generation:
• The round-key generator creates sixteen 48-bit keys out of a 56-bit cipher key.
• The process of key generation is depicted in the Fig. 3.28.
Fig. 3.28
• Consequently two main variations of DES have emerged, which are Double DES and
Triple DES.
1. In double DES, two symmetric keys were used for encryption and decryption,
however double DES also had some limitations. With regard to this context, triple
DES was introduced in the year 1999 by a team led by Walter Tuchman who was
working at IBM.
2. Triple DES resolved all the limitations of double DES by using three symmetric
keys as well as two symmetric keys. Moreover, triple DES is extensively used in
many of the Internet protocols in today's environment.
3.24
Computer Networks - II Cryptography and Network Security
Operation:
o The user takes the first block of plaintext and encrypts it with the key to produce
the first block of ciphertext.
o He then takes the second block of plaintext and follows the same process with
same key and so on so forth.
• The ECB mode is deterministic, that is, if plaintext block P1, P2, …, Pm are encrypted
twice under the same key, the output ciphertext blocks will be the same.
• In fact, for a given key technically we can create a codebook of ciphertexts for all
possible plaintext blocks. Encryption would then entail only looking up for required
plaintext and select the corresponding ciphertext.
• Thus, the operation is analogous to the assignment of code words in a codebook, and
hence gets an official name − Electronic Codebook mode of operation (ECB). It is
illustrated in Fig. 3.29.
Plaintext (P1) Plaintext (P2) Ciphrtext (C1) Ciphrtext (C2)
C1,C2
Block cipher Key Block cipher Key Block cipher Block cipher
Key Key
encryption encryption decryption decryption
Fig. 3.29
Analysis of ECB Mode:
• In reality, any application data usually have partial information which can be
guessed. For example, the range of salary can be guessed. A ciphertext from ECB can
allow an attacker to guess the plaintext by trial-and-error if the plaintext message is
within predictable.
• For example, if a ciphertext from the ECB mode is known to encrypt a salary figure,
then a small number of trials will allow an attacker to recover the figure.
• In general, we do not wish to use a deterministic cipher, and hence the ECB mode
should not be used in most applications.
Cipher Block Chaining (CBC) Mode:
• CBC mode of operation provides message dependence for generating ciphertext and
makes the system non-deterministic.
Operation:
• The operation of CBC mode is depicted in the following illustration. The steps are as
follows:
o Load the n-bit Initialization Vector (IV) in the top register.
3.25
Computer Networks - II Cryptography and Network Security
o XOR the n-bit plaintext block with data value in top register.
o Encrypt the result of XOR operation with under-lying block cipher with key K.
o Feed ciphertext block into top register and continue the operation till all plain-text
blocks are processed.
o For decryption, IV data is XORed with first ciphertext block decrypted. The first
ciphertext block is also fed into to register replacing IV for decrypting next
ciphertext block.
Fig. 3.30
Analysis of CBC Mode:
• In CBC mode, the current plaintext block is added to the previous ciphertext block,
and then the result is encrypted with the key.
• Decryption is thus the reverse process, which involves decrypting the current
ciphertext and then adding the previous ciphertext block to the result.
• Advantage of CBC over ECB is that changing IV results in different ciphertext for
identical message. On the drawback side, the error in transmission gets propagated to
few further block during decryption due to chaining effect.
• It is worth mentioning that CBC mode forms the basis for a well-known data origin
authentication mechanism. Thus, it has an advantage for those applications that
require both symmetric encryption and data origin authentication.
Cipher Feedback (CFB) Mode:
• In this mode, each ciphertext block gets ‘fed back’ into the encryption process in order
to encrypt the next plaintext block.
Operation:
• The operation of CFB mode is depicted in the following illustration. For example, in
the present system, a message block has a size ‘s’ bits where 1 < s < n.
• The CFB mode requires an initialization vector (IV) as the initial random n-bit input
block. The IV need not be secret.
• Steps of operation are given below:
o Load the IV in the top register.
o Encrypt the data value in top register with underlying block cipher with key K.
3.26
Computer Networks - II Cryptography and Network Security
o Take only ‘s’ number of most significant bits (left bits) of output of encryption
process and XOR them with ‘s’ bit plaintext message block to generate ciphertext
block.
o Feed ciphertext block into top register by shifting already present data to the left
and continue the operation till all plaintext blocks are processed.
o Essentially, the previous ciphertext block is encrypted with the key, and then the
result is XORed to the current plaintext block.
o Similar steps are followed for decryption. Pre-decided IV is initially loaded at the
start of decryption.
Fig. 3.31
3.27
Computer Networks - II Cryptography and Network Security
Fig. 3.32
3.28
Computer Networks - II Cryptography and Network Security
o The decryption is the reverse process. The ciphertext block is XORed with the
output of encrypted contents of counter value. After decryption of each ciphertext
block counter is updated as in case of encryption.
Fig. 3.33
3.30
Computer Networks - II Cryptography and Network Security
Sr.
Symmetric Key Cryptography Asymmetric Key Cryptography
No.
1. It uses a single key (secret key) for both It uses two different keys public key for
encryption and decryption of data. encryption and private key for
decryption.
2. Both the communicating parties share Both the communicating parties should
the same algorithm and the key. have at least one of the matched pair of
keys.
3. The processes of encryption and The encryption and decryption processes
decryption are very fast. are slower.
4. Key distribution is a big problem. Key distribution is not a problem.
5. The size of encrypted text is usually The size of encrypted text is usually more
same or less than the original text. than the size of the original text.
6. Based on substitution and permutation Based on applying mathematical
of symbols (characters or bits). functions to numbers.
7. It can only be used for confidentiality, It can be used for confidentiality of data
i.e., only for encryption and decryption as well as for integrity and non-
of data. repudiation checks (i.e., far digital
signatures).
8. DES and AES are the commonly used The most commonly used asymmetric-
symmetric-encryption algorithms. encryption algorithm is RSA.
3.31
Computer Networks - II Cryptography and Network Security
encryption and is widely used to secure sensitive data, particularly when it is being
sent over an insecure network such as the internet.
• We will see two aspects of the RSA cryptosystem, firstly generation of key pair and
secondly encryption-decryption algorithms.
1. Generation of RSA Key Pair:
• Each person or a party who desires to participate in communication using encryption
needs to generate a pair of keys, namely public key and private key.
• The process followed in the generation of keys is described below:
o Generate the RSA Modulus (n):
Select two large primes, p and q.
Calculate n=p*q. For strong unbreakable encryption, let n be a large number,
typically a minimum of 512 bits.
o Find Derived Number (e):
Number e must be greater than 1 and less than (p − 1) (q − 1).
There must be no common factor for e and (p − 1) (q − 1) except for 1. In other
words two numbers e and (p – 1) (q – 1) are coprime.
o Form the Public Key:
The pair of numbers (n, e) form the RSA public key and is made public.
Interestingly, though n is part of the public key, difficulty in factorizing a large
prime number ensures that attacker cannot find in finite time the two primes
(p and q) used to obtain n. This is strength of RSA.
o Generate the Private Key:
Private Key d is calculated from p, q, and e. For given n and e, there is unique
number d.
Number d is the inverse of e modulo (p − 1) (q – 1). This means that d is the
number less than (p − 1) (q − 1) such that when multiplied by e, it is equal to 1
modulo (p − 1) (q − 1).
This relationship is written mathematically as follows:
d
e = 1 mod (p − 1)(q − 1)
The Extended Euclidean Algorithm takes p, q, and e as input and gives d as
output.
Example:
• An example of generating RSA Key pair is given below. (For ease of understanding,
the primes p and q taken here are small values. Practically, these values are very
high).
3.32
Computer Networks - II Cryptography and Network Security
3.33
Computer Networks - II Cryptography and Network Security
• Fig. 3.35 shows the general idea behind the procedure used in RSA.
RSA Analysis:
• The security of RSA depends on the strengths of two separate functions. The RSA
cryptosystem is most popular public-key cryptosystem strength of which is based on
the practical difficulty of factoring the very large numbers.
o Encryption Function: It is considered as a one-way function of converting
plaintext into ciphertext and it can be reversed only with the knowledge of private
key d.
o Key Generation: The difficulty of determining a private key from an RSA public
key is equivalent to factoring the modulus n. An attacker thus cannot use
knowledge of an RSA public key to determine an RSA private key unless he can
factor n. It is also a one way function, going from p and q values to modulus n is
easy but reverse is not possible.
• If either of these two functions are proved non one-way, then RSA will be broken. In
fact, if a technique for factoring efficiently is developed then RSA will no longer be
safe.
• The strength of RSA encryption drastically goes down against attacks if the number p
and q are not large primes and/ or chosen public key e is a small number.
A Server B
2. Integrity: When the contents of a message are changed after the sender sends it,
but before it reaches the intended recipient, the integrity of a message is lost. This
type of attack is called as modification.
3.35
Computer Networks - II Cryptography and Network Security
Ideal route of
the message
A B
Transfer Transfer
Actual route of
$ 100 $ 1000
the message
to D to C
C
A I am B
User A
3.36
Computer Networks - II Cryptography and Network Security
• In technical terms, the process of encoding plain text message into cipher text message
is called encryption.
Hello Amar Ifmmp Prachi
Encrypt Decrypt
• But now a days, communication by using computers and users seating at two different
locations in the world, exchanging a key personally becomes highly impossible.
• A solution is required for key sharing. This can done using a session key. A session key
is one that is used only for the duration of one session. This session key is exchanged
using asymmetric key cryptography.
• Fig. 3.43 shows the use of session symmetric key for sending confidential message
from Amar to Bhushan and vice versa.
• In the Fig. 3.43 one shared key is used in both directions. But using two different keys
for each direction is more secured.
• For long message, symmetric key cryptography is very fast and more efficient than
asymmetric key cryptography.
• Fig. 3.43 shows the use of a session symmetric key for sending confidential messages
from Amar to Bhushan and vice versa.
Shared keys
Amar Bhushan
Shared keys
Amar Bhushan
• One key is used for encryption and only the other corresponding key must be used for
decryption. No other key can decrypt the message, not even the original key used for
encryption.
• Consider, Amar and Bhushan wants to do secure communication by using asymmetric
key cryptography. Both of them needs a pair of key. Public key, known to all and
private key known to themselves only.
• Asymmetric key cryptography works as follows:
1. When Amar wants to send a message to Bhushan, he encrypts the message using
Bhushan’s public key. This is possible because Amar knows Bhushan’s public key.
2. Amar sends encrypted message to Bhushan.
3. Bhushan decrypts Amar’s message by using his own private key, which is known
to him only.
4. Similarly Bhushan can send a message to Amar, exactly reverse step take place.
• Fig. 3.44 message confidentiality using asymmetric keys.
Bhushan's
key
Amar Bhushan
Amar's
key
Amar Bhushan
Fig. 3.44
3.39
Computer Networks - II Cryptography and Network Security
Fig. 3.45
3.40
Computer Networks - II Cryptography and Network Security
• The two pairs (document/fingerprint) and (message/message digest) are similar, with
some differences. The document and fingerprint are physically linked together.
• The message and message digest can be unlinked (or sent separately), and, most
importantly, the message digest needs to be safe from change.
Hash Functions:
• A cryptographic hash function takes a message of arbitrary length and creates a
message digest of fixed length.
• All cryptographic hash functions need to create a fixed-size digest out of a variable-
size message. Creating such a function is best accomplished using iteration.
• Instead of using a hash function with variable-size input, a function with fixed-size
input is created and is used a necessary number of times.
• The fixed-size input function is referred to as a compression function. It compresses
an n-bit string to create an m-bit string where n is normally greater than m. The
scheme is referred to as an iterated cryptographic hash function.
• Values returned by a hash function are called message digest or simply hash values.
The Fig. 3.46 shows hash function.
Fig. 3.46
• Several hash algorithms were designed by Ron Rivest and referred to as MD2, MD4,
and MD5, where MD stands for Message Digest.
• The last version, MD5, is a strengthened version of MD4 that divides the message into
blocks of 512 bits and creates a 128-bit digest. It turns out that a message digest of size
128 bits is too small to resist attack.
• MD5 digests have been widely used in the software world to provide assurance about
integrity of transferred file.
• For example, file servers often provide a pre-computed MD5 checksum for the files, so
that a user can compare the checksum of the downloaded file to it.
• The Secure Hash Algorithm (SHA) is a standard that was developed by the National
Institute of Standards and Technology (NIST). SHA has gone through several versions
like SHA-0, SHA-1, SHA-2, and SHA-3.
3.41
Computer Networks - II Cryptography and Network Security
3.42
Computer Networks - II Cryptography and Network Security
• The receiver receives the message and the signature and applies the verifying
algorithm to the combination. If the result is true, the message is accepted; otherwise,
it is rejected.
• A conventional signature is like a private “key” belonging to the signer of the
document. The signer uses it to sign documents; no one else has this signature.
• The copy of the signature on file is like a public key; anyone can use it to verify a
document, to compare it to the original signature.
• In a digital signature, the signer uses her private key, applied to a signing algorithm, to
sign the document. The verifier, on the other hand, uses the public key of the signer,
applied to the verifying algorithm, to verify the document.
• A digital signature needs a public-key system. The signer signs with her private key;
the verifier verifies with the signer’s public key.
• A cryptosystem uses the private and public keys of the receiver while a digital
signature uses the private and public keys of the sender.
• The sender can sign the message digest and the receiver can verify the message digest.
The effect is the same. Fig. 3.49 shows signing a digest in a digital signature system.
• A digest is made out of the message at Yogita’s site. The digest then goes through the
signing process using Yogita’s private key. Yogita then sends the message and the
signature to Amar.
• At Amar’s site, using the same public hash function, a digest is first created out of the
received message. The verifying process is applied. If authentic, the message is
accepted; otherwise, it is rejected.
Fig. 3.49
3.44
Computer Networks - II Cryptography and Network Security
Fig. 3.50
RSA Digital Signature Scheme:
• The RSA idea can also be used for signing and verifying a message. In this case, it is
called the RSA digital signature scheme.
• In the RSA scheme in which the signing and verifying is done on the digest of the
message instead of the message itself.
Digital Signature Standards (DSS):
• DSS was developed for performing digital signature. DSS uses digital signature
algorithm. DSS make use of SHA-1 algorithm for Calculating message digest. Hash
function is used to generate MD.
• MD is given input to DSA to generate digital signature. Digital signature sent to the
verifier along with the massage.
• Verifier then verifies signature by using sender’s public key. Same hash function is
used in the verification process.
3.46
Computer Networks - II Cryptography and Network Security
Where,
M : Message. s : Signature.
k
H : Hash function. r : (g mod p)mod q (key pair).
Sig : Signature. PUa : Public key of sender.
PRa : Private key of sender. Ver : Verification function.
PUG : Set of global public key. Compare : Compare function.
• DSS is a standard and DSA is actual algorithm. DSA provide capability to generate and
verify signature.
• Signature generation makes use of private key to generate digital signature. Signature
verification makes use of public key which corresponds to, but is not the same as the
private key.
• Each user possesses a private and public key pair. Anyone can verify the signature of
user by employing that user’s public key.
Advantages of DS:
1. Speed: In business no longer have to wait for paper document to be sent by
couriers using DS contracts are easily written completed and signed by all
concerned parties in less time.
2. Cost: Postal or courier service for paper document is much more expensive as
compared using DS.
3. Security: Use of DS and electronic document reduces risk of document being
intercepted read, destroyed.
4. Authenticity: An electronic document signed with DS can stand up in court just as
well as any other signed paper document
5. Non-Republication: DS identifies us as the signatory and later that cannot be
denied.
6. Tracking: Digitally signed document can be easily tracked and located in short
amount of time.
Disadvantages of DS:
1. The private key must be kept in secure manner.
2. The process of generation and verification of digital signature requires
considerable amount of time.
3. Although digital signature provides the authenticity, it does not ensure secrecy of
the data.
4. For using the digital signature the user has to obtain private & public key, the
receiver has to obtain the digital signature certificate also.
3.47
Computer Networks - II Cryptography and Network Security
3.48
Computer Networks - II Cryptography and Network Security
• Passwords, however, are very prone to attack. A password can be stolen, intercepted,
guessed, and so on.
Challenge-Response:
• In password authentication, the claimant proves her identity by demonstrating that
he/she knows a secret, the password. However, because the claimant sends this secret,
it is susceptible to interception by the adversary.
• In challenge-response authentication, the claimant proves that she knows a secret
without sending it.
• In other words, the claimant does not send the secret to the verifier; the verifier either
has it or finds it.
• The challenge is a time-varying value such as a random number or a timestamp that is
sent by the verifier.
• The claimant applies a function to the challenge and sends the result, called a
response, to the verifier. The response shows that the claimant knows the secret.
3.49
Computer Networks - II Cryptography and Network Security
3.50
Computer Networks - II Cryptography and Network Security
PRACTICE QUESTIONS
Q.I Multiple Choice Questions:
1. An asymmetric-key (or public-key) cipher uses,
(a) 1 key (b) 2 key
(c) 3 key (d) 4 key
2. A straight permutation cipher or a straight P-box has the same number of inputs
as,
(a) cipher (b) frames
(c) outputs (d) bits
3. We use Cryptography term to transforming messages to make them,
(a) secure and immune to change
(b) secure and immune to idle
(c) secure and immune to attacks
(d) secure and immune to defend
4. Which is the art and science of making a cryptosystem that is capable of providing
information security?
(a) Cryptography (b) Cryptanalysis
(c) Cryptology (d) None of the mentioned
5. The shift cipher is sometimes referred to as the,
(a) Caesar cipher (b) shift cipher
(c) cipher (d) cipher text
6. The substitutional ciphers are,
(a) monoalphabatic (b) semi alphabetic
(c) polyalphabetic (d) bialphabetic
3.51