8311592: ECKeySizeParameterSpec causes too many exceptions on third party providers

Reviewed-by: hchao, valeriep
This commit is contained in:
Anthony Scarpino 2023-07-25 15:48:31 +00:00
parent 9606cbcd23
commit e554fdee25

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -128,9 +128,10 @@ public final class KeyUtil {
*/
public static final int getKeySize(AlgorithmParameters parameters) {
String algorithm = parameters.getAlgorithm();
switch (algorithm) {
switch (parameters.getAlgorithm()) {
case "EC":
// ECKeySizeParameterSpec is SunEC internal only
if (parameters.getProvider().getName().equals("SunEC")) {
try {
ECKeySizeParameterSpec ps = parameters.getParameterSpec(
ECKeySizeParameterSpec.class);
@ -140,6 +141,7 @@ public final class KeyUtil {
} catch (InvalidParameterSpecException ipse) {
// ignore
}
}
try {
ECParameterSpec ps = parameters.getParameterSpec(