From a87f38e35f8b97570d2b790d6b8ffe3e751e9f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ketelaars?= Date: Wed, 27 Feb 2019 12:05:41 +0100 Subject: [PATCH] crypto: LibreSSL has HMAC_CTX_free and *HMAC_CTX_new While here improve indentation (use 4 spaces instead of 3). --- src/borg/crypto/_crypto_helpers.c | 27 ++++++++++++++------------- src/borg/crypto/_crypto_helpers.h | 7 ++++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/borg/crypto/_crypto_helpers.c b/src/borg/crypto/_crypto_helpers.c index 397d50679..f3d766536 100644 --- a/src/borg/crypto/_crypto_helpers.c +++ b/src/borg/crypto/_crypto_helpers.c @@ -4,26 +4,28 @@ #include #include -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - +#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) HMAC_CTX *HMAC_CTX_new(void) { - HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx)); - if (ctx != NULL) { - memset(ctx, 0, sizeof *ctx); - HMAC_CTX_cleanup(ctx); - } - return ctx; + HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx)); + if (ctx != NULL) { + memset(ctx, 0, sizeof *ctx); + HMAC_CTX_cleanup(ctx); + } + return ctx; } void HMAC_CTX_free(HMAC_CTX *ctx) { - if (ctx != NULL) { - HMAC_CTX_cleanup(ctx); - OPENSSL_free(ctx); - } + if (ctx != NULL) { + HMAC_CTX_cleanup(ctx); + OPENSSL_free(ctx); + } } +#endif + +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) const EVP_CIPHER *EVP_aes_256_ocb(void){ /* dummy, so that code compiles */ return NULL; } @@ -31,5 +33,4 @@ const EVP_CIPHER *EVP_aes_256_ocb(void){ /* dummy, so that code compiles */ const EVP_CIPHER *EVP_chacha20_poly1305(void){ /* dummy, so that code compiles */ return NULL; } - #endif diff --git a/src/borg/crypto/_crypto_helpers.h b/src/borg/crypto/_crypto_helpers.h index 00a396a87..2d6b50dee 100644 --- a/src/borg/crypto/_crypto_helpers.h +++ b/src/borg/crypto/_crypto_helpers.h @@ -4,14 +4,15 @@ #include #include -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - +#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) HMAC_CTX *HMAC_CTX_new(void); void HMAC_CTX_free(HMAC_CTX *ctx); +#endif + +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) const EVP_CIPHER *EVP_aes_256_ocb(void); /* dummy, so that code compiles */ const EVP_CIPHER *EVP_chacha20_poly1305(void); /* dummy, so that code compiles */ - #endif