if anyone answered my quesion i would be very much grateful, my question is in sha256 , if we have 512 bits message length how can i do padding , because in sha256 l+1+k=448mod512, it will overflow 512 bit block, i mean to say that for hashing computation we need to divide 512 bit block into 16 x 32 blocks , and the process is the message bit length (l) + k number of '0' + binary representation of l(length of message). my point is 512 bit after k number 0f '0' and bit representation of l(length of message) we will get more than 512 bits , how ae we going to divide into 16 x 32 bit blocks.
Asked
Active
Viewed 396 times
1
-
Can you rephrase the question? Show us what you're starting with and what you want to end up with and what's going wrong with your attempts to get you there. As it is, your question is a bit jumbled. – mypetlion Oct 09 '18 at 16:41
-
my question is if i want to encript a message whose length is 512 bits , how to do padding before processing into sha256 function , which required 16 x 32 bits block ( 32 bits 16 times to compute it), for more clarification , incase of my question i have 512 bits message length ,512 bits after that 512 bits + 1 +64 bits(for lenth message) , this will give 1024 bits blocks , if i divide into 32 bis blocks it will give 32 bits blocks , which mean that i am getting 32 x 32 bits blocks instead of 16 x 32 bits block , the main doubt i have is do i need to repeat 16 x 32 bits blocks for computaion – hi hello Oct 09 '18 at 17:05
1 Answers
0
You don't need to pad your data to be a certain length in order to get a sha256 checksum value; the algorithm will handle a few bytes as well as megabytes of data:
Linux> echo 'hey' | sha256sum
4e955fea0268518cbaa500409dfbec88f0ecebad28d84ecbe250baed97dba889 -
Linux> echo '' | sha256sum
01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -
Linux> ls -oh L0_2018_08_28_Disk1_8mtbno4o_3_1.bkp
-rw-r-----. 1 nfsnobody 348M Aug 28 23:48 L0_2018_08_28_Disk1_8mtbno4o_3_1.bkp
Linux> sha256sum L0_2018_08_28_Disk1_8mtbno4o_3_1.bkp
34438a1bc45f613b7be8797b1139aaa66a60d73844f2d7554184b17c621b4576 L0_2018_08_28_Disk1_8mtbno4o_3_1.bkp
If you want to learn about the actual algorithm, one open-source implementation says
Algorithm specification can be found here: http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf

Mark Stewart
- 2,046
- 4
- 22
- 32
-
thank you for your answer and time , but i was trying to find out how it function instead of using programming language( i mean in paper) – hi hello Oct 09 '18 at 17:34
-
According to the Linux man page, "The sums are computed as described in FIPS-180-2." Try googling that, or get the source code for `sha256sum` if you dare. – Mark Stewart Oct 09 '18 at 17:39
-
Added source of how it is implemented to my answer. I think that document will answer your question; if so, feel free to accept my answer. – Mark Stewart Oct 09 '18 at 17:52