diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-05-04 05:00:16 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-06 23:16:24 -0400 |
commit | ac02c6ea6b404461829697792cd2b67f6a14d28a (patch) | |
tree | ef903ca3da6aa0f9bb7a011c53ce489da9cddc34 /arch/arm64 | |
parent | f440c4ee3e53f767974fe60bcbc0b6687a5fb53f (diff) |
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>
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/crypto/crc32-arm64.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/arch/arm64/crypto/crc32-arm64.c b/arch/arm64/crypto/crc32-arm64.c index 9499199924ae..6a37c3c6b11d 100644 --- a/arch/arm64/crypto/crc32-arm64.c +++ b/arch/arm64/crypto/crc32-arm64.c | |||
@@ -147,13 +147,21 @@ static int chksum_final(struct shash_desc *desc, u8 *out) | |||
147 | { | 147 | { |
148 | struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); | 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 | put_unaligned_le32(~ctx->crc, out); | 158 | put_unaligned_le32(~ctx->crc, out); |
151 | return 0; | 159 | return 0; |
152 | } | 160 | } |
153 | 161 | ||
154 | static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out) | 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 | return 0; | 165 | return 0; |
158 | } | 166 | } |
159 | 167 | ||
@@ -199,6 +207,14 @@ static int crc32_cra_init(struct crypto_tfm *tfm) | |||
199 | { | 207 | { |
200 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); | 208 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); |
201 | 209 | ||
210 | mctx->key = 0; | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | static int crc32c_cra_init(struct crypto_tfm *tfm) | ||
215 | { | ||
216 | struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); | ||
217 | |||
202 | mctx->key = ~0; | 218 | mctx->key = ~0; |
203 | return 0; | 219 | return 0; |
204 | } | 220 | } |
@@ -229,7 +245,7 @@ static struct shash_alg crc32c_alg = { | |||
229 | .setkey = chksum_setkey, | 245 | .setkey = chksum_setkey, |
230 | .init = chksum_init, | 246 | .init = chksum_init, |
231 | .update = chksumc_update, | 247 | .update = chksumc_update, |
232 | .final = chksum_final, | 248 | .final = chksumc_final, |
233 | .finup = chksumc_finup, | 249 | .finup = chksumc_finup, |
234 | .digest = chksumc_digest, | 250 | .digest = chksumc_digest, |
235 | .descsize = sizeof(struct chksum_desc_ctx), | 251 | .descsize = sizeof(struct chksum_desc_ctx), |
@@ -241,7 +257,7 @@ static struct shash_alg crc32c_alg = { | |||
241 | .cra_alignmask = 0, | 257 | .cra_alignmask = 0, |
242 | .cra_ctxsize = sizeof(struct chksum_ctx), | 258 | .cra_ctxsize = sizeof(struct chksum_ctx), |
243 | .cra_module = THIS_MODULE, | 259 | .cra_module = THIS_MODULE, |
244 | .cra_init = crc32_cra_init, | 260 | .cra_init = crc32c_cra_init, |
245 | } | 261 | } |
246 | }; | 262 | }; |
247 | 263 | ||