Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src New test sys/crypto/aes/t_aes.



details:   https://anonhg.NetBSD.org/src/rev/0b9b3e57eb74
branches:  trunk
changeset: 935360:0b9b3e57eb74
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jun 30 20:32:10 2020 +0000

description:
New test sys/crypto/aes/t_aes.

Runs aes_selftest on all kernel AES implementations supported on the
current hardware, not just the preferred one.

diffstat:

 distrib/sets/lists/debug/mi              |    5 +-
 distrib/sets/lists/tests/mi              |   11 ++-
 etc/mtree/NetBSD.dist.tests              |    6 +-
 sys/crypto/aes/aes_bear.c                |   13 ++-
 sys/crypto/aes/aes_ct.c                  |    8 +-
 sys/crypto/aes/aes_selftest.c            |   35 +++++++-
 sys/crypto/aes/arch/arm/aes_armv8.c      |   35 +++++++-
 sys/crypto/aes/arch/arm/aes_neon.c       |    9 +-
 sys/crypto/aes/arch/arm/aes_neon_impl.c  |   38 +++++++-
 sys/crypto/aes/arch/arm/aes_neon_subr.c  |   12 ++-
 sys/crypto/aes/arch/x86/aes_ni.c         |   27 +++++-
 sys/crypto/aes/arch/x86/aes_sse2.c       |    7 +-
 sys/crypto/aes/arch/x86/aes_sse2_impl.c  |   20 ++++-
 sys/crypto/aes/arch/x86/aes_sse2_subr.c  |   15 ++-
 sys/crypto/aes/arch/x86/aes_ssse3.c      |    9 +-
 sys/crypto/aes/arch/x86/aes_ssse3_impl.c |   24 +++++-
 sys/crypto/aes/arch/x86/aes_ssse3_subr.c |   12 ++-
 sys/crypto/aes/arch/x86/aes_via.c        |   61 +++++++++++++-
 tests/sys/Makefile                       |    9 +-
 tests/sys/crypto/Makefile                |    9 ++
 tests/sys/crypto/aes/Makefile            |   66 +++++++++++++++
 tests/sys/crypto/aes/t_aes.c             |  135 +++++++++++++++++++++++++++++++
 22 files changed, 524 insertions(+), 42 deletions(-)

diffs (truncated from 1015 to 300 lines):

diff -r f012d92b90f5 -r 0b9b3e57eb74 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Tue Jun 30 19:02:42 2020 +0000
+++ b/distrib/sets/lists/debug/mi       Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.321 2020/06/30 16:09:40 jruoho Exp $
+# $NetBSD: mi,v 1.322 2020/06/30 20:32:10 riastradh Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -2408,6 +2408,9 @@
 ./usr/libdata/debug/usr/tests/rump/rumpvfs/t_etfs.debug                tests-syscall-debug     debug,atf,rump
 ./usr/libdata/debug/usr/tests/rump/rumpvfs/t_p2kifs.debug              tests-syscall-debug     debug,atf,rump
 ./usr/libdata/debug/usr/tests/sys                                      tests-sys-debug debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/sys/crypto                               tests-sys-debug debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/sys/crypto/aes                           tests-sys-debug debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/sys/crypto/aes/t_aes.debug               tests-sys-debug debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/sys/net                                  tests-sys-debug debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/sys/net/t_print.debug                    tests-sys-debug debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/sys/netatalk                             tests-sys-debug debug,atf,compattestfile
diff -r f012d92b90f5 -r 0b9b3e57eb74 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Jun 30 19:02:42 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.866 2020/06/30 16:09:40 jruoho Exp $
+# $NetBSD: mi,v 1.867 2020/06/30 20:32:10 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -182,6 +182,8 @@
 ./usr/libdata/debug/usr/tests/sbin                                     tests-sbin-tests        compattestfile,atf
 ./usr/libdata/debug/usr/tests/sbin/resize_ffs                          tests-sbin-tests        compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys                                      tests-sys-debug         compattestfile,atf
