/* If the key is too long, replace it by its hash digest. */
if(keylen > hashparams->maxkeylen) {
if(hashparams->hinit(ctxt->hashctxt1))
- return NULL;
+ goto fail;
hashparams->hupdate(ctxt->hashctxt1, key, keylen);
hkey = (unsigned char *) ctxt->hashctxt2 + hashparams->ctxtsize;
hashparams->hfinal(hkey, ctxt->hashctxt1);
/* Prime the two hash contexts with the modified key. */
if(hashparams->hinit(ctxt->hashctxt1) ||
hashparams->hinit(ctxt->hashctxt2))
- return NULL;
+ goto fail;
for(i = 0; i < keylen; i++) {
b = (unsigned char)(*key ^ hmac_ipad);
/* Done, return pointer to HMAC context. */
return ctxt;
+
+fail:
+ free(ctxt);
+ return NULL;
}
int Curl_HMAC_update(struct HMAC_context *ctxt,