You are on page 1of 21

Visit www.Bustudymate.

in For More Study Material


VI Sem B.C.A. EXAMINATION – 2017

CNS

Section – A (2 marks)

1. What is information security?

Information Security is basically the practice of preventing unauthorized access, use, disclosure, disruption,
modification, inspection, recording or destruction of information. Information can be physical or electrical one.

2. What is data integrity?

Data integrity is the maintenance of, and the assurance of the accuracy and consistency of data over its
entire life-cycle, and is a critical aspect to the design, implementation and usage of any system which stores,
processes, or retrieves data.

3. Who is cryptanalyst?

A cryptanalyst is someone who must understand how to decipher secret codes and write codes that cannot
be cracked by hackers. They assess and decode secret messages and coding systems for government agencies, police
agencies, and the military.

4. Define symmetric key cryptography.

Symmetric key cryptography (or symmetric encryption) is a type of encryption scheme in which the same key
is used both to encrypt and decrypt messages. Such a method of encoding information has been largely used in the
past decades to facilitate secret communication between governments and militaries.

5. What is FIPS?

FIPS (Federal Information Processing Standards) are a set of standards that describe document processing,
encryption algorithms and other information technology standards for use within non-military government agencies
and by government contractors and vendors who work with the agencies.

6. What is permutation process in cryptography?

In cryptography, a permutation box (or P-box) is a method of bit-shuffling used to permute or transpose bits
across S-boxes inputs, retaining diffusion while transposing. The plaintext is then broken into segments of size e and
the letters within that segment are permuted according to this key.

7. What is co-prime? Give example

Two numbers are coprime if their highest common factor (or greatest common divisor) is 1.

Example: So there are 10 integers in the set of integers from 1 to 100 that are ”perfect” co-primes, in that they do
not have common factors with any other integer in the range 1–100 (except 1). The “perfect” co-primes are: 53, 59,
61, 67, 71, 73, 79, 83, 89 and 97.

8. What is integer factorization?

Integer factorization is the process of determining which prime numbers divide a given positive integer.

9. Define stream cipher.

A stream cipher is a symmetric key cipher where plaintext digits are combined with a pseudorandom cipher
digit stream (keystream). In a stream cipher, each plaintext digit is encrypted one at a time with the corresponding
digit of the keystream, to give a digit of the ciphertext stream.

10. What is payload?

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
When data is sent over the Internet, each unit transmitted includes both header information and the actual
data being sent. The header identifies the source and destination of the packet, while the actual data is referred to
as the payload.

11. What is a session?

A session key is an encryption and decryption key that is randomly generated to ensure the security of a
communications session between a user and another computer or between two computers. Session keys are
sometimes called symmetric keys, because the same key is used for both encryption and decryption.

12. What is IPSec?

The IP security (IPSec) is an Internet Engineering Task Force (IETF) standard suite of protocols between 2
communication points across the IP network that provide data authentication, integrity, and confidentiality. It also
defines the encrypted, decrypted and authenticated packets.

Section – B (5 -marks)

13. Explain symmetric key encryption model with a neat diagram.

The encryption process where same keys are used for encrypting and decrypting the information is known as
Symmetric Key Encryption.

The study of symmetric cryptosystems is referred to as symmetric cryptography. Symmetric cryptosystems are also
sometimes referred to as secret key cryptosystems.

A few well-known examples of symmetric key encryption methods are − Digital Encryption Standard (DES), Triple-
DES (3DES), IDEA, and BLOWFISH.

Prior to 1970, all cryptosystems employed symmetric key encryption. Even today, its relevance is very high
and it is being used extensively in many cryptosystems. It is very unlikely that this encryption will fade away, as it has
certain advantages over asymmetric key encryption.

The salient features of cryptosystem based on symmetric key encryption are −

• Persons using symmetric key encryption must share a common key prior to exchange of information.
• Keys are recommended to be changed regularly to prevent any attack on the system.
• A robust mechanism needs to exist to exchange the key between the communicating parties. As keys are
required to be changed regularly, this mechanism becomes expensive and cumbersome.
• In a group of n people, to enable two-party communication between any two persons, the number of keys
required for group is n × (n – 1)/2.
• Length of Key (number of bits) in this encryption is smaller and hence, process of encryption-decryption is
faster than asymmetric key encryption.
• Processing power of computer system required to run symmetric algorithm is less.

Challenge of Symmetric Key Cryptosystem

