L5.pptx
L5.pptx
L5.pptx
Sender Site
3. Sender encrypts the message digest with his/her private key for
authentication. This encrypted message digest is called digital
signature.
4. Sender attaches the digital signature to the end of the message that is
to be sent. The message attached with digital signature is known as
digitally signed message.
5. The sender encrypts the digitally signed message with the recipient’s
public key and sends it to the recipient.
6. After receiving, the recipient decrypts the entire message with his/her
private key.
7. The recipient detaches the message and digital signature.
8. He/she creates a “digest” of the received message using the same
Site
Receiver
Slide-6
Digital Signature Vs. Conventional Signature
Key-point Conventional Digital Signature
Signature
Relationship For a conventional For a digital signature, there is a
signature, there is one-to-one relationship between a
normally a signature and a message. Each
one-to-many message has its own signature. The
relationship between a signature on one message can not be
signature and used in another message. For example, if
documents. A person Bob receives two messages, one after
uses the same signature another, from Alice, he can not use the
to sign many documents. signature of the first message to verify
the second. Each message needs a new
signature.
Duplicity In conventional signature, In digital signature, there is no such
a copy of the signed distinction unless there is a factor of time
document can be (such as a timestamp) on the document.
distinguished from the For example, suppose Alice sends a
original one on file. document instructing Bob to pay Eve. If
the intercepts the documents and the
signature, she can replay it later to get
money again from Bob.
Slide-7
Services Provided by Digital Signature
Slide-8
Services Provided by Digital Signature
Message Authentication:
A digital signature’s main function is to verify that a message or document,
in fact, comes from the claimed sender. That is, to provide authentication
is the main function of digital signature.
Message Integrity:
The integrity of the message is preserved even if we sign the whole
message because we cannot get the same signature if the message is
changed. Therefore, digital signature provides the integrity of the
message.
Non-Repudiation:
Attaching a digital signature with message prevents repudiation. This
ensures that the sender should not be able to later deny that he/she sent a
message. Non-repudiation prevents sender and vendor in a transaction or
communication activity from later falsely denying that the transaction
occurred.
N.B. As contrast to encryption scheme, digital signature does not provides the
confidentiality of the message.
Slide-9
Massage Authentication Code (MAC)
• A Message Authentication Code (MAC) is a short piece of information used to
authenticate a message and ensure its integrity. Here’s a brief overview:
1. Purpose: A MAC verifies that the message came from the stated sender
(authenticity) and that it hasn’t been altered (integrity).
2. How It Works:
1. Key Generation: A secret key is generated and shared between the sender
and the receiver.
2. MAC Generation: The sender uses the secret key and a MAC algorithm to
produce a MAC tag from the message.
3. Transmission: The message and the MAC tag are sent to the receiver.
4. Verification: The receiver uses the same secret key and MAC algorithm to
generate a MAC tag from the received message and compares it with the
received MAC tag. If they match, the message is verified as authentic and
unaltered
Message Authentication Code (MAC) Vs. Digital Signature
Slide-11
Hash Function
A hash function is a formula or an algorithm that-
❖ takes large data sets of variable length as input, and
❖ returns smaller data sets of fixed length as output.
Slide-13
Cryptographic Hash Function
In cryptographic hash function, even a small changes in the input
would cause a large change in the output.
Figure below shows how the slight changes input (here in the word
"over") drastically change the resulting output.
Slide-14
Illustration: Cryptographic Hash Function
An illustration of the potential use of a cryptographic hash is as
follows:
❖ Alice poses a tough math problem to Bob and claims she has solved it.
❖ Bob would like to try it himself, but would yet like to be sure that Alice
is not bluffing. Therefore, Alice writes down her solution, computes its
hash and tells Bob the hash value (whilst keeping the solution secret).
Then, when Bob comes up with the solution himself a few days later,
Alice can prove that she had the solution earlier by revealing it and
having Bob hash it and check that it matches the hash value given to
him before.
Slide-15
Use of Hash Function
Cryptographic hash functions have many information security
applications, such as in-
❖ digital signatures
❖ message authentication codes (MACs)
❑ The last version MD5 is more secured than the previous versions.
❑ It divides the message into blocks of 512 bits and creates a 128-bit
digest.
❑ SHA-1:
❑ SHA stands for Secure Hash Algorithm.
❑ Both MD5 and SHA-1 hash functions are built with the
Slide-17 Merkle-Damgard construction.
Application of Hash Function in Cryptography
Slide-18
Application of Hash Function in Cryptography
Verifying password for secure login:
❖ A related application of hash function is password verification.
❖ Storing all user passwords as plaintext character can result in a massive
security breach if the password file is compromised.
❖ One way to reduce this danger is to only store the hash digest of each
password instead of the plaintext password in the table (a file) that is
stored by user identification.
❖ Any user can read the contents of the file, but, because the hash
function is a one-way function, it is almost impossible to guess the
value of the password.
❖ When the password is created , the system hashes it and stores the
hash in the password file.
❖ When the user sends her user ID and password, the system creates a
hash of the password and then compare the hash value with the one
stored in the file.
❖ If there is a match, the user is granted access; otherwise, access is
denied.
Slide-19
Application of Hash Function in Cryptography
File or data identifier:
❖ A message digest can also serve as a means of reliably identifying
a file;
Authentication:
❖ Authentication is the assurance that the communicating entity is
the one that it claims to be.
Slide-20
Application of Hash Function in Cryptography
Digital Signature:
❖ Digital signature, first proposed in 1976 by Whitfield Diffie of
Stanford University, is a digital code (encrypted message digest)
that can be attached to an electronically transmitted message that
uniquely identifies the sender.
❖ Like a written signature, the purpose of a digital signature is to
guarantee that the individual sending the message really is who he
or she claims to be. It is linked to the data in such a manner that if
the data is changed, the digital signature is invalidated.
❖ When making a digital signature, cryptographic hash functions are
generally used to construct the message digest.
❖ A digital signature servers three important purposes:
❑ Verifies data integrity.
❑ Provides authentication of the sender.
❑ Provides non-repudiation
Slide-21
Properties of Cryptographic Hash
Function
• 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.
Simple Hash Function
Some Popular Hash Function:
Here are some relatively simple hash functions that have been
used:
Division-remainder method
Mid-square method
Folding method
Division-remainder method:
Using this method, choose a number m that is larger than
the number n of keys in K (K is a set of keys). Generally,
the number m is chosen to be a prime number. The hash
function H is defined as:
H(k)= k (mod m) or, H(k)= k (mod m)+1
Here k (mod m) denotes the remainder when k is divided
by m.
The second formula is used when we want the hash
Slide-23 addresses to range from 1 to m rather than from 0 to m-1.
Simple Hash Function
Example: Division-remainder method:
Suppose a company with 68 employees assigned a 4-digit employee number
to each employee which is used as the primary key. Apply the division
method of hash function to each of the following employee number:
3205, 7148, 2345
Solution:
Since, there are 68 employees in the company, two digit employee
number is sufficient to represent them.
Highest 2 digit number is 99 and 97 is the nearest 2 digit prime
number of 99. So, we divide each of the 4 digit employee number by
97.
H(3205)= 3205 (mod 97)= 04.
H(7148)= 7148 (mod 97)= 67
H(2345)= 2345 (mod 97)= 17
In the case that the memory addresses begin with 01 rather than 00,
we choose that the function H(k) = k(mod m)+1 to obtain. H(3205)=
3205 (mod 97)+1= 4+1=05
Slide-24
Simple Hash Function
(Mid-Square Hashing)
• Mid-Square hashing is a hashing technique in which unique keys are
generated.
• In this technique, a seed value is taken and it is squared.
• Then, some digits from the middle are extracted.
• These extracted digits form a number which is taken as the new seed.
• This technique can generate keys with high randomness if a big enough
seed value is taken.
• However, it has a limitation.
• As the seed is squared, if a 6-digit number is taken, then the square will
have 12-digits.
• This exceeds the range of int data type. So, overflow must be taken care
of.
Simple Hash Function
Example: Mid-square method
Suppose a company with 68 employees assigned a 4-digit employee number
to each employee which is used as the primary key. Apply the mid-square
method of hash function to each of the following employee number:
3205, 7148, 2345
Solution:
Observe that the 4th and 5th digits counting from right are chosen for
the hash address.
Slide-26
Simple Hash Function
Folding method:
Folding Method in Hashing: It breaks up a key value into precise segments that are added
to form a hash value
Algorithm:
•The folding method is used for creating hash functions starts with the item being
divided into equal-sized pieces i.e., the last piece may not be of equal size.
•The outcome of adding these bits together is the hash value, H(x) = (a + b + c) mod
M, where a, b, and c represent the preconditioned key broken down into three parts
and M is the table size, and mod stands for modulo.
•In other words, the sum of three parts of the preconditioned key is divided by the
table size. The remainder is the hash key.
Slide-27
• Example 1: The task is to fold the key 123456789 into a Hash
Table of ten spaces (0 through 9).
• It is given that the key, say X is 123456789 and the table size (i.e., M =
10).
• Since it can break X into three parts in any order. Let’s divide it evenly.
• Therefore, a = 123, b = 456, c = 789.
• Now, H(x) = (a + b + c) mod M i.e., H(123456789) =(123 + 456 +
789) mod 10 = 1368 mod 10 = 8.
• Hence, 123456789 is inserted into the table at address 8.
SHA-256
• SHA 256 is a part of the SHA 2 family of algorithms, where SHA stands for
Secure Hash Algorithm. Published in 2001, it was a joint effort between the
NSA and NIST to introduce a successor to the SHA 1 family, which was
slowly losing strength against brute force attacks.
• The significance of the 256 in the name stands for the final hash digest
value, i.e. irrespective of the size of plaintext/cleartext, the hash value will
always be 256 bits.
Characteristics of SHA-256
• Some of the standout features of the SHA algorithm are as
follows:
• Message Length:
• The length of the cleartext should be less than 264 bits. The size needs to be in
the comparison area to keep the digest as random as possible.
• Digest Length:
• The length of the hash digest should be 256 bits in SHA 256 algorithm, 512 bits
in SHA-512, and so on. Bigger digests usually suggest significantly more
calculations at the cost of speed and space.
• Irreversible:
• By design, all hash functions such as the SHA 256 are irreversible. You should
neither get a plaintext when you have the digest beforehand nor should the digest
provide its original value when you pass it through the hash function again.
Algorithm
1.Message Padding:
• The original message is padded so that its length is 64 bits less than a multiple of 512. This
padding includes a single ‘1’ bit followed by ‘0’ bits, and the length of the original message is
appended at the end.
2. Message Parsing: T
The padded message is divided into 512-bit blocks.
3. Initialization of Buffers:
Eight 32-bit words are used as initial hash values. These are constants derived from the
fractional parts of the square roots of the first eight prime numbers.
4. Processing Blocks:
Each 512-bit block is processed in a series of 64 rounds involving bitwise operations, modular
additions, and compression functions. This step uses a set of 64 constant values derived from
the fractional parts of the cube roots of the first 64 prime numbers.
5. Final Hash Value:
After all blocks are processed, the final hash value is produced by concatenating the hash
values from the eight buffers.
Application of SHA-256
• Digital Signature Verification:
• Digital signatures follow asymmetric encryption methodology to verify the
authenticity of a document/file. Hash algorithms like SHA 256 go a long way in
ensuring the verification of the signature.
• Password Hashing:
• As discussed above, websites store user passwords in a hashed format for two
benefits. It helps foster a sense of privacy, and it lessens the load on the central
database since all the digests are of similar size.
• SSL Handshake:
• The SSL handshake is a crucial segment of the web browsing sessions, and it’s
done using SHA functions. It consists of your web browsers and the web servers
agreeing on encryption keys and hashing authentication to prepare a secure
connection.
• Integrity Checks:
• As discussed above, verifying file integrity has been using variants like SHA 256
algorithm and the MD5 algorithm. It helps maintain the full value functionality of
files and makes sure they were not altered in transit.
Message Authentication Code (MAC) Vs. Hash Code
MAC is a technique for message authentication which involves the use of a
secret key to generate from a small block of data, known as a message
authentication code, that is appended to the message.
This technique assumes that two communicating parties, say Alice and
Bob, share a common secret key KAB. When Alice has a message to send to
Bob, she calculates the message authentication code as a complex function
of the message and the key: MACM = F(KAB, M).
Slide-29
Message Authentication Code (MAC) Vs. Hash Code
If we assume that only the receiver and the sender know the identity
of the secret key, and if the received code matches the calculated
code, then
1. The receiver is assured that the message has not been altered.
❖ If an attacker alters the message but does not alter the code, then the
receiver’s calculation of the code will differ from the received code.
❖ Because the attacker is assumed not to know the secret key, the
attacker cannot alter the code to correspond to the alterations in the
message.
2. The receiver is assured that the message is from the alleged sender.
❖ Because no one else knows the secret key, no one else could prepare a
message with a proper code.
Slide-30
Message Authentication Code (MAC) Vs. Hash Code
Slide-31
Message Authentication Code (MAC) Vs. Hash Code
Figure below illustrates three ways in
which the message can be
authenticated using a hash code.
❑ The message digest can be encrypted
using symmetric key encryption (part a); if
it is assumed that only the sender and
receiver share the encryption key, then
authenticity is assured.
❖ Digital Signature
❑ To be familiar with the general idea behind
digital signature
❑ To define security services provided by a
digital signature
❑ To describe some applications of digital
signatures
❖ Cryptographic Hash Function
❑ To introduce general ideas behind hash
function
❑ To discuss the usage and application of hash
function
❑ To know the desirable properties of a hash
Slide-37 function