diff options
Diffstat (limited to 'crypto/ghash-generic.c')
-rw-r--r-- | crypto/ghash-generic.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c index 6425b9cd718e..dad9e1f91a78 100644 --- a/crypto/ghash-generic.c +++ b/crypto/ghash-generic.c | |||
@@ -31,6 +31,7 @@ static int ghash_setkey(struct crypto_shash *tfm, | |||
31 | const u8 *key, unsigned int keylen) | 31 | const u8 *key, unsigned int keylen) |
32 | { | 32 | { |
33 | struct ghash_ctx *ctx = crypto_shash_ctx(tfm); | 33 | struct ghash_ctx *ctx = crypto_shash_ctx(tfm); |
34 | be128 k; | ||
34 | 35 | ||
35 | if (keylen != GHASH_BLOCK_SIZE) { | 36 | if (keylen != GHASH_BLOCK_SIZE) { |
36 | crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); | 37 | crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); |
@@ -39,7 +40,12 @@ static int ghash_setkey(struct crypto_shash *tfm, | |||
39 | 40 | ||
40 | if (ctx->gf128) | 41 | if (ctx->gf128) |
41 | gf128mul_free_4k(ctx->gf128); | 42 | gf128mul_free_4k(ctx->gf128); |
42 | ctx->gf128 = gf128mul_init_4k_lle((be128 *)key); | 43 | |
44 | BUILD_BUG_ON(sizeof(k) != GHASH_BLOCK_SIZE); | ||
45 | memcpy(&k, key, GHASH_BLOCK_SIZE); /* avoid violating alignment rules */ | ||
46 | ctx->gf128 = gf128mul_init_4k_lle(&k); | ||
47 | memzero_explicit(&k, GHASH_BLOCK_SIZE); | ||
48 | |||
43 | if (!ctx->gf128) | 49 | if (!ctx->gf128) |
44 | return -ENOMEM; | 50 | return -ENOMEM; |
45 | 51 | ||