散列 RSA 密钥的标准方法?
创建 RSA 公钥的散列(sha-1 或 MD5)的算法是什么?有没有标准的方法来做到这一点?只需对两者的模数和字符串加法进行哈希处理,然后再进行哈希处理?通常使用SHA-1还是MD5?
我想用它来确保我获得正确的密钥(让发送者发送一个哈希值,然后我自己计算它),并记录所述哈希值,以便我始终知道在加密有效负载时使用的确切密钥。
What's the algorithm for creating hash (sha-1 or MD5) of an RSA public key? Is there a standard way to do this? Hash just the modulus, string addition of both and then take a hash? Is SHA-1 or MD5 usually used?
I want to use it to ensure that I got the right key (have the sender send a hash, and I calculate it myself), and log said hash so I always know which exact key I used when I encrypt the payload.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 OpenSSH 源代码,为 RSA 密钥生成指纹的方式是将公钥中的 n 和 e 转换为大端二进制数据,连接数据,然后使用给定的哈希函数对该数据进行哈希处理。
部分 OpenSSH 源代码如下。添加评论是为了澄清正在发生的事情。
来自
BN_bn2bin
手册页:BN_bn2bin (a, to)
将a
的绝对值转换为big-endian 形式并将其存储在to
中。to
必须指向内存的BN_num_bytes(a)
字节。Based on the OpenSSH source code, the way that a fingerprint is generated for RSA keys is to convert n and e from the public key to big-endian binary data, concatenate the data and then hash that data with the given hash function.
Portions of the OpenSSH source code follows. The comments were added to clarify what is happening.
From the
BN_bn2bin
manual page:BN_bn2bin(a, to)
converts the absolute value ofa
into big-endian form and stores it atto
.to
must point toBN_num_bytes(a)
bytes of memory.