diff options
Diffstat (limited to '')
-rw-r--r-- | lib/isc/hmac.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/lib/isc/hmac.c b/lib/isc/hmac.c index bc35bef..4bce2c8 100644 --- a/lib/isc/hmac.c +++ b/lib/isc/hmac.c @@ -27,26 +27,26 @@ isc_hmac_t * isc_hmac_new(void) { - EVP_MD_CTX *hmac = EVP_MD_CTX_new(); - RUNTIME_CHECK(hmac != NULL); - return ((isc_hmac_t *)hmac); + EVP_MD_CTX *hmac_st = EVP_MD_CTX_new(); + RUNTIME_CHECK(hmac_st != NULL); + return ((isc_hmac_t *)hmac_st); } void -isc_hmac_free(isc_hmac_t *hmac) { - if (hmac == NULL) { +isc_hmac_free(isc_hmac_t *hmac_st) { + if (hmac_st == NULL) { return; } - EVP_MD_CTX_free((EVP_MD_CTX *)hmac); + EVP_MD_CTX_free((EVP_MD_CTX *)hmac_st); } isc_result_t -isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen, +isc_hmac_init(isc_hmac_t *hmac_st, const void *key, const size_t keylen, const isc_md_type_t *md_type) { EVP_PKEY *pkey; - REQUIRE(hmac != NULL); + REQUIRE(hmac_st != NULL); REQUIRE(key != NULL); REQUIRE(keylen <= INT_MAX); @@ -60,7 +60,7 @@ isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen, return (ISC_R_CRYPTOFAILURE); } - if (EVP_DigestSignInit(hmac, NULL, md_type, NULL, pkey) != 1) { + if (EVP_DigestSignInit(hmac_st, NULL, md_type, NULL, pkey) != 1) { EVP_PKEY_free(pkey); ERR_clear_error(); return (ISC_R_CRYPTOFAILURE); @@ -72,10 +72,10 @@ isc_hmac_init(isc_hmac_t *hmac, const void *key, const size_t keylen, } isc_result_t -isc_hmac_reset(isc_hmac_t *hmac) { - REQUIRE(hmac != NULL); +isc_hmac_reset(isc_hmac_t *hmac_st) { + REQUIRE(hmac_st != NULL); - if (EVP_MD_CTX_reset(hmac) != 1) { + if (EVP_MD_CTX_reset(hmac_st) != 1) { ERR_clear_error(); return (ISC_R_CRYPTOFAILURE); } @@ -84,14 +84,15 @@ isc_hmac_reset(isc_hmac_t *hmac) { } isc_result_t -isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) { - REQUIRE(hmac != NULL); +isc_hmac_update(isc_hmac_t *hmac_st, const unsigned char *buf, + const size_t len) { + REQUIRE(hmac_st != NULL); if (buf == NULL || len == 0) { return (ISC_R_SUCCESS); } - if (EVP_DigestSignUpdate(hmac, buf, len) != 1) { + if (EVP_DigestSignUpdate(hmac_st, buf, len) != 1) { ERR_clear_error(); return (ISC_R_CRYPTOFAILURE); } @@ -100,15 +101,15 @@ isc_hmac_update(isc_hmac_t *hmac, const unsigned char *buf, const size_t len) { } isc_result_t -isc_hmac_final(isc_hmac_t *hmac, unsigned char *digest, +isc_hmac_final(isc_hmac_t *hmac_st, unsigned char *digest, unsigned int *digestlen) { - REQUIRE(hmac != NULL); + REQUIRE(hmac_st != NULL); REQUIRE(digest != NULL); REQUIRE(digestlen != NULL); size_t len = *digestlen; - if (EVP_DigestSignFinal(hmac, digest, &len) != 1) { + if (EVP_DigestSignFinal(hmac_st, digest, &len) != 1) { ERR_clear_error(); return (ISC_R_CRYPTOFAILURE); } @@ -119,24 +120,24 @@ isc_hmac_final(isc_hmac_t *hmac, unsigned char *digest, } const isc_md_type_t * -isc_hmac_get_md_type(isc_hmac_t *hmac) { - REQUIRE(hmac != NULL); +isc_hmac_get_md_type(isc_hmac_t *hmac_st) { + REQUIRE(hmac_st != NULL); - return (EVP_MD_CTX_get0_md(hmac)); + return (EVP_MD_CTX_get0_md(hmac_st)); } size_t -isc_hmac_get_size(isc_hmac_t *hmac) { - REQUIRE(hmac != NULL); +isc_hmac_get_size(isc_hmac_t *hmac_st) { + REQUIRE(hmac_st != NULL); - return ((size_t)EVP_MD_CTX_size(hmac)); + return ((size_t)EVP_MD_CTX_size(hmac_st)); } int -isc_hmac_get_block_size(isc_hmac_t *hmac) { - REQUIRE(hmac != NULL); +isc_hmac_get_block_size(isc_hmac_t *hmac_st) { + REQUIRE(hmac_st != NULL); - return (EVP_MD_CTX_block_size(hmac)); + return (EVP_MD_CTX_block_size(hmac_st)); } isc_result_t @@ -144,24 +145,24 @@ isc_hmac(const isc_md_type_t *type, const void *key, const size_t keylen, const unsigned char *buf, const size_t len, unsigned char *digest, unsigned int *digestlen) { isc_result_t res; - isc_hmac_t *hmac = isc_hmac_new(); + isc_hmac_t *hmac_st = isc_hmac_new(); - res = isc_hmac_init(hmac, key, keylen, type); + res = isc_hmac_init(hmac_st, key, keylen, type); if (res != ISC_R_SUCCESS) { goto end; } - res = isc_hmac_update(hmac, buf, len); + res = isc_hmac_update(hmac_st, buf, len); if (res != ISC_R_SUCCESS) { goto end; } - res = isc_hmac_final(hmac, digest, digestlen); + res = isc_hmac_final(hmac_st, digest, digestlen); if (res != ISC_R_SUCCESS) { goto end; } end: - isc_hmac_free(hmac); + isc_hmac_free(hmac_st); return (res); } |