Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: LLVMLinux: Remove VLAIS usage from crypto/hmac.c

Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99
compliant equivalent. This patch allocates the appropriate amount of memory
using a char array using the SHASH_DESC_ON_STACK macro.

The new code can be compiled with both gcc and clang.

Signed-off-by: Jan-Simon Möller <dl9pf@gmx.de>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Cc: pageexec@freemail.hu

authored by

Jan-Simon Möller and committed by
Behan Webster
ffb32e97 b6106265

+11 -14
+11 -14
crypto/hmac.c
··· 52 52 struct hmac_ctx *ctx = align_ptr(opad + ss, 53 53 crypto_tfm_ctx_alignment()); 54 54 struct crypto_shash *hash = ctx->hash; 55 - struct { 56 - struct shash_desc shash; 57 - char ctx[crypto_shash_descsize(hash)]; 58 - } desc; 55 + SHASH_DESC_ON_STACK(shash, hash); 59 56 unsigned int i; 60 57 61 - desc.shash.tfm = hash; 62 - desc.shash.flags = crypto_shash_get_flags(parent) & 63 - CRYPTO_TFM_REQ_MAY_SLEEP; 58 + shash->tfm = hash; 59 + shash->flags = crypto_shash_get_flags(parent) 60 + & CRYPTO_TFM_REQ_MAY_SLEEP; 64 61 65 62 if (keylen > bs) { 66 63 int err; 67 64 68 - err = crypto_shash_digest(&desc.shash, inkey, keylen, ipad); 65 + err = crypto_shash_digest(shash, inkey, keylen, ipad); 69 66 if (err) 70 67 return err; 71 68 ··· 78 81 opad[i] ^= 0x5c; 79 82 } 80 83 81 - return crypto_shash_init(&desc.shash) ?: 82 - crypto_shash_update(&desc.shash, ipad, bs) ?: 83 - crypto_shash_export(&desc.shash, ipad) ?: 84 - crypto_shash_init(&desc.shash) ?: 85 - crypto_shash_update(&desc.shash, opad, bs) ?: 86 - crypto_shash_export(&desc.shash, opad); 84 + return crypto_shash_init(shash) ?: 85 + crypto_shash_update(shash, ipad, bs) ?: 86 + crypto_shash_export(shash, ipad) ?: 87 + crypto_shash_init(shash) ?: 88 + crypto_shash_update(shash, opad, bs) ?: 89 + crypto_shash_export(shash, opad); 87 90 } 88 91 89 92 static int hmac_export(struct shash_desc *pdesc, void *out)