Skip to content

Commit 5e59411

Browse files
kurashige23jerboaa
authored andcommitted
8026976: ECParameters, Point does not match field size
Reviewed-by: phh, mbalao Backport-of: 55f5542ca2104df91e14693534cc7b3c36e81953
1 parent 55273f7 commit 5e59411

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ <T extends KeySpec> T implGetPublicKeySpec(P11Key key, Class<T> keySpec,
294294
try {
295295
token.p11.C_GetAttributeValue(session[0].id(), keyID, attributes);
296296
ECParameterSpec params = decodeParameters(attributes[1].getByteArray());
297-
ECPoint point = decodePoint(attributes[0].getByteArray(), params.getCurve());
297+
ECPoint point;
298+
299+
if (!token.config.getUseEcX963Encoding()) {
300+
point = decodePoint(new DerValue(attributes[0].getByteArray()).getOctetString(), params.getCurve());
301+
} else {
302+
point = decodePoint(attributes[0].getByteArray(), params.getCurve());
303+
}
298304
return keySpec.cast(new ECPublicKeySpec(point, params));
299305
} catch (IOException e) {
300306
throw new InvalidKeySpecException("Could not parse key", e);

jdk/test/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ sun/rmi/transport/tcp/DisableRMIOverHttp/DisableRMIOverHTTPTest.java windows-
277277

278278
# jdk_security
279279

280-
# 8026976
281-
sun/security/pkcs11/ec/TestKeyFactory.java generic-all
282280
# 8180837
283281
sun/security/pkcs11/Secmod/AddTrustedCert.java generic-all
284282
sun/security/pkcs11/tls/TestKeyMaterial.java generic-all

0 commit comments

Comments
 (0)