linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Ofir Drang <ofir.drang@arm.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] crypto: testmgr - use generic algs making test vecs
Date: Tue, 25 Feb 2020 18:32:50 -0800	[thread overview]
Message-ID: <20200226023250.GA1053@sol.localdomain> (raw)
In-Reply-To: <20200225194551.GA114977@gmail.com>

On Tue, Feb 25, 2020 at 11:45:51AM -0800, Eric Biggers wrote:
> On Tue, Feb 25, 2020 at 05:48:33PM +0200, Gilad Ben-Yossef wrote:
> > Use generic algs to produce inauthentic AEAD messages,
> > otherwise we are running the risk of using an untested
> > code to produce the test messages.
> > 
> > As this code is only used in developer only extended tests
> > any cycles/runtime costs are negligible.
> > 
> > Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> > Cc: Eric Biggers <ebiggers@kernel.org>
> 
> It's intentional to use the same implementation to generate the inauthentic AEAD
> messages, because it allows the inauthentic AEAD input tests to run even if the
> generic implementation is unavailable.
> 
> > @@ -2337,8 +2338,42 @@ static int test_aead_inauthentic_inputs(struct aead_extra_tests_ctx *ctx)
> >  {
> >  	unsigned int i;
> >  	int err;
> > +	struct crypto_aead *tfm = ctx->tfm;
> > +	const char *algname = crypto_aead_alg(tfm)->base.cra_name;
> > +	const char *driver = ctx->driver;
> > +	const char *generic_driver = ctx->test_desc->generic_driver;
> > +	char _generic_driver[CRYPTO_MAX_ALG_NAME];
> > +	struct crypto_aead *generic_tfm = NULL;
> > +	struct aead_request *generic_req = NULL;
> > +
> > +	if (!generic_driver) {
> > +		err = build_generic_driver_name(algname, _generic_driver);
> > +		if (err)
> > +			return err;
> > +		generic_driver = _generic_driver;
> > +	}
> > +
> > +	if (!strcmp(generic_driver, driver) == 0) {
> > +		/* Already the generic impl? */
> > +
> > +		generic_tfm = crypto_alloc_aead(generic_driver, 0, 0);
> 
> I think you meant the condition to be 'if (strcmp(generic_driver, driver) != 0)'
> and for the comment to be "Not already the generic impl?".
> 
> > +		if (IS_ERR(generic_tfm)) {
> > +			err = PTR_ERR(generic_tfm);
> > +			pr_err("alg: aead: error allocating %s (generic impl of %s): %d\n",
> > +			generic_driver, algname, err);
> > +			return err;
> > +		}
> 
> This means the test won't run if the generic implementation is unavailable.
> Is there any particular reason to impose that requirement?
> 
> You mentioned a concern about the implementation being "untested", but it
> actually already passed test_aead() before getting to test_aead_extra().
> 
> We could also just move test_aead_inauthentic_inputs() to below
> test_aead_vs_generic_impl() so that it runs last.
> 

Also: if we did make the inauthentic input tests use the generic implementation,
then it would be better to move them into test_aead_vs_generic_impl() so that we
don't duplicate the code that allocates a tfm and request for the generic
implementation.

But to me it makes more sense to keep them separate, since a generic
implementation is not needed to run the inauthentic input tests.

- Eric

  reply	other threads:[~2020-02-26  2:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 15:48 [PATCH 0/2] crypto: testmgr - AEAD extra tests fixes Gilad Ben-Yossef
2020-02-25 15:48 ` [PATCH 1/2] crypto: testmgr - use generic algs making test vecs Gilad Ben-Yossef
2020-02-25 19:45   ` Eric Biggers
2020-02-26  2:32     ` Eric Biggers [this message]
2020-02-26 14:42     ` Gilad Ben-Yossef
2020-02-26 22:17       ` Eric Biggers
2020-02-25 15:48 ` [PATCH 2/2] crypto: testmgr - sync both RFC4106 IV copies Gilad Ben-Yossef
2020-02-25 20:02   ` Eric Biggers
2020-02-26 15:09     ` Gilad Ben-Yossef

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=20200226023250.GA1053@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=davem@davemloft.net \
    --cc=gilad@benyossef.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ofir.drang@arm.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;
as well as URLs for NNTP newsgroup(s).