There are two restrictive challenges of employing symmetric key cryptography.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
• Key establishment − Before any communication, both the sender and the receiver need to agree on a secret
symmetric key. It requires a secure key establishment mechanism in place.
• Trust Issue − Since the sender and the receiver use the same symmetric key, there is an implicit requirement
that the sender and the receiver ‘trust’ each other. For example, it may happen that the receiver has lost the
key to an attacker and the sender is not informed.

These two challenges are highly restraining for modern day communication. Today, people need to exchange
information with non-familiar and non-trusted parties. For example, a communication between online seller and
customer. These limitations of symmetric key encryption gave rise to asymmetric key encryption schemes.

14. Explain various security mechanism.

<img>

The various security mechanisms to provide security are as follows-

1. Encipherment:

This is hiding or covering of data which provides confidentiality. It is also used to complement other
mechanisms to provide other services. Cryptography and Steganography are used for enciphering

2. Digital Integrity:

The data integrity mechanism appends to the data a short check value that has been created by a specific
process from the data itself. Data integrity is preserved by comparing check value received to the check value
generated.

3. Digital Signature:

A digital signature is a means by which the sender can electronically sign the data and the receiver can
electronically verify the signature. Public and private keys can be used.

4. Authentication Exchange:

In this two entities exchange some messages to prove their identity to each other.

5. Traffic Padding:

Traffic padding means inserting some bogus data into the data traffic to thwart the adversary’s attempt to
use the traffic analysis.

6. Routing Control:

Routing control means selecting and continuously changing different available routes between sender and
receiver to prevent the opponent from eavesdropping on a particular route.

7. Notarization:

Notarization means selecting a third trusted party to control the communication between two entities. The
receiver can involve a trusted third party to store the sender request in order to prevent the sender from later
denying that she has made a request.

8. Access Control:

Access control used methods to prove that a user has access right to the data or resources owned by a
system. Examples of proofs are passwords and PINs.

15. Explain Euclid’s algorithm with an example.

Refer – 2018

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
16. Explain transpositional cipher with an example.

Refer – 2019

17. Explain CBC mode of operation.

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 −

• Load the n-bit Initialization Vector (IV) in the top register.


• XOR the n-bit plaintext block with data value in top register.
• Encrypt the result of XOR operation with underlying block cipher with key K.
• Feed ciphertext block into top register and continue the operation till all plaintext blocks are processed.
• 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.

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.

18. Explain digital signature process with a neat diagram.

Refer – 2019

19. Explain PGP services.

Pretty Good Privacy (PGP) is an e-mail encryption scheme. It has become the de-facto standard for providing
security services for e-mail communication.

As discussed above, it uses public key cryptography, symmetric key cryptography, hash function, and digital
signature. It provides −

• Privacy

• Sender Authentication

• Message Integrity

• Non-repudiation
Follow Us on Instagram @Bustudymate
Visit www.Bustudymate.in For More Study Material
Along with these security services, it also provides data compression and key management support. PGP uses
existing cryptographic algorithms such as RSA, IDEA, MD5, etc., rather than inventing the new ones.

Working of PGP

• Hash of the message is calculated. (MD5 algorithm)

• Resultant 128 bit hash is signed using the private key of the sender (RSA Algorithm).

• The digital signature is concatenated to message, and the result is compressed.

• A 128-bit symmetric key, KS is generated and used to encrypt the compressed message with IDEA.

• KS is encrypted using the public key of the recipient using RSA algorithm and the result is appended to the
encrypted message.

The format of PGP message is shown in the following diagram. The IDs indicate which key is used to encrypt KS and
which key is to be used to verify the signature on the hash.

In PGP scheme, a message in signed and encrypted, and then MIME is encoded before transmission.

20. Compare SSL and TLS protocols.

BASIS FOR
SSL TLS
COMPARISON

Version 3.0 1.0

Cipher Suite Supports Fortezza (algorithm) Does not support Fortezza

Cryptography Uses message digest of the pre- Uses a pseudorandom function to


secret master secret for creating master create master secret.
secret.

Record protocol Uses MAC (Message Uses HMAC (Hashed MAC)

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
BASIS FOR
SSL TLS
COMPARISON

Authentication Code)

Alert protocol The "No certificate" alert message It eliminates alert description (No
is included. certificate) and adds a dozen other
values.

Message Ad hoc Standard


authentication

key material Ad hoc Pseudorandom function


