0% found this document useful (0 votes)
7 views12 pages

Unit 3 Ns

The document outlines the authentication requirements and methods to secure data against various attacks, including message authentication, encryption, and the use of message authentication codes (MACs). It discusses the importance of hash functions, their properties, types, and applications, particularly in data integrity and cryptography. Additionally, it highlights the security of hash functions and MACs against brute-force attacks, and introduces the SHA algorithm and its various forms, emphasizing the need for secure hashing in digital communications.

Uploaded by

localhero227
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

Unit 3 Ns

The document outlines the authentication requirements and methods to secure data against various attacks, including message authentication, encryption, and the use of message authentication codes (MACs). It discusses the importance of hash functions, their properties, types, and applications, particularly in data integrity and cryptography. Additionally, it highlights the security of hash functions and MACs against brute-force attacks, and introduces the SHA algorithm and its various forms, emphasizing the need for secure hashing in digital communications.

Uploaded by

localhero227
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UNIT 3

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 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.
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 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:

Read more about symmetric encryption here.


 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.

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: 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:
o Parties should share secret codes that can be used at the time of identity authentication.
o Digital signatures are helpful in the authentication.
o 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.
Another ultimate solution for all kinds of message authentication is Message Authentication Code
(MAC).

Message Authentication Codes



Message Authentication Codes are the codes which plays their role in two important functions:
Authentication Detection and Falsification Detection.
Where do we need these codes?
Suppose User A send message to user B with message – ‘abc’. A encrypts the message using Shared –
Key Cryptosystem for encrypting the message. A sends the key to B using a source key. Key exchange
is based on different protocols such as Public – Key Cryptosystem. B uses the key to decrypt the
Ciphertext and obtains the message.

All this does not happen so easily. There lies a problem.


If a malicious user X has falsified the ciphertext during the transmission. Then, in that case, B has no way
to realize that it has been falsified. When B decrypts the message, it will get the wrong message.
Unknown to the fact B will think wrong information to be the right. Although you can decrypt or encrypt
the data later on but these operations, you are applying the wrong data.
Here we need to detect the falsification in the message B has got.
Here A will create a key (used to create Message Authentication Code) and sends the key to B. A will
create a value using Ciphertext and key and the value is obtained. This value Created by Ciphertext +
Key = Message Authentication Code. B has to check whether the ciphertext is falsified or not using
Message Authentication Code. Now B can clearly know that whether the ciphertext is falsified or not.

Hash functions are a fundamental concept in computer science and play a crucial role in various
applications such as data storage, retrieval, and cryptography. In data structures and algorithms (DSA),
hash functions are primarily used in hash tables, which are essential for efficient data management.
This article delves into the intricacies of hash functions, their properties, and the different types of hash
functions used in DSA.
What is a Hash Function?
A hash function is a function that takes an input (or ‘message’) and returns a fixed-size string of bytes.
The output, typically a number, is called the hash code or hash value. The main purpose of a hash
function is to efficiently map data of arbitrary size to fixed-size values, which are often used as indexes
in hash tables.
Key Properties of Hash Functions
 Deterministic: A hash function must consistently produce the same output for the same input.
 Fixed Output Size: The output of a hash function should have a fixed size, regardless of the size of
the input.
 Efficiency: The hash function should be able to process input quickly.
 Uniformity: The hash function should distribute the hash values uniformly across the output space
to avoid clustering.
 Pre-image Resistance: It should be computationally infeasible to reverse the hash function, i.e., to
find the original input given a hash value.
 Collision Resistance: It should be difficult to find two different inputs that produce the same hash
value.
 Avalanche Effect: A small change in the input should produce a significantly different hash value.
Applications of Hash Functions
 Hash Tables: The most common use of hash functions in DSA is in hash tables, which provide an
efficient way to store and retrieve data.
 Data Integrity: Hash functions are used to ensure the integrity of data by generating checksums.
 Cryptography: In cryptographic applications, hash functions are used to create secure hash
algorithms like SHA-256.
 Data Structures: Hash functions are utilized in various data structures such as Bloom filters and
