RFR: 8360564: Implement JEP 524: PEM Encodings of Cryptographic Objects (Second Preview) [v4]
Sean Mullan
mullan at openjdk.org
Thu Oct 2 21:18:49 UTC 2025
On Thu, 25 Sep 2025 23:03:11 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:
>> Hi
>>
>> Please review the [Second Preview](https://openjdk.org/jeps/8360563) for the PEM API. The most significant changes from [JEP 470](https://openjdk.org/jeps/470) are:
>>
>> - Renamed the name of `PEMRecord` class to `PEM`.
>> - Revised the new `encryptKey` methods of the `EncryptedPrivateKeyInfo` class to accept `DEREncodable` objects rather than just `PrivateKey` objects so that cryptographic objects with public keys, i.e., `KeyPair` and `PKCS8EncodedKeySpec`, can also be encrypted.
>> - Enhanced the `PEMEncoder` and `PEMDecoder` classes to support the encryption and decryption of `KeyPair` and `PKCS8EncodedKeySpec` objects.
>>
>> thanks
>>
>> Tony
>
> Anthony Scarpino has updated the pull request incrementally with one additional commit since the last revision:
>
> missed some decoder comments
src/java.base/share/classes/sun/security/ec/ECPrivateKeyImpl.java line 105:
> 103: Arrays.fill(sArr, (byte) 0);
> 104: makeEncoding(sOctets);
> 105: Arrays.fill(sOctets, (byte) 0);
You need a try-finally block so that the arrays are cleared even in the case an exception is thrown.
src/java.base/share/classes/sun/security/ec/ECPrivateKeyImpl.java line 115:
> 113: ArrayUtil.reverse(privBytes);
> 114: makeEncoding(privBytes);
> 115: Arrays.fill(privBytes, (byte) 0);
You need a try-finally block so that the array is cleared even in the case an exception is thrown.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27147#discussion_r2400077187
PR Review Comment: https://git.openjdk.org/jdk/pull/27147#discussion_r2400075946
More information about the security-dev
mailing list