static unsigned char seq[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static unsigned char ver[2] = { 0x01, 0x00 }; /* DTLS1_BAD_VER */
unsigned char lenbytes[2];
- EVP_MAC *hmac;
- EVP_MAC_CTX *ctx;
+ EVP_MAC *hmac = NULL;
+ EVP_MAC_CTX *ctx = NULL;
EVP_CIPHER_CTX *enc_ctx = NULL;
unsigned char iv[16];
unsigned char pad;
memcpy(enc, msg, len);
/* Append HMAC to data */
- if ((hmac = EVP_MAC_fetch(NULL, "HMAC", NULL)) == NULL)
- return 0;
- ctx = EVP_MAC_CTX_new(hmac);
- EVP_MAC_free(hmac);
- if (ctx == NULL)
- return 0;
+ if (!TEST_ptr(hmac = EVP_MAC_fetch(NULL, "HMAC", NULL))
+ || !TEST_ptr(ctx = EVP_MAC_CTX_new(hmac)))
+ goto end;
params[0] = OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_DIGEST,
"SHA1", 0);
params[1] = OSSL_PARAM_construct_end();
BIO_write(rbio, enc, len);
ret = 1;
end:
+ EVP_MAC_free(hmac);
EVP_MAC_CTX_free(ctx);
EVP_CIPHER_CTX_free(enc_ctx);
OPENSSL_free(enc);