diff mbox series

adiantum testmgr tests not running?

Message ID CAHmME9o4s3B_KUKYAzJr6xNaKdiLSGMJz-EyzP7RUptya1FqMg@mail.gmail.com
State New
Headers show
Series adiantum testmgr tests not running? | expand

Commit Message

Jason A. Donenfeld Dec. 12, 2019, 3:33 p.m. UTC
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

  return rc;

Comments

Eric Biggers Dec. 12, 2019, 5:21 p.m. UTC | #1
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
Jason A. Donenfeld Dec. 12, 2019, 5:28 p.m. UTC | #2
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
diff mbox series

Patch

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);