在BouncyCastle的RSA PKCS1-OAEP冗余支持? [英] Is RSA PKCS1-OAEP padding supported in bouncycastle?

查看:1968
本文介绍了在BouncyCastle的RSA PKCS1-OAEP冗余支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施加密code中的Java / Android的匹配iOS的加密。在iOS系统中有使用RSA加密使用以下填充方案:PKCS1-OAEP

I'm implementing encryption code in Java/Android to match iOS encryption. In iOS there are encrypting with RSA using the following padding scheme: PKCS1-OAEP

然而,当我尝试创建密码与PKCS1-OAEP。

However when I try to create Cipher with PKCS1-OAEP.

Cipher c = Cipher.getInstance("RSA/None/PKCS1-OAEP", "BC");

下面是堆栈跟踪

Below is the stacktrace

javax.crypto.NoSuchPaddingException: PKCS1-OAEP unavailable with RSA.
    at com.android.org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineSetPadding(CipherSpi.java:240)
    at javax.crypto.Cipher.getCipher(Cipher.java:324)
    at javax.crypto.Cipher.getInstance(Cipher.java:237) 

这也许 RSA /无/ PKCS1-OAEP 是不正确的?但找不到任何明确的答案,或者说PKCS1-OAEP是不支持的,或者定义它的正确方法。

Maybe this RSA/None/PKCS1-OAEP is incorrect? but can't find any definitive answer to say either PKCS1-OAEP is unsupported or the correct way to define it.

我使用spongycastle库,以便有充分的BouncyCastle的实施。

I'm using the spongycastle library so have full bouncycastle implementation.

推荐答案

在code。在第一个答案做的工作,但我们不推荐,因为它使用的,而不是JCA通用接口BouncyCastle的内部类,使得code BouncyCastle的具体。例如,它会使得难以切换到SunJCE提供

The code in the first answer does work, but it's not recommended as it uses BouncyCastle internal classes, instead of JCA generic interfaces, making the code BouncyCastle specific. For example, it will make it difficult to switch to SunJCE provider.

充气城堡为1.50版本支持以下OAEP填充名称。

Bouncy Castle as of version 1.50 supports following OAEP padding names.

  • 在RSA /无/ OAEPWithMD5AndMGF1Padding
  • 在RSA /无/ OAEPWithSHA1AndMGF1Padding
  • 在RSA /无/ OAEPWithSHA224AndMGF1Padding
  • 在RSA /无/ OAEPWithSHA256AndMGF1Padding
  • 在RSA /无/ OAEPWithSHA384AndMGF1Padding
  • 在RSA /无/ OAEPWithSHA512AndMGF1Padding

然后适当的RSA-OAEP密码初始化看起来像

Then proper RSA-OAEP cipher initializations would look like

Cipher c = Cipher.getInstance("RSA/NONE/OAEPWithSHA1AndMGF1Padding", "BC");

这篇关于在BouncyCastle的RSA PKCS1-OAEP冗余支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