On Sat, 14 Nov 2020 00:29:41 GMT, Anthony Scarpino <ascarp...@openjdk.org> 
wrote:

>> src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java 
>> line 777:
>> 
>>> 775:         if ((src.remaining() + ((ibuffer != null) ? ibuffer.size() : 
>>> 0) -
>>> 776:             tagLenBytes) > dst.remaining()) {
>>> 777:             throw new RuntimeException("output buffer too small");
>> 
>> Shouldn't this be ShortBufferException instead of RuntimeException?
>
> I thought so too, but that isn't what GCTR returns.  All the GCTR checks are 
> RuntimeExceptions.  This check was original inside of GCTR, but I had to 
> bring it out because of the ibuffer lengths.  I don't mind changing, it's 
> just a strange inconsistency.

GaloisCounterMode is the caller class of GCTR and this API is meant to throw 
ShortBufferException I think (based on the check at lines below at 820-822)...

>> src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java 
>> line 540:
>> 
>>> 538:             // remainder offset is based on original buffer length
>>> 539:             ibuffer.write(in, inOfs + inLen, remainder);
>>> 540:         }
>> 
>> I wonder if this can be moved down for better readability, i.e. process data 
>> in multiple of blocks, and store the remaining into 'ibuffer'?
>
> I tried to, but I don't like how the variable line up doing the remainder 
> afterwards.  I put some hopefully better comments above each section

Ok.

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

PR: https://git.openjdk.java.net/jdk/pull/411

Reply via email to