Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src-all/rev/c1c28001c4cc
branches:  trunk
changeset: 934942:c1c28001c4cc
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Mon Jun 15 20:06:11 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        |  2 +-
 sys/dev/cgd_crypto.c |  2 +-
 sys/dev/cgd_crypto.h |  2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 8bd49c0a7da0 -r c1c28001c4cc sys/dev/cgd.c
--- a/sys/dev/cgd.c     Mon Jun 15 20:04:52 2020 +0000
+++ b/sys/dev/cgd.c     Mon Jun 15 20:06:11 2020 +0000
@@ -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 8bd49c0a7da0 -r c1c28001c4cc sys/dev/cgd_crypto.c
--- a/sys/dev/cgd_crypto.c      Mon Jun 15 20:04:52 2020 +0000
+++ b/sys/dev/cgd_crypto.c      Mon Jun 15 20:06:11 2020 +0000
@@ -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 8bd49c0a7da0 -r c1c28001c4cc sys/dev/cgd_crypto.h
--- a/sys/dev/cgd_crypto.h      Mon Jun 15 20:04:52 2020 +0000
+++ b/sys/dev/cgd_crypto.h      Mon Jun 15 20:06:11 2020 +0000
@@ -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