authentication

Certificate verify Complex Simple

Finished Ad hoc Pseudorandom function

Definition of SSL

The Secure Socket Layer (SSL) protocol is an Internet protocol which ensures the secure exchange of information
between a web browser and a web server.

Definition of TLS

Transport Layer Security (TLS) is an IETF (Internet Engineering Task Force) standardization commencement, which
aimed to come out with an Internet standard version of SSL.

Section – C (15 - marks)

21. a) Explain key elements of public key encryption.

Unlike symmetric key cryptography, we do not find historical use of public-key cryptography. It is a relatively new
concept.
Symmetric cryptography was well suited for organizations such as governments, military, and big financial
corporations were involved in the classified communication.
With the spread of more unsecure computer networks in last few decades, a genuine need was felt to use
cryptography at larger scale. The symmetric key was found to be non-practical due to challenges it faced for key
management. This gave rise to the public key cryptosystems.
The process of encryption and decryption is depicted in the following illustration −

The most important properties of public key encryption scheme are −


Follow Us on Instagram @Bustudymate
Visit www.Bustudymate.in For More Study Material
• Different keys are used for encryption and decryption. This is a property which set this scheme different
than symmetric encryption scheme.
• Each receiver possesses a unique decryption key, generally referred to as his private key.
• Receiver needs to publish an encryption key, referred to as his public key.
• Some assurance of the authenticity of a public key is needed in this scheme to avoid spoofing by adversary
as the receiver. Generally, this type of cryptosystem involves trusted third party which certifies that a
particular public key belongs to a specific person or entity only.
• Encryption algorithm is complex enough to prohibit attacker from deducing the plaintext from the
ciphertext and the encryption (public) key.
• Though private and public keys are related mathematically, it is not be feasible to calculate the private key
from the public key. In fact, intelligent part of any public-key cryptosystem is in designing a relationship
between two keys.
b) Differentiate equality and congruence with an example.
i) Congruence looks like equality operator, but not. In equality operator maps a member of z to itself.
where as congruence operator maps a member from z to a member of Zn.
Equality operator is one to one whereas confluence operator is many to one
ii) the phrase (mod n) that we insert at the right hand side of congruence operator is just an indication of the
destination set (Zn).
22. a) Draw the block diagram of DES algorithm. Explain briefly
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of
Standards and Technology (NIST).
DES is an implementation of a Feistel Cipher. It uses 16 round Feistel structure. The block size is 64-bit. Though, key
length is 64-bit, DES has an effective key length of 56 bits, since 8 of the 64 bits of the key are not used by the
encryption algorithm (function as check bits only). General Structure of DES is depicted in the following illustration

Since DES is based on the Feistel Cipher, all that is required to specify DES is −

• Round function
• Key schedule
• Any additional processing − Initial and final permutation

Initial and Final Permutation

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
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 and final permutations are shown as follows −

Round Function

The heart of this cipher is the DES function, f. The DES function applies a 48-bit key to the rightmost 32 bits to
produce a 32-bit output.

• Expansion Permutation Box − Since right input is 32-bit and round key is a 48-bit, we first need to expand
right input to 48 bits. Permutation logic is graphically depicted in the following illustration −

• The graphically depicted permutation logic is generally described as table in DES specification illustrated as
shown −

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
• 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. Refer the following illustration −

• The S-box rule is illustrated below −

• 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 the following illustration:

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 following illustration −

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material

The logic for Parity drop, shifting, and Compression P-box is given in the DES description.

DES Analysis

The DES satisfies both the desired properties of block cipher. These two properties make cipher very strong.
• Avalanche effect − A small change in plaintext results in the very great change in the ciphertext.
• Completeness − Each bit of ciphertext depends on many bits of plaintext.
During the last few years, cryptanalysis have found some weaknesses in DES when key selected are weak keys.
These keys shall be avoided.
DES has proved to be a very well designed block cipher. There have been no significant cryptanalytic attacks on DES
other than exhaustive key search.
b) Write a short note on multiple DES
. DES was susceptible to attacks due to tremendous advances in computer hardware. Since DES was a very
competent algorithm it would be feasible to reuse DES rather than writing a new cryptographic algorithm.
Due to this variations of DES were introduced known as multiple DES which were as follows:
1.Double DES-
• Double DES is simple as it does that normal DES does. Double DES uses twp keys say K1 and K2. It first
performs DES on the original plain text using K! to get the encrypted text. It again performs DES on the
encrypted text but this time with the other key K2.
• The final output is the encryption of encrypted text with the original plain text encrypted twice with two
different keys shown in figure below.

