On Mon, 12 Oct 2020 20:57:50 GMT, Valerie Peng <valer...@openjdk.org> wrote:

>> I didn't see a way to override this because CipherSpi is a public class, any 
>> methods I added would become a new API. 
>>  Also bufferCrypt is private, so I had to copy it.  CipherSpi does not know 
>> which mode is being used, but AESCipher does.  Maybe I'm missing something, 
>> I'd rather it not be a copy, but I couldn't see a better way. If you have a 
>> specific idea, please give me details.
>
> How about overriding
> protected int engineDoFinal(ByteBuffer input, ByteBuffer output) throws ... {
>     if (core.getMode() == CipherCore.GCM_MODE && !input.hasArray()) {
>         // call your own optimized byte buffer code path
>     } else {
>         super.engineDoFinal(input, output);
>     }
> }
> 
> Would this work? If yes, then no need to duplicate the whole bufferCrypt() 
> method.

Good call.. I wouldn't have thought about super.

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

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

Reply via email to