Module Name:    src
Committed By:   riastradh
Date:           Sat Jul 25 22:14:35 UTC 2020

Modified Files:
        src/sys/crypto/aes: aes.h aes_impl.c aes_rijndael.c
        src/sys/dev: cgd_crypto.c
        src/sys/uvm: uvm_swap.c
Added Files:
        src/sys/crypto/aes: aes_cbc.h aes_xts.h

Log Message:
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.)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/crypto/aes/aes.h
cvs rdiff -u -r0 -r1.1 src/sys/crypto/aes/aes_cbc.h \
    src/sys/crypto/aes/aes_xts.h
cvs rdiff -u -r1.4 -r1.5 src/sys/crypto/aes/aes_impl.c
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/aes/aes_rijndael.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/cgd_crypto.c
cvs rdiff -u -r1.197 -r1.198 src/sys/uvm/uvm_swap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/aes/aes.h
diff -u src/sys/crypto/aes/aes.h:1.3 src/sys/crypto/aes/aes.h:1.4
--- src/sys/crypto/aes/aes.h:1.3	Sat Jul 25 22:12:57 2020
+++ src/sys/crypto/aes/aes.h	Sat Jul 25 22:14:35 2020
@@ -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_enc(const struct aesenc *, cons
 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 */

Index: src/sys/crypto/aes/aes_impl.c
diff -u src/sys/crypto/aes/aes_impl.c:1.4 src/sys/crypto/aes/aes_impl.c:1.5
--- src/sys/crypto/aes/aes_impl.c:1.4	Sat Jul 25 22:12:57 2020
+++ src/sys/crypto/aes/aes_impl.c	Sat Jul 25 22:14:35 2020
@@ -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 @@ __KERNEL_RCSID(1, "$NetBSD: aes_impl.c,v
 #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);
 

Index: src/sys/crypto/aes/aes_rijndael.c
diff -u src/sys/crypto/aes/aes_rijndael.c:1.1 src/sys/crypto/aes/aes_rijndael.c:1.2
--- src/sys/crypto/aes/aes_rijndael.c:1.1	Mon Jun 29 23:27:52 2020
+++ src/sys/crypto/aes/aes_rijndael.c	Sat Jul 25 22:14:35 2020
@@ -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>

Index: src/sys/dev/cgd_crypto.c
diff -u src/sys/dev/cgd_crypto.c:1.26 src/sys/dev/cgd_crypto.c:1.27
--- src/sys/dev/cgd_crypto.c:1.26	Mon Jun 29 23:44:01 2020
+++ src/sys/dev/cgd_crypto.c	Sat Jul 25 22:14:35 2020
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c
 
 #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>
 

Index: src/sys/uvm/uvm_swap.c
diff -u src/sys/uvm/uvm_swap.c:1.197 src/sys/uvm/uvm_swap.c:1.198
--- src/sys/uvm/uvm_swap.c:1.197	Thu Jul  9 05:57:15 2020
+++ src/sys/uvm/uvm_swap.c	Sat Jul 25 22:14:35 2020
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v
 #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.

Added files:

Index: src/sys/crypto/aes/aes_cbc.h
diff -u /dev/null src/sys/crypto/aes/aes_cbc.h:1.1
--- /dev/null	Sat Jul 25 22:14:35 2020
+++ src/sys/crypto/aes/aes_cbc.h	Sat Jul 25 22:14:35 2020
@@ -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 */
Index: src/sys/crypto/aes/aes_xts.h
diff -u /dev/null src/sys/crypto/aes/aes_xts.h:1.1
--- /dev/null	Sat Jul 25 22:14:35 2020
+++ src/sys/crypto/aes/aes_xts.h	Sat Jul 25 22:14:35 2020
@@ -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 */

Reply via email to