Source-Changes-HG archive

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

[src/trunk]: src/sys Split aes_impl declarations out into aes_impl.h.



details:   https://anonhg.NetBSD.org/src/rev/ee7ea9f19631
branches:  trunk
changeset: 936304:ee7ea9f19631
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jul 25 22:12:56 2020 +0000

description:
Split aes_impl declarations out into aes_impl.h.

This will make it less painful to add more operations to struct
aes_impl without having to recompile everything that just uses the
block cipher directly or similar.

diffstat:

 sys/arch/aarch64/aarch64/cpu.c           |   5 +-
 sys/arch/arm/vfp/vfp_init.c              |   6 +-
 sys/arch/x86/x86/identcpu.c              |   5 +-
 sys/crypto/aes/aes.h                     |  25 +------------
 sys/crypto/aes/aes_bear.c                |   5 +-
 sys/crypto/aes/aes_impl.c                |   5 +-
 sys/crypto/aes/aes_impl.h                |  60 ++++++++++++++++++++++++++++++++
 sys/crypto/aes/aes_selftest.c            |   5 +-
 sys/crypto/aes/arch/arm/aes_armv8.c      |   5 +-
 sys/crypto/aes/arch/arm/aes_armv8.h      |   7 ++-
 sys/crypto/aes/arch/arm/aes_neon.h       |   9 +++-
 sys/crypto/aes/arch/arm/aes_neon_impl.c  |   5 +-
 sys/crypto/aes/arch/x86/aes_ni.c         |   5 +-
 sys/crypto/aes/arch/x86/aes_ni.h         |   7 ++-
 sys/crypto/aes/arch/x86/aes_sse2.h       |   9 +++-
 sys/crypto/aes/arch/x86/aes_sse2_impl.c  |   5 +-
 sys/crypto/aes/arch/x86/aes_ssse3.h      |   9 +++-
 sys/crypto/aes/arch/x86/aes_ssse3_impl.c |   5 +-
 sys/crypto/aes/arch/x86/aes_via.c        |   5 +-
 sys/crypto/aes/arch/x86/aes_via.h        |   4 +-
 20 files changed, 130 insertions(+), 61 deletions(-)

diffs (truncated from 541 to 300 lines):

diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/arch/aarch64/aarch64/cpu.c
--- a/sys/arch/aarch64/aarch64/cpu.c    Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/arch/aarch64/aarch64/cpu.c    Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.52 2020/07/01 08:01:07 ryo Exp $ */
+/* $NetBSD: cpu.c,v 1.53 2020/07/25 22:12:56 riastradh Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.52 2020/07/01 08:01:07 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.53 2020/07/25 22:12:56 riastradh Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -44,6 +44,7 @@
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 
+#include <crypto/aes/aes_impl.h>
 #include <crypto/aes/arch/arm/aes_armv8.h>
 #include <crypto/aes/arch/arm/aes_neon.h>
 
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/arch/arm/vfp/vfp_init.c
--- a/sys/arch/arm/vfp/vfp_init.c       Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/arch/arm/vfp/vfp_init.c       Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: vfp_init.c,v 1.68 2020/07/13 16:54:03 riastradh Exp $ */
+/*      $NetBSD: vfp_init.c,v 1.69 2020/07/25 22:12:56 riastradh Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -32,7 +32,7 @@
 #include "opt_cputypes.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.68 2020/07/13 16:54:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.69 2020/07/25 22:12:56 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -50,7 +50,7 @@
 
 #include <uvm/uvm_extern.h>            /* for pmap.h */
 
-#include <crypto/aes/aes.h>
+#include <crypto/aes/aes_impl.h>
 #include <crypto/aes/arch/arm/aes_neon.h>
 
 #ifdef FPU_VFP
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.113 2020/07/20 16:45:41 riastradh Exp $ */
+/*     $NetBSD: identcpu.c,v 1.114 2020/07/25 22:12:56 riastradh Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.113 2020/07/20 16:45:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.114 2020/07/25 22:12:56 riastradh Exp $");
 
 #include "opt_xen.h"
 
@@ -39,6 +39,7 @@
 #include <sys/device.h>
 #include <sys/cpu.h>
 
+#include <crypto/aes/aes_impl.h>
 #include <crypto/aes/arch/x86/aes_ni.h>
 #include <crypto/aes/arch/x86/aes_sse2.h>
 #include <crypto/aes/arch/x86/aes_ssse3.h>
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/aes.h
--- a/sys/crypto/aes/aes.h      Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/aes.h      Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes.h,v 1.2 2020/06/29 23:47:54 riastradh Exp $        */
+/*     $NetBSD: aes.h,v 1.3 2020/07/25 22:12:57 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -54,27 +54,6 @@
        union aes       aesd_aes;
 };
 
-struct aes_impl {
-       const char *ai_name;
-       int     (*ai_probe)(void);
-       void    (*ai_setenckey)(struct aesenc *, const uint8_t *, uint32_t);
-       void    (*ai_setdeckey)(struct aesdec *, const uint8_t *, uint32_t);
-       void    (*ai_enc)(const struct aesenc *, const uint8_t[static 16],
-                   uint8_t[static 16], uint32_t);
-       void    (*ai_dec)(const struct aesdec *, const uint8_t[static 16],
-                   uint8_t[static 16], uint32_t);
-       void    (*ai_cbc_enc)(const struct aesenc *, const uint8_t[static 16],
-                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-       void    (*ai_cbc_dec)(const struct aesdec *, const uint8_t[static 16],
-                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-       void    (*ai_xts_enc)(const struct aesenc *, const uint8_t[static 16],
-                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-       void    (*ai_xts_dec)(const struct aesdec *, const uint8_t[static 16],
-                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-};
-
-int    aes_selftest(const struct aes_impl *);
-
 uint32_t aes_setenckey128(struct aesenc *, const uint8_t[static 16]);
 uint32_t aes_setenckey192(struct aesenc *, const uint8_t[static 24]);
 uint32_t aes_setenckey256(struct aesenc *, const uint8_t[static 32]);
@@ -97,6 +76,4 @@
 void   aes_xts_dec(struct aesdec *, const uint8_t[static 16],
            uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
 
-void   aes_md_init(const struct aes_impl *);
-
 #endif /* _CRYPTO_AES_AES_H */
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/aes_bear.c
--- a/sys/crypto/aes/aes_bear.c Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/aes_bear.c Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_bear.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $   */
+/*     $NetBSD: aes_bear.c,v 1.3 2020/07/25 22:12:57 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_bear.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_bear.c,v 1.3 2020/07/25 22:12:57 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/endian.h>
@@ -44,6 +44,7 @@
 
 #include <crypto/aes/aes.h>
 #include <crypto/aes/aes_bear.h>
+#include <crypto/aes/aes_impl.h>
 
 static void
 aesbear_setkey(uint32_t rk[static 60], const void *key, uint32_t nrounds)
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/aes_impl.c
--- a/sys/crypto/aes/aes_impl.c Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/aes_impl.c Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_impl.c,v 1.3 2020/06/30 16:21:17 riastradh Exp $   */
+/*     $NetBSD: aes_impl.c,v 1.4 2020/07/25 22:12:57 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v 1.3 2020/06/30 16:21:17 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v 1.4 2020/07/25 22:12:57 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/kernel.h>
@@ -38,6 +38,7 @@
 
 #include <crypto/aes/aes.h>
 #include <crypto/aes/aes_bear.h> /* default implementation */
+#include <crypto/aes/aes_impl.h>
 
 static int aes_selftest_stdkeysched(void);
 
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/aes_impl.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/crypto/aes/aes_impl.h Sat Jul 25 22:12:56 2020 +0000
@@ -0,0 +1,60 @@
+/*     $NetBSD: aes_impl.h,v 1.1 2020/07/25 22:12:57 riastradh Exp $   */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef        _CRYPTO_AES_AES_IMPL_H
+#define        _CRYPTO_AES_AES_IMPL_H
+
+#include <sys/types.h>
+
+struct aesenc;
+struct aesdec;
+
+struct aes_impl {
+       const char *ai_name;
+       int     (*ai_probe)(void);
+       void    (*ai_setenckey)(struct aesenc *, const uint8_t *, uint32_t);
+       void    (*ai_setdeckey)(struct aesdec *, const uint8_t *, uint32_t);
+       void    (*ai_enc)(const struct aesenc *, const uint8_t[static 16],
+                   uint8_t[static 16], uint32_t);
+       void    (*ai_dec)(const struct aesdec *, const uint8_t[static 16],
+                   uint8_t[static 16], uint32_t);
+       void    (*ai_cbc_enc)(const struct aesenc *, const uint8_t[static 16],
+                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+       void    (*ai_cbc_dec)(const struct aesdec *, const uint8_t[static 16],
+                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+       void    (*ai_xts_enc)(const struct aesenc *, const uint8_t[static 16],
+                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+       void    (*ai_xts_dec)(const struct aesdec *, const uint8_t[static 16],
+                   uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+};
+
+void   aes_md_init(const struct aes_impl *);
+
+int    aes_selftest(const struct aes_impl *);
+
+#endif /* _CRYPTO_AES_AES_IMPL_H */
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/aes_selftest.c
--- a/sys/crypto/aes/aes_selftest.c     Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/aes_selftest.c     Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_selftest.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $       */
+/*     $NetBSD: aes_selftest.c,v 1.3 2020/07/25 22:12:57 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_selftest.c,v 1.2 2020/06/30 20:32:11 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_selftest.c,v 1.3 2020/07/25 22:12:57 riastradh Exp $");
 
 #ifdef _KERNEL
 
@@ -66,6 +66,7 @@
 #endif /* _KERNEL */
 
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_impl.h>
 
 static const unsigned aes_keybytes[] __unused = { 16, 24, 32 };
 static const unsigned aes_keybits[] __unused = { 128, 192, 256 };
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/arch/arm/aes_armv8.c
--- a/sys/crypto/aes/arch/arm/aes_armv8.c       Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_armv8.c       Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_armv8.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $  */
+/*     $NetBSD: aes_armv8.c,v 1.4 2020/07/25 22:12:57 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_armv8.c,v 1.3 2020/06/30 20:32:11 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_armv8.c,v 1.4 2020/07/25 22:12:57 riastradh Exp $");
 
 #ifdef _KERNEL
 #include <sys/types.h>
@@ -43,6 +43,7 @@
 #endif
 
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_impl.h>
 #include <crypto/aes/arch/arm/aes_armv8.h>
 
 #include <aarch64/armreg.h>
diff -r 83bc6608a4f8 -r ee7ea9f19631 sys/crypto/aes/arch/arm/aes_armv8.h
--- a/sys/crypto/aes/arch/arm/aes_armv8.h       Sat Jul 25 22:11:05 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_armv8.h       Sat Jul 25 22:12:56 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_armv8.h,v 1.1 2020/06/29 23:31:41 riastradh Exp $  */
+/*     $NetBSD: aes_armv8.h,v 1.2 2020/07/25 22:12:57 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.



Home | Main Index | Thread Index | Old Index