<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>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. <br></div>My doubt is that code contains API like CreateHmackey. Whether it is for Hmac-sha1 or for Hmac only. <br>
</div>If i asked silly question please forgive me.<br><br></div><div>Please let me this code is for HMAC-SHA1 signing.<br><br></div><div><br><br></div>The code is:<br><br><br>sign(xmlNodePtr g_SignatureNode, const char* keybuf)<br>
{<br><br> dsigCtx = xmlSecDSigCtxCreate(NULL);<br> if(dsigCtx == NULL) {<br> fprintf(stderr,"Error: failed to create signature context\n");<br> goto done;<br> }<br><br><br> dsigCtx->signKey = CreateHmacKey(keybuf, keysize);<br>
<br><br> xmlSecDSigCtxSign(dsigCtx, g_SignatureNode)<br><br>}<br><br><br><br>xmlSecKeyPtr CreateHmacKey(const xmlSecByte * buf, xmlSecSize size)<br>{<br> xmlSecKeyPtr key;<br> xmlSecKeyDataPtr key_data;<br> int ret;<br>
const unsigned char *p = buf;<br><br> key = xmlSecKeyCreate();<br> if(!key) {<br> return (NULL);<br> }<br><br> key_data = xmlSecKeyDataCreate(xmlSecKeyDataHmacId);<br> if(!key_data) {<br> xmlSecKeyDestroy(key);<br>
return (NULL);<br> }<br><br> ret = xmlSecKeySetValue(key, key_data);<br> if(ret < 0) {<br> xmlSecKeyDataDestroy(key_data);<br> xmlSecKeyDestroy(key);<br> return (NULL);<br> }<br><br><br> ret = xmlSecOpenSSLKeyDataHmacSet(key_data, buf, size);<br>
if(ret < 0) {<br> xmlSecKeyDestroy(key);<br> return (NULL);<br> }<br><br> return (key);<br>}<br><br><br></div>Thanks,<br>Venkat.<br></div>