CSS 2 PPT Notes Handwritten
CSS 2 PPT Notes Handwritten
Digital Certificates
Hash
Hashing and Hash Functions
• A hash function H accepts a variable-length block of data M as input and
produces a fixed-size hash value h=H(M)
• A god hash function has the property that the results of applying the
function to a large set of inputs will produce outputs that are evenly
distributed and apparently random.
• In general terms, the principal object of hash function is data integrity.
A change to any bit or bits in M results, with high propability , in a
change to the hash code.
• Kind of hash function needed for security applications is referred to as a
cryptographic hash function.
• A cryptographic hash function is an algorithm for which it is
computationally infeasible (virtually impossible) to find either
• A) a data object that maps to pre-specified hash result (the one-way
property) or
• B) two data objects that maps to the same hash results (the collision free
property)
1. Message Authentication
2. Digital Signature
1. Message Authentication
•Message authentication is a mechanism or service used to verify
the integrity od a message. Message authentication assures that
data received are exactly as sent (i.e contain no modification ,
insertion, deletion, or replay)
•In many cases there is a requirement that the authentication
mechanism assures that purported identity of the sender is valid.
•When a hash function is used to provide message authentication ,
the hash function value is often referred to as a message digest
• The sender computes a hash Common scenario
value as a function of the bits in
the message and transmits both
the hash value and the
message.
• The receiver performs the same
hash calculation on the
message bits and compares this
value with the incoming hash
value.
• If there is a mismatch , the
receiver knows that the
message (or possibly hash
value) has been altered.
An Attack Scenario (MiTM)
• The hash function must be transmitted in a
secure manner. That is the hash function
must be protected so that if an adversary
alters or replaces the message, it is not
feasible for adversary to also alter the hash
value to fool the receiver.
• This type of attack is shown in the figure. In
this example , Alice transmits a data block
and attaches a hash value. Darth intercepts
the message , alters or replaces the data
block, and calculates and attaches a new
hash value.
• Bob receives the altered data with the new
hash value and does not detect the change.
To prevent this attack , the hash value
generated by Alice must be protected.
How to protect Hash Values from Attacks
• Scenario 1
•The message code concatenated hash code is encrypted using
symmetric encryption.
•Because only A and B share the secrete key , the message must
have come from A and has not been altered.
•The hash code provides the structure or redundancy required to
achieve authentication.
•Because encryption is applied to the entire message plus hash
code, confidentiality is also provided
How to protect Hash Values from Attacks
• Scenario 2
•Only the hash code is encrypted , using symmetric
encryption. This reduces the processing burden for those
applications that do not require confidentiality.
How to protect Hash Values from Attacks
• Scenario 3
•It is possible to use a hash function but no encryption for
message authentication.
•The technique assumes that the two communication parties
share a common secrete value S.
•A computes a hash value over the concatenation of M and S
and appends the resulting hash value to M.
•Because B possesses S, it can recompute the hash value to
verify.
•Because the secrete value itself is not sent, an opponent
cannot modify an intercepted message and cannot generate
a false message.
How to protect Hash Values from Attacks
• Scenario 4
• Confidentiality can be added to the approach of method C by
encrypting the entire message plus the hash code.
• The output of the algorithm is a set of four 32-bit blocks, which make up the
128-bit message digest
Working of MD5
•Step 1: Padding
•The aim of this step is to make the length of the original
message equal to a value which is 64 bits less than an exact
multiple of 512 bits.
•For example, if the length of original message is 1000 bits, we
add a padding of 472 bits to make the length if the message
1472 bits, because 1536=512*3. also 1536-64=1472
•The padding consist of a single 1 bit followed by all 0 bits, as
required.
•Padding bits are always added even if the length is already 64
bits less than an exact multiple of 512.
Working of MD5
•Step 2: Append Length
•After padding bits are added , the next step is to calculate the
length of the original message in terms of 64 bits ( 2 ^ 64),
which is then appended at the end of the (original
msg+padding)
Working of MD5
•Step 3: Divide the input into 512 bit blocks
•Step 4: initialize the chaining variables:
•In this step , four variables (called chaining variables) are initialized.
They are called A,B,C,D.
•Each of these is 32 bit number. The initial hexadecimal values of the
chaining variables are as follows:
A: 01 23 45 67 C:FE DC BA 98
B: 89 AB CD EF D:76 54 32 10
Working of MD5
• Step 5: Process Blocks
• After all initializations, the real algorithm begins. There is a loop that runs for
as many 512-bit blocks are follows:
5.1 : copy the 4 chaining variables into four corresponding variables a,b,c and d.
A=a, B=b,C=c,D=d
5.2: divide the current 512 –bit blocks into 16 sub blocks . Thus, each sub block
contain 32 bits.
5.3: we have 4 rounds. In each round , we process all the 16 sub-blocks
belonging to a block. The inputs to each round are
a) All the 16 sub blocks
b) The variables a,b,c,d
c) Some constant, designated as k
Internal operation of each round
• All the four round vary in one major
way:
• Like MD5, the first step in SHA is add padding to the end of the
original message in such a way that the length of the message is 64
bits shorts of a message of 512.
• The padding bits are always added , even if the message is already 64
bits shorts of a multiple 512
Working of SHA-1
• Step 2: Append length
• The length of the message excluding the length of the padding is now
calculated and appended to the end of the padding as a 64 bit block.
Working of SHA-1
• Step 3: Divide the input
• The input message is divided into blocks, each of length 512 bits.
• These blocks become the input to the message digest processing
logic.
Working of SHA-1
• Step 4: Initializing chaining variables
•
MD5 vs SHA-1
HMAC/CMAC
Hash Based message Authentication Code
• The fundamental idea behind HMAC is to reuse the existing message
digest algorithm, such as MD or SHA-1
• Thus, it treats the message digest as a black box.
Working of HMAC
• Let us start with various variables that will be used in our HMAC discussion