0% found this document useful (0 votes)
8 views

Unit-3 2

The document discusses message authentication requirements and cryptographic hash functions. It describes how cryptographic hash functions can be used for message authentication by mapping messages of arbitrary length to fixed-length hash values. A cryptographic hash function should have properties like pre-image resistance, second pre-image resistance, and collision resistance to securely authenticate messages. Examples of applications that use cryptographic hash functions include digital signatures and message authentication codes.

Uploaded by

yo yo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Unit-3 2

The document discusses message authentication requirements and cryptographic hash functions. It describes how cryptographic hash functions can be used for message authentication by mapping messages of arbitrary length to fixed-length hash values. A cryptographic hash function should have properties like pre-image resistance, second pre-image resistance, and collision resistance to securely authenticate messages. Examples of applications that use cryptographic hash functions include digital signatures and message authentication codes.

Uploaded by

yo yo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Unit-3_2

• Message Authentication Requirements


• Message Authentication Function
• Cryptographic Hash Function
• Applications of Cryptographic Hash Function
• Secure Hash Function-512
• Message Authentication Requirements
Data is prone to various attacks. One of these attacks includes message authentication. This threat
arises when the user does not have any information about the originator of the message. Message
authentication can be achieved using cryptographic methods which further make use of keys.
Authentication Requirements:
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.
• Message Authentication Requirements
Message Authentication Functions:
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.
• Message Authentication Requirements
These message authentication functions are divided into three classes:
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 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:
• Message Authentication Requirements
• Message Authentication Requirements
Public key Encryption: Public key encryption is not as advanced as symmetric
encryption as it provides confidentiality but not authentication. To provide
both authentication and confidentiality, the private key is used.
Message authentication code (MAC): A message authentication code is a
security code that the user of a computer has to type in order to access any
account or portal. These codes are recognized by the system so that it can
grant access to the right user. These codes help in maintaining information
integrity. It also confirms the authenticity of the message.
Hash function: A hash function is nothing but a mathematical function that
can convert a numeric value into another numeric value that is compressed.
The input to this hash function can be of any length but the output is always
of fixed length. The values that a hash function returns are called the message
digest or hash values.
• Message Authentication Requirements
Measures to deal with these attacks:
Each of the above attacks has to be dealt with differently.
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 Requirements
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 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, the content, sequence, and timing
of the messages can be easily monitored. Moreover, it also prevents the
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.
• Message Authentication Function
• Any message authentication or digital signature mechanism has two levels of functionality. At the lower level, there must be some sort of
function that produces an authenticator: a value to be used to authenticate a message. This lower-level function is then used as a primitive
in a higher-level authentication protocol that enables a receiver to verify the authenticity of a message.

• This section is concerned with the types of functions that may be used to pro- duce an authenticator. These may be grouped into three
classes.

• Hash function: A function that maps a message of any length into a fixed-length hash value, which serves as the authenticator

• Message encryption: The ciphertext of the entire message serves as its authenticator

• Message authentication code (MAC): A function of the message and a secret key that produces a fixed-length value that serves
as the authenticator