hash sets.
Types of Hash Functions
There are many hash functions that use numeric or alphanumeric keys. This article focuses on
discussing different hash functions:
1. Division Method.
2. Multiplication Method
3. Mid-Square Method
4. Folding Method
5. Cryptographic Hash Functions
6. Universal Hashing
7. Perfect Hashing
Let’s begin discussing these methods in detail.
1. Division Method
The division method involves dividing the key by a prime number and using the remainder as the hash
value.

Where k is the key and 𝑚m is a prime number.


h(k)=k mod m

Advantages:

 Works well when 𝑚m is a prime number.


 Simple to implement.

 Poor distribution if 𝑚m is not chosen wisely.


Disadvantages:

In the multiplication method, a constant 𝐴A (0 < A < 1) is used to multiply the key. The fractional part
2. Multiplication Method

of the product is then multiplied by 𝑚m to get the hash value.


h(k)=⌊m(kAmod1)⌋
Where ⌊ ⌋ denotes the floor function.

 Less sensitive to the choice of 𝑚m.


Advantages:

Disadvantages:
 More complex than the division method.
3. Mid-Square Method
In the mid-square method, the key is squared, and the middle digits of the result are taken as the hash
value.
Steps:
1. Square the key.
2. Extract the middle digits of the squared value.
Advantages:
 Produces a good distribution of hash values.
Disadvantages:
 May require more computational effort.
4. Folding Method

modulo with respect to 𝑚m.


The folding method involves dividing the key into equal parts, summing the parts, and then taking the

Steps:
1. Divide the key into parts.
3. Take the modulo 𝑚m of the sum.
2. Sum the parts.

Advantages:
 Simple and easy to implement.
Disadvantages:
 Depends on the choice of partitioning scheme.
5. Cryptographic Hash Functions
Cryptographic hash functions are designed to be secure and are used in cryptography. Examples include
MD5, SHA-1, and SHA-256.
Characteristics:
 Pre-image resistance.
 Second pre-image resistance.
 Collision resistance.
Advantages:
 High security.
Disadvantages:
 Computationally intensive.
6. Universal Hashing
Universal hashing uses a family of hash functions to minimize the chance of collision for any given set

h(k)=((a⋅k+b)modp)modm
of inputs.

Where a and b are randomly chosen constants, p is a prime number greater than m, and k is the key.

Advantages:
 Reduces the probability of collisions.
Disadvantages:
 Requires more computation and storage.
7. Perfect Hashing
Perfect hashing aims to create a collision-free hash function for a static set of keys. It guarantees that
no two keys will hash to the same value.
Types:
 Minimal Perfect Hashing: Ensures that the range of the hash function is equal to the number of
keys.
 Non-minimal Perfect Hashing: The range may be larger than the number of keys.
Advantages:
 No collisions.
Disadvantages:
 Complex to construct.

Security of Hash Functions and Macs

Just as with symmetric and public-key encryption, we can group attacks on hash functions and MACs into
two categories: brute-force attacks and cryptanalysis.

Brute-Force Attacks
The nature of brute-force attacks differs somewhat for hash functions and MACs.

Hash Functions

The strength of a hash function against brute-force attacks depends solely on the length of the hash code
produced by the algorithm. Recall from our discussion of hash functions that there are three desirable
properties:

· One-way: For any given code h, it is computationally infeasible to find x such that H(x) = h.

· Weak collision resistance: For any given block x, it is computationally infeasible to find y x with H(y) =
H(x).

· Strong collision resistance: It is computationally infeasible to find any pair (x, y) such that H(x) = H(y).

· For a hash code of length n, the level of effort required, as we have seen is proportional to the
following:

Message Authentication Codes

A brute-force attack on a MAC is a more difficult undertaking because it requires known message-MAC
pairs.. To attack a hash code, we can proceed in the following way. Given a fixed message x with n-bit
hash code h = H(x), a brute-force method of finding a collision is to pick a random bit string y and check
if H(y) = H(x). The attacker can do this repeatedly off line. To proceed, we need to state the desired
security property of a MAC algorithm, which can be expressed as follows:
Computation resistance: Given one or more text-MAC pairs (x i, CK[xi]), it is computationally infeasible to
compute any text-MAC pair (x, CK( x)) for any new input x ≠xi.

