#else /* OpenSSL version >= 3.0 */
HMAC_CTX *ctx;
#endif /* OpenSSL version >= 3.0 */
+ bool failed;
};
if (ctx == NULL)
return;
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
- EVP_MAC_update(ctx->ctx, data, len);
+ if (!EVP_MAC_update(ctx->ctx, data, len))
+ ctx->failed = true;
#else /* OpenSSL version >= 3.0 */
- HMAC_Update(ctx->ctx, data, len);
+ if (!HMAC_Update(ctx->ctx, data, len))
+ ctx->failed = true;
#endif /* OpenSSL version >= 3.0 */
}
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
size_t mdlen;
int res;
+ bool failed;
if (!ctx)
return -2;
}
res = EVP_MAC_final(ctx->ctx, mac, &mdlen, mdlen);
EVP_MAC_CTX_free(ctx->ctx);
+ failed = ctx->failed;
bin_clear_free(ctx, sizeof(*ctx));
if (TEST_FAIL())
return -1;
+ if (failed)
+ return -2;
+
if (res == 1) {
*len = mdlen;
return 0;
#else /* OpenSSL version >= 3.0 */
unsigned int mdlen;
int res;
+ bool failed;
if (ctx == NULL)
return -2;
mdlen = *len;
res = HMAC_Final(ctx->ctx, mac, &mdlen);
HMAC_CTX_free(ctx->ctx);
+ failed = ctx->failed;
bin_clear_free(ctx, sizeof(*ctx));
if (TEST_FAIL())
return -1;
+ if (failed)
+ return -2;
+
if (res == 1) {
*len = mdlen;
return 0;