santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ralph-xmlsecur...@ralphholz.de
Subject Re: How to decrypt with RSA-OAEP/AES?
Date Tue, 28 Aug 2007 13:05:51 GMT
Hi,

Following up myself, I can see that 

xmlCipherRSA.loadEncryptedKey(encryptedKeyElement);

works and 

encryptedKey.getKeyInfo() returns null. Why is that?

Thanks,
Ralph


On Monday 27 August 2007 17:17:00 ralph-xmlsecurity@ralphholz.de wrote:
> Hi,
>
> I'm having difficulty decrypting an RSA/AES-encrypted document. I used
> RSA-OAEP in wrap mode to encrypt a shared key:
>
> xmlCipherRSA.init(XMLCipher.WRAP_MODE, pk);
> xmlCipherAES.init(XMLCipher.ENCRYPT_MODE, symKey);
> encKey = xmlCipherRSA.encryptKey(document, symKey);
>
> and encrypted OK.
>
> Then I wanted to decrypt:
>
>  xmlCipherRSA.init(XMLCipher.UNWRAP_MODE, privateKey);
>
>  Element encryptedDataElement = (Element) document
> 	.getElementsByTagNameNS(EncryptionConstants.EncryptionSpecNS,
> 	EncryptionConstants._TAG_ENCRYPTEDDATA).item(0);
>
> Element encryptedKeyElement = (Element) encryptedDataElement
> 	.getElementsByTagNameNS(EncryptionConstants.EncryptionSpecNS,
> 	EncryptionConstants._TAG_ENCRYPTEDKEY).item(0);
>
> EncryptedKey encryptedKey =
> xmlCipherRSA.loadEncryptedKey(encryptedKeyElement);
>
> // xmlCipherRSA.setKEK(privateKey);
> Key secretKey = xmlCipherRSA.decryptKey(encryptedKey);
>
> At which point I get:
>
> Exception in thread "main" java.lang.NullPointerException
> 	at org.apache.xml.security.encryption.XMLCipher.decryptKey(Unknown Source)
> 	at
> tue.cryptography.messages.PDPCryptoOperator.decryptMsg(PDPCryptoOperator.ja
>va:190) at
> tue.cryptography.messages.FactoryTester.main(FactoryTester.java:64)
>
> I guess I do something in the wrong order or have omitted a step - but
> which?
>
> Thanks,
> Ralph



-- 
For contact details, please see www.ralphholz.de.

Mime
View raw message