Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: mpatocka@redhat.com, linux-crypto@vger.kernel.org, dm-devel@redhat.com
Subject: Re: [PATCH 2/6] crypto: algapi - use common mechanism for inheriting flags
Date: Thu, 9 Jul 2020 23:24:03 -0700	[thread overview]
Message-ID: <20200710062403.GB2805@sol.localdomain> (raw)
In-Reply-To: <20200709053126.GA5510@gondor.apana.org.au>

On Thu, Jul 09, 2020 at 03:31:26PM +1000, Herbert Xu wrote:
> Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > @@ -875,14 +873,21 @@ static void cbcmac_exit_tfm(struct crypto_tfm *tfm)
> > 
> > static int cbcmac_create(struct crypto_template *tmpl, struct rtattr **tb)
> > {
> > +       struct crypto_attr_type *algt;
> >        struct shash_instance *inst;
> >        struct crypto_cipher_spawn *spawn;
> >        struct crypto_alg *alg;
> > +       u32 mask;
> >        int err;
> > 
> > -       err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH);
> > -       if (err)
> > -               return err;
> > +       algt = crypto_get_attr_type(tb);
> > +       if (IS_ERR(algt))
> > +               return PTR_ERR(algt);
> > +
> > +       if ((algt->type ^ CRYPTO_ALG_TYPE_SHASH) & algt->mask)
> > +               return -EINVAL;
> > +
> > +       mask = crypto_algt_inherited_mask(algt);
> 
> How about moving the types check into crypto_algt_inherited_mask,
> e.g.,
> 
> 	u32 mask;
> 	int err;
> 
> 	err = crypto_algt_inherited_mask(tb, CRYPTO_ALG_TYPE_SHASH);
> 	if (err < 0)
> 		return err;
> 
> 	mask = err;
> 
> This could then be used to simplify other templates too, such as
> gcm.
> 

I decided to make crypto_check_attr_type() return the mask instead, and do so
via a pointer argument instead of the return value (so that we don't overload an
errno return value and prevent flag 0x80000000 from working).
Please take a look at v2.  Thanks!

- Eric

  reply	other threads:[~2020-07-10  6:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-01  4:52 [PATCH 0/6] crypto: add CRYPTO_ALG_ALLOCATES_MEMORY Eric Biggers
2020-07-01  4:52 ` [PATCH 1/6] crypto: geniv - remove unneeded arguments from aead_geniv_alloc() Eric Biggers
2020-07-01  4:52 ` [PATCH 2/6] crypto: algapi - use common mechanism for inheriting flags Eric Biggers
2020-07-09  5:31   ` Herbert Xu
2020-07-10  6:24     ` Eric Biggers [this message]
2020-07-10  6:37       ` Herbert Xu
2020-07-01  4:52 ` [PATCH 3/6] crypto: algapi - introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY Eric Biggers
2020-07-01  4:52 ` [PATCH 4/6] crypto: algapi - remove crypto_check_attr_type() Eric Biggers
2020-07-01  4:52 ` [PATCH 5/6] crypto: set the flag CRYPTO_ALG_ALLOCATES_MEMORY Eric Biggers
2020-07-13 15:49   ` Horia Geantă
2020-07-13 16:01     ` Eric Biggers
2020-07-13 17:53       ` Horia Geantă
2020-07-14 13:38         ` Mikulas Patocka
2020-07-01  4:52 ` [PATCH 6/6] dm-crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY Eric Biggers
2020-07-01  7:59 ` [PATCH 0/6] crypto: add CRYPTO_ALG_ALLOCATES_MEMORY Mikulas Patocka
2020-07-06 18:54   ` Eric Biggers
2020-07-07 14:58     ` Mikulas Patocka

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=20200710062403.GB2805@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=mpatocka@redhat.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