[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-security-dev
Subject:    Re: No provider for SHA-256
From:       Michael McIntosh <mikemci () us ! ibm ! com>
Date:       2007-09-22 13:18:00
Message-ID: OF824463EA.7BD7049A-ON8525735E.0047C2BD-8525735E.00490963 () us ! ibm ! com
[Download RAW message or body]

I am not sure how to use SHA-256 as a cipher algorithm, and doubt you 
would use a public key from a certificate with it.
Also, since you seem to be encrypting a significant amount of data I'd 
suggest you generate a symmetric key (TRIPLEDES or AES), encrypt the data 
("rootElement") with it, and then encrypt the symmetric key with the 
public key from the certificate (via RSA_v1dot5 or RSA_OAEP

Good Luck,
Mike

"huang zhimin" <flyerhzm@gmail.com> wrote on 09/22/2007 04:49:18 AM:

> public void encrypt(Document document) throws Exception {
>         KeyStore ks = getKeyStore();
>         X509Certificate certificate = getCertificate(ks);
>         String algorithmURI = XMLCipher.SHA256;
> 
>         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); 
> }
> 
> The keystore is provided from the example of xml-security. The exception 
is 
> 
> Original Exception was java.security.NoSuchAlgorithmException: 
> Cannot find any provider supporting SHA-256
>     at org.apache.xml.security.encryption.XMLCipher.getInstance 
> (Unknown Source)
>     at org.jtang.service.security.engine.SecurityEngine.
> encrypt(SecurityEngine.java:117)
> 
> I don't know how to solve it.
> 
> -- 
> http://sourceforge.net/projects/mycodeline/
> http://rubyforge.org/projects/ropenwiki/ 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic