From 65dd9e617425173d0a6028c0e39ca6270333a8a6 Mon Sep 17 00:00:00 2001 From: Taizo Kurashige Date: Mon, 21 Oct 2024 18:21:09 +0900 Subject: [PATCH 1/2] Backport 55f5542ca2104df91e14693534cc7b3c36e81953 --- .../classes/sun/security/pkcs11/P11ECKeyFactory.java | 10 ++++++++-- jdk/test/ProblemList.txt | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java index 7c3b93e0400..04744789f0f 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, 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 @@ -294,7 +294,13 @@ T implGetPublicKeySpec(P11Key key, Class keySpec, 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); diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 0d432b16a2b..6da2ef5df33 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -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 From 17049521da4e71587c5e673a880c778001216080 Mon Sep 17 00:00:00 2001 From: Taizo Kurashige Date: Fri, 28 Mar 2025 20:22:18 +0900 Subject: [PATCH 2/2] Fix copyright year --- jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java index 04744789f0f..1fc45172198 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2021, 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