• The doubly encrypted cipher text block is first decrypted using the key K2 to produce singly encrypted
cipher text. This cipher text block is then decrypted using the key K1 to obtain the original plain text block.
• Since the cryptanalysis for basic version of DES requires a search of 256 thus the assumption is double DES
require 2128 keys which is not true.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
• Meet-in-the-middle attack is the drawback of double DES. This attack involves encryption from one end,
decryption from the other and matching the results in the middle hence the name.
2.Triple DES-
To improve the security of DES to a higher level triple DES was proposed. This uses three stages on DES for
encryption and decryption. Two versions of triple DES are as follows:
i. Triple DES with Two Keys-
• In triple DES with two keys there are only two keys K1 used by first and third stage and K2 used in second
stage. First the plain text is encrypted with key K1 then the output of step one is decrypted with K2 and final
the output second step is encrypted again with key K1. Thus
having EK1(DK2(EK1(P)))EK1(DK2(EK1(P))) shown below.

• This is also called as encrypt decrypt encrypt (ECE) mode. Triple DES with two keys is not susceptible to the
meet-in-the-middle attack.
ii. Triple DES with Three Keys-
• The figure below shows the idea of Triple DES with three keys:

• The plain text block P is first encrypted with a key K1 then encrypts with a second key K2 and finally with a
third key K3 where K1, K2 and K3 are all different from each other. Decryption is done in reverse order. This
algorithm is mostly used in PGP and S/MIME.
23. a) Explain Fermat’s theorem of primality test.
Refer - 2018
b) Explain RSA algorithm with one example.
Refer – 2019
24. a) Write a short note on Whirlpool hash function
Whirlpool, which is a block-cipher-based secure hash function. Whirlpool produces a hash code of 512 bits
for an input message of maximum length less than 2256 bits. The underlying block cipher, based on the Advanced
Encryption Standard (AES), takes a 512-bit key and operates on 512-bit blocks of plaintext. Whirlpool has been
endorsed by NESSIE (New European Schemes for Signatures, Integrity, and Encryption), which is a European Union-
sponsored effort to put forward a portfolio of strong cryptographic primitives of various types.
b) Explain Diffie – Hellman key agreement.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
Refer – 2018

25. a) Write a short note on IKE

Internet Key Exchange (IKE) is a key management protocol standard used in conjunction with the Internet
Protocol Security (IPSec) standard protocol. It provides security for virtual private networks' (VPNs) negotiations and
network access to random hosts. It can also be described as a method for exchanging keys for encryption and
authentication over an unsecured medium, such as the Internet.

IKE is a hybrid protocol based on:

ISAKMP (RFC2408): Internet Security Association and Key Management Protocols are used for negotiation and
establishment of security associations. This protocol establishes a secure connection between two IPSec peers.

Oakley (RFC2412): This protocol is used for key agreement or key exchange. Oakley defines the mechanism that is
used for key exchange over an IKE session. The default algorithm for key exchange used by this protocol is the Diffie-
Hellman algorithm.

SKEME: This protocol is another version for key exchange.

IKE enhances IPsec by providing additional features along with flexibility. IPsec, however, can be configured without
IKE.

IKE has many benefits. It eliminates the need to manually specify all the IPSec security parameters at both peers. It
allows the user to specify a particular lifetime for the IPsec security association. Furthermore, encryption can be
changed during IPsec sessions. Moreover, it permits certification authority. Finally, it allows dynamic authentication
of peers.

b) Explain the modes of IPSec

IPsec Communication Modes

IPsec Communication has two modes of functioning; transport and tunnel modes. These modes can be used in
combination or used individually depending upon the type of communication desired.

Transport Mode
• IPsec does not encapsulate a packet received from upper layer.
• The original IP header is maintained and the data is forwarded based on the original attributes set by the
upper layer protocol.
• The following diagram shows the data flow in the protocol stack.

• The limitation of transport mode is that no gateway services can be provided. It is reserved for point-to-
point communications as depicted in the following image.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material

Tunnel Mode
• This mode of IPsec provides encapsulation services along with other security services.
• In tunnel mode operations, the entire packet from upper layer is encapsulated before applying security
protocol. New IP header is added.
• The following diagram shows the data flow in the protocol stack.

