Source-Changes-HG archive

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

[src/trunk]: src/sys/dev cgd(4): Align IVs on the stack.



details:   https://anonhg.NetBSD.org/src/rev/ddd6c1e0e1df
branches:  trunk
changeset: 973395:ddd6c1e0e1df
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Jun 29 23:36:06 2020 +0000

description:
cgd(4): Align IVs on the stack.

This will make it easier for some hardware crypto support.

diffstat:

 sys/dev/cgd.c        |  6 +++---
 sys/dev/cgd_crypto.c |  6 +++---
 sys/dev/cgd_crypto.h |  4 +++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r 126808b39996 -r ddd6c1e0e1df sys/dev/cgd.c
--- a/sys/dev/cgd.c     Mon Jun 29 23:35:26 2020 +0000
+++ b/sys/dev/cgd.c     Mon Jun 29 23:36:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.136 2020/06/29 23:35:26 riastradh Exp $ */
+/* $NetBSD: cgd.c,v 1.137 2020/06/29 23:36:06 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.136 2020/06/29 23:35:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.137 2020/06/29 23:36:06 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1587,7 +1587,7 @@
        cfunc_cipher    *cipher = sc->sc_cfuncs->cf_cipher;
        size_t          blocksize = sc->sc_cdata.cf_blocksize;
        size_t          todo;
-       char            blkno_buf[CGD_MAXBLOCKSIZE];
+       char            blkno_buf[CGD_MAXBLOCKSIZE] __aligned(CGD_BLOCKALIGN);
 
        DPRINTF_FOLLOW(("cgd_cipher() dir=%d\n", dir));
 
diff -r 126808b39996 -r ddd6c1e0e1df sys/dev/cgd_crypto.c
--- a/sys/dev/cgd_crypto.c      Mon Jun 29 23:35:26 2020 +0000
+++ b/sys/dev/cgd_crypto.c      Mon Jun 29 23:36:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd_crypto.c,v 1.24 2020/06/29 23:33:05 riastradh Exp $ */
+/* $NetBSD: cgd_crypto.c,v 1.25 2020/06/29 23:36:06 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.24 2020/06/29 23:33:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.25 2020/06/29 23:36:06 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -167,7 +167,7 @@
     const void *blkno, int dir)
 {
        struct aes_privdata     *apd = privdata;
-       uint8_t                  iv[CGD_AES_BLOCK_SIZE] = {0};
+       uint8_t iv[CGD_AES_BLOCK_SIZE] __aligned(CGD_AES_BLOCK_SIZE) = {0};
 
        /* Compute the CBC IV as AES_k(blkno).  */
        aes_enc(&apd->ap_enckey, blkno, iv, apd->ap_nrounds);
diff -r 126808b39996 -r ddd6c1e0e1df sys/dev/cgd_crypto.h
--- a/sys/dev/cgd_crypto.h      Mon Jun 29 23:35:26 2020 +0000
+++ b/sys/dev/cgd_crypto.h      Mon Jun 29 23:36:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd_crypto.h,v 1.12 2020/06/13 22:15:06 riastradh Exp $ */
+/* $NetBSD: cgd_crypto.h,v 1.13 2020/06/29 23:36:06 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,6 +39,8 @@
 #define CGD_3DES_BLOCK_SIZE    8
 #define CGD_BF_BLOCK_SIZE      8
 
+#define        CGD_BLOCKALIGN          16
+
 typedef void *(cfunc_init)(size_t, const void *, size_t *);
 typedef void  (cfunc_destroy)(void *);
 typedef void  (cfunc_cipher)(void *, void *, const void *, size_t,



Home | Main Index | Thread Index | Old Index