You are on page 1of 8

NIGERIAN ARMY UNIVERSITY BIU

FACULTY OF COMPUTING

DEPARTMENT OF CYBER SECURITY

COURSE TITLE
CRYPTOGRAPHY: ALGORITHM & APPLICATION

COURSE CODE
CBS 416
QUESTIONS
1. Explain Message Integrity.
2. Explain Message Authentication Codes.
3. Explain Hash Function.
4. Their uses and applications.

1. MESSAGE INTEGRITY

Message integrity in cryptography is for the guarantee that a message has not been modify,
altered or tampered with during transmission. It assures that the recipient of a message can verify
that the received message is exactly the same as the one sent by the sender.

Message integrity is important in cryptograph as it helps protect against unauthorized


modifications, forgery, or corruption of data. Without message integrity, an attacker could
potentially modify the contents of a message without the recipient being aware, leading to
potential security breaches or compromised data.

There are various methods and mechanisms used to ensure message integrity in cryptography:

1. Message Authentication Codes (MAC): MAC is a cryptographic technique that uses a secret
key to generate a fixed-size tag or code for a message. This tag is appended to the message and
can be used by the recipient to verify the integrity of the message. Popular MAC algorithms
include HMAC (Hash-based MAC) and CBC-MAC (Cipher Block Chaining-MAC).

2. Digital Signatures: Digital signatures provide both authentication and integrity. They use
public-key cryptography to generate a unique signature for a message that can be verified using
the sender's public key. The signature ensures that the message has not been modified during
transmission and that it came from the genuine sender. A digital signature is generated using the
sender's private key and appended to the message. The recipient can use the sender's public key
to verify the signature, ensuring that the message has not been altered and that it was indeed
sent by the claimed sender. In both cases, if any modification is made to the message during
transmission, the MAC or digital signature will not match, indicating that the message has been
tampered with. This helps to ensure the integrity of the message and provides confidence in its
authenticity.

3. Hash Functions: Hash functions, as mentioned earlier, generate a fixed-size digest or hash
value for a given message. By comparing the received hash with the computed hash of the
received message, the recipient can verify the integrity of the message.

4. Secure Hash Algorithms: Secure hash algorithms like SHA-256 or SHA-3 are widely used for
message integrity. These algorithms generate a hash value that is resistant to tampering, making
it computationally infeasible to modify the message and retain the same hash value.

5. Message Authenticity: Apart from ensuring the integrity of the message, mechanisms like
digital certificates, public key infrastructure (PKI), and authenticated key exchanges can also
establish the authenticity of the sender, ensuring that the received message is indeed from the
expected source.

1.1 How does message integrity works?


1. Sender's Side:
 The sender takes the original message that needs to be transmitted.
 The sender applies a cryptographic hash function to the message, generating a fixed-length
hash value or digest.
 The sender encrypts the message (if necessary) and sends both the encrypted message
and the hash value to the receiver.

2. Receiver's Side:
 The receiver receives the encrypted message and the hash value.
 The receiver decrypts the message (if necessary).
 The receiver applies the same cryptographic hash function used by the sender to the
received message, generating a new digest.
 The receiver compares the received hash value with the computed hash value.
 If the two hash values match, the receiver can be confident that the message has not been
tampered with and that it is intact.

The diagram below illustrates how the receiver can verify the integrity of the message by
comparing the hash value received with the computed hash value. If they match, it indicates that
the message has not been modified during transmission and that its integrity is preserved. Data or
Message Integrity is different from data confidentiality. In confidential data transmission, the data
is encrypted before transmission and therefore only the intended recipient will be able to recover
the data. Confidential data may be accompanied by a Message Integrity Code, but it is not
required. The intended recipient of confidential data with no MIC is confident that the data has
not been recovered by an intruder, but the data may have been changed in transit. On the other
hand, data can be transmitted unencrypted but accompanied with a MIC. In this case, the data is
not confidential, but its authenticity can be verified.

The role of AES-CCM in data authentication and confidentiality, on the transmitter side, the
plaintext in the form of 128-bit blocks of data enters the AES-CCM. The responsibility of the AES-
CCM is to encrypt the data and generate an associated MIC, which is sent to the receiver along
with the frame. The receiver uses the AES-CCM to decrypt the data and generate its own MIC
from the received frame to be compared with the received MIC. The CCM is referred to as a
generic mode of operation that combines the encryption and data authentication. The CCM offers
encryption-only and integrity-only capabilities.

Diagram showing Application of the Message Integrity Code (MIC) in Data Authentication

1.2 USES AND APPLICATIONS OF MESSAGE INTEGRITY


Here are some of the uses and applications of message integrity:

