Skip to content

Commit

Permalink
8314199: Initial size PBEKeyFactory#validTypes is not up-to-date
Browse files Browse the repository at this point in the history
Reviewed-by: jnimeh
  • Loading branch information
driverkt committed Oct 10, 2023
1 parent d313915 commit e882718
Showing 1 changed file with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import javax.crypto.spec.PBEKeySpec;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

/**
* This class implements a key factory for PBE keys according to PKCS#5,
Expand All @@ -46,7 +47,7 @@
abstract class PBEKeyFactory extends SecretKeyFactorySpi {

private String type;
private static HashSet<String> validTypes;
private static final HashSet<String> validTypes;

/**
* Simple constructor
Expand All @@ -56,29 +57,29 @@ private PBEKeyFactory(String keytype) {
}

static {
validTypes = HashSet.newHashSet(17);
validTypes.add("PBEWithMD5AndDES".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithSHA1AndDESede".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase(Locale.ENGLISH));
// Proprietary algorithm.
validTypes.add("PBEWithMD5AndTripleDES".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512/224AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512/256AndAES_128".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512/224AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes.add("PBEWithHmacSHA512/256AndAES_256".toUpperCase(Locale.ENGLISH));
validTypes = new HashSet<String>(
Set.of("PBEWithMD5AndDES".toUpperCase(Locale.ENGLISH),
"PBEWithSHA1AndDESede".toUpperCase(Locale.ENGLISH),
"PBEWithSHA1AndRC2_40".toUpperCase(Locale.ENGLISH),
"PBEWithSHA1AndRC2_128".toUpperCase(Locale.ENGLISH),
"PBEWithSHA1AndRC4_40".toUpperCase(Locale.ENGLISH),
"PBEWithSHA1AndRC4_128".toUpperCase(Locale.ENGLISH),
// Proprietary algorithm.
"PBEWithMD5AndTripleDES".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA1AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA224AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA256AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA384AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512/224AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512/256AndAES_128".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA1AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA224AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA256AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA384AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512/224AndAES_256".toUpperCase(Locale.ENGLISH),
"PBEWithHmacSHA512/256AndAES_256".toUpperCase(Locale.ENGLISH)));
}

public static final class PBEWithMD5AndDES extends PBEKeyFactory {
Expand Down

1 comment on commit e882718

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.