Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Steve Capper <steve.capper@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
ac02c6ea f440c4ee

+19 -3
+19 -3
arch/arm64/crypto/crc32-arm64.c
··· 147 147 { 148 148 struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); 149 149 150 + put_unaligned_le32(ctx->crc, out); 151 + return 0; 152 + } 153 + 154 + static int chksumc_final(struct shash_desc *desc, u8 *out) 155 + { 156 + struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); 157 + 150 158 put_unaligned_le32(~ctx->crc, out); 151 159 return 0; 152 160 } 153 161 154 162 static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out) 155 163 { 156 - put_unaligned_le32(~crc32_arm64_le_hw(crc, data, len), out); 164 + put_unaligned_le32(crc32_arm64_le_hw(crc, data, len), out); 157 165 return 0; 158 166 } 159 167 ··· 207 199 { 208 200 struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); 209 201 202 + mctx->key = 0; 203 + return 0; 204 + } 205 + 206 + static int crc32c_cra_init(struct crypto_tfm *tfm) 207 + { 208 + struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); 209 + 210 210 mctx->key = ~0; 211 211 return 0; 212 212 } ··· 245 229 .setkey = chksum_setkey, 246 230 .init = chksum_init, 247 231 .update = chksumc_update, 248 - .final = chksum_final, 232 + .final = chksumc_final, 249 233 .finup = chksumc_finup, 250 234 .digest = chksumc_digest, 251 235 .descsize = sizeof(struct chksum_desc_ctx), ··· 257 241 .cra_alignmask = 0, 258 242 .cra_ctxsize = sizeof(struct chksum_ctx), 259 243 .cra_module = THIS_MODULE, 260 - .cra_init = crc32_cra_init, 244 + .cra_init = crc32c_cra_init, 261 245 } 262 246 }; 263 247