1. File and software integrity: Message integrity techniques, such as checksums or hash
functions, are used to verify the integrity of files, software, or firmware during distribution,
installation, or execution. They ensure that the files have not been modified or corrupted.

2. Secure protocols and APIs: Message integrity is employed in secure protocols and APIs to
safeguard the integrity of communication and prevent data tampering. It helps validate that the
received data has not been modified or altered.

3. IoT and sensor networks: Message integrity is crucial in Internet of Things (IoT) and sensor
networks, where various devices communicate and exchange data. It ensures the integrity and
authenticity of sensor data, preventing malicious actors from manipulating or forging sensor
readings.

4. Network security: Message integrity plays a role in network security mechanisms like
firewalls, intrusion detection systems (IDS), and network monitoring tools. It helps detect
tampering attempts and ensures that network traffic remains unaltered.

5. Secure communication: Message integrity is essential in secure communication protocols like


SSL/TLS, SSH, and IPsec. It helps to verify that data transmitted over these protocols has not
been tampered with during transit.

6. Data storage and backup: Message integrity is crucial in ensuring the integrity of data stored
in databases, file systems, or backups. It allows the detection of any unauthorized modifications
or corruption of stored data.

7. Digital signatures: Message integrity is a fundamental component of digital signatures. It


ensures that a digitally signed message remains intact and unaltered, providing authenticity, non-
repudiation, and integrity of the signed data.

8. Digital forensic analysis: Message integrity is valuable in digital forensic investigations. It


assists in verifying the integrity of digital evidence, ensuring that the collected data has not been
altered or tampered with.
2. MESSAGE AUTHENTICATION CODE

Message Authentication Code also known as (MAC) is a cryptographic technique used to ensure
the integrity and authenticity of a message. It is a type of symmetric key algorithm that involves
the use of a secret key shared between the sender and the receiver.

Here is an explanation of how MAC works:

1. Sender's Side:
 The sender takes the original message that needs to be transmitted.
 The sender applies a MAC algorithm to the message along with a secret key, generating a
MAC tag.
 The sender sends both the original message and the MAC tag to the receiver.

2. Receiver's Side:
 The receiver receives the message and the MAC tag.
 The receiver applies the same MAC algorithm to the received message using the shared
secret key, generating a new MAC tag for comparison.
 The receiver compares the received MAC tag with the computed MAC tag.
 If the two MAC tags match, the receiver can be confident that the message has not been
tampered with and that it is authentic and intact.

The MAC provides message authentication by using a secret key that only the sender and receiver
possess. If an attacker tries to modify the message during transmission, the computed MAC tag at
the receiver's end will not match the received MAC tag, indicating that the message integrity has
been compromised.

It is important to note that MAC only protects against tampering and ensures authenticity of the
message, but it does not provide confidentiality. If confidentiality is also desired, encryption can
be combined with MAC to achieve both integrity and confidentiality.

Image showing Message Authentication: Only A and B share K

2.1 MAC PROPERTIES


MAC is a cryptographic checksum
MAC = CK(M)
 condenses a variable-length message M
 using a secret key K
 to a fixed-sized authenticator
 is a many-to-one function
 potentially many messages have same MAC
 but finding these needs to be very difficult
2.2 MESSAGE AUTHENTICATION CODES (MACS) USES AND APPLICATIONS

1. Data Integrity: MACs are primarily used to verify the integrity of data during transmission. By
generating and comparing MAC tags, it ensures that the received data has not been tampered
with or modified.

2. Message Authentication: MACs provide a means to authenticate the origin of a message. By


using a secret key known only to the sender and receiver, MACs can verify that the message is
indeed sent by the claimed sender.

3. Password Protection: MACs can be used to protect passwords during storage or


transmission. Instead of storing passwords in plain text, a MAC can be generated from the
password, ensuring that even if an attacker gains access to the MAC, they cannot derive the
original password.

4. Secure Communication: MACs can be used in combination with encryption algorithms to


provide a secure communication channel. By encrypting the message for confidentiality and
generating a MAC for integrity and authentication, the receiver can be assured that the message
is both secure and intact.

5. Digital Signatures: MACs can be used in digital signature schemes. In this case, the sender
generates a MAC using their private key and attaches it to the message. The receiver can then
verify the authenticity and integrity of the message by verifying the MAC using the sender's public
key.

6. Network Security: MACs are used in various network security protocols and algorithms, such
as IPsec (Internet Protocol Security) and SSL/TLS (Secure Sockets Layer/Transport Layer
Security), to ensure secure communication and protect against data tampering.
3. HASH FUNCTIONS
A hash function is a mathematical function that takes an input (or "message") and produces a
fixed-size string of characters, which is typically a sequence of numbers and letters. The output is
commonly referred to as the "hash value" or simply "hash." The primary purpose of a hash
function is to convert data of arbitrary size into a unique, fixed-size representation.

