-
Bug
-
Resolution: Fixed
-
P3
-
unknown
-
beagle
-
sparc
-
solaris_8
-
Verified
The AES cipher can not accept the key size correctly.
1: put the sunaes.jar file in the $JAVA_HOME/lib/ext.
2: add the line "security.provider.6=com.sun.advcrypto.provider.SunAES" in the java.security file in $JAVA_HOME/lib/security directory.
3: complie the test file(seems compiler find the correct jar file)
4: execute it. you will find a exception.
the following program demonstrates this:
import java.io.PrintStream;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
import com.sun.advcrypto.provider.SunAES;
public class test {
public static void main( String argv[] ) {
try{
String algorithm = "AES";
String mode = "ECb";
String padding = "NoPadding";
int keyStrength=128;
AlgorithmParameterSpec aps = null;
Cipher ci = Cipher.getInstance( algorithm, "SunAES" );
KeyGenerator kg = KeyGenerator.getInstance( algorithm, "SunAES" );
kg.init(keyStrength);
SecretKey key = kg.generateKey();
ci.init( Cipher.ENCRYPT_MODE, key, aps);
System.out.println("PASSED");
}catch(Exception ex){
System.out.println("FAILED");
ex.printStackTrace();
}
}
}
lwang:/home/lw129730( 211 )%java test
FAILED
java.security.InvalidKeyException
at cryptix.jce.provider.cipher.Rijndael.engineGetKeySize(DashoA6275)
at javax.crypto.Cipher.init(DashoA6275)
at test.main(test.java:28)
1: put the sunaes.jar file in the $JAVA_HOME/lib/ext.
2: add the line "security.provider.6=com.sun.advcrypto.provider.SunAES" in the java.security file in $JAVA_HOME/lib/security directory.
3: complie the test file(seems compiler find the correct jar file)
4: execute it. you will find a exception.
the following program demonstrates this:
import java.io.PrintStream;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.Provider;
import com.sun.advcrypto.provider.SunAES;
public class test {
public static void main( String argv[] ) {
try{
String algorithm = "AES";
String mode = "ECb";
String padding = "NoPadding";
int keyStrength=128;
AlgorithmParameterSpec aps = null;
Cipher ci = Cipher.getInstance( algorithm, "SunAES" );
KeyGenerator kg = KeyGenerator.getInstance( algorithm, "SunAES" );
kg.init(keyStrength);
SecretKey key = kg.generateKey();
ci.init( Cipher.ENCRYPT_MODE, key, aps);
System.out.println("PASSED");
}catch(Exception ex){
System.out.println("FAILED");
ex.printStackTrace();
}
}
}
lwang:/home/lw129730( 211 )%java test
FAILED
java.security.InvalidKeyException
at cryptix.jce.provider.cipher.Rijndael.engineGetKeySize(DashoA6275)
at javax.crypto.Cipher.init(DashoA6275)
at test.main(test.java:28)