RFR: 8255557: Decouple GCM from CipherCore [v4]
Anthony Scarpino
ascarpino at openjdk.java.net
Wed Jun 2 03:14:43 UTC 2021
On Tue, 1 Jun 2021 19:28:44 GMT, Valerie Peng <valeriep at openjdk.org> wrote:
>> src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java line 874:
>>
>>> 872: } else if (!src.isDirect() && !dst.isDirect()) {
>>> 873: // if src is read only, then we need a copy
>>> 874: if (!src.isReadOnly()) {
>>
>> Do you mean if (src.hasArray() && dst.hasArray())? Even if src is not read only, but array()/arrayOffset() methods are optional and can only be safely invoked after the hasArray() call.
>
> I assume this is again the case of !isDirect()&&!isReadOnly => hasArray()?
hasArray() would not be appropriate here. The code needs to get into this if, being a heap bytebuffer. If I use hasArray() it will skip to the ending else and cause a test failure. Having the isReadOnly checked inside the if(isDirect) causes it to create the necessary copy
-------------
PR: https://git.openjdk.java.net/jdk/pull/4072
More information about the security-dev
mailing list