• Hash functions, and how they may serve for message authentication, are discussed. The remainder of this section briefly examines the
remaining two topics. The remainder of the chapter elaborates on the topic of MACs.
• Cryptographic Hash Function
Hash functions are extremely useful and appear in almost all
information security applications.
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 −
• Cryptographic Hash Function
• Cryptographic Hash Function
Features of Hash Functions
The typical features of hash functions are −
Fixed Length Output (Hash Value)
• Hash function coverts data of arbitrary length to a fixed length. This process is
often referred to as hashing the data.
• In general, the hash is much smaller than the input data, hence hash functions
are sometimes called compression functions.
• Since a hash is a smaller representation of a larger data, it is also referred to as
a digest.
• Hash function with n-bit output is referred to as an n-bit hash function.
Popular hash functions generate values between 160 and 512 bits.
• Cryptographic Hash Function
Efficiency of Operation
Generally for any hash function h with input x, computation of h(x) is a fast operation.
Computationally hash functions are much faster than a symmetric encryption.
Properties of Hash Functions
In order to be an effective cryptographic tool, the hash function is desired to
possess following properties −
Pre-Image Resistance
• This property means that it should be computationally hard to reverse a hash
function.
• In other words, if a hash function h produced a hash value z, then it should be a
difficult process to find any input value x that hashes to z.
• This property protects against an attacker who only has a hash value and is trying
to find the input.
• Cryptographic Hash Function
Second Pre-Image Resistance
• This property means given an input and its hash, it should be hard to find a
different input with the same hash.
• In other words, if a hash function h for an input x produces hash value h(x),
then it should be difficult to find any other input value y such that h(y) = h(x).
• This property of hash function protects against an attacker who has an input
value and its hash, and wants to substitute different value as legitimate value
in place of original input value.
• Cryptographic Hash Function
Collision Resistance
• This property means it should be hard to find two different inputs of any length
that result in the same hash. This property is also referred to as collision free hash
function.
• In other words, for a hash function h, it is hard to find any two different inputs x
and y such that h(x) = h(y).
• Since, hash function is compressing function with fixed hash length, it is impossible
for a hash function not to have collisions. This property of collision free only
confirms that these collisions should be hard to find.
• This property makes it very difficult for an attacker to find two input values with
the same hash.
• Also, if a hash function is collision-resistant then it is second pre-image resistant.
• Cryptographic Hash Function
Design of Hashing Algorithms
• 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 −
• Cryptographic Hash Function
• Cryptographic Hash Function
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.
• Cryptographic Hash Function
Popular Hash Functions
Let us briefly see some popular hash functions −
Message Digest (MD)
• MD5 wasa most popular and widely used hash function for quite some years.
• 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 the integrity of the 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 a computer cluster. This collision attack
resulted in compromised MD5 and hence it is no longer recommended for use.
• Cryptographic Hash Function
Secure Hash Function (SHA)
• 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.
• Cryptographic 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.
• Cryptographic Hash Function
Whirlpool

This is a 512-bit hash function.


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.
Applications of Hash Functions
There are two direct applications of the hash function based on its cryptographic
properties.
Password Storage
Hash functions provide protection for password storage.
Instead of storing passwords 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 login is depicted in the following illustration −
Applications of Hash Functions
• Applications of Hash Functions
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.
• Applications of Hash Functions
Data Integrity Check
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 the correctness of the data.
The process is depicted in the following illustration −
Applications of Hash Functions
• The integrity check helps the user to detect any changes made to the
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 it to the
receiver. This integrity check application is useful only if the user is
sure about the originality of the file.
Implement Secure Hashing
Algorithm – 512 ( SHA-512 ) as
Functional Programming Paradigm
Given a string S of length N, the task is to find the SHA-512 Hash Value of the given string S.
Examples:
Input: S = “GeeksforGeeks”
Output: acc10c4e0b38617f59e88e49215e2e894afaee5ec948c2af6f44039f03c9fe47a9210e01d5cd926c142bdc9179c2ad30f927a8faf69421ff60a5eaddcf8cb9c
Input: S = “hello world”
Output:
309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
Implement Secure Hashing
Algorithm – 512 ( SHA-512 ) as
Functional Programming Paradigm
Approach: Follow the steps below to solve the problem:
Convert the given string into the binary form.
Append ‘1’ to the string and then ‘0’ continuously until length of the string is
< (N%(1024 – 128)).
Add the 128-bit binary representation of N in the string S.
Find the number of chunks of the size of 1024 and store it in a variable,
say chunks as N/1024.
Divide the string S into 16 chunks of 64 characters.
Implement Secure Hashing
Algorithm – 512 ( SHA-512 ) as
Functional Programming Paradigm
Extend the number of chunks to 80 by performing the following operations:
Iterate over the range [16, 80] and then find 4 values say WordA, WordB, WordC,
WordD as:
WordA = rotate_right(Message[g – 2], 19) ^ rotate_right(Message[g – 2], 61) ^
shift_right(Message[g – 2], 6).
WordB = Message[g – 7].
WordC = rotate_right(Message[g – 15], 1) ^ rotate_right(Message[g – 15], 8) ^
shift_right(Message[g – 15], 7).
WordD = Message[g – 16].
Update the value of Message[g] as (WordA + WordB + WordC + WordD).
Implement Secure Hashing
Algorithm – 512 ( SHA-512 ) as
Functional Programming Paradigm
Initialize 8 variables say A, B, C, D, E, F, G, H of type 64-bit to store the final
hash value of the given string S.
Traverse the array Block[] and perform the following steps:
Update the value of A, B, C, D, E, F, G, H using the Hash Function till 80 iterations by
rotating one by one.
Now, update the value of A, B, C, D, E, F, G, H by the summation of previous values
of A, B, C, D, E, F, G, H and the newly updated value of A, B, C, D, E, F, G, H.
After completing the above steps, print the hexadecimal
values of A, B, C, D, E, F, G, H to get the Hash Value of the given string.

You might also like