crypto: LLVMLinux: Remove VLAIS from crypto/n2_core.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>
This commit is contained in:
parent
7128470f6b
commit
ce1f3e47d9
|
@ -445,10 +445,7 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||||
struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm);
|
struct n2_hmac_ctx *ctx = crypto_ahash_ctx(tfm);
|
||||||
struct crypto_shash *child_shash = ctx->child_shash;
|
struct crypto_shash *child_shash = ctx->child_shash;
|
||||||
struct crypto_ahash *fallback_tfm;
|
struct crypto_ahash *fallback_tfm;
|
||||||
struct {
|
SHASH_DESC_ON_STACK(shash, child_shash);
|
||||||
struct shash_desc shash;
|
|
||||||
char ctx[crypto_shash_descsize(child_shash)];
|
|
||||||
} desc;
|
|
||||||
int err, bs, ds;
|
int err, bs, ds;
|
||||||
|
|
||||||
fallback_tfm = ctx->base.fallback_tfm;
|
fallback_tfm = ctx->base.fallback_tfm;
|
||||||
|
@ -456,15 +453,15 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key,
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
desc.shash.tfm = child_shash;
|
shash->tfm = child_shash;
|
||||||
desc.shash.flags = crypto_ahash_get_flags(tfm) &
|
shash->flags = crypto_ahash_get_flags(tfm) &
|
||||||
CRYPTO_TFM_REQ_MAY_SLEEP;
|
CRYPTO_TFM_REQ_MAY_SLEEP;
|
||||||
|
|
||||||
bs = crypto_shash_blocksize(child_shash);
|
bs = crypto_shash_blocksize(child_shash);
|
||||||
ds = crypto_shash_digestsize(child_shash);
|
ds = crypto_shash_digestsize(child_shash);
|
||||||
BUG_ON(ds > N2_HASH_KEY_MAX);
|
BUG_ON(ds > N2_HASH_KEY_MAX);
|
||||||
if (keylen > bs) {
|
if (keylen > bs) {
|
||||||
err = crypto_shash_digest(&desc.shash, key, keylen,
|
err = crypto_shash_digest(shash, key, keylen,
|
||||||
ctx->hash_key);
|
ctx->hash_key);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue