mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8265500: Some impls of javax.crypto.Cipher.init() do not throw UnsupportedOperationExc for unsupported modes
Reviewed-by: xuelei
This commit is contained in:
parent
9130b8a9d7
commit
80dc262e81
8 changed files with 302 additions and 53 deletions
|
@ -535,12 +535,11 @@ abstract class ChaCha20Cipher extends CipherSpi {
|
|||
*/
|
||||
private void init(int opmode, Key key, byte[] newNonce)
|
||||
throws InvalidKeyException {
|
||||
// Cipher.init() already checks opmode to be:
|
||||
// ENCRYPT_MODE/DECRYPT_MODE/WRAP_MODE/UNWRAP_MODE
|
||||
if ((opmode == Cipher.WRAP_MODE) || (opmode == Cipher.UNWRAP_MODE)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"WRAP_MODE and UNWRAP_MODE are not currently supported");
|
||||
} else if ((opmode != Cipher.ENCRYPT_MODE) &&
|
||||
(opmode != Cipher.DECRYPT_MODE)) {
|
||||
throw new InvalidKeyException("Unknown opmode: " + opmode);
|
||||
}
|
||||
|
||||
// Make sure that the provided key and nonce are unique before
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue