使用私钥解密Openssl文件

问题描述 投票:0回答:1

几个月前我加密了一个文件,并且我也拥有该文件的私钥和公钥。 现在我正在尝试解密文件,但出现错误。我猜我已经使用 openSSL 来加密该文件。 这是我正在尝试的命令

sss@sss:~/ws/prev$ openssl pkeyutl -decrypt -in image.img.dat -out decryptedfile -inkey private-key.pem Public Key operation error 40F700BFBE7F0000:error:0200006C:rsa routines:rsa_ossl_private_decrypt:data greater than mod len:../crypto/rsa/rsa_ossl.c:407: sss@sss:~/ws/prev$ openssl pkeyutl -decrypt -in image.img.dat -out decrypted.bin -inkey private-key.pem Public Key operation error 40D78E9B6D7F0000:error:0200006C:rsa routines:rsa_ossl_private_decrypt:data greater than mod len:../crypto/rsa/rsa_ossl.c:407: sss@sss:~/ws/prev$  

有恢复文件的想法吗。

我尝试使用解密命令解密它,但没有成功。我已将所有命令粘贴在上面。

encryption openssl decode md5 encode
1个回答
0
投票

要解密的文件有多大? RSA 密钥有多少位? RSA 密钥只能加密比密钥大小“更小”的数据,而且这是针对纯粹的、未填充的数据,但几乎从未这样做过,因为它不安全。添加的填充通常占用 11 到 66 字节之间的某个位置,因此 2048 位或 256-byte RSA 密钥在正常使用情况下只能加密 190 到 245 字节之间的某个位置。并且写入的密文将与 RSA 密钥的大小完全相同。 如果您输入的密文大于您的密钥大小,则您没有使用简单的 RSA 加密来对其进行加密。

此错误表明您的数据未经过 RSA 加密:

Public Key operation error 40D78E9B6D7F0000:error:0200006C:rsa routines:rsa_ossl_private_decrypt:data greater than mod len:../crypto/rsa/rsa_ossl.c:407

有关 RSA 加密和解密的一些见解,

RSA 维基百科页面

提供了很好的描述。 有关 OpenSSL 实用程序的更多详细信息,请参阅 OpenSSL

pkeyutil

文档,网址为

https://www.openssl.org/docs/manmaster/man1/openssl-pkeyutl.html

© www.soinside.com 2019 - 2024. All rights reserved.