Openssl"数据大于mod len"

aut*_*ton 11 encryption openssl private-key

"数据大于mod len"错误消息是什么意思?我在尝试使用php的openssl_private_decrypt解密数据时遇到过这种情况.如何解决这个问题呢?在网上搜索时间,没有到达任何地方.

jar*_*riq 15

非对称RSA密钥只能加密/解密有限长度的数据,即RFC3447中定义的RSAES-PKCS1-v1_5加密方案可以对长度高达k-11个八位字节的消息进行操作(k是RSA模数的八位字节长度),所以如果你是使用2048位RSA密钥,则要加密的明文数据的最大长度为245字节.

  • @automaton如果你想加密更大的数据,你应该看一下[openssl_seal()](http://www.php.net/manual/en/function.openssl-seal.php)和[openssl_open() ](http://www.php.net/manual/en/function.openssl-open.php)的功能. (3认同)

Ped*_*llo 8

如果您遇到此解密错误:RSA_EAY_PRIVATE_DECRYPT:data greater than mod len在解密文件之前尝试此命令:

cat yourEncryptedFile| base64 -D > yourEncryptedRawFile
Run Code Online (Sandbox Code Playgroud)

  • 不应该是`base64 -d`或`base64 --decode`而不是? (4认同)