linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Uiterwijk <patrick@puiterwijk.org>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
	linux-integrity@vger.kernel.org, pbrobinson@redhat.com
Subject: Re: [PATCH 1/2] Fix sign_hash not observing the hashalgo argument
Date: Thu, 7 Jan 2021 16:13:48 +0100	[thread overview]
Message-ID: <CAJweMdbAeuVMmqdcUohZKWY7GC0oiU7-TL+nTi7282Yrip7Tsw@mail.gmail.com> (raw)
In-Reply-To: <20210107131555.t7k4r2kytftj2nip@altlinux.org>

On Thu, Jan 7, 2021 at 2:15 PM Vitaly Chikunov <vt@altlinux.org> wrote:
>
> On Thu, Jan 07, 2021 at 04:08:16PM +0300, Vitaly Chikunov wrote:
> > Patrick, Mimi,
> >
> > On Thu, Jan 07, 2021 at 07:24:43AM -0500, Mimi Zohar wrote:
> > > On Wed, 2021-01-06 at 10:43 +0100, Patrick Uiterwijk wrote:
> > > > This fixes sign_hash not using the correct algorithm for creating the
> > > > signature, by ensuring it uses the passed in variable value.
> > > >
> > > > Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
> > >
> > > Thank you.  This is a regression first introduced in commit
> > > 07e623b60848 ("ima-evm-utils: Convert sign_hash_v2 to EVP_PKEY API").
> >
> > Ah, when sign_hash() is used not via evmctl, but as a library
> > imaevm_params may be not set.
>
> Thinking about imaevm_params -- it's still belong to a library and
> extensively used in libimaevm.c, so I wonder if the fix is perfect.
> Since, now there is hash_algo and algo duplication which one to prefer
> and why?
>
> Maybe, it should be [also] set like keypass in sign_hash?

I had this exact diff as an initial version of this patch, but then
personally thought that because "hashalgo" is passed to sign_hash_v2
anyway, and sign_hash_v1 already prefers the argument (and ignores
imaevm_params.hash_algo), keeping this behaviour in sync is more
consistent.
With my patch, imaevm_params.hash_algo is only used in verify_hash_v2
and ima_calc_hash, both of which are primarily called by
ima_verify_signature which sets it, as a way to pass the argument
without having it explicit everywhere.

>
>   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 (hashalgo)
> +                 imaevm_params.hash_algo = hashalgo;
>
>           return imaevm_params.x509 ?
>                   sign_hash_v2(hashalgo, hash, size, keyfile, sig) :
>                   sign_hash_v1(hashalgo, hash, size, keyfile, sig);
>   }
>
>

  parent reply	other threads:[~2021-01-07 15:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06  9:43 [PATCH 0/2] ima-evm-utils: Fix use of sign_hash via API Patrick Uiterwijk
2021-01-06  9:43 ` [PATCH 1/2] Fix sign_hash not observing the hashalgo argument Patrick Uiterwijk
2021-01-07 12:24   ` Mimi Zohar
2021-01-07 13:08     ` Vitaly Chikunov
2021-01-07 13:15       ` Vitaly Chikunov
2021-01-07 14:55         ` Mimi Zohar
2021-01-07 15:13         ` Patrick Uiterwijk [this message]
2021-01-06  9:43 ` [PATCH 2/2] Add test for using sign_hash API Patrick Uiterwijk
2021-01-07 12:25   ` Mimi Zohar
2021-01-07 12:53     ` Vitaly Chikunov
2021-01-07 15:08       ` Patrick Uiterwijk
2021-07-05 15:49 ` [PATCH ima-evm-utils v2 0/2] Fix use of sign_hash via API Patrick Uiterwijk
2021-07-05 15:49   ` [PATCH ima-evm-utils v2 1/2] Fix sign_hash not observing the hashalgo argument Patrick Uiterwijk
2021-07-05 15:49   ` [PATCH ima-evm-utils v2 2/2] Add test for using sign_hash API Patrick Uiterwijk
2021-07-06 15:53     ` 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=CAJweMdbAeuVMmqdcUohZKWY7GC0oiU7-TL+nTi7282Yrip7Tsw@mail.gmail.com \
    --to=patrick@puiterwijk.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=pbrobinson@redhat.com \
    --cc=vt@altlinux.org \
    --cc=zohar@linux.ibm.com \
    --subject='Re: [PATCH 1/2] Fix sign_hash not observing the hashalgo argument' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).