You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Ruchith Fernando <ru...@gmail.com> on 2004/08/18 15:32:20 UTC

Problems in encrypting with AES_192 and AES_256

Hi All,

I'm trying to simply encrypt a simple XML file with the encryption
sample available.
org.apache.xml.security.samples.encryption.Encrypter;

But I get the foollowning exception when I set the key size to 192 or
256 in the GenerateDataEncryptionKey() method.

java.lang.SecurityException: Unsupported keysize or algorithm parameters
	at javax.crypto.Cipher.init(DashoA6275)
	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:957)
	at org.apache.xml.security.encryption.XMLCipher.encryptElementContent(XMLCipher.java:735)
	at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:858)
	at org.apache.xml.security.samples.encryption.Encrypter.main(Encrypter.java:195)


Can someone please explain whether I'm doing some thing theoritically
wrong or the correct way to encrypt using AES 192 and AES 256.

Thanks,
Ruchith


   private static SecretKey GenerateDataEncryptionKey() throws Exception {

        String jceAlgorithmName = "AES";
        KeyGenerator keyGenerator =
            KeyGenerator.getInstance(jceAlgorithmName);
        keyGenerator.init(192);  //Setting the key length :-?
        return keyGenerator.generateKey();
    }

Re: Problems in encrypting with AES_192 and AES_256

Posted by Sean Mullan <Se...@Sun.COM>.
You probably are not using the unlimited strength JCE. See 
http://java.sun.com/products/jce/index-14.html#UnlimitedDownload for further 
downloading instructions.

--Sean

Ruchith Fernando wrote:
> Hi All,
> 
> I'm trying to simply encrypt a simple XML file with the encryption
> sample available.
> org.apache.xml.security.samples.encryption.Encrypter;
> 
> But I get the foollowning exception when I set the key size to 192 or
> 256 in the GenerateDataEncryptionKey() method.
> 
> java.lang.SecurityException: Unsupported keysize or algorithm parameters
> 	at javax.crypto.Cipher.init(DashoA6275)
> 	at org.apache.xml.security.encryption.XMLCipher.encryptData(XMLCipher.java:957)
> 	at org.apache.xml.security.encryption.XMLCipher.encryptElementContent(XMLCipher.java:735)
> 	at org.apache.xml.security.encryption.XMLCipher.doFinal(XMLCipher.java:858)
> 	at org.apache.xml.security.samples.encryption.Encrypter.main(Encrypter.java:195)
> 
> 
> Can someone please explain whether I'm doing some thing theoritically
> wrong or the correct way to encrypt using AES 192 and AES 256.
> 
> Thanks,
> Ruchith
> 
> 
>    private static SecretKey GenerateDataEncryptionKey() throws Exception {
> 
>         String jceAlgorithmName = "AES";
>         KeyGenerator keyGenerator =
>             KeyGenerator.getInstance(jceAlgorithmName);
>         keyGenerator.init(192);  //Setting the key length :-?
>         return keyGenerator.generateKey();
>     }