• Tunnel mode is typically associated with gateway activities. The encapsulation provides the ability to send
several sessions through a single gateway.
• The typical tunnel mode communication is as depicted in the following diagram.

• As far as the endpoints are concerned, they have a direct transport layer connection. The datagram from
one system forwarded to the gateway is encapsulated and then forwarded to the remote gateway. The
remote associated gateway de-encapsulates the data and forwards it to the destination endpoint on the
internal network.
• Using IPsec, the tunneling mode can be established between the gateway and individual end system as well.

Section – D (10 marks)

26. Explain one round of processing in AES.

The more popular and widely adopted symmetric encryption algorithm likely to be encountered nowadays is the
Advanced Encryption Standard (AES). It is found at least six time faster than triple DES.
Follow Us on Instagram @Bustudymate
Visit www.Bustudymate.in For More Study Material
A replacement for DES was needed as its key size was too small. With increasing computing power, it was
considered vulnerable against exhaustive key search attack. Triple DES was designed to overcome this drawback
but it was found slow.
The features of AES are as follows −

• Symmetric key symmetric block cipher


• 128-bit data, 128/192/256-bit keys
• Stronger and faster than Triple-DES
• Provide full specification and design details
• Software implementable in C and Java

Operation of AES

AES is an iterative rather than Feistel cipher. It is based on ‘substitution–permutation network’. It comprises of a
series of linked operations, some of which involve replacing inputs by specific outputs (substitutions) and others
involve shuffling bits around (permutations).
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.
The schematic of AES structure is given in the following illustration −

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 −

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material

Byte Substitution (SubBytes)


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 −
• First row is not shifted.
• Second row is shifted one (byte) position to the left.
• Third row is shifted two positions to the left.
• Fourth row is shifted three positions to the left.
• The result is a new matrix consisting of the same 16 bytes but shifted with respect to each other.
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 −

• Add round key


• Mix columns
• Shift rows
• Byte substitution
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.

AES Analysis

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
In present day cryptography, AES is widely adopted and supported in both hardware and software. Till date, no
practical cryptanalytic attacks against AES has been discovered. Additionally, AES has built-in flexibility of key
length, which allows a degree of ‘future-proofing’ against progress in the ability to perform exhaustive key
searches.
However, just as for DES, the AES security is assured only if it is correctly implemented and good key management
is employed.
27. Explain SHA-512 algorithm with a neat diagram.
SHA-512 is a hashing algorithm that performs a hashing function on some data given to it.

Hashing algorithms are used in many things such as internet security, digital certificates and even
blockchains. Since hashing algorithms play such a vital role in digital security and cryptography, this is an easy-to-
understand walkthrough, with some basic and simple maths along with some diagrams, for a hashing algorithm
called SHA-512. It’s part of a group of hashing algorithms called SHA-2 which includes SHA-256 as well which is used
in the bitcoin blockchain for hashing.

Hashing Functions

Hashing functions take some data as input and produce an output (called hash digest) of fixed length for that input
data. This output should, however, satisfy some conditions to be useful.

1. Uniform distribution: Since the length of the output hash digest is of a fixed length and the input size may vary, it
is apparent that there are going to be some output values that can be obtained for different input values. Even
though this is the case, the hash function should be such that for any input value, each possible output value
should be equally likely. That is to say that every possible output has the same likelihood to be produced for any
given input value.

2. Fixed Length: This is should be quite self-explanatory. The output values should all be of a fixed length. So, for
example, a hashing function could have an output size of 20 characters or 12 characters, etc. SHA-512 has an
output size of 512 bits.

3. Collision resistance: Simply speaking, this means that there aren’t any or rather it is not feasible to find two
distinct inputs to the hash function that result in the same output (hash digest).

That’s a simple introduction about hash functions. Now let’s look at SHA-512.

Hashing Algorithm — SHA-512

So, SHA-512 does its work in a few stages. These stages go as follows:

1. Input formatting

2. Hash buffer initialization

3. Message Processing

4. Output

Let’s look at these one-by-one.

1. Input Formatting:

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
SHA-512 can’t actually hash a message input of any size, i.e. it has an input size limit. This limit is imposed by its very
structure as you may see further on. The entire formatted mesage has basically three parts: the original message,
padding bits, size of original message. And this should all have a combined size of a whole multiple of 1024 bits. This is
because the formatted message will be processed as blocks of 1024 bits each, so each bock should have 1024 bits to
work with.