For example, if the hash function SHA256 is used to determine the hash value for “Hello” the
output shall be the following digest:
SHA256 (Hello) =
104123755207289804956272089233072171500574028163694787093464498998073160165519

In this example, “Hello” is translated into a set of bits, from which, after a series of operations, a
256-bit string is obtained (here represented by its value in decimal notation).

In general, hash functions work as follows:


 The input message is divided into blocks.
 Then the hash for the first block, a value with a fixed size, is calculated for the first block.
 Then, the hash for the second block is obtained and added to the previous output.
 This process is repeated until all blocks are calculated.

3.1 CHARACTERISTICS OF HASH FUNCTIONS:

1. Preimage Resistance: It should be computationally infeasible to reconstruct the original input


from the hash value. In other words, given a hash value, it should be extremely difficult to find a
message that produces that specific hash.

2. Deterministic: Given the same input, a hash function will always produce the same hash
value. This property ensures reproducibility.

3. Fixed Output Size: Hash functions generate output of a fixed length, regardless of the size of
the input. For example, a common hash function, such as SHA-256 (Secure Hash Algorithm 256-
bit), produces a hash value of 256 bits.

4. Collision Resistance: A hash function should strive to minimize the probability of two
different inputs producing the same hash value. While it's theoretically possible for two different
inputs to result in the same hash (collision), a good hash function minimizes the likelihood of such
occurrences.

3.2 HASH FUNCTIONS USES AND APPLICATIONS

1. Data Integrity and Verification: Hash functions are commonly used to ensure the integrity
of data. By generating a fixed-size hash value (digest) from a given input, hash functions can
detect any changes made to the data. This is useful for verifying the integrity of files, messages,
or digital signatures.

2. Password Storage: Hash functions are employed to store passwords securely. Instead of
storing the actual passwords, the hash of the password is stored. When a user attempts to log in,
their input is hashed and compared against the stored hash. This way, even if the password
database is compromised, the original passwords are not easily revealed.
3. Cryptographic Applications: Hash functions play a crucial role in many cryptographic
protocols. For example, they are used in digital signatures, key derivation functions, message
authentication codes (MACs), and various other cryptographic constructs. Hash functions help
ensure data integrity, non-repudiation, and authentication.

4. Data Structures: Hash functions are fundamental in various data structures, such as hash
tables. Hash tables provide efficient data retrieval by mapping keys to array indices using hash
functions. This allows for constant-time average case access to stored values.

5. Data Indexing and Searching: Hash functions can be used for indexing and searching data
efficiently. In databases, hash-based indexing allows for fast retrieval of records based on their
keys. Additionally, in content-addressable storage systems, hash functions are used to uniquely
identify and locate data chunks.

6. Digital Forensics: In digital forensics, hash functions are used to create unique identifiers,
known as digital fingerprints, for files or disk images. These fingerprints can be used to identify
known malicious files, detect file tampering, or perform file deduplication.

7. Data Deduplication: Hash functions help identify duplicate data chunks in storage systems.
By comparing hash values, identical chunks can be identified and stored only once, reducing
storage requirements.

8. Caching: Hash functions are utilized in caching mechanisms to quickly determine whether a
requested item is present in the cache. By hashing the item's identifier, the cache can efficiently
check if the item is already stored, avoiding the need for resource-intensive lookups.

9. Bloom Filters: Bloom filters are probabilistic data structures that use hash functions to test set
membership efficiently. They are commonly employed in scenarios where false positives are
acceptable, such as caching, spell-checking, and network routing.

References

1. Susan Landau, “Find Me a Hash,” Notices of the American Mathematical Society, 53(3),
March 2006, 330 – 332.
2. Richard Spillman, Classical and Contemporary Cryptology, Prentice Hall, 2005.
This text has a nice discussion of MD5 and SHA.
3. S. Granger, Social Engineering Fundamentals, Part I: Hacker Tactics, Security Focus, 2001.
4. A. Wagner, Computer Engineering Attacks, Techniques & Prevention, UK: Lightning Source,
2019.
5. Ana Ferreira and Gabriele Lenzini. (2015) “An Analysis of Cryptography Principles in
Effective Phishing” Workshop on Socio-Technical Aspects in Security and Trust: 9-16.
6. Fatima Salahdine and Naima Kaabouch (2019) “Encryption Algorithm Attacks: A
survey” Future Internet 11(89).

You might also like