SHA-256填充 [英] SHA-256 Padding

查看:298
本文介绍了SHA-256填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要计算的SHA-256散列我需要垫我的消息。现在用的是下面的描述: (摘自 HTTP://csrc.nist。 GOV /组/ STM / CAVP /文件/ SHS / sha256-384-512.pdf

To calculate the SHA-256 hash I need to pad my message. Am using the following description: (taken from http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf)

垫以通常的方式的信息:假设消息的长度M,   以位为l。追加位1的消息的结束,然后   ķ零比特,其中k是最小的非负溶液到   方程L + 1 + K 448模512向该附加的64位的块中,这是   等于数字升写入二进制

Pad the message in the usual way: Suppose the length of the message M, in bits, is l. Append the bit "1" to the end of the message, and then k zero bits, where k is the smallest non-negative solution to the equation l+1+k 448 mod 512. To this append the 64-bit block which is equal to the number l written in binary

但是,什么人应该做的,如果在位的消息长度小于64位的短512bit的块的......也就是说,没有余地上述最终64位块?或64位长度和1的位

But what should one do if the message length in bits is less than 64-bits short of a 512bit block... i.e., there isn't room for the end 64-bit block mentioned above? Or the 64-bit length and the "1" bit?

我对维基百科也看,但是这不会引发任何更亮的主题。谷歌搜索一直没太富有成果或者,将AP preciate任何建议:)

I had a look on wikipedia too, but this doesn't throw any more light on the subject. Google searches haven't been too fruitful either, would appreciate any suggestions :)

感谢

推荐答案

如果您的信息仅仅只有短暂的完整街区(少于65位短),你会需要你的输出是一个块大于输入。在最坏的情况下,如果你的信息是完全64位的短一个完整的块,将添加一个 1 ,然后511 0 S,不过那是多么填充有工作。

If your message is only just short of a full block (less than 65 bits short), you will need your output to be a block longer than your input. In the worst case, if your message is exactly 64 bits short of a full block, you will add a 1 and then 511 0s before the "number" bits, but that is how the padding has to work.

这篇关于SHA-256填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