diff options
author | Behan Webster <behanw@converseincode.com> | 2014-04-04 17:18:00 -0400 |
---|---|---|
committer | Behan Webster <behanw@converseincode.com> | 2014-10-14 04:51:23 -0400 |
commit | 7128470f6b21b922b42f790d429330562eb6eab1 (patch) | |
tree | f996e4200d42154b6252bafee1effe975918de94 | |
parent | 61ded52438d5fdc4dea87f823c455f8ac1e426df (diff) |
crypto: LLVMLinux: Remove VLAIS from crypto/mv_cesa.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: Behan Webster <behanw@converseincode.com>
Reviewed-by: Mark Charlebois <charlebm@gmail.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/mv_cesa.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 29d0ee504907..032c72c1f953 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c | |||
@@ -402,26 +402,23 @@ static int mv_hash_final_fallback(struct ahash_request *req) | |||
402 | { | 402 | { |
403 | const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm); | 403 | const struct mv_tfm_hash_ctx *tfm_ctx = crypto_tfm_ctx(req->base.tfm); |
404 | struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req); | 404 | struct mv_req_hash_ctx *req_ctx = ahash_request_ctx(req); |
405 | struct { | 405 | SHASH_DESC_ON_STACK(shash, tfm_ctx->fallback); |
406 | struct shash_desc shash; | ||
407 | char ctx[crypto_shash_descsize(tfm_ctx->fallback)]; | ||
408 | } desc; | ||
409 | int rc; | 406 | int rc; |
410 | 407 | ||
411 | desc.shash.tfm = tfm_ctx->fallback; | 408 | shash->tfm = tfm_ctx->fallback; |
412 | desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; | 409 | shash->flags = CRYPTO_TFM_REQ_MAY_SLEEP; |
413 | if (unlikely(req_ctx->first_hash)) { | 410 | if (unlikely(req_ctx->first_hash)) { |
414 | crypto_shash_init(&desc.shash); | 411 | crypto_shash_init(shash); |
415 | crypto_shash_update(&desc.shash, req_ctx->buffer, | 412 | crypto_shash_update(shash, req_ctx->buffer, |
416 | req_ctx->extra_bytes); | 413 | req_ctx->extra_bytes); |
417 | } else { | 414 | } else { |
418 | /* only SHA1 for now.... | 415 | /* only SHA1 for now.... |
419 | */ | 416 | */ |
420 | rc = mv_hash_import_sha1_ctx(req_ctx, &desc.shash); | 417 | rc = mv_hash_import_sha1_ctx(req_ctx, shash); |
421 | if (rc) | 418 | if (rc) |
422 | goto out; | 419 | goto out; |
423 | } | 420 | } |
424 | rc = crypto_shash_final(&desc.shash, req->result); | 421 | rc = crypto_shash_final(shash, req->result); |
425 | out: | 422 | out: |
426 | return rc; | 423 | return rc; |
427 | } | 424 | } |
@@ -794,23 +791,21 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, | |||
794 | ss = crypto_shash_statesize(ctx->base_hash); | 791 | ss = crypto_shash_statesize(ctx->base_hash); |
795 | 792 | ||
796 | { | 793 | { |
797 | struct { | 794 | SHASH_DESC_ON_STACK(shash, ctx->base_hash); |
798 | struct shash_desc shash; | 795 | |
799 | char ctx[crypto_shash_descsize(ctx->base_hash)]; | ||
800 | } desc; | ||
801 | unsigned int i; | 796 | unsigned int i; |
802 | char ipad[ss]; | 797 | char ipad[ss]; |
803 | char opad[ss]; | 798 | char opad[ss]; |
804 | 799 | ||
805 | desc.shash.tfm = ctx->base_hash; | 800 | shash->tfm = ctx->base_hash; |
806 | desc.shash.flags = crypto_shash_get_flags(ctx->base_hash) & | 801 | shash->flags = crypto_shash_get_flags(ctx->base_hash) & |
807 | CRYPTO_TFM_REQ_MAY_SLEEP; | 802 | CRYPTO_TFM_REQ_MAY_SLEEP; |
808 | 803 | ||
809 | if (keylen > bs) { | 804 | if (keylen > bs) { |
810 | int err; | 805 | int err; |
811 | 806 | ||
812 | err = | 807 | err = |
813 | crypto_shash_digest(&desc.shash, key, keylen, ipad); | 808 | crypto_shash_digest(shash, key, keylen, ipad); |
814 | if (err) | 809 | if (err) |
815 | return err; | 810 | return err; |
816 | 811 | ||
@@ -826,12 +821,12 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key, | |||
826 | opad[i] ^= 0x5c; | 821 | opad[i] ^= 0x5c; |
827 | } | 822 | } |
828 | 823 | ||
829 | rc = crypto_shash_init(&desc.shash) ? : | 824 | rc = crypto_shash_init(shash) ? : |
830 | crypto_shash_update(&desc.shash, ipad, bs) ? : | 825 | crypto_shash_update(shash, ipad, bs) ? : |
831 | crypto_shash_export(&desc.shash, ipad) ? : | 826 | crypto_shash_export(shash, ipad) ? : |
832 | crypto_shash_init(&desc.shash) ? : | 827 | crypto_shash_init(shash) ? : |
833 | crypto_shash_update(&desc.shash, opad, bs) ? : | 828 | crypto_shash_update(shash, opad, bs) ? : |
834 | crypto_shash_export(&desc.shash, opad); | 829 | crypto_shash_export(shash, opad); |
835 | 830 | ||
836 | if (rc == 0) | 831 | if (rc == 0) |
837 | mv_hash_init_ivs(ctx, ipad, opad); | 832 | mv_hash_init_ivs(ctx, ipad, opad); |