diff options
author | Jan-Simon Möller <dl9pf@gmx.de> | 2014-09-04 14:39:24 -0400 |
---|---|---|
committer | Behan Webster <behanw@converseincode.com> | 2014-10-14 04:51:23 -0400 |
commit | 61ded52438d5fdc4dea87f823c455f8ac1e426df (patch) | |
tree | f56000217a5de79cd49e79d60e8a8fb3f7a96a29 | |
parent | 0458a953d85088a9ba3e448745676377775879e0 (diff) |
crypto: LLVMLinux: Remove VLAIS from crypto/ccp/ccp-crypto-sha.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>
-rw-r--r-- | drivers/crypto/ccp/ccp-crypto-sha.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c index 873f23425245..96531571f7cf 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c | |||
@@ -198,10 +198,9 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, | |||
198 | { | 198 | { |
199 | struct ccp_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); | 199 | struct ccp_ctx *ctx = crypto_tfm_ctx(crypto_ahash_tfm(tfm)); |
200 | struct crypto_shash *shash = ctx->u.sha.hmac_tfm; | 200 | struct crypto_shash *shash = ctx->u.sha.hmac_tfm; |
201 | struct { | 201 | |
202 | struct shash_desc sdesc; | 202 | SHASH_DESC_ON_STACK(sdesc, shash); |
203 | char ctx[crypto_shash_descsize(shash)]; | 203 | |
204 | } desc; | ||
205 | unsigned int block_size = crypto_shash_blocksize(shash); | 204 | unsigned int block_size = crypto_shash_blocksize(shash); |
206 | unsigned int digest_size = crypto_shash_digestsize(shash); | 205 | unsigned int digest_size = crypto_shash_digestsize(shash); |
207 | int i, ret; | 206 | int i, ret; |
@@ -216,11 +215,11 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, | |||
216 | 215 | ||
217 | if (key_len > block_size) { | 216 | if (key_len > block_size) { |
218 | /* Must hash the input key */ | 217 | /* Must hash the input key */ |
219 | desc.sdesc.tfm = shash; | 218 | sdesc->tfm = shash; |
220 | desc.sdesc.flags = crypto_ahash_get_flags(tfm) & | 219 | sdesc->flags = crypto_ahash_get_flags(tfm) & |
221 | CRYPTO_TFM_REQ_MAY_SLEEP; | 220 | CRYPTO_TFM_REQ_MAY_SLEEP; |
222 | 221 | ||
223 | ret = crypto_shash_digest(&desc.sdesc, key, key_len, | 222 | ret = crypto_shash_digest(sdesc, key, key_len, |
224 | ctx->u.sha.key); | 223 | ctx->u.sha.key); |
225 | if (ret) { | 224 | if (ret) { |
226 | crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); | 225 | crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |