Linux cryptographic layer development
 help / color / mirror / Atom feed
* adiantum testmgr tests not running?
@ 2019-12-12 15:33 Jason A. Donenfeld
  2019-12-12 17:21 ` Eric Biggers
  0 siblings, 1 reply; 3+ messages in thread
From: Jason A. Donenfeld @ 2019-12-12 15:33 UTC (permalink / raw)
  To: Linux Crypto Mailing List, Eric Biggers; +Cc: Ard Biesheuvel

Hey Eric,

I had to do this ugly hack to get the adiantum testmgr tests running.
Did you wind up doing the same when developing it, or was there some
other mechanism that invoked this naturally? I see all the other
primitives running, but not adiantum.

Jason

diff --git a/crypto/chacha_generic.c b/crypto/chacha_generic.c
index 8beea79ab117..f446b19429e9 100644
--- a/crypto/chacha_generic.c
+++ b/crypto/chacha_generic.c
@@ -117,7 +117,9 @@ static struct skcipher_alg algs[] = {

 static int __init chacha_generic_mod_init(void)
 {
- return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
+ int ret = crypto_register_skciphers(algs, ARRAY_SIZE(algs));
+ BUG_ON(alg_test("adiantum(xchacha20,aes)", "adiantum", 0, 0));
+ return ret;
 }

 static void __exit chacha_generic_mod_fini(void)
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 82513b6b0abd..7de24e431c5e 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -5328,7 +5328,7 @@ int alg_test(const char *driver, const char
*alg, u32 type, u32 mask)
        driver, alg, fips_enabled ? "fips" : "panic_on_fail");
  }

- if (fips_enabled && !rc)
+ if (!rc)
  pr_info("alg: self-tests for %s (%s) passed\n", driver, alg);

  return rc;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: adiantum testmgr tests not running?
  2019-12-12 15:33 adiantum testmgr tests not running? Jason A. Donenfeld
@ 2019-12-12 17:21 ` Eric Biggers
  2019-12-12 17:28   ` Jason A. Donenfeld
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2019-12-12 17:21 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Linux Crypto Mailing List, Ard Biesheuvel

Hi Jason,

On Thu, Dec 12, 2019 at 04:33:25PM +0100, Jason A. Donenfeld wrote:
> Hey Eric,
> 
> I had to do this ugly hack to get the adiantum testmgr tests running.
> Did you wind up doing the same when developing it, or was there some
> other mechanism that invoked this naturally? I see all the other
> primitives running, but not adiantum.
> 
> Jason
> 
> diff --git a/crypto/chacha_generic.c b/crypto/chacha_generic.c
> index 8beea79ab117..f446b19429e9 100644
> --- a/crypto/chacha_generic.c
> +++ b/crypto/chacha_generic.c
> @@ -117,7 +117,9 @@ static struct skcipher_alg algs[] = {
> 
>  static int __init chacha_generic_mod_init(void)
>  {
> - return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
> + int ret = crypto_register_skciphers(algs, ARRAY_SIZE(algs));
> + BUG_ON(alg_test("adiantum(xchacha20,aes)", "adiantum", 0, 0));
> + return ret;
>  }
> 

You need to do something which instantiates the template, since "adiantum" is a
template, not an algorithm itself.  The easiest way to do this is with AF_ALG,
e.g.:

python3 <<EOF
import socket
s = socket.socket(socket.AF_ALG, 5, 0)
s.bind(("skcipher", "adiantum(xchacha12,aes)"))
s.bind(("skcipher", "adiantum(xchacha20,aes)"))
EOF

All the other templates work this way too.  So for more general testing of the
crypto API, I've actually been running a program that uses AF_ALG to try to bind
to every algorithm name for which self-tests are defined.

- Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: adiantum testmgr tests not running?
  2019-12-12 17:21 ` Eric Biggers
@ 2019-12-12 17:28   ` Jason A. Donenfeld
  0 siblings, 0 replies; 3+ messages in thread
From: Jason A. Donenfeld @ 2019-12-12 17:28 UTC (permalink / raw)
  To: Eric Biggers; +Cc: Linux Crypto Mailing List, Ard Biesheuvel

On Thu, Dec 12, 2019 at 6:21 PM Eric Biggers <ebiggers@kernel.org> wrote:
>
> Hi Jason,
>
> On Thu, Dec 12, 2019 at 04:33:25PM +0100, Jason A. Donenfeld wrote:
> > Hey Eric,
> >
> > I had to do this ugly hack to get the adiantum testmgr tests running.
> > Did you wind up doing the same when developing it, or was there some
> > other mechanism that invoked this naturally? I see all the other
> > primitives running, but not adiantum.
> >
> > Jason
> >
> > diff --git a/crypto/chacha_generic.c b/crypto/chacha_generic.c
> > index 8beea79ab117..f446b19429e9 100644
> > --- a/crypto/chacha_generic.c
> > +++ b/crypto/chacha_generic.c
> > @@ -117,7 +117,9 @@ static struct skcipher_alg algs[] = {
> >
> >  static int __init chacha_generic_mod_init(void)
> >  {
> > - return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
> > + int ret = crypto_register_skciphers(algs, ARRAY_SIZE(algs));
> > + BUG_ON(alg_test("adiantum(xchacha20,aes)", "adiantum", 0, 0));
> > + return ret;
> >  }
> >
>
> You need to do something which instantiates the template, since "adiantum" is a
> template, not an algorithm itself.  The easiest way to do this is with AF_ALG,
> e.g.:
>
> python3 <<EOF
> import socket
> s = socket.socket(socket.AF_ALG, 5, 0)
> s.bind(("skcipher", "adiantum(xchacha12,aes)"))
> s.bind(("skcipher", "adiantum(xchacha20,aes)"))
> EOF
>
> All the other templates work this way too.  So for more general testing of the
> crypto API, I've actually been running a program that uses AF_ALG to try to bind
> to every algorithm name for which self-tests are defined.

Ahh, that makes sense. Upon registration I guess it will hit that
crypto notifier block, which then will call into the testmgr code.
Thanks.

Well, the good news is that the new poly1305 code works fine on
Adiantum. I'll have a v3 submitted shortly.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-12 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-12 15:33 adiantum testmgr tests not running? Jason A. Donenfeld
2019-12-12 17:21 ` Eric Biggers
2019-12-12 17:28   ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox