From e8dda21218a0bcb5363490a35e2cfed798421f2c Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 4 Jul 2017 08:28:54 +0300 Subject: support for openssl-1.1 --- accel-pppd/extra/chap-secrets.c | 15 ++++++++------- crypto/crypto.h | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/accel-pppd/extra/chap-secrets.c b/accel-pppd/extra/chap-secrets.c index b693a326..f99bd0b9 100644 --- a/accel-pppd/extra/chap-secrets.c +++ b/accel-pppd/extra/chap-secrets.c @@ -7,7 +7,6 @@ #include #ifdef CRYPTO_OPENSSL -#include "openssl/evp.h" #include "crypto.h" #endif @@ -129,7 +128,7 @@ static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username) char username_hash[EVP_MAX_MD_SIZE * 2 + 1]; uint8_t hash[EVP_MAX_MD_SIZE]; struct hash_chain *hc; - EVP_MD_CTX md_ctx; + EVP_MD_CTX *md_ctx = NULL; char c; #endif @@ -140,11 +139,13 @@ static struct cs_pd_t *create_pd(struct ap_session *ses, const char *username) if (conf_encrypted && !list_empty(&hash_chain)) { unsigned int size = 0; list_for_each_entry(hc, &hash_chain, entry) { - EVP_MD_CTX_init(&md_ctx); - EVP_DigestInit_ex(&md_ctx, hc->md, NULL); - EVP_DigestUpdate(&md_ctx, size == 0 ? (void *)username : (void *)hash, size == 0 ? strlen(username) : size); - EVP_DigestFinal_ex(&md_ctx, hash, &size); - EVP_MD_CTX_cleanup(&md_ctx); + md_ctx = EVP_MD_CTX_new(); + EVP_MD_CTX_init(md_ctx); + EVP_DigestInit_ex(md_ctx, hc->md, NULL); + EVP_DigestUpdate(md_ctx, size == 0 ? (void *)username : (void *)hash, size == 0 ? strlen(username) : size); + EVP_DigestFinal_ex(md_ctx, hash, &size); + EVP_MD_CTX_free(md_ctx); + md_ctx = NULL; } for (n = 0; n < size; n++) diff --git a/crypto/crypto.h b/crypto/crypto.h index 3fbc3282..9e2e8401 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -7,7 +7,12 @@ #include #include #include +#include +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined (LIBRESSL_VERSION_NUMBER) +#define EVP_MD_CTX_new EVP_MD_CTX_create +#define EVP_MD_CTX_free EVP_MD_CTX_destroy +#endif #else #ifdef CRYPTO_TOMCRYPT -- cgit v1.2.3