In SHA-512, the size of the original message is 1650 bits. What is the number of padding bits?
Answers
SHA-512 Pre-Processing
Answer is 270 bits [398 bits if you count the 128-bit block too]. Read on for the full explanation. Or, scroll down to the Short Method section to directly see how to solve the question if you already know all the concepts.
The Secure Hash Algorithm - 512 bits is a Hashing Algorithm to generate a 512 bit hash value of any given message of size upto bits.
It is one of the different algorithms specified in the Secure Hash Standard (SHS). The official documentation for the SHS is the FIPS PUB 180-4 [Federal Information Processing Standards Publication 180-4]. It is maintained by the National Institute of Standards and Technology [NIST].
Overview of SHA-512
The first step is Pre-Processing of the message. For SHA-512, the message must be padded so that its length is a multiple of 1024 bits.
After the Message is Padded, various constant values and different functions are used to manipulate the message and generate the Hash value. The specifics of the SHA-512 Constants and Hashing Functions can be found in the FIPS PUB 180-4.
For the purpose of this question, we must understand the first step: Pre-Processing.
Pre-Processing Messages in SHA-512
We denote the message by .
Suppose the length of this message in bits, is .
The final message length after pre-processing should be a multiple of 1024 bits.
The Pre-Processing Steps are as follows:
- Append the bit "1" to the end of the message.
- Now, append "0" bits to the end of the message, where is the smallest non-negative solution to .
- After this, express the message length in binary in a 128-bit block and append this block at the end.
For example, consider a message
So,
We first express the message in binary by using the ASCII values for each character.
Each character is expressed as an 8-bit binary block, using the ASCII Values. The numbers 10 and 2 in subscript represent the Decimal and Binary ASCII Values respectively.
Now, we have the message in binary.
The Message Length is 24. It is 24 bits long.
Now, we append the bit "1" to the message, and now we need the smallest solution of for
So, we append 871 "0" bits. After this, we need the 128 bit block of expressed in binary.
[We just append the required number of "0" bits to the beginning of binary form of to make it a 128 bit block.]
Hence, the final padded message would become:
The Answer:
We have a message of the length bits.
We append "1" at the end. Now, we need the smallest solution of for:
So, we append 269 "0" bits towards the end of the message.
After that, we append the 128 bit block of expressed in binary.
Hence, the final padded message is:
So, The number of padding bits is bits.
Hence, Answer is 270 bits. If we include the 128 bit block, answer will be 398 bits.
Short Method:
The final message length must be a multiple of 1024 bits.
Now, we know that we compulsorily append "1" and a 128-bit-block of the message length expressed in binary.
The rest of the message length is accomplished by appending "0" bits in between the "1" bit and the 128-bit-block.
So, suppose we need to append zeros. Then, must be a multiple of 1024.
Here,
For 1779, the closest greater multiple of 1024 is 2048.
So,
Hence, the number of padding bits would be . Thus, The Answer is 270 bits. [398 bits if we include the 128 bit block as well]
Answer:
Explanation:
270