public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: Mimi Zohar <zohar@linux.ibm.com>, linux-integrity@vger.kernel.org
Subject: Re: [ima-evm-utils PATCH v2 12/13] Update sign_hash_v*() definition to include the key password
Date: Tue, 2 Jan 2024 08:44:22 -0500	[thread overview]
Message-ID: <e530b4ab-dcd1-449a-a66e-83ae671655c9@linux.ibm.com> (raw)
In-Reply-To: <20231206192734.339999-13-zohar@linux.ibm.com>



On 12/6/23 14:27, Mimi Zohar wrote:
> The library sign_hash() definition already includes a key password as a
> parameter, but it isn't passed on to sign_hash_v*() functions.  Update
> the sign_hash_v*() function definitions and callers.
> 
> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>

> ---
>   src/libimaevm.c | 18 ++++++++++--------
>   1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/src/libimaevm.c b/src/libimaevm.c
> index 10e1ed3eab4d..9d8f419ae64d 100644
> --- a/src/libimaevm.c
> +++ b/src/libimaevm.c
> @@ -1115,7 +1115,8 @@ static int get_hash_algo_v1(const char *algo)
>   }
>   
>   static int sign_hash_v1(const char *hashalgo, const unsigned char *hash,
> -			int size, const char *keyfile, unsigned char *sig)
> +			int size, const char *keyfile, const char *keypass,
> +			unsigned char *sig)
>   {
>   	int len = -1, hashalgo_idx;
>   	SHA_CTX ctx;
> @@ -1149,7 +1150,7 @@ static int sign_hash_v1(const char *hashalgo, const unsigned char *hash,
>   	log_info("hash(%s): ", hashalgo);
>   	log_dump(hash, size);
>   
> -	key = read_priv_key(keyfile, imaevm_params.keypass);
> +	key = read_priv_key(keyfile, keypass);
>   	if (!key)
>   		return -1;
>   
> @@ -1202,7 +1203,8 @@ out:
>    * Return: -1 signing error, >0 length of signature
>    */
>   static int sign_hash_v2(const char *algo, const unsigned char *hash,
> -			int size, const char *keyfile, unsigned char *sig)
> +			int size, const char *keyfile, const char *keypass,
> +			unsigned char *sig)
>   {
>   	struct signature_v2_hdr *hdr;
>   	int len = -1;
> @@ -1237,7 +1239,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash,
>   	log_info("hash(%s): ", algo);
>   	log_dump(hash, size);
>   
> -	pkey = read_priv_pkey(keyfile, imaevm_params.keypass);
> +	pkey = read_priv_pkey(keyfile, keypass);
>   	if (!pkey)
>   		return -1;
>   
> @@ -1307,14 +1309,14 @@ err:
>   
>   int sign_hash(const char *hashalgo, const unsigned char *hash, int size, const char *keyfile, const char *keypass, unsigned char *sig)
>   {
> -	if (keypass)
> -		imaevm_params.keypass = keypass;
> +	if (!keypass)	/* Avoid breaking existing libimaevm usage */
> +		keypass = imaevm_params.keypass;
>   
>   	if (imaevm_params.x509)
> -		return sign_hash_v2(hashalgo, hash, size, keyfile, sig);
> +		return sign_hash_v2(hashalgo, hash, size, keyfile, keypass, sig);
>   #if CONFIG_SIGV1
>   	else
> -		return sign_hash_v1(hashalgo, hash, size, keyfile, sig);
> +		return sign_hash_v1(hashalgo, hash, size, keyfile, keypass, sig);
>   #endif
>   	log_info("Signature version 1 deprecated.");
>   	return -1;

  reply	other threads:[~2024-01-02 13:44 UTC|newest]

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

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=e530b4ab-dcd1-449a-a66e-83ae671655c9@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=zohar@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