@@ -86,9 +86,9 @@ void init(boolean decrypting, String algorithm, byte[] key)
86
86
throw new InvalidKeyException
87
87
("Wrong algorithm: AES or Rijndael required" );
88
88
}
89
- if (! isKeySizeValid ( key . length )) {
90
- throw new InvalidKeyException ( "Invalid AES key length: " +
91
- key . length + " bytes " );
89
+
90
+ if ( key == null ) { // Unlikely, but just double check it.
91
+ throw new InvalidKeyException ( "Empty key " );
92
92
}
93
93
94
94
if (!MessageDigest .isEqual (key , lastKey )) {
@@ -602,13 +602,11 @@ private void implDecryptBlock(byte[] in, int inOffset,
602
602
* @exception InvalidKeyException If the key is invalid.
603
603
*/
604
604
private void makeSessionKey (byte [] k ) throws InvalidKeyException {
605
- if (k == null ) {
606
- throw new InvalidKeyException ("Empty key" );
607
- }
608
605
if (!isKeySizeValid (k .length )) {
609
- throw new InvalidKeyException ("Invalid AES key length: " +
610
- k .length + " bytes" );
606
+ throw new InvalidKeyException ("Invalid AES key length: " +
607
+ k .length + " bytes" );
611
608
}
609
+
612
610
int ROUNDS = getRounds (k .length );
613
611
int ROUND_KEY_COUNT = (ROUNDS + 1 ) * 4 ;
614
612
@@ -696,7 +694,6 @@ private void makeSessionKey(byte[] k) throws InvalidKeyException {
696
694
sessionK = new int [][] { expandedKe , expandedKd };
697
695
}
698
696
699
-
700
697
/**
701
698
* Return The number of rounds for a given Rijndael keysize.
702
699
*
0 commit comments