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.java: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.
signature.asc
Description: This is a digitally signed message part.
