From: Stefan Berger <stefanb@linux.ibm.com>
To: Roberto Sassu <roberto.sassu@huaweicloud.com>,
zohar@linux.ibm.com, dmitry.kasatkin@gmail.com
Cc: linux-integrity@vger.kernel.org, vt@altlinux.org, pvorel@suse.cz,
Roberto Sassu <roberto.sassu@huawei.com>
Subject: Re: [PATCH ima-evm-utils v2 1/9] Fix error messages and mdlen init in calc_evm_hmac()
Date: Thu, 12 Jan 2023 09:16:38 -0500 [thread overview]
Message-ID: <2d9918be-3083-e967-c666-fffb5c7191c8@linux.ibm.com> (raw)
In-Reply-To: <20230112122426.3759938-2-roberto.sassu@huaweicloud.com>
On 1/12/23 07:24, Roberto Sassu wrote:
> From: Roberto Sassu <roberto.sassu@huawei.com>
>
> Make sure that the function name in the error message corresponds to the
> actual function called. Also, initialize mdlen to the size of 'hash'
> (MAX_DIGEST_SIZE), as this is expected by EVP_DigestSignFinal().
This code was converted from HMAC_Final() where the man page doesn't say much
about mdlen on input but required md to be of size EVP_MAX_MD_SIZE. Now it's
called sig & siglen in the man page:
maximum necessary size of the output buffer is written to the siglen parameter. If sig is not NULL then before the
call the siglen parameter should contain the length of the sig buffer. If the call is successful the signature is
written to sig and the amount of data written to siglen.
It say's 'should' not 'must'. Following the last sentence abive I think evmctl will NOT have created short
HMAC signatures.
The mdlen should be called siglen and hash should defintely be renamed to sig at some point because it's not a 'hash'
and never was.
>
> Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> src/evmctl.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/evmctl.c b/src/evmctl.c
> index 0ac7930da6f2..d4912d7ee891 100644
> --- a/src/evmctl.c
> +++ b/src/evmctl.c
> @@ -1186,7 +1186,7 @@ static int cmd_setxattr_ima(struct command *cmd)
>
> static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *hash)
> {
> - size_t mdlen;
> + size_t mdlen = MAX_DIGEST_SIZE;
> EVP_MD_CTX *pctx;
> EVP_PKEY *pkey = NULL;
> struct stat st;
> @@ -1260,7 +1260,7 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
>
> pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, evmkey, sizeof(evmkey));
> if (!pkey) {
> - log_err("HMAC_Init() failed\n");
> + log_err("EVP_PKEY_new_mac_key() failed\n");
> goto out;
> }
>
> @@ -1326,12 +1326,12 @@ static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
>
> err = EVP_DigestSignUpdate(pctx, &hmac_misc, hmac_size);
> if (err != 1) {
> - log_err("HMAC_Update() failed\n");
> + log_err("EVP_DigestSignUpdate() failed\n");
> goto out_ctx_cleanup;
> }
> err = EVP_DigestSignFinal(pctx, hash, &mdlen);
> if (err != 1)
> - log_err("HMAC_Final() failed\n");
> + log_err("EVP_DigestSignFinal() failed\n");
> out_ctx_cleanup:
> EVP_PKEY_free(pkey);
> #if OPENSSL_VERSION_NUMBER >= 0x10100000
next prev parent reply other threads:[~2023-01-12 14:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 12:24 [PATCH ima-evm-utils v2 0/9] Support testing with UML kernel Roberto Sassu
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 1/9] Fix error messages and mdlen init in calc_evm_hmac() Roberto Sassu
2023-01-12 14:16 ` Stefan Berger [this message]
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 2/9] Add config for UML kernel Roberto Sassu
2023-01-12 14:18 ` Stefan Berger
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 3/9] Compile the UML kernel and download it in Github Actions Roberto Sassu
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 4/9] Add support for UML in functions.sh Roberto Sassu
2023-01-12 15:00 ` Stefan Berger
2023-01-12 15:01 ` Roberto Sassu
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 5/9] Introduce TST_LIST variable to select a test to execute Roberto Sassu
2023-01-12 15:07 ` Stefan Berger
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 6/9] Add tests for EVM portable signatures Roberto Sassu
2023-01-12 15:22 ` Stefan Berger
2023-01-12 15:38 ` Roberto Sassu
2023-01-23 14:40 ` Mimi Zohar
2023-01-23 15:31 ` Roberto Sassu
2023-01-23 15:43 ` Mimi Zohar
2023-01-23 15:46 ` Roberto Sassu
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 7/9] Adapt fsverity.test to work with UML kernel Roberto Sassu
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 8/9] Use in-place built fsverity binary instead of installing it Roberto Sassu
2023-01-12 16:11 ` Stefan Berger
2023-01-12 16:20 ` Roberto Sassu
2023-01-12 16:26 ` Stefan Berger
2023-01-12 16:28 ` Roberto Sassu
2023-01-19 11:51 ` Mimi Zohar
2023-01-12 12:24 ` [PATCH ima-evm-utils v2 9/9] ci: haveged requires EPEL on CentOS stream:8 Roberto Sassu
2023-01-12 16:08 ` Stefan Berger
2023-01-12 14:32 ` [PATCH ima-evm-utils v2 0/9] Support testing with UML kernel Mimi Zohar
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=2d9918be-3083-e967-c666-fffb5c7191c8@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=pvorel@suse.cz \
--cc=roberto.sassu@huawei.com \
--cc=roberto.sassu@huaweicloud.com \
--cc=vt@altlinux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.