Blob Blame Raw
From 368b92384c347b774f76f306eace5a1f41400112 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Sat, 23 Jun 2018 16:02:27 -0400
Subject: [PATCH] Fix for OpenSSL 1.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 spmd/shell.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/spmd/shell.c b/spmd/shell.c
index 3a7b28d..db384c2 100644
--- a/spmd/shell.c
+++ b/spmd/shell.c
@@ -655,7 +655,7 @@ shell_gen_challenge(void)
 	char *p;
 	int i;
 	const EVP_MD *m;
-	EVP_MD_CTX ctx;
+	EVP_MD_CTX *ctx;
 	unsigned char digest[EVP_MAX_MD_SIZE];
 	unsigned int digest_len;
 
@@ -693,27 +693,27 @@ shell_gen_challenge(void)
 		}
 	}
 #endif
-	EVP_MD_CTX_init(&ctx);
-	if (!EVP_DigestInit_ex(&ctx, m, SPMD_EVP_ENGINE)) {
-		SPMD_PLOG(SPMD_L_INTERR, "Failed to initilize Message Digest function");
+	ctx = EVP_MD_CTX_new();
+	if (ctx == NULL) {
+		SPMD_PLOG(SPMD_L_INTERR, "Failed to allocate Message Digest context");
 		goto fin;
 	}
-	if (!EVP_DigestUpdate(&ctx, seed, seed_len)) {
+	if (!EVP_DigestInit_ex(ctx, m, SPMD_EVP_ENGINE)) {
+		SPMD_PLOG(SPMD_L_INTERR, "Failed to initialize Message Digest function");
+		goto fin;
+	}
+	if (!EVP_DigestUpdate(ctx, seed, seed_len)) {
 		SPMD_PLOG(SPMD_L_INTERR, "Failed to hash Seed");
 		goto fin;
 	}
-	if (!EVP_DigestFinal_ex(&ctx, digest, &digest_len)) {
+	if (!EVP_DigestFinal_ex(ctx, digest, &digest_len)) {
 		SPMD_PLOG(SPMD_L_INTERR, "Failed to get Message Digest value");
 		goto fin;
 	}
-	if (digest_len != EVP_MD_CTX_size(&ctx)) {
+	if (digest_len != EVP_MD_CTX_size(ctx)) {
 		SPMD_PLOG(SPMD_L_INTERR, "Message Digest length is not enough");
 		goto fin;
 	}
-	if (!EVP_MD_CTX_cleanup(&ctx)) {
-		SPMD_PLOG(SPMD_L_INTERR, "Failed to cleanup Message Digest context");
-		goto fin;
-	}
 
 	challenge_len = digest_len*2+1;
 	challenge = spmd_calloc(challenge_len);
@@ -729,6 +729,7 @@ shell_gen_challenge(void)
         }
 
 fin:
+	EVP_MD_CTX_free(ctx);
 	spmd_free(seed);
 just_fin:
 	return challenge;
-- 
2.20.1