8026976: ECParameters, Point does not match field size

Reviewed-by: phh, mbalao
Backport-of: 55f5542ca2104df91e14693534cc7b3c36e81953
This commit is contained in:
Taizo Kurashige 2025-05-08 10:06:42 +00:00 committed by Severin Gehwolf
parent 55273f7267
commit 5e59411bd3
2 changed files with 7 additions and 3 deletions

View File

@ -294,7 +294,13 @@ final class P11ECKeyFactory extends P11KeyFactory {
try {
token.p11.C_GetAttributeValue(session[0].id(), keyID, attributes);
ECParameterSpec params = decodeParameters(attributes[1].getByteArray());
ECPoint point = decodePoint(attributes[0].getByteArray(), params.getCurve());
ECPoint point;
if (!token.config.getUseEcX963Encoding()) {
point = decodePoint(new DerValue(attributes[0].getByteArray()).getOctetString(), params.getCurve());
} else {
point = decodePoint(attributes[0].getByteArray(), params.getCurve());
}
return keySpec.cast(new ECPublicKeySpec(point, params));
} catch (IOException e) {
throw new InvalidKeySpecException("Could not parse key", e);

View File

@ -277,8 +277,6 @@ sun/rmi/transport/tcp/DisableRMIOverHttp/DisableRMIOverHTTPTest.java windows-
# jdk_security
# 8026976
sun/security/pkcs11/ec/TestKeyFactory.java generic-all
# 8180837
sun/security/pkcs11/Secmod/AddTrustedCert.java generic-all
sun/security/pkcs11/tls/TestKeyMaterial.java generic-all