On Fri, 1 May 2026 19:14:52 GMT, Anthony Scarpino <[email protected]> wrote:
>> src/java.base/share/classes/java/security/PEMDecoder.java line 71:
>>
>>> 69: *
>>> 70: * <p> For {@code PublicKey} and {@code PrivateKey} types,
>>> algorithm-specific
>>> 71: * subclasses are returned if supported, such as {@code ECPublicKey} or
>>
>> Is this always true?
>
> If an EC key is decoded, it will return the underlying EC key implementation
> that implements the EC interface.
Provider p11s = getPkcs11Provider();
PrivateKey sk =
KeyPairGenerator.getInstance("EC").generateKeyPair().getPrivate();
String pem = PEMEncoder.of().encodeToString(sk);
PrivateKey sk2 = (PrivateKey)
PEMDecoder.of().withFactoryFrom(p11s).decode(pem);
System.out.println(sk2 instanceof ECPrivateKey); // shows "false"
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29640#discussion_r3175657113