public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Stefan Berger <stefanb@linux.ibm.com>, Mimi Zohar <zohar@linux.ibm.com>
Subject: [ima-evm-utils PATCH v3 13/13] Define and use a file specific "keypass" variable
Date: Thu,  4 Jan 2024 14:05:58 -0500	[thread overview]
Message-ID: <20240104190558.3674008-14-zohar@linux.ibm.com> (raw)
In-Reply-To: <20240104190558.3674008-1-zohar@linux.ibm.com>

Instead of relying on the "imaevm_parrams.keypass" global variable,
which is not concurrency-safe, define and use a file specific variable.

To avoid library incompatibility, don't remove imaevm_params.keypass
variable.

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/evmctl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 37441b1b77ea..d050b5e36765 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -141,6 +141,7 @@ static bool evm_portable;
 static bool veritysig;
 static bool hwtpm;
 static char *g_hash_algo = DEFAULT_HASH_ALGO;
+static char *g_keypass;
 
 #define HMAC_FLAG_NO_UUID	0x0001
 #define HMAC_FLAG_CAPS_SET	0x0002
@@ -576,7 +577,7 @@ static int sign_evm(const char *file, char *hash_algo, const char *key)
 		return len;
 	assert(len <= sizeof(hash));
 
-	len = sign_hash(hash_algo, hash, len, key, NULL, sig + 1);
+	len = sign_hash(hash_algo, hash, len, key, g_keypass, sig + 1);
 	if (len <= 1)
 		return len;
 	assert(len < sizeof(sig));
@@ -662,7 +663,7 @@ static int sign_ima(const char *file, char *hash_algo, const char *key)
 		return len;
 	assert(len <= sizeof(hash));
 
-	len = sign_hash(hash_algo, hash, len, key, NULL, sig + 1);
+	len = sign_hash(hash_algo, hash, len, key, g_keypass, sig + 1);
 	if (len <= 1)
 		return len;
 	assert(len < sizeof(sig));
@@ -844,7 +845,7 @@ static int cmd_sign_hash(struct command *cmd)
 			}
 
 			siglen = sign_hash(algo, sigv3_hash, hashlen / 2,
-					   key, NULL, sig + 1);
+					   key, g_keypass, sig + 1);
 
 			sig[0] = IMA_VERITY_DIGSIG;
 			sig[1] = DIGSIG_VERSION_3;	/* sigv3 */
@@ -856,7 +857,7 @@ static int cmd_sign_hash(struct command *cmd)
 			hex2bin(hash, line, hashlen / 2);
 
 			siglen = sign_hash(g_hash_algo, hash,
-					   hashlen / 2, key, NULL, sig + 1);
+					   hashlen / 2, key, g_keypass, sig + 1);
 			sig[0] = EVM_IMA_XATTR_DIGSIG;
 		}
 
@@ -3092,9 +3093,9 @@ int main(int argc, char *argv[])
 			break;
 		case 'p':
 			if (optarg)
-				imaevm_params.keypass = optarg;
+				g_keypass = optarg;
 			else
-				imaevm_params.keypass = get_password();
+				g_keypass = get_password();
 			break;
 		case 'f':
 			sigfile = 1;
@@ -3236,8 +3237,8 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	if (!imaevm_params.keypass)
-		imaevm_params.keypass = getenv("EVMCTL_KEY_PASSWORD");
+	if (!g_keypass)
+		g_keypass = getenv("EVMCTL_KEY_PASSWORD");
 
 	if (imaevm_params.keyfile != NULL &&
 	    imaevm_params.eng == NULL &&
-- 
2.39.3


      parent reply	other threads:[~2024-01-04 19:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04 19:05 [ima-evm-utils PATCH v3 00/13] Address non concurrency-safe libimaevm global variables Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 01/13] Rename "public_keys" to "g_public_keys" Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 02/13] Free public keys list Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 03/13] Update library function definitions to include a "public_keys" parameter Mimi Zohar
2024-01-09 16:18   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 04/13] Update imaevm_verify_hash() definition to include "hash_algo" parameter Mimi Zohar
2024-01-09 16:34   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 05/13] Update cmd_verify_ima() to define and use a local list of public keys Mimi Zohar
2024-01-09 16:37   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 06/13] Update cmd_verify_evm " Mimi Zohar
2024-01-09 17:00   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 07/13] Update ima_measurements " Mimi Zohar
2024-01-09 17:07   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 08/13] Define library ima_calc_hash2() function with a hash algorithm parameter Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 09/13] Use a local hash algorithm variable when verifying file signatures Mimi Zohar
2024-01-09 17:21   ` Stefan Berger
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 10/13] Update EVM signature verification to use a local hash algorithm variable Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 11/13] Use a file specific hash algorithm variable for signing files Mimi Zohar
2024-01-04 19:05 ` [ima-evm-utils PATCH v3 12/13] Update sign_hash_v*() definition to include the key password Mimi Zohar
2024-01-04 19:05 ` Mimi Zohar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240104190558.3674008-14-zohar@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=stefanb@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox