RFR: 8308808: SunMSCAPI public keys returns internal key array

Sean Mullan mullan at openjdk.org
Wed Jun 14 20:30:59 UTC 2023


On Mon, 12 Jun 2023 18:49:59 GMT, Ben Perez <duke at openjdk.org> wrote:

> Changed `getEncoded` for both EC and RSA to return a copy of the internal key array to avoid mutability issues.

src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CPublicKey.java line 99:

> 97:             byte[] safeEncoding = new byte[encoding.length];
> 98:             System.arraycopy(encoding, 0, safeEncoding, 0, encoding.length);
> 99:             return safeEncoding;

You can replace these lines (and below) with `return encoding.clone();` which is more compact and the same AFAICT.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14425#discussion_r1230130701



More information about the security-dev mailing list