+./usr/libdata/debug/usr/tests/sys/crypto                               tests-sys-debug         compattestfile,atf
+./usr/libdata/debug/usr/tests/sys/crypto/aes                           tests-sys-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/net                                  tests-sys-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netatalk                             tests-sys-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/sys/netinet                              tests-sys-debug         compattestfile,atf
@@ -4061,6 +4063,13 @@
 ./usr/tests/sys                                        tests-sys-tests compattestfile,atf
 ./usr/tests/sys/Atffile                                tests-sys-tests compattestfile,atf
 ./usr/tests/sys/Kyuafile                       tests-sys-tests compattestfile,atf,kyua
+./usr/tests/sys/crypto                         tests-sys-tests compattestfile,atf
+./usr/tests/sys/crypto/Atffile                 tests-sys-tests compattestfile,atf
+./usr/tests/sys/crypto/Kyuafile                        tests-sys-tests compattestfile,atf,kyua
+./usr/tests/sys/crypto/aes                     tests-sys-tests compattestfile,atf
+./usr/tests/sys/crypto/aes/Atffile             tests-sys-tests compattestfile,atf
+./usr/tests/sys/crypto/aes/Kyuafile            tests-sys-tests compattestfile,atf,kyua
+./usr/tests/sys/crypto/aes/t_aes               tests-sys-tests compattestfile,atf
 ./usr/tests/sys/net                            tests-sys-tests compattestfile,atf
 ./usr/tests/sys/net/Atffile                    tests-sys-tests compattestfile,atf
 ./usr/tests/sys/net/Kyuafile                   tests-sys-tests compattestfile,atf,kyua
diff -r f012d92b90f5 -r 0b9b3e57eb74 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Tue Jun 30 19:02:42 2020 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.170 2020/06/30 14:30:49 jruoho Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.171 2020/06/30 20:32:11 riastradh Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -162,6 +162,8 @@
 ./usr/libdata/debug/usr/tests/sbin
 ./usr/libdata/debug/usr/tests/sbin/resize_ffs
 ./usr/libdata/debug/usr/tests/sys
+./usr/libdata/debug/usr/tests/sys/crypto
+./usr/libdata/debug/usr/tests/sys/crypto/aes
 ./usr/libdata/debug/usr/tests/sys/net
 ./usr/libdata/debug/usr/tests/sys/netatalk
 ./usr/libdata/debug/usr/tests/sys/netinet
@@ -386,6 +388,8 @@
 ./usr/tests/share/examples/lutok
 ./usr/tests/share/mk
 ./usr/tests/sys
