From c75e9c7630273d430389e010e681a0350cf5b67d 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] --- 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 075f043cd4..b2771c7add 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4714. [port] openbsd/libressl: add support for building with + --enable-openssl-hash. [RT #45982] + --- 9.12.0a1 released --- 4713. [func] Added support for the DNS Response Policy Service diff --git a/lib/isc/aes.c b/lib/isc/aes.c index e47ecf367b..c187f6f0ef 100644 --- a/lib/isc/aes.c +++ b/lib/isc/aes.c @@ -25,7 +25,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 @@ -34,7 +34,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; @@ -54,7 +54,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; @@ -74,7 +74,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 7121cbcc9c..bd6e454a26 100644 --- a/lib/isc/hmacmd5.c +++ b/lib/isc/hmacmd5.c @@ -32,7 +32,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 6e42ade218..d57ea7a511 100644 --- a/lib/isc/hmacsha.c +++ b/lib/isc/hmacsha.c @@ -30,7 +30,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 1ff0b872d4..f716762e77 100644 --- a/lib/isc/include/isc/hmacmd5.h +++ b/lib/isc/include/isc/hmacmd5.h @@ -33,7 +33,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 d90c194058..6797ba99c8 100644 --- a/lib/isc/include/isc/hmacsha.h +++ b/lib/isc/include/isc/hmacsha.h @@ -34,7 +34,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 b707aa6f59..a91ad5794c 100644 --- a/lib/isc/include/isc/md5.h +++ b/lib/isc/include/isc/md5.h @@ -51,7 +51,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 7160a66ec8..480543e31f 100644 --- a/lib/isc/include/isc/sha1.h +++ b/lib/isc/include/isc/sha1.h @@ -32,7 +32,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 196f12052c..6808e13110 100644 --- a/lib/isc/include/isc/sha2.h +++ b/lib/isc/include/isc/sha2.h @@ -70,13 +70,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 8ada1cc01c..0d69fb837b 100644 --- a/lib/isc/md5.c +++ b/lib/isc/md5.c @@ -45,7 +45,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 f33758f58d..acfc5082ec 100644 --- a/lib/isc/sha1.c +++ b/lib/isc/sha1.c @@ -39,7 +39,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 3558144d11..4a813efe1c 100644 --- a/lib/isc/sha2.c +++ b/lib/isc/sha2.c @@ -58,7 +58,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) @@ -1604,7 +1604,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); @@ -1645,7 +1645,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); @@ -1686,7 +1686,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); @@ -1727,7 +1727,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);