Hello Mailinglist,

how does xmlSecKeyReadMemory() work? In what format should be the key?
Lets take the example rsakey.pem. This works:
xmlSecCryptoAppKeyLoad("Z:\\XmlSec\\examples\\rsakey.pem", 
xmlSecKeyDataFormatPem, 0, 0, 0);

Now I'm trying to load the key from the RAM.

In the Konstruktor I have placed this code:
// The whole key of rsakey.pem in one line without the new lines:
const char 
*cRsaKey2048Private="MIIEpQIBAAKCAQEAzFuwv0gXgmiSib1Py38Rkd/d6fOsujvGN09PBXInEiVWVtyyd3EHAU98+X3i"
 // ...


// Convert key into binary:
int iBinLength = strlen(cRsaKey2048Private)*6/8+2; // Calulate buffer size
unsigned char *cBuffer = new unsigned char[iBinLength]; // Create Buffer
iBinLength = xmlSecBase64Decode(BAD_CAST cRsaKey2048Private, 
        cBuffer,
        iBinLength); // Convert key from base64 to binary. Checked, in cBuffer 
is the key in binary.

// Try to load the key... but oKey is still zero!
xmlSecKey *oKey = xmlSecKeyReadMemory(xmlSecKeyDataRsaId,
        cBuffer,
        iBinLength);
dsigCtx->signKey = oKey;


The error messages are:
func=xmlSecKeyDataBinRead:file=..\src\keysdata.c:line=349:obj=unknown:subj=id->binRead
 != NULL:error=100:assertion:
func=xmlSecKeyReadBuffer:file=..\src\keys.c:line=1184:obj=rsa:subj=xmlSecKeyDataBinRead:error=1:xmlsec
 library function failed:
func=xmlSecKeyReadMemory:file=..\src\keys.c:line=1298:obj=rsa:subj=xmlSecKeyReadBuffer:error=1:xmlsec
 library function failed:

I can go though the XmlSec source but it doesnt help much why this should be 
"id->binRead!=NULL". The id comes from my input param xmlSecKeyDataRsaId, but 
if this not work, what should I take instead?


Regards

Martin

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
_______________________________________________
xmlsec mailing list
[email protected]
http://www.aleksey.com/mailman/listinfo/xmlsec

Reply via email to