From 85cec1cf37c0217ba2de29392b58ead31f14d4ca Mon Sep 17 00:00:00 2001 From: "Keith W. Campbell" Date: Mon, 8 Feb 2021 19:53:19 -0500 Subject: [PATCH] Access nonce only when non-null Methods engineGetIV() and engineGetParameters() should be independent of the value of 'initialized' for consistency with the reference implementation. Signed-off-by: Keith W. Campbell --- .../classes/com/sun/crypto/provider/NativeChaCha20Cipher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java b/closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java index a6a42bac39c..3bd1ae7f15e 100644 --- a/closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java +++ b/closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java @@ -193,7 +193,7 @@ protected int engineGetOutputSize(int inputLen) { */ @Override protected byte[] engineGetIV() { - return (nonce == null)? null : nonce.clone(); + return (nonce != null) ? nonce.clone() : null; } /** @@ -211,7 +211,7 @@ protected byte[] engineGetIV() { @Override protected AlgorithmParameters engineGetParameters() { AlgorithmParameters params = null; - byte[] nonceData = (initialized || nonce != null) ? nonce : createRandomNonce(null); + byte[] nonceData = (nonce != null) ? nonce : createRandomNonce(null); if (mode == MODE_AEAD) { try { // Force the 12-byte nonce into a DER-encoded OCTET_STRING