[xmlsec] xmlsec problem with decrypting EncryptedData using rsa 1.5 encrypted key for symmetric aes256-cbc algorithm key

Aleksey Sanin aleksey at aleksey.com
Wed Feb 22 22:08:33 PST 2012


Sounds like a problem with the document. Do you mind sharing it?

Aleksey

On 2/21/12 1:33 PM, Dolf Andringa wrote:
> Hi Everyone.
> 
> I am trying to decrypt an xml message in python using XMLSec in python
> (PyXMLSec) and run into an error message that seems to come from the C
> xmlsec library.
> I have found the examples on
> http://pyxmlsec.labs.libre-entreprise.org/index.php?section=examples&id=11
> <http://pyxmlsec.labs.libre-entreprise.org/index.php?section=examples&id=11>
> and accordingly did the following, but am receiving errors, which I
> really don't understand.
> The xml seems to be fine, since I can read the xml file and find the
> EncryptedData node.
> The private key file is an RSA private key, which is valid and I can
> successfully use it in other cryptographic libraries.
> I hope anyone can help. Thanks in advance for the effort.
> 
> Cheers,
> 
> Dolf.
> 
> The python code:
> 
> private_key_file='my.private.key'
> xmlstring=open('temp.xml','rb').read()
> 
> import libxml2
> import xmlsec
> 
> libxml2.initParser()
> libxml2.substituteEntitiesDefault(1)
> xmlsec.init()
> xmlsec.cryptoAppInit(None)
> xmlsec.cryptoInit()
> 
> doc=libxml2.parseMemory(xmlstring,len(xmlstring))
> node=xmlsec.findNode(doc.getRootElement(),xmlsec.NodeEncryptedData,xmlsec.EncNs)
> node.get_name()
> '''EncryptedData'''
> print(node.children)
> '''<EncryptionMethod
> Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>'''
> key=xmlsec.keyReadBinaryFile(xmlsec.keyDataRsaId(),private_key_file)
> '''
> func=xmlSecKeyDataBinRead:file=keysdata.c:line=349:obj=unknown:subj=id->binRead
> != NULL:error=100:assertion:
> func=xmlSecKeyReadBuffer:file=keys.c:line=1190:obj=rsa:subj=xmlSecKeyDataBinRead:error=1:xmlsec
> library function failed:
> func=xmlSecKeyReadBinaryFile:file=keys.c:line=1247:obj=rsa:subj=xmlSecKeyReadBuffer:error=1:xmlsec
> library function failed:filename=my.private.key
> '''
> key.setName(private_key_file)
> enc_ctx = xmlsec.EncCtx(None)
> enc_ctx.encKey=key
> 
> enc_ctx.decrypt(node)
> '''func=xmlSecEncCtxEncDataNodeRead:file=xmlenc.c:line=809:obj=unknown:subj=encCtx->mimeType
> == NULL:error=100:assertion:
> func=xmlSecEncCtxDecryptToBuffer:file=xmlenc.c:line=715:obj=unknown:subj=xmlSecEncCtxEncDataNodeRead:error=1:xmlsec
> library function failed:
> func=xmlSecEncCtxDecrypt:file=xmlenc.c:line=623:obj=unknown:subj=xmlSecEncCtxDecryptToBuffer:error=1:xmlsec
> library function failed:
> -1
> '''
> 
> 
> _______________________________________________
> xmlsec mailing list
> xmlsec at aleksey.com
> http://www.aleksey.com/mailman/listinfo/xmlsec


More information about the xmlsec mailing list