krb5: Stash the HMAC context in the krb5_crypto object

Store the EVP HMAC context in the krb5_crypto object so that we
don't have to allocate it for every hashing operating we perform.
This commit is contained in:
Simon Wilkinson
2018-05-14 14:21:41 +01:00
committed by Jeffrey Altman
parent e50faea7f0
commit b9b8e76376
4 changed files with 17 additions and 4 deletions

View File

@@ -329,7 +329,7 @@ _krb5_SP_HMAC_SHA1_checksum(krb5_context context,
unsigned char hmac[EVP_MAX_MD_SIZE];
unsigned int hmaclen = sizeof(hmac);
ret = _krb5_evp_hmac_iov(context, key, iov, niov, hmac, &hmaclen,
ret = _krb5_evp_hmac_iov(context, crypto, key, iov, niov, hmac, &hmaclen,
EVP_sha1(), NULL);
heim_assert(result->checksum.length <= hmaclen,
@@ -2526,6 +2526,9 @@ krb5_crypto_destroy(krb5_context context,
if (crypto->mdctx)
EVP_MD_CTX_destroy(crypto->mdctx);
if (crypto->hmacctx)
HMAC_CTX_free(crypto->hmacctx);
free (crypto);
return 0;
}