RFR: 8257769: Cipher.getParameters() throws NPE for ChaCha20-Poly1305 [v2]

Bernd Eckenfels ecki at zusammenkunft.net
Tue Dec 8 01:19:48 UTC 2020


BTW stupid - somewhat related - question, why does the nonce to be parsed out of a DER blob, shouldn’t there be an getter on the Parameter Spec object? Many protocols would need the raw array, is there a matching spec - or should we add one?

Gruss
Bernd
--
http://bernd.eckenfels.net
________________________________
Von: security-dev <security-dev-retn at openjdk.java.net> im Auftrag von Jamil Nimeh <jnimeh at openjdk.java.net>
Gesendet: Monday, December 7, 2020 9:05:16 PM
An: security-dev at openjdk.java.net <security-dev at openjdk.java.net>
Betreff: Re: RFR: 8257769: Cipher.getParameters() throws NPE for ChaCha20-Poly1305 [v2]

On Mon, 7 Dec 2020 19:53:27 GMT, Valerie Peng <valeriep at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20201208/1507b679/attachment.htm>


More information about the security-dev mailing list