Unit 2 ISS
Unit 2 ISS
UNIT-2(BASIC OF CRYPTOGRAPHY)
LECTURE NO: -1
SYMMETRIC CRYPTOGRAPHY
In this article, we will cover the techniques used in symmetric key cryptography, its
applications, principles on which it works, its types and limitations as well as what type of
attacks in the digital world it gets to face.
Substitution Techniques
The symmetric key cryptographic method employs one secret key for the operations of
encryption and decryption. Substitution techniques provide two significant approaches,
wherein elements (letters, characters) from the plaintext message are replaced with new
elements according to the rules based on the secret key.
Caesar Cipher: Caesar cipher has since their predictability is so complete and no
complexity is invested.
Monoalphabetic Ciphers: This is where the ciphers use one rule of substitution
throughout the message. This may involve replacing letters with numbers, symbols,
or another set of letters in another order.
1
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Hill Cipher: This cipher operates on blocks of letters (typically bigrams or trigrams)
using a matrix multiplication approach. The Hill ciphers have a limitation on key size
and susceptibility towards cryptanalysis for larger key sizes.
Polyalphabetic Ciphers: This is the type of cipher where any one of the letters in the
plaintext is substituted by a different letter to keep frequency analysis challenging.
For example, the Vigenère cipher operates with a keyword that would determine the
shift value for each letter in the plaintext.
One-Time Pad (OTP): It is a theoretically impossible cipher where the key is a random
string of characters that is exactly as long as the message itself. The key is used for a
single encryption and then discarded.
Transposition Techniques
Transposition techniques rearrange the order of elements in the plaintext message without
changing the elements themselves.
Rail Fence Cipher: This is a simple cipher that rearranges the elements by writing the
plaintext message in a zigzag pattern, with the different components written in rows
2
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
(rails) of an imaginary fence and then reading through the columns in a standard
order. The key to this is the number of rails used.
1. Single Key – The same key is used for encryption and decryption.
2. Fast and Efficient – Compared to asymmetric cryptography, symmetric encryption is
much faster.
3. Key Distribution Challenge – Securely sharing the secret key between sender and
receiver is a major challenge.
4. Used for Bulk Data Encryption – It is commonly used for encrypting large amounts of
data, such as files or entire communication channels.
AES (Advanced Encryption Standard) – A widely used standard for secure encryption.
DES (Data Encryption Standard) – An older algorithm, now considered insecure due
to its small key size.
3DES (Triple DES) – An improvement over DES that applies encryption three times for
better security.
Blowfish & Twofish – Flexible key-length algorithms, commonly used in software
applications.
ChaCha20 – A modern stream cipher known for efficiency and security.
3
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Key management and distribution: Both the sender and the receiver in the SKC of a
message need to have the same key, and the key should not be seen by a third party.
In case the key is somehow captured or compromised by a third party, the security of
the encrypted data is also lost.
References
1.Cryptography and Network Security - Principles and Practice: William Stallings, Pearson
Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
4
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
ASYMMETRIC CRYPTOGRAPHY
LECTURE No.-2
Asymmetric encryption, also known as public-key cryptography, is a type of encryption that
uses a pair of keys to encrypt and decrypt data. The pair of keys includes a public key, which
can be shared with anyone, and a private key, which is kept secret by the owner.
In asymmetric encryption, the sender uses the recipient’s public key to encrypt the data. The
recipient then uses their private key to decrypt the data. This approach allows for secure
communication between two parties without the need for both parties to have the same
secret key. Asymmetric encryption has several advantages over symmetric encryption, which
uses the same key for both encryption and decryption. One of the main advantages is that it
eliminates the need to exchange secret keys, which can be a challenging process, especially
when communicating with multiple parties.
Additionally, asymmetric encryption allows for the creation of digital signatures, which can
be used to verify the authenticity of data. Asymmetric encryption is commonly used in
various applications, including secure online communication, digital signatures, and secure
data transfer. Examples of asymmetric encryption algorithms include RSA, Diffie-Hellman,
and Elliptic Curve Cryptography (ECC).
5
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
and the private key used for decryption is kept secret by the receiver making, it harder
for an attacker to intercept and decrypt the data.
Key distribution: Asymmetric encryption eliminates the need for a secure key
distribution system that is required in symmetric encryption with symmetric
encryption, the same key is used for both encryption and decryption and the key
needs to be securely shared between the sender and the receiver asymmetric
encryption, on the other hand, allows the public key to be shared openly and the
private key is kept secret by the receiver.
Email communication is one way to show asymmetric encryption in action. Let’s say Alice
and Bob have a public-private key pair and Alice wishes to send Bob an encrypted message.
Using Bob’s public key, Alice encrypts her message before sending it to him. Bob uses his
private key to decrypt the message after receiving it encrypted.
For instance, Alice composes and encrypts an email for Bob using Bob’s public key. She
follows up by sending Bob the encrypted email. After receiving the email, Bob uses his private
key to decrypt it so that it may be read. As a result, Alice can communicate Bob securely
without being concerned that the message’s content will be viewed by someone else.
With the use of the matching private key, only the intended recipient may decode and read
the email, guaranteeing the confidentiality of its contents. To provide secure and private
communication over the internet, asymmetric encryption is commonly employed in a variety
of communication methods, including messaging apps, digital signatures, and file encryption.
6
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
The Main Features of Asymmetric Encryption (also known as public-key cryptography) are:
Dual keys: Asymmetric encryption uses a pair of keys, including a public key and a
private key. The public key can be freely shared with anyone, while the private key is
kept secret and known only to the key owner.
Encryption and decryption: Asymmetric encryption uses the public key to encrypt
data and the private key to decrypt data. This allows secure communication between
two parties without the need to exchange secret keys.
Secure key exchange: Asymmetric encryption allows for secure key exchange, which
is a critical feature in secure communication. For example, the Diffie-Hellman key
exchange algorithm uses asymmetric encryption to establish a shared secret key
between two parties without exchanging the key itself.
References
1.Cryptography and Network Security - Principles and Practice: William Stallings,
Pearson Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
7
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
What is DES?
Data Encryption Standard (DES) is a block cipher with a 56-bit key length that has played a
significant role in data security. Data encryption standard (DES) has been found vulnerable
to very powerful attacks therefore, the popularity of DES has been found slightly on the
decline. DES is a block cipher and encrypts data in blocks of size of 64 bits each, which means
64 bits of plain text go as the input to DES, which produces 64 bits of ciphertext. The same
algorithm and key are used for encryption and decryption, with minor differences. The key
length is 56 bits.
We have mentioned that DES uses a 56-bit key. Actually, The initial key consists of 64 bits.
However, before the DES process even starts, every 8th bit of the key is discarded to produce
a 56-bit key. That is bit positions 8, 16, 24, 32, 40, 48, 56, and 64 are discarded.
Thus, the discarding of every 8th bit of the key produces a 56-bit key from the original 64-bit
key.
DES is based on the two fundamental attributes of cryptography: substitution (also called
confusion) and transposition (also called diffusion). DES consists of 16 steps, each of which is
called a round. Each round performs the steps of substitution and transposition. Let us now
discuss the broad-level steps in DES.
In the first step, the 64-bit plain text block is handed over to an initial Permutation
(IP) function.
Next, the initial permutation (IP) produces two halves of the permuted block; saying
Left Plain Text (LPT) and Right Plain Text (RPT).
8
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Now each LPT and RPT go through 16 rounds of the encryption process.
In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed on the
combined block
9
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
10
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
As we have noted, the initial permutation (IP) happens only once and it happens before the
first round. It suggests how the transposition in IP should proceed, as shown in the figure.
For example, it says that the IP replaces the first bit of the original plain text block with the
58th bit of the original plain text, the second bit with the 50th bit of the original plain text
block, and so on.
This is nothing but jugglery of bit positions of the original plain text block. the same rule
applies to all the other bit positions shown in the figure.
As we have noted after IP is done, the resulting 64-bit permuted text block is divided into
two half blocks. Each half-block consists of 32 bits, and each of the 16 rounds, in turn, consists
of the broad-level steps outlined in the figure.
11
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
We have noted initial 64-bit key is transformed into a 56-bit key by discarding every 8th bit
of the initial key. Thus, for each a 56-bit key is available. From this 56-bit key, a different 48-
bit Sub Key is generated during each round using a process called key transformation. For
this, the 56-bit key is divided into two halves, each of 28 bits. These halves are circularly
shifted left by one or two positions, depending on the round.
For example: if the round numbers 1, 2, 9, or 16 the shift is done by only one position for
other rounds, the circular shift is done by two positions. The number of key bits shifted per
round is shown in the figure.
12
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
After an appropriate shift, 48 of the 56 bits are selected. From the 48 we might obtain 64 or
56 bits based on requirement which helps us to recognize that this model is very versatile
and can handle any range of requirements needed or provided. for selecting 48 of the 56 bits
the table is shown in the figure given below. For instance, after the shift, bit number 14
moves to the first position, bit number 17 moves to the second position, and so on. If we
observe the table , we will realize that it contains only 48-bit positions. Bit number 18 is
discarded (we will not find it in the table), like 7 others, to reduce a 56-bit key to a 48-bit key.
Since the key transformation process involves permutation as well as a selection of a 48-bit
subset of the original 56-bit key it is called Compression Permutation.
Because of this compression permutation technique, a different subset of key bits is used in
each round. That makes DES not easy to crack.
Recall that after the initial permutation, we had two 32-bit plain text areas called Left Plain
Text(LPT) and Right Plain Text(RPT). During the expansion permutation, the RPT is expanded
from 32 bits to 48 bits. Bits are permuted as well hence called expansion permutation. This
happens as the 32-bit RPT is divided into 8 blocks, with each block consisting of 4 bits. Then,
each 4-bit block of the previous step is then expanded to a corresponding 6-bit block, i.e.,
per 4-bit block, 2 more bits are added.
13
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
This process results in expansion as well as a permutation of the input bit while creating
output. The key transformation process compresses the 56-bit key to 48 bits. Then the
expansion permutation process expands the 32-bit RPT to 48-bits. Now the 48-bit key is XOR
with 48-bit RPT and the resulting output is given to the next step, which is the S-Box
substitution.
References
1.Cryptography and Network Security - Principles and Practice: William Stallings,
Pearson Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
14
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
STRENGTH OF DES
LECTURE NO.-4
Data encryption standard (DES) is a symmetric key block cipher algorithm. The algorithm is
based on Feistel network. The algorithm uses a 56-bit key to encrypt data in 64-bit blocks.
There are mainly two categories of concerns about the strength of Data encryption standard.
They are:
The first concern regarding the algorithm used addresses the possibility of cryptanalysis by
making use of the DES algorithm characteristics. A more severe concern is about the length
of secret key used. There can be (approximately 7.2 × keys) possible keys with a
key length of 56 bits. Thus, a brute force attack appears to be impractical. Assuming that on
an average one has to search half the key space, to break the cipher text, a system performing
one DES encryption per microsecond might require more than thousand years. But, the
assumption of one DES encryption per microsecond is too conservative. In July 1998, DES
was finally proved to be insecure when the Electronic Frontier Foundation (EFF) had broken
a DES encryption. The encryption was broken with the help of a special-purpose “DES
cracker” machine. It was reported that the attack took less than 3 days. Simply running
through all possible keys won’t result in cracking the DES encryption. Unless known plain text
is given, the attacker must be able to differentiate the plain text from other data. Some
degree of knowledge about the target plain text and some techniques for automatically
distinguishing plain text from garble are required to supplement the brute-force approach.
If brute force attack is the only means to crack the DES encryption algorithm, then using
longer keys will obviously help us to counter such attacks. An algorithm is guaranteed
unbreakable by brute force if a 128- bit key is used. The differential cryptanalysis, linear
cryptanalysis, are examples for statistical attacks on DES algorithm. Few of the important
alternatives for DES are AES (Advanced Encryption Standard) and triple DES.
15
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
16
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
so that all computations have the same performance, regardless of the specific
key and message being utilized.
References
1.Cryptography and Network Security - Principles and Practice: William Stallings, Pearson
Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
17
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Block ciphers are built in the Feistel cipher structure. Block cipher has a specific number of
rounds and keys for generating ciphertext.Block cipher is a type of encryption algorithm that
processes fixed-size blocks of data, usually 64 or 128 bits, to produce ciphertext. The design
of a block cipher involves several important principles to ensure the security and efficiency
of the algorithm. Some of these principles are:
18
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
8. Avalanche Effect: The cipher should exhibit the avalanche effect, which means that a
small change in the plaintext or key should cause a significant change in the
ciphertext. This ensures that any change in the input results in a complete change in
the output.
9. Security Analysis: The cipher should be analyzed for its security against various
attacks such as differential cryptanalysis, linear cryptanalysis, and brute-force attacks.
The cipher should also be tested for its resistance to implementation attacks, such as
side-channel attacks.
Block Cipher is an encryption algorithm that works with a symmetric key in a deterministic
way. The plain text is divided into several blocks of equal size. If the length of the plain text
does not allow block division of equal size, padding is done over the plain text. His type of
encryption method can encrypt on blocks of 128 bits, the key can be 128, 192, or 256 bits. In
block ciphers, the length of the plain text is equal to the length of the cipher text.
This type of encryption process considered each block at a time and gives an output of n bits
for an input of n bits. But if there are two identical blocks, the process will produce two
different cipher texts for them. It is a reversible function having a public and a private key,
which makes its computation easy and also a deterministic process.
Operation
There are 5 modes of operation of block cipher so that algorithm can be improved and a
wider range of applications can be achieved. The modes are as follows −
Electronic Code Book Mode − in this type of operation, the plain text is divided into
multiple blocks of 64 bits each. Each of the blocks separately goes through encryption
with the help of the same key. After encryption, the blocks of cipher text are sent to
the receiver which goes through a decryption process to decode the plain text. These
blocks are decrypted separately with the help of the same key for all the blocks. In the
encryption process, since the same key was used, it always produces the same result
for a single character. That is, if there are two identical blocks, the process will not
produce two different cipher texts for them. Hence, ECB is preferred for small plain
texts with fewer or no repetitive characters.
Cipher Block Chaining Mode − to overcome the problem of repetitive texts in ECB,
CBC was developed which produces new cipher texts every time for identical blocks.
To establish this, a method of chaining is done here. While encryption of a block, along
with the key the encryption result of the previous block is also fed to the current
encryption. Hence, the current encryption box is not only dependent on the current
plain text but also on the result of the former block. In the case of the first block
19
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
operation, there is no previous block result to be added to a random text block that
is generated called Initialization Vector and it is given as input to the first block
encryption.
Cipher Feedback Mode − in the case of encryption where there are no blocks of data,
that is, the plain text is composed of characters or bits, and cipher feedback mode is
applied. In this type of encryption, the encrypted results of one bit are fed to the next
bit encryption due to which there are chances of error propagation as errors from the
bit are again passed to the next bit.
Output Feedback Mode − this type of encryption also concerns bits and characters
but unlike CFB it does not consider each bit at a time, rather a block of bits is
considered at each encryption step. Also, the bit rate propagation is removed over
here as the results of previous blocks are not added to the next block, instead, a
feedback mechanism is used.
Counter Mode − it works similarly to OFB but the use of feedback from previous
blocks is removed over here instead a number series called counter, is added to each
encryption step. After each step, the counter is increased by 1 so that the same
counter is not fed to all the blocks and the same cipher for identical blocks is not
created.
Principles
In block cipher, several points are to be managed to define the level of complexity of the
algorithm. The factors are as follows −
The number of encryption rounds − the number of encryption rounds that the plain
text will go through explains the decoding difficulty and hence establishes security.
For example, the DES block cipher mechanism goes through 16 rounds while AES goes
through 10 rounds. Hence, comparatively, DES is more secure than AES. But the
excessive increase in the rounds can also affect slowing the algorithm, hence a perfect
trade-off between the speed and the security must be maintained while determining
the number of rounds.
Function’s designing − in the designing of the Feistal block cipher, the construction of
the round function greatly affects the complexity of the algorithm. The function
designed should be non-linear to increase the strength of the function. It should also
be created in a way that no other function can substitute it and can make the same
output. With the increase in complexity, the security level also increases, for this the
avalanche effect is also integrated such that for a minimal change in the input block
there occurs a noticeable change in the cipher text.
20
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Key scheduling algorithm − the generation of the keys for each of the rounds is
defined by this algorithm. For example, in DES the key of the original length of 56bit
is divided into two halves of 28 bit each.
References
1.Cryptography and Network Security - Principles and Practice: William Stallings,
Pearson
Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
21
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Advanced Encryption Standard (AES) is a highly trusted encryption algorithm used to secure
data by converting it into an unreadable format without the proper key. It is developed by
the National Institute of Standards and Technology (NIST) in 2001. It is is widely used today
as it is much stronger than DES and triple DES despite being harder to implement. AES
encryption uses various key lengths (128, 192, or 256 bits) to provide strong protection
against unauthorized access. This data security measure is efficient and widely implemented
in securing internet communication, protecting sensitive data, and encrypting files. AES, a
cornerstone of modern cryptography, is recognized globally for its ability to keep information
safe from cyber threats.
That means it takes 128 bits as input and outputs 128 bits of encrypted cipher text. AES relies
on the substitution-permutation network principle, which is performed using a series of
linked operations that involve replacing and shuffling the input data.
Applications of AES
AES is widely used in many applications which require secure data storage and transmission.
Some common use cases include:
Wireless security: AES is used in securing wireless networks, such as Wi-Fi networks,
to ensure data confidentiality and prevent unauthorized access.
22
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Data storage: AES is used to encrypt sensitive data stored on hard drives, USB drives,
and other storage media, protecting it from unauthorized access in case of loss or
theft.
Virtual Private Networks (VPNs): AES is commonly used in VPN protocols to secure
the communication between a user’s device and a remote server. It ensures that data
sent and received through the VPN remains private and cannot be deciphered by
eavesdroppers.
File and Disk Encryption: AES is used to encrypt files and folders on computers,
external storage devices, and cloud storage. It protects sensitive data stored on
devices or during data transfer to prevent unauthorized access.
Operation of AES
Interestingly, AES performs all its computations on bytes rather than bits. Hence, AES treats
the 128 bits of a plaintext block as 16 bytes. These 16 bytes are arranged in four columns and
four rows for processing as a matrix −
Unlike DES, the number of rounds in AES is variable and depends on the length of the key.
AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys and 14 rounds for 256-bit
keys. Each of these rounds uses a different 128-bit round key, which is calculated from the
original AES key.
23
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Encryption Process
Here, we restrict to description of a typical round of AES encryption. Each round comprise of
four sub-processes. The first round process is depicted below −
24
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
The 16 input bytes are substituted by looking up a fixed table (S-box) given in design. The
result is in a matrix of four rows and four columns.
Shiftrows
Each of the four rows of the matrix is shifted to the left. Any entries that ‘fall off’ are re-
inserted on the right side of row. Shift is carried out as follows −
MixColumns
Each column of four bytes is now transformed using a special mathematical function. This
function takes as input the four bytes of one column and outputs four completely new bytes,
which replace the original column. The result is another new matrix consisting of 16 new
bytes. It should be noted that this step is not performed in the last round.
Addroundkey
The 16 bytes of the matrix are now considered as 128 bits and are XORed to the 128 bits of
the round key. If this is the last round then the output is the ciphertext. Otherwise, the
resulting 128 bits are interpreted as 16 bytes and we begin another similar round.
Decryption Process
The process of decryption of an AES ciphertext is similar to the encryption process in the
reverse order. Each round consists of the four processes conducted in the reverse order −
25
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Since sub-processes in each round are in reverse manner, unlike for a Feistel Cipher, the
encryption and decryption algorithms needs to be separately implemented, although they
are very closely related.
We will now go through each of the four AES transformations one by one. We describe the
forward (encryption) algorithm, the inverse (decryption) algorithm, and the stage's rationale
for each step.
The primary phase in the AES encryption process is the Substitute Bytes transformation, or
SubBytes. Now we are going to study it −
Purpose
Making the encryption process non-linear is the goal of the SubBytes transformation.
Using a pre-made substitution table called the S-box, each byte in the state matrix is
changed to a new byte.
This modification increases the encryption process' resilience to cryptanalysis
techniques by introducing confusion.
26
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
S−box
How it Works?
During the SubBytes transformation, each byte in the state matrix is changed to match
a byte from the S-box.
Every byte in the state matrix is replaced individually, resulting in the creation of a
new state matrix.
This substitution phase improves the encryption process's defence against various
kinds of attacks, including differential cryptanalysis, by introducing non-linearity.
Advantages
SubBytes breaks any symmetries in the plaintext, which adds difficulty to the
encryption.
It increases the diffusion and confusion characteristics required for strong encryption.
When a preset S-box is used, the inverse S-box ensures a constant and reversible
replacement method, which makes it useful for decryption.
As a result, the SubBytes transformation is important to the AES encryption process because
it improves the non-linearity and confusion of the encrypted data, hence enhancing its
security. It is a crucial component of the well-known AES encryption method that secures
private information.
ShiftRows Transformation
27
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Purpose
The purpose of the ShiftRows transformation is to produce diffusion in the state matrix,
distributing each byte's influence across the matrix. It contributes to creating uncertainty and
raising the encryption's complexity, which improves the ciphertext's security.
How it works?
During the ShiftRows transformation, the bytes in each row of the state matrix are
shifted continually to the left.
The third row is moved by two positions, the fourth row by three positions, and the
second row is shifted to the left by one position. The initial row remains unchanged.
The shifting, which is carried out independently for each row in the state matrix,
results in a new state matrix.
Example
ShiftRows adds diffusion to the encryption process by rearranging the bytes within
each row of the state matrix.
It increases the overall security of the encryption by making sure that each byte in the
state matrix influences several bytes in subsequent encryption rounds.
A key component of the AES encryption process, the ShiftRows transformation adds to the
difussion and confusion properties needed for robust encryption. It is essential to
maintaining the security of encrypted data since it distributes each byte's impact across the
state matrix.
28
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
References
1.Cryptography and Network Security - Principles and Practice: William Stallings, Pearson
Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
29
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
RSA CRYPTOSYSTEM
LECTURE NO.-7
Public Key encryption algorithm is also called the Asymmetric algorithm. Asymmetric
algorithms are those algorithms in which sender and receiver use different keys for
encryption and decryption. Each sender is assigned a pair of keys:
Public key
Private key
The Public key is used for encryption, and the Private Key is used for decryption. Decryption
cannot be done using a public key. The two keys are linked, but the private key cannot be
derived from the public key. The public key is well known, but the private key is secret and it
is known only to the user who owns the key. It means that everybody can send a message to
the user using user's public key. But only the user can decrypt the message using his private
key.
30
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
The data to be sent is encrypted by sender A using the public key of the intended
receiver
B decrypts the received ciphertext using its private key, which is known only to B. B
replies to A encrypting its message using A's public key.
A decrypts the received ciphertext using its private key, which is known only to him.
RSA is the most common public-key algorithm, named after its inventors Rivest, Shamir, and
Adelman (RSA).
Duration 7:01
RSA algorithm uses the following procedure to generate public and private keys:
31
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
This example shows how we can encrypt plaintext 9 using the RSA public-key encryption
algorithm. This example uses prime numbers 7 and 11 to generate the public and private
keys.
Explanation:
p=7
q = 11
Step 2: Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
First, we calculate
n=pxq
n = 7 x 11
32
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
n = 77
Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x (q -1). It
means that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such that 1<e
< φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
Second, we calculate
φ (n) = (p - 1) x (q-1)
φ (n) = (7 - 1) x (11 - 1)
φ (n) = 6 x 10
φ (n) = 60
Step 4: A plaintext message m is encrypted using public key <e, n>. To find ciphertext from
the plain text following formula is used to get ciphertext C.
To find ciphertext from the plain text following formula is used to get ciphertext C.
C = me mod n
C = 97 mod 77
C = 37
Step 5: The private key is <d, n>. To determine the private key, we use the following formula
d such that:
Step 6: A ciphertext message c is decrypted using private key <d, n>. To calculate plain text
m from the ciphertext c following formula is used to get plain text m.
33
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
m = cd mod n
m = 3743 mod 77
m=9
Example 2:
In an RSA cryptosystem, a particular A uses two prime numbers, 13 and 17, to generate the
public and private keys. If the public of A is 35. Then the private key of A is ……………?.
Explanation:
Step 1: in the first step, select two large prime numbers, p and q.
p = 13
q = 17
Step 2: Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
First, we calculate
n=pxq
n = 13 x 17
n = 221
Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x (q -1). It
means that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such that 1<e
< φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
Second, we calculate
φ (n) = (p - 1) x (q-1)
φ (n) = 12 x 16
34
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
φ (n) = 192
Step 3: To determine the private key, we use the following formula to calculate the d such
that:
d = d x 35 mod 192 = 1
Put k = 0
d = (1 + 0 x 192)/35
d = 1/35
Put k = 1
d = (1 + 1 x 192)/35
d = 193/35
Put k = 2
d = (1 + 2 x 192)/35
d = 385/35
d = 11
Example 3:
A RSA cryptosystem uses two prime numbers 3 and 13 to generate the public key= 3 and the
private key = 7. What is the value of cipher text for a plain text?
Explanation:
35
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Step 1: In the first step, select two large prime numbers, p and q.
p=3
q = 13
Step 2: Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
First, we calculate
n=pxq
n = 3 x 13
n = 39
Step 3: If n = p x q, then the public key is <e, n>. A plaintext message m is encrypted using
public key <e, n>. Thus the public key is <e, n> = (3, 39).
To find ciphertext from the plain text following formula is used to get ciphertext C.
C = me mod n
C = 53 mod 39
C = 125 mod 39
C=8
Example 4:
A RSA cryptosystem uses two prime numbers, 3 and 11, to generate private key = 7. What is
the value of ciphertext for a plain text 5 using the RSA public-key encryption algorithm?
Explanation:
Step 1: in the first step, select two large prime numbers, p and q.
p=3
36
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
q = 11
Step 2: Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
First, we calculate
n=pxq
n = 3 x 11
n = 33
Step 3: Choose a number e less that n, such that n is relatively prime to (p - 1) x (q -1). It
means that e and (p - 1) x (q - 1) have no common factor except 1. Choose "e" such that 1<
e < φ (n), e is prime to φ (n), gcd (e, d (n)) =1.
Second, we calculate
φ (n) = (p - 1) x (q-1)
φ (n) = (3 - 1) x (11 - 1)
φ (n) = 2 x 10
φ (n) = 20
Step 4: To determine the public key, we use the following formula to calculate the d such
that:
e x 7 = 1 mod 20
e x 7 = 1 mod 20
Put k = 0
e = (1 + 0 x 20) / 7
e = 1/7
37
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)
UNIT-2 BASIC OF CRYPTOGRAPHY CSE-6 SEM
Put k = 1
e = (1 + 1 x 20) / 7
e = 21/7
e=3
References
1.Cryptography and Network Security - Principles and Practice: William Stallings, Pearson
Education,6th Edition
2.Cryptography and Network Security: Atul Kahate, Mc Graw Hill, 3rd Edition
3.Network Security and Cryptography: Bernard Menezes, CENGAGE Learning
38
NOTES BY: - MR.ABHIMANYU SARASWAT (ASSISTANT PROFESSOR, MITRC, ALWAR)