[PATCH 2/5] cipher-ccm: remove VLA usage

Jussi Kivilinna jussi.kivilinna at iki.fi
Sat Oct 1 09:48:20 CEST 2022


* cipher/cipher-ccm.c (do_cbc_mac): Avoid VLA for stack array.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/cipher-ccm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cipher/cipher-ccm.c b/cipher/cipher-ccm.c
index f8b6865c..b325c966 100644
--- a/cipher/cipher-ccm.c
+++ b/cipher/cipher-ccm.c
@@ -38,9 +38,9 @@ static unsigned int
 do_cbc_mac (gcry_cipher_hd_t c, const unsigned char *inbuf, size_t inlen,
             int do_padding)
 {
-  const unsigned int blocksize = 16;
   gcry_cipher_encrypt_t enc_fn = c->spec->encrypt;
-  unsigned char tmp[blocksize];
+  unsigned char tmp[16];
+  const unsigned int blocksize = DIM(tmp);
   unsigned int burn = 0;
   unsigned int unused = c->u_mode.ccm.mac_unused;
   size_t nblocks;
-- 
2.34.1




More information about the Gcrypt-devel mailing list