From owner-svn-src-projects@freebsd.org Wed Sep 19 07:07:04 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 495511091BAD for ; Wed, 19 Sep 2018 07:07:04 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 00DA174727; Wed, 19 Sep 2018 07:07:04 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F00663AFB; Wed, 19 Sep 2018 07:07:03 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8J77395071992; Wed, 19 Sep 2018 07:07:03 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8J773h6071991; Wed, 19 Sep 2018 07:07:03 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <201809190707.w8J773h6071991@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Wed, 19 Sep 2018 07:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r338782 - projects/openssl111/sbin/decryptcore X-SVN-Group: projects X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: projects/openssl111/sbin/decryptcore X-SVN-Commit-Revision: 338782 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2018 07:07:04 -0000 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); }