All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Andrew Zaborowski <andrew.zaborowski@intel.com>
Cc: keyrings@vger.kernel.org, David Howells <dhowells@redhat.com>
Subject: Re: [PATCH v2] keys: X.509 public key issuer lookup without AKID
Date: Wed, 20 Jan 2021 03:54:51 +0200	[thread overview]
Message-ID: <YAeNa6vqLGLfTRbw@kernel.org> (raw)
In-Reply-To: <CAOq732JD-M-L3BBDskMBw-5qp=wZjY=Sjm_q5WQNhCq61NM3Yw@mail.gmail.com>

On Fri, Jan 15, 2021 at 11:40:18AM +0100, Andrew Zaborowski wrote:
> On Fri, 15 Jan 2021 at 09:20, Jarkko Sakkinen <jarkko@kernel.org> wrote:
> > On Thu, Jan 14, 2021 at 09:40:35PM +0100, Andrew Zaborowski wrote:
> > > @@ -183,8 +193,8 @@ bool asymmetric_key_id_partial(const struct asymmetric_key_id *kid1,
> > >  EXPORT_SYMBOL_GPL(asymmetric_key_id_partial);
> > >
> > >  /**
> > > - * asymmetric_match_key_ids - Search asymmetric key IDs
> > > - * @kids: The list of key IDs to check
> > > + * asymmetric_match_key_ids - Search asymmetric key IDs 1 & 2
> > > + * @kids: The pair of key IDs to check
> > >   * @match_id: The key ID we're looking for
> > >   * @match: The match function to use
> > >   */
> > > @@ -198,7 +208,7 @@ static bool asymmetric_match_key_ids(
> > >
> > >       if (!kids || !match_id)
> > >               return false;
> > > -     for (i = 0; i < ARRAY_SIZE(kids->id); i++)
> > > +     for (i = 0; i < 2; i++)
> > >               if (match(kids->id[i], match_id))
> > >                       return true;
> > >       return false;
> >
> > Why are key ID 2 and key ID 3 handled differently? They are both
> > optional.
> 
> This is to minimise the impact of having a new ID added.  I guess the
> danger is that it could add ambiguity in the lookup, i.e. a different
> key could be returned for an existing search query.

Right I do get that. It could potentially break some scripts.

> 
> There's a specific logic in how ID 1 and 2 interact documented as
> follows in restrict.c:
> 
>                         * The first auth_id is the preferred id, and
>                         * the second is the fallback. If only one
>                         * auth_id is present, it may match against
>                         * either signer_id. If two auth_ids are
>                         * present, the first auth_id must match one
>                         * signer_id and the second auth_id must match
>                         * the second signer_id.
> 
> I'm not sure what the use case motivates this.  For the
> x509_public_key subtype you'd expect that ID 1 in the signature
> matches subject ID 1 of the issuer and ID 2 matches ID 2.  Most of the
> time both will be present for a CA certificate.
> 
> I imagine restrict.c only tries to mirror the logic that was already
> implemented in find_asymmetric_key when the restrict functions were
> added.
> 
> For ID 2, only ever filled in by the x509_public_key subtype (right
> now), we only have any use for it being matched against the issuer's
> ID 2.
> 
> Note: asymmetric_match_key_ids can be used as part of a generic key
> API query, or as part of a find_asymmetric_key call (only used in
> crypto/asymmetric_keys/ for trust verification and similar) but
> find_asymmetric_key will then perform an extra check.  In any case
> without more background I think it's preferable to minimize the
> matching logic changes, and even assuming that the logic could be
> improved it may be best to keep it as is because existing tools may
> rely on it.

You could give a couple of usage examples, by using this cert

https://letsencrypt.org/docs/certificates-for-localhost/

That is good information to store in the commit log for future and
also works as a tested-by criteria.

/Jarkko

  parent reply	other threads:[~2021-01-20  1:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 20:40 [PATCH v2] keys: X.509 public key issuer lookup without AKID Andrew Zaborowski
2021-01-15  8:19 ` Jarkko Sakkinen
2021-01-15  8:21   ` Jarkko Sakkinen
2021-01-15 10:40   ` Andrew Zaborowski
2021-01-15 10:44     ` Andrew Zaborowski
2021-01-20  1:54     ` Jarkko Sakkinen [this message]
2021-01-21 11:31       ` Andrew Zaborowski
2021-01-21 15:22         ` Jarkko Sakkinen

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=YAeNa6vqLGLfTRbw@kernel.org \
    --to=jarkko@kernel.org \
    --cc=andrew.zaborowski@intel.com \
    --cc=dhowells@redhat.com \
    --cc=keyrings@vger.kernel.org \
    /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.