Skip to content

Commit

Permalink
crypto: x86/aegis256 - Fix wrong key buffer size
Browse files Browse the repository at this point in the history
AEGIS-256 key is two blocks, not one.

Fixes: 1d373d4 ("crypto: x86 - Add optimized AEGIS implementations")
Reported-by: Eric Biggers <[email protected]>
Signed-off-by: Ondrej Mosnacek <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
WOnder93 authored and herbertx committed May 26, 2018
1 parent 9f50fd5 commit dd09f58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/x86/crypto/aegis256-aesni-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct aegis_state {
};

struct aegis_ctx {
struct aegis_block key;
struct aegis_block key[AEGIS256_KEY_SIZE / AEGIS256_BLOCK_SIZE];
};

struct aegis_crypt_ops {
Expand Down Expand Up @@ -164,7 +164,7 @@ static int crypto_aegis256_aesni_setkey(struct crypto_aead *aead, const u8 *key,
return -EINVAL;
}

memcpy(ctx->key.bytes, key, AEGIS256_KEY_SIZE);
memcpy(ctx->key, key, AEGIS256_KEY_SIZE);

return 0;
}
Expand All @@ -190,7 +190,7 @@ static void crypto_aegis256_aesni_crypt(struct aead_request *req,

kernel_fpu_begin();

crypto_aegis256_aesni_init(&state, ctx->key.bytes, req->iv);
crypto_aegis256_aesni_init(&state, ctx->key, req->iv);
crypto_aegis256_aesni_process_ad(&state, req->src, req->assoclen);
crypto_aegis256_aesni_process_crypt(&state, req, ops);
crypto_aegis256_aesni_final(&state, tag_xor, req->assoclen, cryptlen);
Expand Down

0 comments on commit dd09f58

Please sign in to comment.