Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm Split aes_cbc_* and aes_xts_* into their own header ...



details:   https://anonhg.NetBSD.org/src/rev/5b0545c9479d
branches:  trunk
changeset: 1012174:5b0545c9479d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jul 25 22:14:35 2020 +0000

description:
Split aes_cbc_* and aes_xts_* into their own header files.

aes.h will remain just for key setup; any particular construction using
AES can have its own header file so we can have many of them without
rebuilding everything AES-related whenever one of them changes.

(Planning to add AES-CCM and AES-GCM too.)

diffstat:

 sys/crypto/aes/aes.h          |  12 +-----------
 sys/crypto/aes/aes_cbc.h      |  42 ++++++++++++++++++++++++++++++++++++++++++
 sys/crypto/aes/aes_impl.c     |   6 ++++--
 sys/crypto/aes/aes_rijndael.c |   6 ++++--
 sys/crypto/aes/aes_xts.h      |  42 ++++++++++++++++++++++++++++++++++++++++++
 sys/dev/cgd_crypto.c          |   6 ++++--
 sys/uvm/uvm_swap.c            |   5 +++--
 7 files changed, 100 insertions(+), 19 deletions(-)

diffs (223 lines):

diff -r e98aba1d2743 -r 5b0545c9479d sys/crypto/aes/aes.h
--- a/sys/crypto/aes/aes.h      Sat Jul 25 22:12:56 2020 +0000
+++ b/sys/crypto/aes/aes.h      Sat Jul 25 22:14:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes.h,v 1.3 2020/07/25 22:12:57 riastradh Exp $        */
+/*     $NetBSD: aes.h,v 1.4 2020/07/25 22:14:35 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -66,14 +66,4 @@
 void   aes_dec(const struct aesdec *, const uint8_t[static 16],
            uint8_t[static 16], uint32_t);
 
-void   aes_cbc_enc(struct aesenc *, const uint8_t[static 16],
-           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-void   aes_cbc_dec(struct aesdec *, const uint8_t[static 16],
-           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-
-void   aes_xts_enc(struct aesenc *, const uint8_t[static 16],
-           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-void   aes_xts_dec(struct aesdec *, const uint8_t[static 16],
-           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
-
 #endif /* _CRYPTO_AES_AES_H */
diff -r e98aba1d2743 -r 5b0545c9479d sys/crypto/aes/aes_cbc.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/crypto/aes/aes_cbc.h  Sat Jul 25 22:14:35 2020 +0000
@@ -0,0 +1,42 @@
+/*     $NetBSD: aes_cbc.h,v 1.1 2020/07/25 22:14:35 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_CBC_H
+#define        _CRYPTO_AES_AES_CBC_H
+
+#include <sys/types.h>
+
+struct aesenc;
+struct aesdec;
+
+void   aes_cbc_enc(struct aesenc *, const uint8_t[static 16],
+           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+void   aes_cbc_dec(struct aesdec *, const uint8_t[static 16],
+           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+
+#endif /* _CRYPTO_AES_AES_CBC_H */
diff -r e98aba1d2743 -r 5b0545c9479d sys/crypto/aes/aes_impl.c
--- a/sys/crypto/aes/aes_impl.c Sat Jul 25 22:12:56 2020 +0000
+++ b/sys/crypto/aes/aes_impl.c Sat Jul 25 22:14:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_impl.c,v 1.4 2020/07/25 22:12:57 riastradh Exp $   */
+/*     $NetBSD: aes_impl.c,v 1.5 2020/07/25 22:14:35 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.4 2020/07/25 22:12:57 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v 1.5 2020/07/25 22:14:35 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/kernel.h>
@@ -37,8 +37,10 @@
 #include <sys/systm.h>
 
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_cbc.h>
 #include <crypto/aes/aes_bear.h> /* default implementation */
 #include <crypto/aes/aes_impl.h>
+#include <crypto/aes/aes_xts.h>
 
 static int aes_selftest_stdkeysched(void);
 
diff -r e98aba1d2743 -r 5b0545c9479d sys/crypto/aes/aes_rijndael.c
--- a/sys/crypto/aes/aes_rijndael.c     Sat Jul 25 22:12:56 2020 +0000
+++ b/sys/crypto/aes/aes_rijndael.c     Sat Jul 25 22:14:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_rijndael.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $       */
+/*     $NetBSD: aes_rijndael.c,v 1.2 2020/07/25 22:14:35 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -44,12 +44,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_rijndael.c,v 1.1 2020/06/29 23:27:52 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_rijndael.c,v 1.2 2020/07/25 22:14:35 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
 
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_cbc.h>
+#include <crypto/aes/aes_xts.h>
 #include <crypto/rijndael/rijndael.h>
 #include <crypto/rijndael/rijndael-alg-fst.h>
 #include <crypto/rijndael/rijndael-api-fst.h>
diff -r e98aba1d2743 -r 5b0545c9479d sys/crypto/aes/aes_xts.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/crypto/aes/aes_xts.h  Sat Jul 25 22:14:35 2020 +0000
@@ -0,0 +1,42 @@
+/*     $NetBSD: aes_xts.h,v 1.1 2020/07/25 22:14:35 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_XTS_H
+#define        _CRYPTO_AES_AES_XTS_H
+
+#include <sys/types.h>
+
+struct aesenc;
+struct aesdec;
+
+void   aes_xts_enc(struct aesenc *, const uint8_t[static 16],
+           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+void   aes_xts_dec(struct aesdec *, const uint8_t[static 16],
+           uint8_t[static 16], size_t, uint8_t[static 16], uint32_t);
+
+#endif /* _CRYPTO_AES_AES_XTS_H */
diff -r e98aba1d2743 -r 5b0545c9479d sys/dev/cgd_crypto.c
--- a/sys/dev/cgd_crypto.c      Sat Jul 25 22:12:56 2020 +0000
+++ b/sys/dev/cgd_crypto.c      Sat Jul 25 22:14:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd_crypto.c,v 1.26 2020/06/29 23:44:01 riastradh Exp $ */
+/* $NetBSD: cgd_crypto.c,v 1.27 2020/07/25 22:14:35 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.26 2020/06/29 23:44:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.27 2020/07/25 22:14:35 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -47,6 +47,8 @@
 
 #include <crypto/adiantum/adiantum.h>
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_cbc.h>
+#include <crypto/aes/aes_xts.h>
 #include <crypto/blowfish/blowfish.h>
 #include <crypto/des/des.h>
 
diff -r e98aba1d2743 -r 5b0545c9479d sys/uvm/uvm_swap.c
--- a/sys/uvm/uvm_swap.c        Sat Jul 25 22:12:56 2020 +0000
+++ b/sys/uvm/uvm_swap.c        Sat Jul 25 22:14:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_swap.c,v 1.197 2020/07/09 05:57:15 skrll Exp $     */
+/*     $NetBSD: uvm_swap.c,v 1.198 2020/07/25 22:14:35 riastradh Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.197 2020/07/09 05:57:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.198 2020/07/25 22:14:35 riastradh Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_compat_netbsd.h"
@@ -66,6 +66,7 @@
 #include <miscfs/specfs/specdev.h>
 
 #include <crypto/aes/aes.h>
+#include <crypto/aes/aes_cbc.h>
 
 /*
  * uvm_swap.c: manage configuration and i/o to swap space.



Home | Main Index | Thread Index | Old Index