8293779: redundant checking in AESCrypt.makeSessionKey() method
Reviewed-by: djelinski, hchao, mullan
This commit is contained in:
parent
6fca9ae047
commit
ecb456ae29
@ -86,9 +86,9 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
|
|||||||
throw new InvalidKeyException
|
throw new InvalidKeyException
|
||||||
("Wrong algorithm: AES or Rijndael required");
|
("Wrong algorithm: AES or Rijndael required");
|
||||||
}
|
}
|
||||||
if (!isKeySizeValid(key.length)) {
|
|
||||||
throw new InvalidKeyException("Invalid AES key length: " +
|
if (key == null) { // Unlikely, but just double check it.
|
||||||
key.length + " bytes");
|
throw new InvalidKeyException("Empty key");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MessageDigest.isEqual(key, lastKey)) {
|
if (!MessageDigest.isEqual(key, lastKey)) {
|
||||||
@ -602,13 +602,11 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
|
|||||||
* @exception InvalidKeyException If the key is invalid.
|
* @exception InvalidKeyException If the key is invalid.
|
||||||
*/
|
*/
|
||||||
private void makeSessionKey(byte[] k) throws InvalidKeyException {
|
private void makeSessionKey(byte[] k) throws InvalidKeyException {
|
||||||
if (k == null) {
|
|
||||||
throw new InvalidKeyException("Empty key");
|
|
||||||
}
|
|
||||||
if (!isKeySizeValid(k.length)) {
|
if (!isKeySizeValid(k.length)) {
|
||||||
throw new InvalidKeyException("Invalid AES key length: " +
|
throw new InvalidKeyException("Invalid AES key length: " +
|
||||||
k.length + " bytes");
|
k.length + " bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
int ROUNDS = getRounds(k.length);
|
int ROUNDS = getRounds(k.length);
|
||||||
int ROUND_KEY_COUNT = (ROUNDS + 1) * 4;
|
int ROUND_KEY_COUNT = (ROUNDS + 1) * 4;
|
||||||
|
|
||||||
@ -696,7 +694,6 @@ final class AESCrypt extends SymmetricCipher implements AESConstants
|
|||||||
sessionK = new int[][] { expandedKe, expandedKd };
|
sessionK = new int[][] { expandedKe, expandedKd };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return The number of rounds for a given Rijndael keysize.
|
* Return The number of rounds for a given Rijndael keysize.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user