From 70100c664a06bef484326c651b9fd29ec453a5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 12 Mar 2020 09:45:58 +0100 Subject: [PATCH] Stop leaking OpenSSL types and defines in the isc/hmac.h The header directly included header which enforced all users of the libisc library to explicitly list the include path to OpenSSL and link with -lcrypto. By hiding the specific implementation into the private namespace, we no longer enforce this. In the long run, this might also allow us to switch cryptographic library implementation without affecting the downstream users. --- lib/isc/hmac.c | 8 +++----- lib/isc/include/isc/hmac.h | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/isc/hmac.c b/lib/isc/hmac.c index 4a9c97abc8..2f186f8df7 100644 --- a/lib/isc/hmac.c +++ b/lib/isc/hmac.c @@ -25,9 +25,9 @@ isc_hmac_t * isc_hmac_new(void) { - isc_hmac_t *hmac = HMAC_CTX_new(); + HMAC_CTX *hmac = HMAC_CTX_new(); RUNTIME_CHECK(hmac != NULL); - return (hmac); + return ((struct hmac *)hmac); } void @@ -120,10 +120,8 @@ isc_result_t isc_hmac(isc_md_type_t type, const void *key, const int keylen, const unsigned char *buf, const size_t len, unsigned char *digest, unsigned int *digestlen) { - isc_hmac_t *hmac = NULL; isc_result_t res; - - hmac = isc_hmac_new(); + isc_hmac_t *hmac = isc_hmac_new(); res = isc_hmac_init(hmac, key, keylen, type); if (res != ISC_R_SUCCESS) { diff --git a/lib/isc/include/isc/hmac.h b/lib/isc/include/isc/hmac.h index 6bff1c6b25..ab349c10f1 100644 --- a/lib/isc/include/isc/hmac.h +++ b/lib/isc/include/isc/hmac.h @@ -22,9 +22,7 @@ #include #include -#include - -typedef HMAC_CTX isc_hmac_t; +typedef void isc_hmac_t; /** * isc_hmac: