Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2018 07:07:03 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r338782 - projects/openssl111/sbin/decryptcore
Message-ID:  <201809190707.w8J773h6071991@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Wed Sep 19 07:07:03 2018
New Revision: 338782
URL: https://svnweb.freebsd.org/changeset/base/338782

Log:
  Make decryptcore(8) buildable.

Modified:
  projects/openssl111/sbin/decryptcore/decryptcore.c

Modified: projects/openssl111/sbin/decryptcore/decryptcore.c
==============================================================================
--- projects/openssl111/sbin/decryptcore/decryptcore.c	Wed Sep 19 07:06:20 2018	(r338781)
+++ projects/openssl111/sbin/decryptcore/decryptcore.c	Wed Sep 19 07:07:03 2018	(r338782)
@@ -120,7 +120,7 @@ decrypt(int ofd, const char *privkeyfile, const char *
     const char *input)
 {
 	uint8_t buf[KERNELDUMP_BUFFER_SIZE], key[KERNELDUMP_KEY_MAX_SIZE];
-	EVP_CIPHER_CTX ctx;
+	EVP_CIPHER_CTX *ctx;
 	const EVP_CIPHER *cipher;
 	FILE *fp;
 	struct kerneldumpkey *kdk;
@@ -134,6 +134,7 @@ decrypt(int ofd, const char *privkeyfile, const char *
 	PJDLOG_ASSERT(keyfile != NULL);
 	PJDLOG_ASSERT(input != NULL);
 
+	ctx = NULL;
 	privkey = NULL;
 
 	/*
@@ -179,7 +180,9 @@ decrypt(int ofd, const char *privkeyfile, const char *
 		    ERR_error_string(ERR_get_error(), NULL));
 		goto failed;
 	}
-	EVP_CIPHER_CTX_init(&ctx);
+	ctx = EVP_CIPHER_CTX_new();
+	if (ctx == NULL)
+		goto failed;
 
 	kdk = read_key(kfd);
 	close(kfd);
@@ -219,8 +222,8 @@ decrypt(int ofd, const char *privkeyfile, const char *
 	RSA_free(privkey);
 	privkey = NULL;
 
-	EVP_DecryptInit_ex(&ctx, cipher, NULL, key, kdk->kdk_iv);
-	EVP_CIPHER_CTX_set_padding(&ctx, 0);
+	EVP_DecryptInit_ex(ctx, cipher, NULL, key, kdk->kdk_iv);
+	EVP_CIPHER_CTX_set_padding(ctx, 0);
 
 	explicit_bzero(key, sizeof(key));
 
@@ -233,13 +236,13 @@ decrypt(int ofd, const char *privkeyfile, const char *
 		}
 
 		if (bytes > 0) {
-			if (EVP_DecryptUpdate(&ctx, buf, &olen, buf,
+			if (EVP_DecryptUpdate(ctx, buf, &olen, buf,
 			    bytes) == 0) {
 				pjdlog_error("Unable to decrypt core.");
 				goto failed;
 			}
 		} else {
-			if (EVP_DecryptFinal_ex(&ctx, buf, &olen) == 0) {
+			if (EVP_DecryptFinal_ex(ctx, buf, &olen) == 0) {
 				pjdlog_error("Unable to decrypt core.");
 				goto failed;
 			}
@@ -252,13 +255,14 @@ decrypt(int ofd, const char *privkeyfile, const char *
 	} while (bytes > 0);
 
 	explicit_bzero(buf, sizeof(buf));
-	EVP_CIPHER_CTX_cleanup(&ctx);
+	EVP_CIPHER_CTX_free(ctx);
 	exit(0);
 failed:
 	explicit_bzero(key, sizeof(key));
 	explicit_bzero(buf, sizeof(buf));
 	RSA_free(privkey);
-	EVP_CIPHER_CTX_cleanup(&ctx);
+	if (ctx != NULL)
+		EVP_CIPHER_CTX_free(ctx);
 	exit(1);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809190707.w8J773h6071991>