summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-05-19 22:07:38 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2018-05-27 00:12:08 +0800
commit4314c9ffc197fe30d69f541e11578842054da611 (patch)
tree2b2f4d1672c2a2e80511bc90c341e955a58e0725
parentc2cb49e7b3f73d8b36b3f0164aceaf5fdb4db39a (diff)
downloadlinux-crypto-4314c9ffc197fe30d69f541e11578842054da611.tar.gz
linux-crypto-4314c9ffc197fe30d69f541e11578842054da611.zip
crypto: crc32c-generic - remove cra_alignmask
crc32c-generic sets an alignmask, but actually its ->update() works with any alignment; only its ->setkey() and outputting the final digest assume an alignment. To prevent the buffer from having to be aligned by the crypto API for just these cases, switch these cases over to the unaligned access macros and remove the cra_alignmask. Note that this also makes crc32c-generic more consistent with crc32-generic. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/crc32c_generic.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/crc32c_generic.c b/crypto/crc32c_generic.c
index 37232039..7283066e 100644
--- a/crypto/crc32c_generic.c
+++ b/crypto/crc32c_generic.c
@@ -35,6 +35,7 @@
*
*/
+#include <asm/unaligned.h>
#include <crypto/internal/hash.h>
#include <linux/init.h>
#include <linux/module.h>
@@ -82,7 +83,7 @@ static int chksum_setkey(struct crypto_shash *tfm, const u8 *key,
crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
return -EINVAL;
}
- mctx->key = le32_to_cpu(*(__le32 *)key);
+ mctx->key = get_unaligned_le32(key);
return 0;
}
@@ -99,13 +100,13 @@ static int chksum_final(struct shash_desc *desc, u8 *out)
{
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
- *(__le32 *)out = ~cpu_to_le32p(&ctx->crc);
+ put_unaligned_le32(~ctx->crc, out);
return 0;
}
static int __chksum_finup(u32 *crcp, const u8 *data, unsigned int len, u8 *out)
{
- *(__le32 *)out = ~cpu_to_le32(__crc32c_le(*crcp, data, len));
+ put_unaligned_le32(~__crc32c_le(*crcp, data, len), out);
return 0;
}
@@ -148,7 +149,6 @@ static struct shash_alg alg = {
.cra_priority = 100,
.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
.cra_blocksize = CHKSUM_BLOCK_SIZE,
- .cra_alignmask = 3,
.cra_ctxsize = sizeof(struct chksum_ctx),
.cra_module = THIS_MODULE,
.cra_init = crc32c_cra_init,