aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJan-Simon Möller <dl9pf@gmx.de>2012-07-02 07:47:40 -0400
committerBehan Webster <behanw@converseincode.com>2014-10-14 04:51:23 -0400
commitffb32e973eb5105ec55e0bbf2e77a1ea4a7a123a (patch)
tree7fb370b40fe18ee004d49ce999b3b031aad49f9b /crypto
parentb610626523cf5c780bf7d9746580c323e90580e6 (diff)
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
Diffstat (limited to 'crypto')
-rw-r--r--crypto/hmac.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 8d9544cf8169..e392219ddc61 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -52,20 +52,17 @@ static int hmac_setkey(struct crypto_shash *parent,
52 struct hmac_ctx *ctx = align_ptr(opad + ss, 52 struct hmac_ctx *ctx = align_ptr(opad + ss,
53 crypto_tfm_ctx_alignment()); 53 crypto_tfm_ctx_alignment());
54 struct crypto_shash *hash = ctx->hash; 54 struct crypto_shash *hash = ctx->hash;
55 struct { 55 SHASH_DESC_ON_STACK(shash, hash);
56 struct shash_desc shash;
57 char ctx[crypto_shash_descsize(hash)];
58 } desc;
59 unsigned int i; 56 unsigned int i;
60 57
61 desc.shash.tfm = hash; 58 shash->tfm = hash;
62 desc.shash.flags = crypto_shash_get_flags(parent) & 59 shash->flags = crypto_shash_get_flags(parent)
63 CRYPTO_TFM_REQ_MAY_SLEEP; 60 & CRYPTO_TFM_REQ_MAY_SLEEP;
64 61
65 if (keylen > bs) { 62 if (keylen > bs) {
66 int err; 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 if (err) 66 if (err)
70 return err; 67 return err;
71 68
@@ -81,12 +78,12 @@ static int hmac_setkey(struct crypto_shash *parent,
81 opad[i] ^= 0x5c; 78 opad[i] ^= 0x5c;
82 } 79 }
83 80
84 return crypto_shash_init(&desc.shash) ?: 81 return crypto_shash_init(shash) ?:
85 crypto_shash_update(&desc.shash, ipad, bs) ?: 82 crypto_shash_update(shash, ipad, bs) ?:
86 crypto_shash_export(&desc.shash, ipad) ?: 83 crypto_shash_export(shash, ipad) ?:
87 crypto_shash_init(&desc.shash) ?: 84 crypto_shash_init(shash) ?:
88 crypto_shash_update(&desc.shash, opad, bs) ?: 85 crypto_shash_update(shash, opad, bs) ?:
89 crypto_shash_export(&desc.shash, opad); 86 crypto_shash_export(shash, opad);
90} 87}
91 88
92static int hmac_export(struct shash_desc *pdesc, void *out) 89static int hmac_export(struct shash_desc *pdesc, void *out)