In other words, the attacker would like to come up with the valid MAC code for a given message
x. There are two lines of attack possible: Attack the key space and attack the MAC value. We
examine each of these in turn.

To summarize, the level of effort for brute-force attack on a MAC algorithm can be expressed as
min(2k, 2n). The assessment of strength is similar to that for symmetric encryption algorithms. It
would appear reasonable to require that the key length and MAC length satisfy a relationship
such as min(k, n) ≥N, where N is perhaps in the range of 128 bits.

Introduction to SHA

SHA stands for secure hashing algorithm. SHA is a modified version of MD5 and used for hashing data
and certificates. A hashing algorithm shortens the input data into a smaller form that cannot be
understood by using bitwise operations, modular additions, and compression functions. You may be
wondering, can hashing be cracked or decrypted?

Hashing is similar to encryption, the only difference between hashing and encryption is that hashing is
one-way, meaning once the data is hashed, the resulting hash digest cannot be cracked, unless a brute
force attack is used. See the image below for the working of SHA algorithm. SHA works in such a way
even if a single character of the message changed, then it will generate a different hash. For example,
hashing of two similar, but different messages like, Heaven and heaven are different, however, there is
only a difference of a capital and small letter.

The initial message is hashed with SHA-2, resulting in the hash digest
“06b73bd57b3b938786daed820cb9fa4561bf0e8e”. If the second, similar, message is hashed with SHA-2,
the hash digest will look like “66da9f3b8d9d83f34770a14c38276a69433a535b”. This is referred to as the
avalanche effect. This effect is important in cryptography, as it means even the slightest change in the
input message completely changes the output. This will stop attackers from being able to understand what
the hash digest originally said and telling the receiver of the message whether or not the message has been
changed while in transit.

SHAs also assist in revealing if an original message was changed in any way. By referencing the original
hash digest, a user can tell if even a single letter has been changed, as the hash digests will be completely
different. One of the most important parts of SHAs are that they are deterministic. This means that as long
as the hash function used is known, any computer or user can recreate the hash digest. The determinism
of SHAs is one of reasons every SSL certificate on the Internet is required to have been hashed with a
SHA-2 function.

Different SHA Forms

When learning about SHA forms, several different types of SHA are referenced. Examples of SHA names
used are SHA-1, SHA-2, SHA-256, SHA-512, SHA-224, and SHA-384, but in actuality there are only
two types: SHA-1 and SHA-2. The other larger numbers, like SHA-256, are just versions of SHA-2 that
note the bit lengths of the SHA-2. SHA-1, introduced in 1993, was the original secure hashing algorithm,
returning a 160-bit hash digest after hashing.

However, due to its short bit length, vulnerabilities like collision attacks surfaced. In cryptography, a
collision occurs when two different inputs produce the same hash. Over time, it became easier to find
these collisions, significantly undermining SHA-1’s security. A landmark event was the 2017
“SHAttered” attack conducted by Google and CWI researchers, which successfully demonstrated a
collision in SHA-1, marking its obsolescence in secure applications. SHA-1 is now a deprecated
algorithm, no longer used for hashing online.

Someone may wonder, can SHA-2 be cracked like SHA-1? The answer is yes. Due to the short length of
the hash digest, SHA-1 is more easily brute-forced than SHA-2, but SHA-2 can still be brute-forced.
SHA-1 can give the same hash digest to two different values, as the number of combinations that can be
created with 160 bits is so small. SHA-2 on the other hand gives every digest a unique value, which is
why all certificates are required to use SHA-2. SHA-2 can produce a variety of bit-lengths, from 256 to
512 bit, allowing it to assign completely unique values to every hash digest created.

The industry began transitioning to SHA-2 in the early 2000s, though the full migration took time. SHA-
2, with its larger bit lengths (e.g., 256-bit and 512-bit), offered stronger security against collisions and
brute force attacks. By 2016, most major systems had phased out SHA-1 in favor of SHA-2, but
resistance and challenges persisted during the transition.

