使用 RSA-1024 签署 SHA-256 摘要:大小是多少?
我想知道: 1)如果我用 SHA-512 => 计算一些数据的摘要;产生 64 字节的哈希值 2) 然后我用 RSA-1024 => 签署这个哈希值所以一个 128 字节的块,比摘要的 64 字节大
=>这是否意味着最终我的签名哈希值将恰好 128 字节?
非常感谢您提供任何信息。
I was wondering:
1) if I compute the digest of some datas with SHA-512 => resulting in a hash of 64 bytes
2) and then I sign this hash with RSA-1024 => so a block of 128 bytes, which is bigger than the 64 bytes of the digest
=> does it mean in the end my signed hash will be exactly 128 bytes?
Thanks a lot for any info.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 RSA,如 PKCS#1 指定,要签名的数据首先使用散列函数进行散列,然后对结果进行填充(将散列结果转换为模整数的或多或少复杂的运算),然后对该数字应用 RSA 数学运算。结果是一个 n 位整数,其中 n 是“模数”的位长度,通常称为“RSA 密钥大小”。基本上,对于 RSA-1024,n 是 1024。 1024 位整数被编码为 128 个字节,准确地说,按照 PKCS#1 中描述的编码方法(PKCS#1 非常可读,并且不太长)。
n 位 RSA 密钥是否可用于通过生成长度 m 输出的散列函数对数据进行签名取决于填充的详细信息。顾名思义,填充涉及在哈希输出周围添加一些额外的数据,因此 n 必须大于 m,为额外数据留出一些空间。 1024 位密钥可与 SHA-512(生成 512 位字符串)一起使用。您不能将 640 位密钥与 SHA-512 一起使用(而且您也不会,无论如何,因为 640 位 RSA 密钥可能会被破坏 - 尽管不是微不足道的)。
With RSA, as specified by PKCS#1, the data to be signed is first hashed with a hash function, then the result is padded (a more or less complex operation which transforms the hash result into a modular integer), and then the mathematical operation of RSA is applied on that number. The result is a n-bit integer, where n is the length in bits of the "modulus", usually called "the RSA key size". Basically, for RSA-1024, n is 1024. A 1024-bit integer is encoded as 128 bytes, exactly, as per the encoding method described in PKCS#1 (PKCS#1 is very readable and not too long).
Whether a n-bit RSA key can be used to sign data with a hash function which produces outputs of length m depends on the details of the padding. As the name suggests, padding involves adding some extra data around the hash output, hence n must be greater than m, leaving some room for the extra data. A 1024-bit key can be used with SHA-512 (which produces 512-bit strings). You could not use a 640-bit key with SHA-512 (and you would not, anyway, since 640-bit RSA keys can be broken -- albeit not trivially).