mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +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
|
@ -179,14 +179,16 @@ public final class ARCFOURCipher extends CipherSpi {
|
|||
init(opmode, key);
|
||||
}
|
||||
|
||||
// init method. Check opmode and key, then call init(byte[]).
|
||||
// init method. Check key, then call init(byte[]).
|
||||
private void init(int opmode, Key key) throws InvalidKeyException {
|
||||
|
||||
// Cipher.init() already checks opmode to be:
|
||||
// ENCRYPT_MODE/DECRYPT_MODE/WRAP_MODE/UNWRAP_MODE
|
||||
|
||||
if (lastKey != null) {
|
||||
Arrays.fill(lastKey, (byte)0);
|
||||
}
|
||||
if ((opmode < Cipher.ENCRYPT_MODE) || (opmode > Cipher.UNWRAP_MODE)) {
|
||||
throw new InvalidKeyException("Unknown opmode: " + opmode);
|
||||
}
|
||||
|
||||
lastKey = getEncodedKey(key);
|
||||
init(lastKey);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue