algorithm - RSA算法查询报文大小

标签 algorithm rsa

在 RSA 算法中,规定明文大小必须小于或等于( key 大小 - 11)。

为什么会这样。那个 11 实际上是什么?

最佳答案

这只是使用 PKCS1 填充时的要求。 “裸”RSA 虽然不安全,但可以执行长度达到 key 大小的操作,并且 OAEP 填充取决于您使用的哈希算法。

来自the PKCS1 spec :

   Steps:

   1. Length checking: If mLen > k - 11, output "message too long" and
      stop.

   2. EME-PKCS1-v1_5 encoding:

      a. Generate an octet string PS of length k - mLen - 3 consisting
         of pseudo-randomly generated nonzero octets.  The length of PS
         will be at least eight octets.

      b. Concatenate PS, the message M, and other padding to form an
         encoded message EM of length k octets as

            EM = 0x00 || 0x02 || PS || 0x00 || M.

据此,明文前面至少添加了 11 个字节。 0x00 和 0x02,然后是 PS,其长度为“至少八个八位字节”,然后是 0x00。所以 3 + 8 = 11。

关于algorithm - RSA算法查询报文大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20114560/

相关文章:

java - 插入排序和哨兵

python - 如何检查笛卡尔坐标是否有效构成矩形?

algorithm - 负载均衡和调度算法

math - 部分密文的RSA加密和解密?

java - 求模数的互质数

python - 查找列表模态值的最有效方法是什么?

java - 为什么该方法会更改传递的数组的值

java - RSA公钥编码,Java和Android中,相同的代码,不同的结果

encryption - 散列 RSA key 的标准方法?

c# - C# 中的 RSASSA-PSS