RFR: 8282038: CipherSpi.bufferCrypt leaves plaintext copy on the heap
Weijun Wang
weijun at openjdk.java.net
Wed Jun 15 22:30:56 UTC 2022
On Wed, 15 Jun 2022 20:17:47 GMT, Mark Powers <duke 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.
Yes, we can.
-------------
PR: https://git.openjdk.org/jdk/pull/9158
More information about the security-dev
mailing list