-/* $OpenBSD: hm_pmeth.c,v 1.16 2023/11/29 21:35:57 tb Exp $ */
+/* $OpenBSD: hm_pmeth.c,v 1.17 2023/12/28 22:00:56 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2007.
*/
{
ASN1_OCTET_STRING *hkey = NULL;
HMAC_PKEY_CTX *hctx = ctx->data;
+ int ret = 0;
- if (!hctx->ktmp.data)
- return 0;
- hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp);
- if (!hkey)
- return 0;
- EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey);
+ if (hctx->ktmp.data == NULL)
+ goto err;
+ if ((hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp)) == NULL)
+ goto err;
+ if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey))
+ goto err;
+ hkey = NULL;
- return 1;
+ ret = 1;
+
+ err:
+ ASN1_OCTET_STRING_free(hkey);
+
+ return ret;
}
static int