Unit 2
Unit 2
ii. The size of cipher text is the same or smaller than the original plain text.
iii. The encryption process is very fast.
iv. It is used when a large amount of data is required to transfer.
v. It only provides confidentiality.
vi. The length of key used is 128 or 256 bits
vii. It is efficient as it is used for handling large amount of
data.
It isviii.
effective as this technique is recommended for high amounts of text.
ix. Symmetric key cryptography is also known as secret-key cryptography or
private key cryptography.
i. It requires two keys, a public key and a private key, one to encrypt and the other
one to decrypt.
ii. The size of cipher text is the same or larger than the original plain text.
iii. The encryption process is slow.
iv. It is used to transfer small amounts of data.
v. It provides confidentiality, authenticity, and non-repudiation.
vi. The length of key used is 2048 or higher
vii. It is comparatively less efficient as it can handle a small amount of data.
viii. It is inefficient as this approach is used only for short messages.
ix. Asymmetric key cryptography is also known as public-key cryptography or a
conventional cryptographic system.
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.
The basic idea is shown below:
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.
Page 1
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.
The initial permutation is performed on plain text.
Next, the initial permutation (IP) produces two halves of the permuted block;
saying Left Plain Text (LPT) and Right Plain Text (RPT).
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
The result of this process produces 64-bit ciphertext.
Page 2
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.
The phase of the encryption process (step 4, above) is further divided into the following five
stages:
o Key transition
o Expansion permutation
o XOR and swap
o S-Box
o P-Box permutations
Page 3
Step 1: Key transformation
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.
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.
Step 2: Expansion Permutation
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.
Page 4
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.
Step 3: S-Box permutation — A substitution box permutation, or S-box, is the only non-
linear component in the DES algorithm. It provides additional security to the cipher. After
the block is mixed with the subkey, it is divided into eight 6-bit parts. The S-box process
uses a lookup table to convert the eight 6-bit parts into 4-bit output each, resulting in 32-bit
output in total.
Step 4: P-Box permutation — The 32-bit output from the S-box permutation is rearranged
according to the P-box permutation. The design of the P-box permutation ensures that the
output of each S-box is spread across four different S-boxes for the next round of
encryption.
Step 5: ExclusiveOR (XOR) and swap — XOR is a mathematical function that compares two
sets of bits that can be either 1s or 0s. If the bits from both sets match, the XOR output is
0. On the other hand, if they don‘t match, the output is 1. This bit-wise comparison results in
stronger encryption, and XORing is something we‘ll speak more about in our next article on
how DES encryption works.
Triple DES uses the DES cipher in triple and is a symmetric key-block cipher. It encrypts
with key number one (k1), decrypts with key number two (k2), and then encrypts with key
number three (k3).
Main Points
o The DES algorithm had to be replaced by the NIST because, in light of the more
powerful processing of modern computers, its 56-bit key lengths were insufficient.
Because key size affects encryption strength, DES became obsolete due to continual
Page 5
advancements in computing technology. When the new encryption issues arose, 56-bit
encryption was no longer sufficient.
o The fact that DES is no longer the NIST federal standard should not be taken to
imply that it is no longer in use. Even though Triple DES is still in use today, it is
regarded as an old encryption algorithm. Keep in mind that starting in 2024, NIST
intends to outlaw all variations of Triple-DES.
In plain English, DES transforms 64-bit plain text into a 64-bit cipher text. The same key is
also utilized to decode the text because asymmetric methods are being employed.
o The 64-bit plain text block is first sent to an initial permutation (IP) function to start
the process.
o The plain text is subsequently subjected to the initial permutation (IP).
o The Left Plain Text (LPT) and Right Plain Text (RPT) portions of the permuted block
are then created by the initial permutation (IP).
o There are 16 rounds of encryption for each LPT and RPT.
o Finally, the LPT and RPT are reunited, and the newly combined block is subjected to a
Final Permutation (FP).
o This procedure provides the necessary 64-bit ciphertext as a result.
We employ the same procedure for decryption and arrange the 16 round keys in the other
direction.
Let's study about the several ways that DES might operate next so that we can better
comprehend what it is.
There are five main modes of operation available to experts utilizing DES.
o (ECB) Electronic Codebook. Each 64-bit block is separately encrypted and decrypted.
o CBC, or cypher block chaining. Each 64-bit block employs an Initialization Vector (IV)
and is dependent on the previous one.
o CFB, or Cypher Feedback. The previous unit of cipher text serves as the input for the
encryption algorithm, which generates pseudorandom output that is then XORed with
the plaintext to create the following unit of cipher text.
o OFB (Output Feedback). similar to CFB, but where the input for the encryption
technique is the result of the previous DES
Page 6
o CTR, or counter. An encrypted counter is XORed with each plaintext piece. Following
that, the counter gets increased for each additional block.
We'll then deepen our understanding of DES by examining its implementation and testing.
Page 7
Creation of Round keys :
A Key Schedule algorithm is used to calculate all the round keys from the key. So the initial
key is used to create many different round keys which will be used in the corresponding
round of the encryption.
Encryption :
AES considers each block as a 16 byte (4 byte x 4 byte = 128 ) grid in a column major
arrangement.
[ b0 | b4 | b8 | b12 |
| b1 | b5 | b9 | b13 |
| b2 | b6 | b10| b14 |
| b3 | b7 | b11| b15 ]
Each round comprises of 4 steps :
SubBytes
ShiftRows
MixColumns
Add Round Key
The last round doesn‘t have the MixColumns round.
The SubBytes does the substitution and ShiftRows and MixColumns performs the
permutation in the algorithm.
Page 8
SubBytes :
This step implements the substitution.
In this step each byte is substituted by another byte. Its performed using a lookup table
also called the S-box. This substitution is done in a way that a byte is never substituted by
itself and also not substituted by another byte which is a compliment of the current byte.
The result of this step is a 16 byte (4 x 4 ) matrix like before.
ShiftRows :
This step is just as it sounds. Each row is shifted a particular number of times.
The first row is not shifted
The second row is shifted once to the left.
The third row is shifted twice to the left.
The fourth row is shifted thrice to the left.
(A left circular shift is performed.)
[ b0 | b1 | b2 | b3 ] [ b0 | b1 | b2 | b3 ]
| b4 | b5 | b6 | b7 | -> | b5 | b6 | b7 | b4 |
| b8 | b9 | b10 | b11 | | b10 | b11 | b8 | b9 |
[ b12 | b13 | b14 | b15 ] [ b15 | b12 | b13 | b14 ]
MixColumns :
This step is basically a matrix multiplication. Each column is multiplied with a specific
matrix and thus the position of each byte in the column is changed as a result.
This step is skipped in the last round.
[ c0 ] [ 2 3 1 1 ] [ b0 ]
| c1 | = | 1 2 3 1 | | b1 |
| c2 | | 1 1 2 3 | | b2 |
[ c3 ] [ 3 1 1 2 ] [ b3 ]
Add Round Keys :
Now the resultant output of the previous stage is XOR-ed with the corresponding round
key. Here, the 16 bytes is not considered as a grid but just as 128 bits of data.
Page 9
After all these rounds 128 bits of encrypted data is given back as output. This process is
repeated until all the data to be encrypted undergoes this process.
Decryption :
The stages in the rounds can be easily undone as these stages have an opposite to it which
when performed reverts the changes.Each 128 blocks goes through the 10,12 or 14 rounds
depending on the key size.
The stages of each round in decryption is as follows :
Inverse MixColumns :
This step is similar to the MixColumns step in encryption, but differs in the matrix used to
carry out the operation.
[ b0 ] [ 14 11 13 9 ] [ c0 ]
| b1 | = | 9 14 11 13 | | c1 |
| b2 | | 13 9 14 11 | | c2 |
[ b3 ] [ 11 13 9 14 ] [ c3 ]
Inverse SubBytes :
Inverse S-box is used as a lookup table and using which the bytes are substituted during
decryption.
Applications:
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.
Database Encryption: AES can be applied to encrypt sensitive data stored in databases.
This helps protect personal information, financial records, and other confidential data
from unauthorized access in case of a data breach.
Secure communications: AES is widely used in protocols like such as internet
communications, email, instant messaging, and voice/video calls.It ensures that the data
remains confidential.
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.
Page 10
Secure Storage of Passwords: AES encryption is commonly employed to store
passwords securely. Instead of storing plaintext passwords, the encrypted version is
stored. This adds an extra layer of security and protects user credentials in case of
unauthorized access to the storage.
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.
Applications:
o Many applications that call for secure data storage and transfer frequently employ
AES.
o AES is used in wireless network security, such as that of Wi-Fi networks, to guarantee
data secrecy and thwart unauthorized access.
o AES may be used to encrypt private information kept in databases. This aids in
preventing unauthorized access to private data such as financial records, personal
information, and other data in the event of a data breach.
o AES is frequently used in protocols for voice/video conversations, email, instant
messaging, and internet communications. It makes sure the information is kept private.
o Data storage: To prevent unauthorized access in the event of loss or theft, sensitive
data is encrypted using AES and stored on hard discs, USB drives, and other storage
devices.
o AES is frequently used in Virtual Private Networks (VPN) protocols to protect
communication between a user's device and a remote server. It makes sure that data
transmitted and received via the VPN is secure and cannot be read by eyes droppers.
o Password Security: AES encryption is frequently used to store passwords securely.
Passwords are saved in encrypted form rather than plaintext. In the event of
unauthorized access to the storage, this adds an additional layer of protection and
safeguards user credentials.
o File and Disc Encryption: On PCs, external storage devices, and cloud storage, AES is
used to encrypt files and folders. It safeguards sensitive data during data transport
or storage to stop unauthorized access.
Characteristics
Page 11
Advantages
Disadvantages
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:
o Public key
o 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.
Page 12
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 algorithm:
RSA is the most common public-key algorithm, named after its inventors Rivest, Shamir,
and Adelman (RSA).
RSA algorithm uses the following procedure to generate public and private keys:
Page 13
o Select two large prime numbers, p and q.
o Multiply these numbers to find n = p x q, where n is called the modulus for encryption
and decryption.
o Choose a number e less than 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
o If n = p x q, then the public key is <e, n>. 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.
e
C = m mod n
Here, m must be less than n. A larger message (>n) is treated as a concatenation of
messages, each of which is encrypted separately.
o To determine the private key, we use the following formula to calculate the d such
that:
De mod {(p - 1) x (q - 1)} = 1
Or
De mod φ (n) = 1
o The private key is <d, n>. 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.
d
m = c mod n
Example 1:
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
Page 14
n = p x q
n = 7 x 11
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.
Page 15
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 = p x q
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
φ (n) = 192
Page 16
g.c.d (35, 192) = 1
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:
Step 1: In the first step, select two large prime numbers, p and q.
p=3
Page 17
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 = p x q
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
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
Page 18
n = p x q
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
Put k = 1
e = (1 + 1 x 20) / 7
e = 21/7
e=3
Page 19
Hence, public key i.e. e = 3
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output
is always of fixed length.
Values returned by a hash function are called message digest or simply hash values. The
following picture illustrated hash function −
At the heart of a hashing is a mathematical function that operates on two fixed-size blocks
of data to create a hash code. This hash function forms the part of the hashing algorithm.
The size of each data block varies depending on the algorithm. Typically the block sizes are
from 128 bits to 512 bits. The following illustration demonstrates hash function −
Page 21
Hashing algorithm involves rounds of above hash function like a block cipher. Each round
takes an input of a fixed size, typically a combination of the most recent message block and
the output of the last round.
This process is repeated for as many rounds as are required to hash the entire message.
Schematic of hashing algorithm is depicted in the following illustration −
Since, the hash value of first message block becomes an input to the second hash operation,
output of which alters the result of the third operation, and so on. This effect, known as
an avalanche effect of hashing.
Avalanche effect results in substantially different hash values for two messages that differ
by even a single bit of data.
Understand the difference between hash function and algorithm correctly. The hash
function generates a hash code by operating on two blocks of fixed-length binary data.
Hashing algorithm is a process for using the hash function, specifying how the message will
be broken up and how the results from previous message blocks are chained together.
MD5 was most popular and widely used hash function for quite some years.
Page 22
The MD family comprises of hash functions MD2, MD4, MD5 and MD6. It was adopted
as Internet Standard RFC 1321. It is a 128-bit hash function.
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.
In 2004, collisions were found in MD5. An analytical attack was reported to be
successful only in an hour by using computer cluster. This collision attack resulted in
compromised MD5 and hence it is no longer recommended for use.
Family of SHA comprise of four SHA algorithms; SHA-0, SHA-1, SHA-2, and SHA-3. Though
from same family, there are structurally different.
The original version is SHA-0, a 160-bit hash function, was published by the National
Institute of Standards and Technology (NIST) in 1993. It had few weaknesses and did
not become very popular. Later in 1995, SHA-1 was designed to correct alleged
weaknesses of SHA-0.
SHA-1 is the most widely used of the existing SHA hash functions. It is employed in
several widely used applications and protocols including Secure Socket Layer (SSL)
security.
In 2005, a method was found for uncovering collisions for SHA-1 within practical time
frame making long-term employability of SHA-1 doubtful.
SHA-2 family has four further SHA variants, SHA-224, SHA-256, SHA-384, and
SHA-512 depending up on number of bits in their hash value. No successful attacks
have yet been reported on SHA-2 hash function.
Though SHA-2 is a strong hash function. Though significantly different, its basic
design is still follows design of SHA-1. Hence, NIST called for new competitive hash
function designs.
In October 2012, the NIST chose the Keccak algorithm as the new SHA-3 standard.
Keccak offers many benefits, such as efficient performance and good resistance for
attacks.
RIPEMD
The RIPEMD is an acronym for RACE Integrity Primitives Evaluation Message Digest. This
set of hash functions was designed by open research community and generally known as a
family of European hash functions.
The set includes RIPEMD, RIPEMD-128, and RIPEMD-160. There also exist 256, and
320-bit versions of this algorithm.
Page 23
Original RIPEMD (128 bit) is based upon the design principles used in MD4 and found
to provide questionable security. RIPEMD 128-bit version came as a quick fix
replacement to overcome vulnerabilities on the original RIPEMD.
RIPEMD-160 is an improved version and the most widely used version in the family.
The 256 and 320-bit versions reduce the chance of accidental collision, but do not
have higher levels of security as compared to RIPEMD-128 and RIPEMD-160
respectively.
Whirlpool
It is derived from the modified version of Advanced Encryption Standard (AES). One
of the designer was Vincent Rijmen, a co-creator of the AES.
Three versions of Whirlpool have been released; namely WHIRLPOOL-0,
WHIRLPOOL-T, and WHIRLPOOL.
There are two direct applications of hash function based on its cryptographic properties.
Password Storage
Instead of storing password in clear, mostly all logon processes store the hash values
of passwords in the file.
The Password file consists of a table of pairs which are in the form (user id, h(P)).
The process of logon is depicted in the following illustration −
An intruder can only see the hashes of passwords, even if he accessed the password.
He can neither logon using hash nor can he derive the password from hash value since
hash function possesses the property of pre-image resistance.
Page 24
Data integrity check is a most common application of the hash functions. It is used to
generate the checksums on data files. This application provides assurance to the user about
correctness of the data.
The integrity check helps the user to detect any changes made to original file. It however,
does not provide any assurance about originality. The attacker, instead of modifying file
data, can change the entire file and compute all together new hash and send to the receiver.
This integrity check application is useful only if the user is sure about the originality of file.
Hash
Functions Message Authentication Another type of threat that exist for data is the lack
of message authentication. In this threat, the user is not sure about the originator of the
message. Message authentication can be provided using the cryptographic techniques that
use secret keys as done in case of encryption.
The process of using MAC for authentication is depicted in the following illustration −
Page 25
Let us now try to understand the entire process in detail −
The sender uses some publicly known MAC algorithm, inputs the message and the
secret key K and produces a MAC value.
Similar to hash, MAC function also compresses an arbitrary long input into a fixed
length output. The major difference between hash and MAC is that MAC uses secret
key during the compression.
The sender forwards the message along with the MAC. Here, we assume that the
message is sent in the clear, as we are concerned of providing message origin
authentication, not confidentiality. If confidentiality is required then the message
needs encryption.
On receipt of the message and the MAC, the receiver feeds the received message and
the shared secret key K into the MAC algorithm and re-computes the MAC value.
The receiver now checks equality of freshly computed MAC with the MAC received
from the sender. If they match, then the receiver accepts the message and assures
himself that the message has been sent by the intended sender.
If the computed MAC does not match the MAC sent by the sender, the receiver
cannot determine whether it is the message that has been altered or it is the origin
that has been falsified. As a bottom-line, a receiver safely assumes that the message
is not the genuine.
Limitations of MAC
There are two major limitations of MAC, both due to its symmetric nature of operation −
Page 26
o Non-repudiation is the assurance that a message originator cannot deny any
previously sent messages and commitments or actions.
o MAC technique does not provide a non-repudiation service. If the sender and
receiver get involved in a dispute over message origination, MACs cannot provide
a proof that a message was indeed sent by the sender.
o Though no third party can compute the MAC, still sender could deny having sent
the message and claim that the receiver forged it, as it is impossible to
determine which of the two parties computed the MAC.
Both these limitations can be overcome by using the public key based digital signatures
discussed in following section.
Revelation: It means releasing the content of the message to someone who does not
have an appropriate cryptographic key.
Analysis of Traffic: Determination of the pattern of traffic through the duration of
connection and frequency of connections between different parties.
Deception: Adding out of context messages from a fraudulent source into a
communication network. This will lead to mistrust between the parties communicating
and may also cause loss of critical data.
Modification in the Content: Changing the content of a message. This includes
inserting new information or deleting/changing the existing one.
Modification in the sequence: Changing the order of messages between parties. This
includes insertion, deletion, and reordering of messages.
Modification in the Timings: This includes replay and delay of messages sent between
different parties. This way session tracking is also disrupted.
Source Refusal: When the source denies being the originator of a message.
Destination refusal: When the receiver of the message denies the reception.
All message authentication and digital signature mechanisms are based on two functionality
levels:
Lower level: At this level, there is a need for a function that produces an
authenticator, which is the value that will further help in the authentication of a
message.
Higher-level: The lower level function is used here in order to help receivers verify the
authenticity of messages.
These message authentication functions are divided into three classes:
Page 27
Message encryption: While sending data over the internet, there is always a risk of a
Man in the middle(MITM) attack. A possible solution for this is to use message
encryption. In message encryption, the data is first converted to a ciphertext and then
sent any further. Message encryption can be done in two ways:
Symmetric Encryption: Say we have to send the message M from a source P to
destination Q. This message M can be encrypted using a secret key K that both P and Q
share. Without this key K, no other person can get the plain text from the ciphertext.
This maintains confidentiality. Further, Q can be sure that P has sent the message. This
is because other than Q, P is the only party who possesses the key K and thus the
ciphertext can be decrypted only by Q and no one else. This maintains authenticity. At a
very basic level, symmetric encryption looks like this:
Page 28
Message Confidentiality: To prevent the messages from being revealed, care must be
taken during the transmission of messages. For this, the message should be encrypted
before it is sent over the network.
Message Authentication: To deal with the analysis of traffic and deception issues,
message authentication is helpful. Here, the receiver can be sure of the real sender and
his identity. To do this, these methods can be incorporated:
Parties should share secret codes that can be used at the time of identity
authentication.
Digital signatures are helpful in the authentication.
A third party can be relied upon for verifying the authenticity of parties.
Digital Signatures: Digital signatures provide help against a majority of these issues.
With the help of digital signatures, content, sequence, and timing of the messages can
be easily monitored. Moreover, it also prevents denial of message transmission by the
source.
Combination of protocols with Digital Signatures: This is needed to deal with the
denial of messages received. Here, the use of digital signature is not sufficient and it
additionally needs protocols to support its monitoring.
Page 29
Birthday paradox problem –
Let us consider the example of a classroom of 30 students and a teacher. The teacher
wishes to find pairs of students that have the same birthday. Hence the teacher asks for
everyone‘s birthday to find such pairs. Intuitively this value may seem small. For example,
if the teacher fixes a particular date say October 10, then the probability that at least
one student is born on that day is 1 – (364/365)30 which is about 7.9%. However, the
probability that at least one student has the same birthday as any other student is
around 70% using the following formula:
A hash function H is said to be one-way if it is hard to invert, where ―hard to invert‖ means
that given a hash value h, it is computationally infeasible to find some input x such
that H(x) = h.
If, given a message x, it is computationally infeasible to find a message y not equal to x
such that H(x) = H(y) then H is said to be a weakly collision-free hash function.
A strongly collision-free hash function H is one for which it is computationally infeasible to
find any two messages x and y such that H(x) = H(y).
Let H: M => {0, 1}n be a hash function (|M| >> 2n )
Page 30
Following is a generic algorithm to find a collision in time O(2n/2) hashes.
Algorithm:
We consider the following experiment. From a set of H values, we choose n values uniformly
at random thereby allowing repetitions. Let p(n; H) be the probability that during this
experiment at least one value is chosen more than once. This probability can be
approximated as:
Hash functions
play a crucial role in information security by providing data integrity, authentication, and
digital signatures. The security of a hash function is determined based on its resistance to
various attacks. The main properties of a secure hash function are:
Hash functions provide preimage resistance. This concept says that the original
function H(M)=h cannot resolve H(N)=h.
H(M)=h
h=! H(M)
Page 31
Where M is the message input,
h is hash code,
H is a hash function.
This means it is practically impossible to obtain a message from a hash code as it is
one-way.
Hash functions provide second preimage resistance. This concept says that the
original function H(M) can never be equal to H(N), where n and m are different
messages.
H(M)!=H(N)
Where M and N are different message inputs,
H is a hash function.
This means it is practically impossible to obtain a different input message when we
decode a hash value. The second preimage resistance works on the one-way principle of
hash functions.
Page 32
This ensures the security of hash functions in cryptography in the following ways:
An attacker cannot read or observe data messages.
An attacker cannot create a fake hash code for messages received in the absence of
security.
An attacker cannot generate an alternative message for the same hash codes.
Hash functions provide collision resistance. This concept says that the original
function H(M) is not equal to H(N)
It is similar to the second pre-image resistance. The difference is that in collision
resistance, you cannot have two messages that indicate the same output of hash
values. Whereas in the second preimage resistance, a hash value cannot indicate a
different input message.
H(M)!=H(N)
Where M and N are different message inputs,
H is a hash function.
This means that it is practically impossible to create a hash value that indicates two
distinct message inputs.
Page 33
This ensures the security of hash functions in cryptography, not creating confusion
and providing one message input that is authenticated.
In electronic money transfers, message authentication codes (MACs) are employed to ensure
information integrity.
Now, let‘s see the types of message authentication code (MAC) in Cryptography.
There are different types of models Of Message Authentication Code (MAC) as following
below:
Page 34
M' = MAC(M, k)
Problems in MAC –
If we do reverse engineering we can reach plain text or even the key. Here we have mapped
input to output, to overcome this we move on to hash functions which are ―One way‖.
There are four important components used for generating a Message Authentication Code
(MAC):
2. Key
3. MAC algorithm
4. MAC value
Page 35
The sender and receiver share the same secret key to produce a Message Authentication
Code or Cryptographic Checksum. This generated MAC is appended to the message and sent
to the receiver. At the receiving end, the receiver also generates the Message
Authentication Code (MAC) with the same shared key which is compared with the MAC
generated by the sender. If both the MACs are equal, then the message is valid and coming
from the correct sender, otherwise, the message is invalid.
A message‘s hash value would be different if a sender didn‘t know the secret key, indicating
to a receiver that it wasn‘t from the original sender.
MD5 Algorithm
Page 36
MD5 algorithm follows the following steps
1. Append Padding Bits: In the first step, we add padding bits in the original message in
such a way that the total length of the message is 64 bits less than the exact multiple of
512.
Suppose we are given a message of 1000 bits. Now we have to add padding bits to the
original message. Here we will add 472 padding bits to the original message. After adding
the padding bits the size of the original message/output of the first step will be 1472 i.e.
64 bits less than an exact multiple of 512 (i.e. 512*3 = 1536).
- L = 0x98CBADFE
- M = 0x13DCE476
4. Process Each 512-bit Block: This is the most important step of the MD5 algorithm.
Here, a total of 64 operations are performed in 4 rounds. In the 1st round, 16 operations
will be performed, 2nd round 16 operations will be performed, 3rd round 16 operations will
be performed, and in the 4th round, 16 operations will be performed. We apply a different
function on each round i.e. for the 1st round we apply the F function, for the 2nd G
function, 3rd for the H function, and 4th for the I function.
We perform OR, AND, XOR, and NOT (basically these are logic gates) for calculating
functions. We use 3 buffers for each function i.e. K, L, M.
- F(K,L,M) = (K AND L) OR (NOT K AND M)
- G(K,L,M) = (K AND L) OR (L AND NOT M)
After applying the function now we perform an operation on each block. For performing
operations we need
Page 37
<<<n – Left shift by n bits.
Now take input as initialize MD buffer i.e. J, K, L, M. Output of K will be fed in L, L will be
fed into M, and M will be fed into J. After doing this now we perform some operations to
find the output for J.
In the first step, Outputs of K, L, and M are taken and then the function F is applied to
them. We will add modulo 232 bits for the output of this with J.
In the second step, we add the M[i] bit message with the output of the first step.
Then add 32 bits constant i.e. K[i] to the output of the second step.
At last, we do left shift operation by n (can be any value of n) and addition modulo by
232.
After all steps, the result of J will be fed into K. Now same steps will be used for all
functions G, H, and I. After performing all 64 operations we will get our message digest.
SHAs also help in revealing if an original message was transformed in any way. By imputing
the original hash digest, a user can tell if even an individual letter has been shifted, as the
hash digests will be effectively different.
The important element of SHAs are that they are deterministic. This define that consider
the hash function used is known, any computer or user can regenerate the hash digest. The
determinism of SHAs is one of main reasons that each SSL certificate on the Internet is
needed to have been hashed with a SHA-2 function.
A secure hash algorithm is generally a pair of algorithms invented by the National Institutes
of Standards and Technology (NIST) and other government and private parties
SHA1 SHA2
Page 39
SHA1 SHA2
certificates.
Digital Signature
A digital signature is a mathematical technique which validates the authenticity and integrity
of a message, software or digital documents. It allows us to verify the author name, date and
time of signatures, and authenticate the message contents. The digital signature offers far
Page 40
more inherent security and intended to solve the problem of tampering and impersonation
(Intentionally copy another person's characteristics) in digital communications.
Page 41
o Authentication
o Non-repudiation
o Integrity
Authentication
Authentication is a process which verifies the identity of a user who wants to access the
system. In the digital signature, authentication helps to authenticate the sources of
messages.
Non-repudiation
Integrity
Integrity ensures that the message is real, accurate and safeguards from unauthorized user
modification during the transmission.
The key generation algorithm selects private key randomly from a set of possible private
keys. This algorithm provides the private key and its corresponding public key.
2. Signing algorithm
Digital signatures are created and verified by using public key cryptography, also known as
asymmetric cryptography. By the use of a public key algorithm, such as RSA, one can
generate two keys that are mathematically linked- one is a private key, and another is a
public key.
Page 42
The user who is creating the digital signature uses their own private key to encrypt the
signature-related document. There is only one way to decrypt that document is with the use
of signer's public key.
This technology requires all the parties to trust that the individual who creates the
signature has been able to keep their private key secret. If someone has access the signer's
private key, there is a possibility that they could create fraudulent signatures in the name of
the private key holder.
Different document processing platform supports different types of digital signature. They
are described below:
Certified Signatures
The certified digital signature documents display a unique blue ribbon across the top of the
document. The certified signature contains the name of the document signer and the
certificate issuer which indicate the authorship and authenticity of the document.
Approval Signatures
Page 43
The approval digital signatures on a document can be used in the organization's business
workflow. They help to optimize the organization's approval procedure. The procedure
involves capturing approvals made by us and other individuals and embedding them within the
PDF document. The approval signatures to include details such as an image of our physical
signature, location, date, and official seal.
The visible digital signature allows a user to sign a single document digitally. This signature
appears on a document in the same way as signatures are signed on a physical document.
The invisible digital signatures carry a visual indication of a blue ribbon within a document in
the taskbar. We can use invisible digital signatures when we do not have or do not want to
display our signature but need to provide the authenticity of the document, its integrity, and
its origin.
Authentication Protocols
When we develop software, our first and most important priority is user authentication. To
authenticate the user there are several mechanisms by which we can authenticate the data
that are given by the user. In this article, we are going to learn the most common types of
the authentication protocol and their advantages and disadvantages.
Requiring users to provide and prove their identity adds a layer of security between
adversaries and sensitive data. With authentication, IT teams can employ the least
privileged access to limit what employees can see. The average employee, for example,
doesn't need access to company financials, and accounts payable doesn't need to touch
developer projects. When selecting an authentication type, companies must consider UX
along with security. Some user authentication types are less secure than others, but too
much friction during authentication can lead to poor employee practices.
1. Kerberos
Kerberos is a type of protocol that is used to authenticate users. It validates the client and
server during networking with the help of a cryptographic key. It is designed to strongly
Page 45
authenticate the users during the reporting of the application. All the proposals of Kerberos
are available at MIT. The main use of the Kerberos is in the product-based companies.
Advantages
Disadvantages
1. The client and service can only authenticate themselves with the help of Kerberos.
2. When we use a soft or weak password, it always shows vulnerability.
LDAP stands for Lightweight Directory Access Protocol. With the help of this protocol, we
can determine the organization, individual, or any other devices during the networking over
the internet. It is also called a Directory as a service. Lightweight Directory Access Protocol
(LDAP) is the ground for Microsoft Building Activity Directory.
1. It is a type of automated protocol that is why it is very easier for the organization.
2. All the existing software is supported by Lightweight Directory Access Protocol
(LDAP).
3. Multiple directories can be allowed in Lightweight Directory Access Protocol(LDAP)
3. OAuth2
Advantages of OAuth2
Page 46
2. It provides the code for server-side authentication.
4. SAML
Advantages of SAML
1. The administrative cost is reduced for the end user with the help of SAML (Security
Assertion Markup Language).
2. It provides a single window for authentication for all the services.
Disadvantages of SAML
5. RADIUS
RADIUS stands for Remote Authentication Dial-In User Service. It is a type of network
protocol that provides accounting, centralized authentication, and authorization. When the
user makes a request to access all the resources, the RADIUS server creates a temporary
credential to access all the resources. After this, the temporary credential is saved on the
local database and provides access to the user.
Advantages of RADIUS
Page 47
As we have studied,
signature is a way of authenticating the data coming from a trusted individual.
Similarly, digital signature is a way of authenticating a digital data coming from a trusted
source. Digital Signature Standard (DSS) is a Federal Information Processing
Standard(FIPS) which defines algorithms that are used to generate digital signatures with
the help of Secure Hash Algorithm(SHA) for the authentication of electronic documents.
DSS only provides us with the digital signature function and not with any encryption or key
exchanging strategies.
Sender
Side : In DSS Approach, a hash code is generated out of the message and following inputs
are given to the signature function –
1. The hash code.
2. The random number ‗k‘ generated for that particular signature.
3. The private key of the sender i.e., PR(a).
4. A global public key(which is a set of parameters for the communicating principles) i.e.,
PU(g).
These input to the function will provide us with the output signature containing two
components – ‗s‘ and ‗r‘. Therefore, the original message concatenated with the signature is
sent to the receiver. Receiver Side : At the receiver end, verification of the sender is
done. The hash code of the sent message is generated. There is a verification function
which takes the following inputs –
1. The hash code generated by the receiver.
2. Signature components ‗s‘ and ‗r‘.
3. Public key of the sender.
4. Global public key.
The output of the verification function is compared with the signature component ‗r‘. Both
the values will match if the sent signature is valid because only the sender with the help of
it private key can generate a valid signature.
Page 48
Benefits of advanced signature:
1. A computerized signature gives better security in the exchange. Any unapproved
individual can‘t do fakeness in exchanges.
2. You can undoubtedly follow the situation with the archives on which the computerized
mark is applied.
3. High velocity up record conveyance.
4. It is 100 percent lawful it is given by the public authority approved ensuring authority.
5. In the event that you have marked a report carefully, you can‘t deny it.
6. In this mark, When a record is get marked, date and time are consequently stepped on it.
7. It is preposterous to expect to duplicate or change the report marked carefully.
8. ID of the individual that signs.
9. Disposal of the chance of committing misrepresentation by a sham.
Page 49