Commit ac02c6ea authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: arm64/crc32 - bring in line with generic CRC32

The arm64 CRC32 (not CRC32c) implementation was not quite doing
the same thing as the generic one. Fix that.
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: default avatarSteve Capper <steve.capper@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f440c4ee
...@@ -147,13 +147,21 @@ static int chksum_final(struct shash_desc *desc, u8 *out) ...@@ -147,13 +147,21 @@ static int chksum_final(struct shash_desc *desc, u8 *out)
{ {
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
put_unaligned_le32(ctx->crc, out);
return 0;
}
static int chksumc_final(struct shash_desc *desc, u8 *out)
{
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
put_unaligned_le32(~ctx->crc, out); put_unaligned_le32(~ctx->crc, out);
return 0; return 0;
} }
static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out) static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out)
{ {
put_unaligned_le32(~crc32_arm64_le_hw(crc, data, len), out); put_unaligned_le32(crc32_arm64_le_hw(crc, data, len), out);
return 0; return 0;
} }
...@@ -199,6 +207,14 @@ static int crc32_cra_init(struct crypto_tfm *tfm) ...@@ -199,6 +207,14 @@ static int crc32_cra_init(struct crypto_tfm *tfm)
{ {
struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
mctx->key = 0;
return 0;
}
static int crc32c_cra_init(struct crypto_tfm *tfm)
{
struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
mctx->key = ~0; mctx->key = ~0;
return 0; return 0;
} }
...@@ -229,7 +245,7 @@ static struct shash_alg crc32c_alg = { ...@@ -229,7 +245,7 @@ static struct shash_alg crc32c_alg = {
.setkey = chksum_setkey, .setkey = chksum_setkey,
.init = chksum_init, .init = chksum_init,
.update = chksumc_update, .update = chksumc_update,
.final = chksum_final, .final = chksumc_final,
.finup = chksumc_finup, .finup = chksumc_finup,
.digest = chksumc_digest, .digest = chksumc_digest,
.descsize = sizeof(struct chksum_desc_ctx), .descsize = sizeof(struct chksum_desc_ctx),
...@@ -241,7 +257,7 @@ static struct shash_alg crc32c_alg = { ...@@ -241,7 +257,7 @@ static struct shash_alg crc32c_alg = {
.cra_alignmask = 0, .cra_alignmask = 0,
.cra_ctxsize = sizeof(struct chksum_ctx), .cra_ctxsize = sizeof(struct chksum_ctx),
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
.cra_init = crc32_cra_init, .cra_init = crc32c_cra_init,
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment