RFR: 8282038: CipherSpi.bufferCrypt leaves plaintext copy on the heap

Mark Powers duke at openjdk.java.net
Wed Jun 15 20:21:03 UTC 2022


On Tue, 14 Jun 2022 17:57:17 GMT, Weijun Wang <weijun at openjdk.org> wrote:

> Clearing buffers and temporary arrays to avoid data leaks in cipher operations.

src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 1014:

> 1012:             dst.flip();
> 1013:             originalDst.put(dst);
> 1014:             dst.clear().put(new byte[dst.capacity()]);

If `dst` is an array-backed ByteByffer, could you use `Array.fill` to avoid a memory allocation? It's surprising to me that ByteBuffer doesn't have a method to set all of the bytes in the ByteBuffer.

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

PR: https://git.openjdk.org/jdk/pull/9158



More information about the security-dev mailing list