I think you are using 256 bit encryption with the limited
strenth
jurisdiction files.
See: Java Cryptography Extension (JCE), Unlimited Strength
Jurisdiction
Policy Files 1.4.2 (htt
p://java.sun.com/j2se/1.4.2/download.html#docs)
Regards,
Mike
"huang zhimin" <flyerhzm gmail.com> wrote on
09/21/2007 10:13:16 AM:
> public void encrypt(Document document) throws Exception
{
> KeyStore ks = getKeyStore();
> X509Certificate certificate =
getCertificate(ks);
> String algorithmURI = XMLCipher.AES_256;
>
> Element rootElement =
document.getDocumentElement();
>
> XMLCipher xmlCipher =
XMLCipher.getInstance(algorithmURI);
> xmlCipher.init(XMLCipher.ENCRYPT_MODE,
certificate.getPublicKey
());
>
> EncryptedData encryptedData =
xmlCipher.getEncryptedData();
> KeyInfo keyInfo = new KeyInfo(document);
> encryptedData.setKeyInfo(keyInfo);
> xmlCipher.doFinal(document, rootElement, true);
> }
>
> I have do it, but get the exception
>
> Exception was java.security.InvalidKeyException:
Illegal key size or
> default parameters
> at org.apache.xml.security.encryption.XMLCipher.
> encryptData(Unknown Source)
> at org.apache.xml.security.encryption.XMLCipher.
> encryptData(Unknown Source)
> at org.apache.xml.security.encryption.XMLCipher.
> encryptElementContent(Unknown Source)
> at
org.apache.xml.security.encryption.XMLCipher.doFinal
(Unknown
Source)
> at
org.jtang.service.security.engine.SecurityEngine.
> encrypt(SecurityEngine.java:121)
> at
org.jtang.service.security.engine.SecurityEngineTest.
> testEncrypt(SecurityEngineTest.java:141)
>
> What's wrong?
> On 9/21/07, Daniele Gagliardi <daniele.gagliardi eng.it
> wrote:
> If you're using asymmetric cryptography, why do you
want to use private
> key for encryption? In this way everyone who has the
public key (which
> is PUBLIC) can decrypt the xml.
> For xml encryption, you can use the very good examples
in apache xml
> signature package (you can found these in
>
xml-security-1_4_1/src_samples/org/apache/xml/security/sampl
es/encryption
> directory of the apache distribution in
> htt
p://xml.apache.org/security/dist/java-library/ )
>
> huang zhimin ha scritto:
> > Can anybody give me an example to encrypt xml with
private key?
> >
> > --
> > http://so
urceforge.net/projects/mycodeline/
> > http://rubyf
orge.org/projects/ropenwiki/
>
>
>
> --
> http://so
urceforge.net/projects/mycodeline/
> http://rubyf
orge.org/projects/ropenwiki/
|