RSA / ECB / OAEPWithSHA-256AndMGF1Padding但MGF1使用SHA-256? [英] RSA/ECB/OAEPWithSHA-256AndMGF1Padding but with MGF1 using SHA-256?

查看:287
本文介绍了RSA / ECB / OAEPWithSHA-256AndMGF1Padding但MGF1使用SHA-256?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Oracle的Java标准加密提供程序中找到了困难的方法

I found the hard way that in Oracle's Java standard crypto provider

Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");

使用与SHA-1相关的MFG1; SHA-256仅用于散列标签(实际上是空的)。我发现在MFG1中实际使用SHA-256的唯一解决方案(由答案评论)使用了另一种形式的 Cipher.init

uses MFG1 instanciated with SHA-1; SHA-256 is only used to hash the label (in practice empty). The only solution that I found to actually use SHA-256 in MFG1 (helped by that answer and comment) was using an alternate form of Cipher.init:

cipher.init(Cipher.DECRYPT_MODE, privKey, new OAEPParameterSpec(
    "SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT
));

问题:是否有转换 Cipher .getInstance 会识别,效果类似于RSA / ECB / OAEPWithSHA-256AndMGF1Padding,除了MGF1使用SHA-256?

Question: is there a transformation that Cipher.getInstance will recognize, with effect similar to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding", except with MGF1 using SHA-256?

推荐答案

不,没有。

Java是开源的。如果不确定,你可以看一下OpenJDK的来源。

Java is open source. If unsure you can take a look at the sources for the OpenJDK.

init 方法=http://www.docjar.com/html/api/com/sun/crypto/provider/RSACipher.java.html\"rel =nofollow> com.sun.crypto.provider。它读取RSACipher

In the init method of com.sun.crypto.provider.RSACipher it reads:

            spec = new OAEPParameterSpec(oaepHashAlgorithm, "MGF1",
                MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT);

我已经检查了OpenJDK的Java 8更新60。如您所见,您需要使用算法参数。

I've checked this up to Java 8 update 60 for the OpenJDK. As you can see, you need to use the algorithm parameters.

这篇关于RSA / ECB / OAEPWithSHA-256AndMGF1Padding但MGF1使用SHA-256?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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