Hi,
I have written the follwing code to sign the element in the document using
HMAC-SHA1 Algorithm. I have taken the sample code from this mailing list.
My doubt is that code contains API like CreateHmackey. Whether it is for
Hmac-sha1 or for Hmac only.
If i asked silly question please forgive me.
Please let me this code is for HMAC-SHA1 signing.
The code is:
sign(xmlNodePtr g_SignatureNode, const char* keybuf)
{
dsigCtx = xmlSecDSigCtxCreate(NULL);
if(dsigCtx == NULL) {
fprintf(stderr,"Error: failed to create signature context\n");
goto done;
}
dsigCtx->signKey = CreateHmacKey(keybuf, keysize);
xmlSecDSigCtxSign(dsigCtx, g_SignatureNode)
}
xmlSecKeyPtr CreateHmacKey(const xmlSecByte * buf, xmlSecSize size)
{
xmlSecKeyPtr key;
xmlSecKeyDataPtr key_data;
int ret;
const unsigned char *p = buf;
key = xmlSecKeyCreate();
if(!key) {
return (NULL);
}
key_data = xmlSecKeyDataCreate(xmlSecKeyDataHmacId);
if(!key_data) {
xmlSecKeyDestroy(key);
return (NULL);
}
ret = xmlSecKeySetValue(key, key_data);
if(ret < 0) {
xmlSecKeyDataDestroy(key_data);
xmlSecKeyDestroy(key);
return (NULL);
}
ret = xmlSecOpenSSLKeyDataHmacSet(key_data, buf, size);
if(ret < 0) {
xmlSecKeyDestroy(key);
return (NULL);
}
return (key);
}
Thanks,
Venkat.
_______________________________________________
xmlsec mailing list
[email protected]
http://www.aleksey.com/mailman/listinfo/xmlsec