8282534: Remove redundant null check in ChaCha20Cipher.engineInit

Reviewed-by: xuelei
This commit is contained in:
Andrey Turbanov 2022-03-19 13:31:50 +00:00
parent e8caf84fb9
commit 80415e04c5

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -159,7 +159,7 @@ abstract class ChaCha20Cipher extends CipherSpi {
* ciphers, but allow {@code NoPadding}. See JCE spec.
*
* @param padding The padding type. The only allowed value is
* {@code NoPadding} case insensitive).
* {@code NoPadding} case insensitive.
*
* @throws NoSuchPaddingException if a padding scheme besides
* {@code NoPadding} is provided.
@ -393,7 +393,7 @@ abstract class ChaCha20Cipher extends CipherSpi {
return;
}
byte[] newNonce = null;
byte[] newNonce;
switch (mode) {
case MODE_NONE:
throw new InvalidAlgorithmParameterException(
@ -420,12 +420,6 @@ abstract class ChaCha20Cipher extends CipherSpi {
throw new RuntimeException("Invalid mode: " + mode);
}
// If after all the above processing we still don't have a nonce value
// then supply a random one provided a random source has been given.
if (newNonce == null) {
newNonce = createRandomNonce(random);
}
// Continue with initialization
init(opmode, key, newNonce);
}