Skip to content

Commit 55f5542

Browse files
author
Anthony Scarpino
committed
8026976: ECParameters, Point does not match field size
Reviewed-by: xuelei
1 parent d3f3c32 commit 55f5542

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java 8141694 linux-al
661661

662662
# jdk_security
663663

664-
sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all
665664
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java 8161536 generic-all
666665

667666
sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all

0 commit comments

Comments
 (0)