+./usr/tests/sys/crypto
+./usr/tests/sys/crypto/aes
 ./usr/tests/sys/net
 ./usr/tests/sys/netatalk
 ./usr/tests/sys/netinet
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/aes_bear.c
--- a/sys/crypto/aes/aes_bear.c Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/aes_bear.c Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_bear.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $   */
+/*     $NetBSD: aes_bear.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,11 +27,20 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_bear.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_bear.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/endian.h>
+
+#ifdef _KERNEL
 #include <sys/systm.h>
+#else
+#include <assert.h>
+#include <err.h>
+#include <string.h>
+#define        KASSERT                 assert
+#define        panic(fmt, args...)     err(1, fmt, args)
+#endif
 
 #include <crypto/aes/aes.h>
 #include <crypto/aes/aes_bear.h>
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/aes_ct.c
--- a/sys/crypto/aes/aes_ct.c   Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/aes_ct.c   Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_ct.c,v 1.2 2020/06/29 23:36:59 riastradh Exp $     */
+/*     $NetBSD: aes_ct.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $     */
 
 /*
  * Copyright (c) 2016 Thomas Pornin <pornin%bolet.org@localhost>
@@ -25,11 +25,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_ct.c,v 1.2 2020/06/29 23:36:59 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_ct.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $");
 
 #include <sys/types.h>
 
+#ifdef _KERNEL
 #include <lib/libkern/libkern.h>
+#else
+#include <string.h>
+#endif
 
 #include <crypto/aes/aes_bear.h>
 
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/aes_selftest.c
--- a/sys/crypto/aes/aes_selftest.c     Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/aes_selftest.c     Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_selftest.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $       */
+/*     $NetBSD: aes_selftest.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,13 +27,44 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_selftest.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_selftest.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $");
+
+#ifdef _KERNEL
 
 #include <sys/types.h>
 #include <sys/systm.h>
 
 #include <lib/libkern/libkern.h>
 
+#else  /* !_KERNEL */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+static void
+hexdump(int (*prf)(const char *, ...) __printflike(1,2), const char *prefix,
+    const void *buf, size_t len)
+{
+       const uint8_t *p = buf;
+       size_t i;
+
+       (*prf)("%s (%zu bytes)\n", prefix, len);
+       for (i = 0; i < len; i++) {
+               if (i % 16 == 8)
+                       (*prf)("  ");
+               else
+                       (*prf)(" ");
+               (*prf)("%02hhx", p[i]);
+               if ((i + 1) % 16 == 0)
+                       (*prf)("\n");
+       }
+       if (i % 16)
+               (*prf)("\n");
+}
+
+#endif /* _KERNEL */
+
 #include <crypto/aes/aes.h>
 
 static const unsigned aes_keybytes[] __unused = { 16, 24, 32 };
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/arch/arm/aes_armv8.c
--- a/sys/crypto/aes/arch/arm/aes_armv8.c       Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_armv8.c       Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_armv8.c,v 1.2 2020/06/29 23:53:12 riastradh Exp $  */
+/*     $NetBSD: aes_armv8.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,18 +27,34 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_armv8.c,v 1.2 2020/06/29 23:53:12 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_armv8.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $");
 
+#ifdef _KERNEL
 #include <sys/types.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
+#else
+#include <assert.h>
+#include <err.h>
+#include <stdint.h>
+#include <string.h>
+#define        KASSERT                 assert
+#define        panic(fmt, args...)     err(1, fmt, args)
+#endif
 
 #include <crypto/aes/aes.h>
 #include <crypto/aes/arch/arm/aes_armv8.h>
 
-#include <arm/fpu.h>
+#include <aarch64/armreg.h>
 
-#include <aarch64/armreg.h>
+#ifdef _KERNEL
+#include <arm/fpu.h>
+#else
+#include <sys/sysctl.h>
+#include <stddef.h>
+#define        fpu_kern_enter()        ((void)0)
+#define        fpu_kern_leave()        ((void)0)
+#endif
 
 static void
 aesarmv8_setenckey(struct aesenc *enc, const uint8_t key[static 16],
@@ -226,7 +242,18 @@
        int result = 0;
 
        /* Verify that the CPU supports AES.  */
+#ifdef _KERNEL
        id = &curcpu()->ci_id;
+#else
+       struct aarch64_sysctl_cpu_id ids;
+       size_t idlen;
+       id = &ids;
+       idlen = sizeof ids;
+       if (sysctlbyname("machdep.cpu0.cpu_id", id, &idlen, NULL, 0))
+               return -1;
+       if (idlen != sizeof ids)
+               return -1;
+#endif
        switch (__SHIFTOUT(id->ac_aa64isar0, ID_AA64ISAR0_EL1_AES)) {
        case ID_AA64ISAR0_EL1_AES_AES:
        case ID_AA64ISAR0_EL1_AES_PMUL:
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/arch/arm/aes_neon.c
--- a/sys/crypto/aes/arch/arm/aes_neon.c        Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_neon.c        Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_neon.c,v 1.2 2020/06/29 23:57:56 riastradh Exp $   */
+/*     $NetBSD: aes_neon.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -39,11 +39,16 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_neon.c,v 1.2 2020/06/29 23:57:56 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_neon.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $");
 
 #include <sys/types.h>
 
+#ifdef _KERNEL
 #include <sys/systm.h>
+#else
+#include <err.h>
+#define        panic(fmt, args...)             err(1, fmt, ##args)
+#endif
 
 #include "aes_neon_impl.h"
 
diff -r f012d92b90f5 -r 0b9b3e57eb74 sys/crypto/aes/arch/arm/aes_neon_impl.c
--- a/sys/crypto/aes/arch/arm/aes_neon_impl.c   Tue Jun 30 19:02:42 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_neon_impl.c   Tue Jun 30 20:32:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_neon_impl.c,v 1.1 2020/06/29 23:56:31 riastradh Exp $      */
+/*     $NetBSD: aes_neon_impl.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_neon_impl.c,v 1.1 2020/06/29 23:56:31 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_neon_impl.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $");
 
 #include <sys/types.h>



Home | Main Index | Thread Index | Old Index