Skip to content

Commit 8785172

Browse files
kurashige23jerboaa
authored andcommitted
8026976: ECParameters, Point does not match field size
Reviewed-by: sgehwolf Backport-of: 55f5542
1 parent 289644a commit 8785172

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

+7-1
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);

test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al
604604

605605
# jdk_security
606606

607-
sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all
608607
sun/security/pkcs11/KeyStore/ClientAuth.sh 8254806 solaris-all
609608
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all
610609

0 commit comments

Comments
 (0)