From b51a66b4f38e29177afa6458ca4e2405381ca9aa Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 12 Sep 2017 14:19:10 +1000 Subject: [PATCH] 4714. [port] openbsd/libressl: add support for building with --enable-openssl-hash. [RT #45982] (cherry picked from commit c75e9c7630273d430389e010e681a0350cf5b67d) --- CHANGES | 3 +++ lib/isc/aes.c | 8 ++++---- lib/isc/hmacmd5.c | 2 +- lib/isc/hmacsha.c | 2 +- lib/isc/include/isc/hmacmd5.h | 2 +- lib/isc/include/isc/hmacsha.h | 2 +- lib/isc/include/isc/md5.h | 2 +- lib/isc/include/isc/sha1.h | 2 +- lib/isc/include/isc/sha2.h | 8 ++++++-- lib/isc/md5.c | 2 +- lib/isc/sha1.c | 2 +- lib/isc/sha2.c | 10 +++++----- 12 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index b16708753e..278fbb63ce 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4714. [port] openbsd/libressl: add support for building with + --enable-openssl-hash. [RT #45982] + 4712. [bug] "dig +domain" and "dig +search" didn't retain the search domain when retrying with TCP. [RT #45547] diff --git a/lib/isc/aes.c b/lib/isc/aes.c index 480f306bff..cb1d6c0b3c 100644 --- a/lib/isc/aes.c +++ b/lib/isc/aes.c @@ -33,7 +33,7 @@ #include #include -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #define EVP_CIPHER_CTX_new() &(_context), EVP_CIPHER_CTX_init(&_context) #define EVP_CIPHER_CTX_free(c) RUNTIME_CHECK(EVP_CIPHER_CTX_cleanup(c) == 1) #endif @@ -42,7 +42,7 @@ void isc_aes128_crypt(const unsigned char *key, const unsigned char *in, unsigned char *out) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_CIPHER_CTX _context; #endif EVP_CIPHER_CTX *c; @@ -62,7 +62,7 @@ void isc_aes192_crypt(const unsigned char *key, const unsigned char *in, unsigned char *out) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_CIPHER_CTX _context; #endif EVP_CIPHER_CTX *c; @@ -82,7 +82,7 @@ void isc_aes256_crypt(const unsigned char *key, const unsigned char *in, unsigned char *out) { -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_CIPHER_CTX _context; #endif EVP_CIPHER_CTX *c; diff --git a/lib/isc/hmacmd5.c b/lib/isc/hmacmd5.c index 83628a6695..9cdd5709d7 100644 --- a/lib/isc/hmacmd5.c +++ b/lib/isc/hmacmd5.c @@ -43,7 +43,7 @@ #endif #ifdef ISC_PLATFORM_OPENSSLHASH -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #define HMAC_CTX_new() &(ctx->_ctx), HMAC_CTX_init(&(ctx->_ctx)) #define HMAC_CTX_free(ptr) HMAC_CTX_cleanup(ptr) #endif diff --git a/lib/isc/hmacsha.c b/lib/isc/hmacsha.c index ef89e62cb3..9ea9ad89b8 100644 --- a/lib/isc/hmacsha.c +++ b/lib/isc/hmacsha.c @@ -40,7 +40,7 @@ #endif #ifdef ISC_PLATFORM_OPENSSLHASH -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #define HMAC_CTX_new() &(ctx->_ctx), HMAC_CTX_init(&(ctx->_ctx)) #define HMAC_CTX_free(ptr) HMAC_CTX_cleanup(ptr) #endif diff --git a/lib/isc/include/isc/hmacmd5.h b/lib/isc/include/isc/hmacmd5.h index 4b31d8fdab..3c96a4beb9 100644 --- a/lib/isc/include/isc/hmacmd5.h +++ b/lib/isc/include/isc/hmacmd5.h @@ -42,7 +42,7 @@ typedef struct { HMAC_CTX *ctx; -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) HMAC_CTX _ctx; #endif } isc_hmacmd5_t; diff --git a/lib/isc/include/isc/hmacsha.h b/lib/isc/include/isc/hmacsha.h index f57805b6d6..e4309a016b 100644 --- a/lib/isc/include/isc/hmacsha.h +++ b/lib/isc/include/isc/hmacsha.h @@ -42,7 +42,7 @@ typedef struct { HMAC_CTX *ctx; -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) HMAC_CTX _ctx; #endif } isc_hmacsha_t; diff --git a/lib/isc/include/isc/md5.h b/lib/isc/include/isc/md5.h index b770c8957a..7d843dcda0 100644 --- a/lib/isc/include/isc/md5.h +++ b/lib/isc/include/isc/md5.h @@ -60,7 +60,7 @@ typedef struct { EVP_MD_CTX *ctx; -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX _ctx; #endif } isc_md5_t; diff --git a/lib/isc/include/isc/sha1.h b/lib/isc/include/isc/sha1.h index 23d871ddb2..742834c34f 100644 --- a/lib/isc/include/isc/sha1.h +++ b/lib/isc/include/isc/sha1.h @@ -41,7 +41,7 @@ typedef struct { EVP_MD_CTX *ctx; -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX _ctx; #endif } isc_sha1_t; diff --git a/lib/isc/include/isc/sha2.h b/lib/isc/include/isc/sha2.h index f1ead8f44b..dfbc6e60e2 100644 --- a/lib/isc/include/isc/sha2.h +++ b/lib/isc/include/isc/sha2.h @@ -78,13 +78,17 @@ /*** SHA-256/384/512 Context Structures *******************************/ -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) #include #include +#endif + +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) + typedef struct { EVP_MD_CTX *ctx; -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX _ctx; #endif } isc_sha2_t; diff --git a/lib/isc/md5.c b/lib/isc/md5.c index a0775b50a0..ff43715fdc 100644 --- a/lib/isc/md5.c +++ b/lib/isc/md5.c @@ -54,7 +54,7 @@ #include #ifdef ISC_PLATFORM_OPENSSLHASH -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #define EVP_MD_CTX_new() &(ctx->_ctx) #define EVP_MD_CTX_free(ptr) EVP_MD_CTX_cleanup(ptr) #endif diff --git a/lib/isc/sha1.c b/lib/isc/sha1.c index 662a880349..f34a428536 100644 --- a/lib/isc/sha1.c +++ b/lib/isc/sha1.c @@ -50,7 +50,7 @@ #endif #ifdef ISC_PLATFORM_OPENSSLHASH -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) #define EVP_MD_CTX_new() &(context->_ctx) #define EVP_MD_CTX_free(ptr) EVP_MD_CTX_cleanup(ptr) #endif diff --git a/lib/isc/sha2.c b/lib/isc/sha2.c index d453f93b24..f0e131dd1b 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -68,7 +68,7 @@ #include #endif -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) #if OPENSSL_VERSION_NUMBER < 0x10100000L #define EVP_MD_CTX_new() &(context->_ctx) #define EVP_MD_CTX_free(ptr) EVP_MD_CTX_cleanup(ptr) @@ -1614,7 +1614,7 @@ isc_sha224_end(isc_sha224_t *context, char buffer[]) { } *buffer = (char)0; } else { -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX_reset(context->ctx); #elif PKCS11CRYPTO pk11_return_session(context); @@ -1655,7 +1655,7 @@ isc_sha256_end(isc_sha256_t *context, char buffer[]) { } *buffer = (char)0; } else { -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX_reset(context->ctx); #elif PKCS11CRYPTO pk11_return_session(context); @@ -1696,7 +1696,7 @@ isc_sha512_end(isc_sha512_t *context, char buffer[]) { } *buffer = (char)0; } else { -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX_reset(context->ctx); #elif PKCS11CRYPTO pk11_return_session(context); @@ -1737,7 +1737,7 @@ isc_sha384_end(isc_sha384_t *context, char buffer[]) { } *buffer = (char)0; } else { -#ifdef ISC_PLATFORM_OPENSSLHASH +#if defined(ISC_PLATFORM_OPENSSLHASH) && !defined(LIBRESSL_VERSION_NUMBER) EVP_MD_CTX_reset(context->ctx); #elif PKCS11CRYPTO pk11_return_session(context);