Many organizations were slow to adopt SHA-2 due to the need for significant infrastructure updates,
including upgrading legacy systems, ensuring compatibility with older hardware and software, replacing
outdated certificates, and reconfiguring security protocols to support the stronger encryption standard.
Despite the delay, SHA-256 became the new standard, especially for SSL/TLS certificates and digital
signatures, providing better resistance to cryptographic attacks.

Compared to SHA-1, SHA-2 is much more secure and has been required in all digital signatures and
certificates since 2016. Common attacks like brute force attacks can take years or even decades to crack
the hash digest, so SHA-2 is considered the most secure hash algorithm.

What is SHA used for?

As previously mentioned, Secure Hashing Algorithms are required in all digital signatures and certificates
relating to SSL/TLS connections, but there are more uses to SHAs as well. Applications such as SSH, S-
MIME (Secure / Multipurpose Internet Mail Extensions), and IPSec utilize SHAs as well. SHAs are also
used to hash passwords so that the server only needs to remember hashes rather than passwords.
In this way, if an attacker steals the database containing all the hashes, they would not have direct access
to all of the plaintext passwords, they would also need to find a way to crack the hashes to be able to use
the passwords. SHAs can also work as indicators of a file’s integrity. If a file has been changed in transit,
the resulting hash digest created from the hash function will not match the hash digest originally created
and sent by the file’s owner.

In blockchain technology, particularly in cryptocurrencies like Bitcoin, SHA-256 plays a crucial role. It is
integral to the mining process, where it helps solve complex mathematical puzzles to validate and add
new transactions to the blockchain.

Key Reasons to use SHA

We have now learned what SHAs are used for, but why use a Secure Hashing Algorithm in the first
place? A common reason is their ability to stop attackers. Though some methods, like brute force attacks,
can reveal the plaintext of the hash digests, these tactics are made extremely difficult by SHAs. A
password hashed by a SHA-2 can take years, even decades to break, thus wasting resources and time on a
simple password, which may turn many attackers away.

Another reason to use SHAs is the uniqueness of all the hash digests. If SHA-2 is used, there will likely
be few to no collisions, meaning a simple change of one word in a message would completely change the
hash digest. Since there are few or no collisions, a pattern cannot be found to make breaking the Secure
Hashing Algorithm easier for the attacker. These are just a few reasons why SHA is used so often.

What is HMAC?
HMAC (Hash-Based Message Authentication Code) is a cryptographic technique that ensures data
integrity and authenticity using a hash function and a secret key. Unlike approaches based on signatures
and asymmetric cryptography. Checking data integrity is necessary for the parties involved in
communication. HTTPS, SFTP, FTPS, and other transfer protocols use HMAC. The cryptographic hash
function may be MD-5, SHA-1, or SHA-256. Digital signatures are nearly similar to HMACs i.e. they
both employ a hash function and a shared key. The difference lies in the keys i.e. HMAC uses
a symmetric key(same copy) while Signatures uses an asymmetric (two different keys).

Security in Hash-based Message Authentication Code


HMAC is more secure than MAC since the key and message are hashed in different steps:
HMAC(key, message) = H(mod1(key) || H(mod2(key) || message).
The data is initially hashed by the client using a private key before being sent to the server as part of
the request. The server then creates its own HMAC. This assures that the process is not vulnerable to
attacks, which could result in crucial data being disclosed as subsequent MACs are generated.
Additionally, once the procedure is completed, the delivered message becomes irreversible and
resistant to hackers. Even if a malicious party attempts to steal the communication, they will be unable
to determine its length or decrypt it because they do not have the decryption key.
Advantages of HMAC
 HMACs are ideal for high-performance systems like routers due to the use of hash functions which
are calculated and verified quickly unlike the public key systems.
 Digital signatures are larger than HMACs, yet the HMACs provide comparably higher security.
 HMACs are used in administrations where public key systems are prohibited.
Disadvantages of HMAC
 HMACs uses shared key which may lead to non-repudiation. If either sender or receiver’s key is
compromised then it will be easy for attackers to create unauthorized messages.
 Securely managing and distributing secret keys can be challenging.
 Although unlikely, hash collisions (where two different messages produce the same hash) can
occur.
 The security of HMAC depends on the length of the secret key. Short keys are more vulnerable to
brute-force attacks.
 The security of HMAC relies on the strength of the chosen hash function (e.g., SHA-256). If the
hash function is compromised, HMAC is also affected.
Applications of HMAC
 Verification of e-mail address during activation or creation of an account.
 Authentication of form data that is sent to the client browser and then submitted back.
 HMACs can be used for Internet of things (IoT) due to less cost.
 Whenever there is a need to reset the password, a link that can be used once is sent without adding
a server state.
 It can take a message of any length and convert it into a fixed-length message digest. That is even if
you got a long message, the message digest will be small and thus permits maximizing bandwidth.

CMAC (Cipher-Based Message Authentication Code)

Introduction:

The Cipher-Based Message Authentication Code (CMAC) is a cryptographic technique used for message
authentication. It is designed to provide strong security against various types of attacks, including
message forgery and replay attacks. CMAC is a block cipher-based algorithm that generates a fixed-
length message authentication code (MAC) for a given message.

In this article, we will explain in detail the working of CMAC, its features, advantages, and limitations.

Working of CMAC:

CMAC is a block cipher-based algorithm that uses a secret key to generate a message authentication code
(MAC) for a given message. The algorithm works by dividing the input message into fixed-length blocks,
each of which is processed by the block cipher in a special way.

The CMAC algorithm is based on the CBC-MAC (Cipher Block Chaining Message Authentication Code)
technique, which uses the block cipher in CBC mode to generate a MAC for a given message. However,
CMAC introduces some modifications to the CBC-MAC technique to overcome its limitations.
The CMAC algorithm can be summarized in the following steps:

1. Key Generation: A secret key is generated by the user, which is used to generate the MAC.
2. Padding: The input message is padded with zeros to ensure that its length is a multiple of the
block size.
3. Initialization: The algorithm initializes two block-sized vectors, denoted by L and R. The L
vector is used to generate the first MAC block, while the R vector is used for the remaining
blocks.
4. First Block Processing: The first block of the message is XORed with the L vector, and the
result is encrypted using the block cipher. The resulting ciphertext is then XORed with the R
vector.
5. Intermediate Block Processing: The remaining blocks of the message are processed in a similar
way. Each block is XORed with the previous ciphertext, encrypted using the block cipher, and
XORed with the R vector.
6. Final Block Processing: After all the blocks have been processed, the resulting ciphertext is
encrypted once more using the block cipher, and the result is XORed with the L vector to obtain
the final MAC value.
7. Output: The final MAC value is the output of the CMAC algorithm.

Features of CMAC:

1. Strong Security: CMAC provides strong security against various types of attacks, including
message forgery, replay attacks, and substitution attacks.
2. Fixed-Length Output: The output of the CMAC algorithm is a fixed-length MAC, which makes
it easy to compare and verify.
3. Efficient: CMAC is an efficient algorithm that can generate a MAC for a given message in a
short amount of time.
4. Key Reuse: The same key can be reused for multiple messages without compromising the
security of the MAC.
5. Easy Implementation: CMAC is easy to implement in software and hardware, making it a
popular choice for many applications.

Advantages of CMAC:

1. Resistance to Attack: CMAC is resistant to various types of attacks, including message forgery,
replay attacks, and substitution attacks. This makes it a secure choice for applications where data
integrity is critical.
2. Fixed-Length Output: The fixed-length output of CMAC makes it easy to compare and verify
MAC values, which simplifies the implementation of security protocols.
3. Efficient: CMAC is an efficient algorithm that can generate MAC values for large amounts of
data in a short amount of time. This makes it a good choice for applications that require fast
authentication of data.
4. Key Reuse: CMAC allows for key reuse, which simplifies the implementation of security
protocols and reduces the risk of key management errors.
5. Easy Implementation: CMAC is easy to implement in software and hardware, making

You might also like