Is Unit 3 PPT - Part 1
Is Unit 3 PPT - Part 1
Prepared By:
Dr.B.Veeramallu
Dept. of CSE ,GNITC
1
1. Message Encryption
2. Message Authentication Code.(MAC)
3. Hash function
Message Encryption approach for message authentication
Encryption itself can also provide authentication.
Symmetric Encryption:
If symmetric encryption is used then: Message M is transmitted from Source A to
B and encrypted using a secret(symmetric) key shared by A & B.
If no other party knows key, then confidentiality is provided.
Also Receiver B is Sure that message generated by A because secret key used by
only A and B ,so authenticity is provided.
B knows that message have not been altered, because attacker does not know key
to alter the message.
So we may say that symmetric encryption provides authentication and
confidentiality.
Public-Key Encryption
If public-key encryption is used:
– The public key encryption provides confidentiality but not authentication.
– Since B has its private key, only B can decrypt the message.
– No authentication because any attacker can use public key of B to encrypt the
message and claim to be A.
– To provide authentication, A uses its private key to encrypt and B uses A’s
public key to decrypt.
– It also provides digital signature as A has signed the message by using its
private key to encrypt.
Note that ,it does not provide confidentiality, as anyone having A’s public key can
decrypt the cipher text.
A can encrypt message M first using its private key, which provides authentication or
digital signature, and then encrypt using B’s public key which provides confidentiality.
Now B can decrypt using its own private key, and then public key of A.
The disadvantage of this is that the algorithm must be exercised four times rather than
two times.
Message Authentication Code (MAC)
• An alternative authentication technique.
• Involves the use of secret key.
• It takes a variable length message and a secret key to generate a
small fixed size block.
• This block of data is called cryptographic checksum or MAC that is
appended to the message.
• Assumes two communicating parties A and B share a common secret
key K.
• When A has to send message to B, it calculates MAC which is the
function of message and key as
• MAC = C(K,M)
• Message plus MAC is sent to the receiver.
• Receiver performs same computation on message using same secret
key and generate new MAC.
• Then received MAC is compared with calculated MAC.
If received MAC matches with calculated MAC ,then :
To allow for easy replace ability of hash function in case more secure
faster hash functions are required.
2. Append 0’s to the left end of the secret key K to create a b-bit string K+
(e.g. ,if K is of length 160 bits and b = 512, then K will be appended with
44 0’s in hexadecimal form)
3. The result of step 2 i.e. K+ is XORed (bitwise X-OR) with a constant called
ipad(input pad) to produce b- bit block Si.
HMAC Algorithm :
2. The attacker finds collisions in the hash function even when the
IV is random and secret.
HMAC security
Attacking HMAC requires either :
In the second attack , the attacker is looking for two messages M and M’ that
produce the same hash; H(M) = H(M’)
If speed is concern , MD5 is accepted rather than SHA-1 as the embedded hash
function for HMAC.
DAA , CMAC (MAC based on block ciphers)
• Can use any block cipher chaining mode and use final block as a MAC
• Data Authentication Algorithm (DAA) is a widely used MAC based on DES-
CBC.
• Using IV=0 and final block is padded on right with 0’s to form 64 bit block.
– Encrypt message using DES and secret key K in CBC mode.
– And then send just the final block ON as the MAC.
• Or the leftmost M bits (16≤M≤64) of final block.
• But final MAC is now too small for security.
• Figure: Data Authentication Algorithm
CMAC
Previously saw the DAA (CBC-MAC)
Widely used in govt. & industry.
The idea for CMAC is to create one block of MAC from N blocks of plaintext message using a
symmetric key block cipher N times.
CMAC
Firstly, we define the operation of CMAC when message is an integer multiple n of
cipher block length b ,i.e. length of each block of message is b-bits.
The algorithm use k-bit encryption key K and an n-bit constant key K1 applied only at
the last block.
For AES, the key size k is 128,192,256 bits, for triple DES, the key size is 128 or 168 bits.
CMAC Overview
Then CMAC is calculated as :
But the person who knows the original message can prove
the "hash value" is created from that message.
Hash Functions
It should be impossible to find two different messages
whose digests ("hash values") are similar.
The sender appends the hash code H(M) with the original message M
for authentication check and sent to the receiver.
At the receiving side , receiver compute the hash code for the received
message M.
The new hash code is compared with the received hash function H(M)
If both are equal, the receiver is assured that message come from the
authenticated person.
Hash Function Requirements and properties
To be useful for message authentication, hash function H must have
following Properties:
The Left of table shows the requirements, and right side lists the
properties of hash function.
Hash Function Requirements and properties
Two terms need to be defined :
Pre-image: For a hash value h = H(x), x is the pre-image of h i.e. the
message itself .
That is, x is the message block whose hash function is h using the
function H.
H is many to one function, means a single hash value can have
multiple pre-images.
Collision: It occurs if message block x ≠ y and H(x) = H(y). i.e.
So, collisions are undesirable because we use hash function for data
integrity.
Hash Function Requirements and properties
The first three properties are requirements for practical
application of hash function.
If hash function is not one way ,attacker easily gets secret value.
Hash Function Requirements and properties
The fifth property is second pre-image resistant (weak collision
resistant);
It means it is impossible to find an alternative message from the
same hash value as given message is having.
Following figures describe the ways in which a hash code can be used
to provide message authentication.
Examples of use of Hash Functions for Message Authentication :
In figure 1(a), the message plus hash code is encrypted using symmetric encryption.
Encryption applied to message and hash code provides confidentiality.
Hash code provides authentication.
Only A and B share secret key, message must have come from A without any modification.
In figure 1(b), only hash code is encrypted using symmetric encryption.
So in this, encrypted hash code and shared secret key is used.
It reduce processing for those applications that does not require confidentiality.
Examples of use of Hash Functions for Message Authentication continued ….
In figure 1(c), only hash function is used for authentication but no encryption .
It assumes that two parties share a common secret value S.
A computes hash value for combination of M and S and append it to M.
Only B has S, it re- compute hash value to verify.
Since, secret value S is not sent, attacker can not modify or generate false message.
In figure 1(d), confidentiality is added to the method (c), by encrypting the message plus hash code.
When confidentiality is not required ,Method (b) is better than method (a) and (d) which encrypts
the message in less computation.
Applications of Hash Function
2. Digital signatures( Non - repudiation):
It is another important application similar to message authentication.
Encrypt hash with private (signing) key Verify with public (verification)
key
The operation of digital signature is similar to MAC.
But In case of digital signature, the hash value of a message is
encrypted with sender’s private key.
The receiver who knows the sender’s public key can verify the
integrity of the message which is having digital signature.
So attacker who wants to alter the message must know the sender’s
private key.
Following figures shows how the hash code is used to provide digital
signature :
In figure 2(a) , the hash code is encrypted, using public key encryption with
sender’s private key which provides authentication.
It provides digital signature, because only sender have produced encrypted hash
code.
Figure 2(b) provides both confidentiality as well as digital signature because in
this , message plus private key encrypted hash code is encrypted again using a
symmetric secret key.
Other Hash Function Applications (Uses)
Used to create a one-way password file
Operating system stores hash of a password not actual
password
So actual password can not be retrieved by hacker who has
Symmetric Key
Advantages of hash function:
Designed for compatibility with increased security provided by the AES cipher
Structure & Detail of these hash algorithms is similar to SHA-1.
Hence analysis should be similar.
But security levels are rather higher.
53
Secure Hash Algorithm
In 2005, NIST phase out approval of SHA-1 and moved to SHA-2.
Shortly thereafter , an attack was described in which two messages delivered the
same SHA-1 hash using 269 operations which was less than previous 280
operations needed to find a collision in SHA-1.
This reason resulted transition to SHA-2.
Firstly we discuss SHA-1 :
Revised version of SHA published in 1995 as (FIPS -181).
Actual document is named “ Secure hash standard”.
Design is very similar to the hash function MD4.
Algorithm takes message of less than 264 bits length.
It produces 160 bits hash value or message digest.
It is slightly slower than MD5, but larger message digest makes it more secure.
Encipher the starting values using the 80 sub keys for message block.
Add each of 32 bit pieces of cipher text to the starting value, modulo 232 and use
that result as the starting value for handling next message block.
Message Digest Generation
Using SHA-1
55
Diagram of ShA-1
Steps or process of SHA-1 Hash Algorithm
Overall processing of message to produce a message digest or hash value is :
Step 1 Padding bits : Padding bits are added to the original message such that
length of padded message is 64 bits less than a multiple of 512 bits. i.e
448mod512
The input message block including padded message is of 512 bits only.
The padded message consists of single 1 bit followed by number of 0 – bits.
Step 2 Appending Length : Append 64 bit length value to the end of padded
message of the . These bits hold the binary format of 64 bits indicating the length
of the original message.
Step 3 Initialize buffer : To hold all intermediate results and the final result of the
hash function , we can use a 160-bit buffer.
It ca be made of 5 buffer registers of 32-bit size each (32*5 = 160) called
A,B,C,D,E.
These registers are initialized with following hexadecimal values :
A = 67452301, B = EFCDAB89 , C = 98BADCFE , D = 10325476 , E = C3D2E1F0
All these five buffer register values are stored in big endian format means MSB of
a word is in low address (leftmost) position where as in MD5 algorithm these
buffer register values are stored in little endian format.
Steps or process of SHA-1 Hash Algorithm
A = 67 45 23 01
B = EF CD AB 89
C = 98 BA DC FE
D = 10 32 54 76
E = C3 D2 E1 F0
Step 4 Processing message : The plaintext message and padded message plus
length field goes trough four rounds each having 20 steps.
To do this , we use four separate compression function f1, f2, f3, f4.
Each function takes plaintext message block of 512 bits Yq and the values of A, B,
C, D, and E.
It also takes an additive constant Kt.
So total processing will require 20*4 = 80 steps.
Step 5 : Now the output obtained after last step is added with initial values of
160-bits buffer Cyq to produce 160 bit message.
SHA-512
The algorithm takes a message with maximum length of less than 2128 bits as input
and produces 512- bit message digest or hash value as output.
The input is processed in 1024 bit blocks.
Now we examine the structure of SHA-512 ,and other versions are quite similar.
SHA-512 follows the structure shown in following figure.
The processing consists of the following steps :
Step 1 Append padding bits : Append padding bits so that its length =
896mod1024
The padding bits is always added ,even if the message is already of desired length.
Padding consists of a single 1 bit followed by necessary number of 0 bits.
Step 2 Append length : A block of 128 bits is appended to the message.
The output of these two steps gives the message which is an integer multiple of
1024 bits in length.
In figure, the expanded message is a sequence of 1024- bit blocks M 1 , M2 ,…MN.
So total length of the expanded message is N*1024 bits.
SHA-512
Step 3 Initialize hash buffer : To hold intermediate and final results of hash
function a 512-bit buffer is used.
The buffer is made up of eight 64- bit registers (a,b,c,d,e,f,g,h).
These registers are initialized to the following 64 bit integers (hexadecimal values) :
These values are stored in big endian format, which is the most significant byte of a
word in the left-most byte position.
These words are obtained by taking first 64 bits of the fractional parts of square
root of first eight prime numbers.
Step 4 Process the message in 1024- bit (128 words) :
This step is the heart of algorithm
SHA-512 Overview
SHA-512
It consist of 80 rounds; it is represented as F in above diagram.
Each round takes 512- bit buffer values a,b,c,d,e,f,g,h, as input and updates the
contents of buffer.
At the first round, the buffer has the value of intermediate hash value Hi-1.
Each round ‘t’ use 64 bit value Wt,derived from current 1024- bit block (Mi)
Each round also make use of an additive constant Kt ,where (0 <=t <= 79) indicates
one of the 80 rounds.
These words are the first 64 bits of the fractional parts of cube roots of first 80
prime numbers, provides random set of 64- bit patterns, which eliminate regularity.
The output of last round is added to the input to the first round Hi-1 to produce Hi.
The addition is done independently for each of the eight words in the buffer with
each of the corresponding words in Hi-1 using addition modulo 264.
Step 5 Output : After all N 1024- bit blocks have been processed , the output from
the last stage is 512- bit hash value or message digest.
We can summarize the behavior of SHA-512 as follows :
Ho = IV , Hi = SUM64 (Hi-1 , abcdefghi ) , MD = HN
SHA-512
Where, IV = initial value of the abcdefgh buffer shown in step 3
abcdefghi = the output of the last round of processing of the ith message block
N = the number of blocks in the message (including padding and length fields)
SUM64 = addition modulo 264 performed separately on each word of the pair of inputs.
MD = final message digest value or hash value.
SHA-512 Round Function
SHA-512 Compression Function
Heart of the algorithm
Processing message in 1024-bit blocks
Consists of 80 rounds
Updating a 512-bit buffer
Using a 64-bit value Wt derived from the current message block
and a round constant based on cube root of first 80 prime numbers
The structure of each of the 80 rounds is shown in above figure.
Each 64-bit word is shuffled along one place, and in some cases manipulated
using a series of simple logical functions (ANDs, NOTs, ORs, XORs, ROTates), in
order to provide the avalanche & completeness properties of the hash
function.
Ch(e,f,g) = (e AND f) XOR (NOT e AND g)
Maj(a,b,c) = (a AND b) XOR (a AND c) XOR (b AND c)
∑(a) = ROTR(a,28) XOR ROTR(a,34) XOR ROTR(a,39)
∑(e) = ROTR(e,14) XOR ROTR(e,18) XOR ROTR(e,41)
+ = addition modulo 2^64
SHA-512 Compression Function
Kt = a 64-bit additive constant
Wt = a 64-bit word derived from the current 512-bit input block.
ROTR (n,x) = circular right shift (rotation of 64 bit argument x by n bits)
Six of the eight words of the output of the round function involve simply
permutation (b, c, d, f, g, h) by means of rotation.
This is indicated by shading in next figure.
Only two of the output words (a, e) are generated by substitution.
Word e is a function of input variables d, e, f, g, h, as well as the round word W
t and the constant Kt.
Word a is a function of all of the input variables, as well as the round word W t
and the constant Kt.
SHA-512
Next Figure illustrates how the 64-bit word values Wt are derived from the 1024-
bit message.
The first 16 values of Wt are taken directly from the 16 words of the current block.
The remaining values are defined as a function of the earlier values using ROTates,
SHIFTs and XORs as shown.
The function elements are:
∂0(x) = ROTR(x,1) XOR ROTR(x,8) XOR SHR(x,7)
∂1(x) = ROTR(x,19) XOR ROTR(x,61) XOR SHR(x,6)
Thus, in the first 16 steps of processing, the value of Wt is equal to the
corresponding word in the message block.
For the remaining 64 steps, the value of Wt consists of the circular left shift by one
bit of the XOR of four of the preceding values of Wt, with two of those values
subjected to shift and rotate operations.
This introduces a great deal of redundancy and interdependence into the message
blocks that are compressed, which complicates the task of finding a different
message block that maps to the same compression function output.
SHA-512 Round Function
The Whirlpool Secure Hash Function
79
The Whirlpool Secure Hash Function
80
Digital Signatures
• A digital signature is an authentication mechanism that enables the
sender of a message to attach a code that acts as a signature.`
Figure: Digital Signature Mechanism with the essential elements of Digital signature Process.
• Characteristics of Digital Signature :
• Un-forgeable
• Not reusable
• Unalterable
• It refers to a digital signature scheme that involve only sender & receiver
• Step 3 : Sender X has a message M & computes its hash code H(M).
• Signature consists of : Identifier (ID) of sender X ,Encrypted Hash
code using secret key k2
• It was developed in 1991 and revised in 1993, 1996 & then 2000.
• The DSS uses the Secure hash algorithm (SHA) and presents new digital
signature technique ,Digital signature Algorithm.
• Receiver takes the message and produces a hash code and decrypt the
signature using sender’s public key
• Because only sender knows his private key, only he can produce a valid
signature.
DSS vs RSA Signatures approach
Digital Signature Standard (DSS)
• DSS Approach :
• DSS is designed to provide digital signature only.
• Only sender who has private key can produce the valid signature.
Digital Signature Algorithm (DSA)
Proposed by NIST in August 1991
Have three parameters that are public and common to a group of users
Digital Signature Algorithm (DSA)
A 160 bit prime number q is chosen.
Choose Private key ‘x’ is number from 1 to (p-1) i.e. x<q and chosen
randomly
w = s-1 mod q
u2= (rw)mod q
107
Digital Signature
• Sender encrypts message with their private
key
• Receiver can decrypt using sneders public key
• This authenticates sender, who is only person
who has the matching key
• Does not give privacy of data
– Decrypt key is public
108
Generic Model of Digital Signature Process
109
Generic Model of Digital Signature Process
110
Digital signature-RSA approach
111
Digital signature-RSA approach
112
Digital signature-DSA approach
113
Digital signature-DSA approach
• The hash code is provided as input to a signature function along with a random
number k generated for this particular signature.
• The signature function also depends on the sender’s private key (PRa) and a set
of parameters known to a group of communicating principals.
• We can consider this set to constitute a global public key (PUG).The result is a
signature consisting of two components, labeled s and r.
• At the receiving end, the hash code of the incoming message is generated. This
plus the signature is input to a verification function.
• The verification function also depends on the global public key as well as the
sender’s public key (PUa), which is paired with the sender’s private key.
• The output of the verification function is a value that is equal to the signature
component r if the signature is valid.
• The signature function is such that only the sender, with knowledge of the
private key, could have produced the valid signature.
114
Digital signature-DSA approach
sender’s private key (PRa), sender’s public key (PUa)
a global public key (PUG), H (Secure Hash Algorithm (SHA))
115
The Digital Signature Algorithm (DSA)
116
ElGamal Digital Signatures
• Signature variant of ElGamal, related to D-H
– Uses exponentiation in a finite (Galois)
– security is based on difficulty of computing discrete
logarithms, as in D-H
– Signature is :(S1,S2)
ElGamal Digital Signature
– Signature is valid if V1 = V2
ElGamal Signature Example