<pic: original message>

Original message

Padding bits

The input message is taken and some padding bits are appended to it in order to get it to the desired length. The bits
that are used for padding are simply ‘0’ bits with a leading ‘1’ (100000…000). Also, according to the algorithm,
padding needs to be done, even if it is by one bit. So a single padding bit would only be a ‘1’.

The total size should be equal to 128 bits short of a multiple of 1024 since the goal is to have the formatted message
size as a multiple of 1024 bits (N x 1024).

<pic: msg + pad>

Message with padding

Padding size

After this, the size of the original message given to the algorithm is appended. This size value needs to be represented
in 128 bits and is the only reason that the SHA-512 has a limitation for its input message.

Since the size of the original message needs to be represented in 128 bits, the message size can be at most (2¹²⁹-1) bits
and also taking into consideration the necessary single padding bit, it maximum size would then be (2¹²⁹-2). Even
though this limit exists, it doesn’t actually cause a problem since the actual limit is so high (2¹²⁹-2 =
680,564,733,841,876,926,926,749,214,863,536,422,910 bits).

Message with padding and size

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
Now that the padding bits and the size of the message have been appended, we are left with the completely
formatted input for the SHA-512 algorithm.

Formatted Message

2. Hash buffer initialization:

The algorithm works in a way where it processes each block of 1024 bits from the message using the result from the
previous block. Now, this poses a problem for the first 1024 bit block which can’t use the result from any previous
processing. This problem can be solved by using a default value to be used for the first block in order to start off the
process. (Have a look at the second-last diagram).

Since each intermediate result needs to be used in processing the next block, it needs to be stored somewhere for
later use. This would be done by the hash buffer, this would also then hold the final hash digest of the entire
processing phase of SHA-512 as the last of these ‘intermediate’ results.

So, the default values used for starting off the chain processing of each 1024 bit block are also stored into the hash
buffer at the start of processing. The actual value used is of little consequence, but for those interested, the values
used are obtained by taking the first 64 bits of the fractional parts of the square roots of the first 8 prime numbers
(2,3,5,7,11,13,17,19). These values are called the Initial Vectors (IV).

Why 8 prime numbers instead of 9? Because the hash buffer actually consists of 8 subparts (registers) for storing
them.

Hash buffer and Initialization Vector values

3. Message Processing:

Message processing is done upon the formatted input by taking one block of 1024 bits at a time. The actual
processing takes place by using two things: The 1024 bit block, and the result from the previous processing.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material
This part of the SHA-512 algorithm consists of several ‘Rounds’ and an addition operation.

So, the Message block (1024 bit) is expanded out into ‘Words’ using a ‘message sequencer’. Eighty Words to be
precise, each of them having a size of 64 bits.

Rounds

The main part of the message processing phase may be considered to be the Rounds. Each round takes 3 things: one
Word, the output of the previous Round, and a SHA-512 constant. The first Round doesn’t have a previous Round
whose output it can use, so it uses the final output from the previous message processing phase for the previous block
of 1024 bits. For the first Round of the first block (1024 bits) of the formatted input, the Initial Vector (IV) is used.

SHA-512 constants are predetermined values, each of whom is used for each Round in the message processing phase.
Again, these aren’t very important, but for those interested, they are the first 64 bits from the fractional part of the
cube roots of the first 80 prime numbers.Why 80? Because there are 80 Rounds and each of them needs one of these
constants.

Once the Round function takes these 3 things, it processes them and gives an output of 512 bits. This is repeated for
80 Rounds. After the 80th Round, its output is simply added to the result of the previous message processing phase to
get the final result for this iteration of message processing.

Follow Us on Instagram @Bustudymate


Visit www.Bustudymate.in For More Study Material

4. Output:

After every block of 1024 bits goes through the message processing phase, i.e. the last iteration of the phase, we get
the final 512 bit Hash value of our original message. So, the intermediate results are all used from each block for
processing the next block. And when the final 1024 bit block has finished being processed, we have with us the final
result of the SHA-512 algorithm for our original message.

Thus, we obtain the final hash value from our original message. The SHA-512 is part of a group of hashing algorithms
that are very similar in how they work, called SHA-2. Algorithms such as SHA-256 and SHA-384 are a part of this group
alongside SHA-512. SHA-256 is also used in the Bitcoin blockchain as the designated hash function.

Follow Us on Instagram @Bustudymate

You might also like