Skip to content

Commit

Permalink
tt/P124525118: Add alias for RSA/ECB/OAEPWithSHA-1AndMGF1Padding
Browse files Browse the repository at this point in the history
We add this alias to better support [open-source projects using
non-JCA-standard algorithm names][1].

[1]: https://github.com/search?q=RSA%2FECB%2FOAEPWithSHA1AndMGF1Padding&type=code
  • Loading branch information
WillChilds-Klein committed Apr 2, 2024
1 parent 4ec7ff6 commit 544c969
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private void buildServiceMap() {
addService("Cipher", "RSA/ECB/Pkcs1Padding", "RsaCipher$Pkcs1");
addService("Cipher", "RSA/ECB/OAEPPadding", "RsaCipher$OAEP");
addService("Cipher", "RSA/ECB/OAEPWithSHA-1AndMGF1Padding", "RsaCipher$OAEPSha1");
addService("Cipher", "RSA/ECB/OAEPWithSHA1AndMGF1Padding", "RsaCipher$OAEPSha1");

for (String hash : new String[] {"MD5", "SHA1", "SHA256", "SHA384", "SHA512"}) {
addService("Mac", "Hmac" + hash, "EvpHmac$" + hash);
Expand Down
10 changes: 9 additions & 1 deletion tst/com/amazon/corretto/crypto/provider/test/RsaCipherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
@ResourceLock(value = TestUtil.RESOURCE_GLOBAL, mode = ResourceAccessMode.READ)
public class RsaCipherTest {
private static final String OAEP_SHA1_PADDING = "RSA/ECB/OAEPWithSHA-1AndMGF1Padding";
// Aliases are used for compatibility with projects specifying non-JCA-standard names
private static final List<String> OAEP_SHA1_PADDING_ALIASES =
Arrays.asList("RSA/ECB/OAEPWithSHA1AndMGF1Padding");
private static final String OAEP_PADDING = "RSA/ECB/OAEPPadding";
private static final String PKCS1_PADDING = "RSA/ECB/Pkcs1Padding";
private static final String NO_PADDING = "RSA/ECB/NoPadding";
Expand Down Expand Up @@ -94,7 +97,12 @@ public class RsaCipherTest {
}

public static List<String> paddingParams() {
return Arrays.asList(OAEP_PADDING, OAEP_SHA1_PADDING, PKCS1_PADDING, NO_PADDING);
List<String> params =
new ArrayList<>(Arrays.asList(OAEP_PADDING, OAEP_SHA1_PADDING, PKCS1_PADDING, NO_PADDING));
for (String alias : OAEP_SHA1_PADDING_ALIASES) {
params.add(alias);
}
return params;
}

public static List<String> messageDigestParams() {
Expand Down

0 comments on commit 544c969

Please sign in to comment.