On Mon, 7 Dec 2020 19:53:27 GMT, Valerie Peng <valer...@openjdk.org> wrote:

>> Jamil Nimeh has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   pre-init getParameters nonce data is now a local variable
>
> src/java.base/share/classes/com/sun/crypto/provider/ChaCha20Cipher.java line 
> 232:
> 
>> 230:             // this call should cause a random nonce to be generated, 
>> but
>> 231:             // not attached to the object.
>> 232:             byte[] nonceData = initialized ? nonce : 
>> createRandomNonce(null);
> 
> The "initialized" variable is set to false in engineDoFinal() call. So, if 
> users call getParameters() after finish cipher operation, this will return 
> random nonces instead of the one used in previous doFinal operation. Will 
> this be a little un-intuitive?

Unintuitive is a charitable way to put it.  After doFinal the Cipher 
technically isn't in an uninitialized state per the spec, it's supposed to be 
in the state it would be immediately following init().  So the wrong behavior 
would happen in this use case.  Will fix.

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

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

Reply via email to