-/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2007.
*/
/* ====================================================================
return 0;
hctx->md = NULL;
hctx->ktmp.data = NULL;
+ hctx->ktmp.length = 0;
+ hctx->ktmp.flags = 0;
+ hctx->ktmp.type = V_ASN1_OCTET_STRING;
HMAC_CTX_init(&hctx->ctx);
ctx->data = hctx;
ctx->keygen_info_count = 0;
-
+
return 1;
}
HMAC_CTX_cleanup(&hctx->ctx);
if (hctx->ktmp.data)
{
- OPENSSL_cleanse(hctx->ktmp.data, hctx->ktmp.length);
+ if (hctx->ktmp.length)
+ OPENSSL_cleanse(hctx->ktmp.data, hctx->ktmp.length);
OPENSSL_free(hctx->ktmp.data);
hctx->ktmp.data = NULL;
}
{
unsigned int hlen;
HMAC_PKEY_CTX *hctx = ctx->data;
- *siglen = EVP_MD_CTX_size(mctx);
+ int l = EVP_MD_CTX_size(mctx);
+
+ if (l < 0)
+ return 0;
+ *siglen = l;
if (!sig)
return 1;
}
if (!strcmp(type, "key"))
{
+ void *p = (void *)value;
return pkey_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY,
- -1, (void *)value);
+ -1, p);
}
if (!strcmp(type, "hexkey"))
{