本文介绍了javax.crypto.Cipher为RSA使用了哪个填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要通过RSA解密消息,以便通过不安全的通道发送消息,但我害怕填充Oracle攻击。因此我已经问过以下几个问题:I need to decrypt messages via RSA in order to send it over an unsecured channel, but I'm afraid of the Padding Oracle Attack. Therefore I already have asked the follwoing questions: 如何验证RSA加密邮件的完整性? 如何使用javax.crypto.Cipher确保RSA密码的消息完整性 How to verify the integrity of RSA encrypted messages?How to ensure message integrity for RSA ciphers by using javax.crypto.Cipher与第一个问题中建议的一样,Like suggested in the first question, 我不应该考虑。据我所知, PKCS#1 v1.5 的RSA实施容易受到 Padding Oracale Attack 的攻击 OAEP 不是(假设它已正确实施)I shouldn't consider about. As far I know, the RSA implementation of PKCS#1 v1.5 is vulnerable to the Padding Oracale Attack whereby OAEP isn't (assumed it's implemented correctly)因此我想知道Java 7的 javax.crypt.Cipher 使用了哪种填充实现Hence I want to know which padding implementation is used by javax.crypt.Cipher by Java 7推荐答案取决于所选择的或默认的提供程序,当你实例化一个密码而没有完全限定它时,实际使用了哪个填充:It depends on the chosen or default provider which padding is actually used when you instantiate a Cipher without fully qualifying it like:Cipher.getInstance("RSA")这样做是一个糟糕的做法,因为如果你切换Java实现,可能会有不同的默认值,突然间,你将不再与旧的密文兼容。 始终完全符合密码。 Doing so is a bad practice, because if you switch Java implementations, there might be different defaults and suddenly, you won't be compatible with the old ciphertexts anymore. Always fully qualify the cipher.正如我之前所说,默认可能(有很多提供商,一个不能确定)是PKCS#1 v1.5填充。如果您需要另一个,则必须指定它。如果你想使用OAEP,这里是一个完全限定的密码字符串来自这里:As I said before, the default will probably (there are many providers, one can't be sure) be PKCS#1 v1.5 padding. If you need another, you would have to specify it. If you want to use OAEP, here is a fully qualified cipher string from here:Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); 这篇关于javax.crypto.Cipher为RSA使用了哪个填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-13 13:26