diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-11 14:05:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-11 14:05:13 -0400 |
commit | 9c922a55dbfff812e8becbcfd90d1ce856adb0d9 (patch) | |
tree | b5a93c2887ba63b23120dee37967bb6ad56b356f /arch/arm64 | |
parent | b3e5838ac01c6815fc3d15fd00c8eb23889e5962 (diff) | |
parent | ec59a65d694e5fd99d76565b93468c99ae8dff79 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
"This fixes a the implementation of CRC32 on arm64 where it incorrectly
applied negation on the result.
It also fixes the arm64 implementations of SHA/SHA256 where in some
cases it may end up finalising the result twice"
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: arm64/sha2-ce - prevent asm code finalization in final() path
crypto: arm64/sha1-ce - prevent asm code finalization in final() path
crypto: arm64/crc32 - bring in line with generic CRC32
Diffstat (limited to 'arch/arm64')
-rw-r--r-- | arch/arm64/crypto/crc32-arm64.c | 22 | ||||
-rw-r--r-- | arch/arm64/crypto/sha1-ce-glue.c | 3 | ||||
-rw-r--r-- | arch/arm64/crypto/sha2-ce-glue.c | 3 |
3 files changed, 25 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 | ||
diff --git a/arch/arm64/crypto/sha1-ce-glue.c b/arch/arm64/crypto/sha1-ce-glue.c index 114e7cc5de8c..aefda9868627 100644 --- a/arch/arm64/crypto/sha1-ce-glue.c +++ b/arch/arm64/crypto/sha1-ce-glue.c | |||
@@ -74,6 +74,9 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data, | |||
74 | 74 | ||
75 | static int sha1_ce_final(struct shash_desc *desc, u8 *out) | 75 | static int sha1_ce_final(struct shash_desc *desc, u8 *out) |
76 | { | 76 | { |
77 | struct sha1_ce_state *sctx = shash_desc_ctx(desc); | ||
78 | |||
79 | sctx->finalize = 0; | ||
77 | kernel_neon_begin_partial(16); | 80 | kernel_neon_begin_partial(16); |
78 | sha1_base_do_finalize(desc, (sha1_block_fn *)sha1_ce_transform); | 81 | sha1_base_do_finalize(desc, (sha1_block_fn *)sha1_ce_transform); |
79 | kernel_neon_end(); | 82 | kernel_neon_end(); |
diff --git a/arch/arm64/crypto/sha2-ce-glue.c b/arch/arm64/crypto/sha2-ce-glue.c index 1340e44c048b..7cd587564a41 100644 --- a/arch/arm64/crypto/sha2-ce-glue.c +++ b/arch/arm64/crypto/sha2-ce-glue.c | |||
@@ -75,6 +75,9 @@ static int sha256_ce_finup(struct shash_desc *desc, const u8 *data, | |||
75 | 75 | ||
76 | static int sha256_ce_final(struct shash_desc *desc, u8 *out) | 76 | static int sha256_ce_final(struct shash_desc *desc, u8 *out) |
77 | { | 77 | { |
78 | struct sha256_ce_state *sctx = shash_desc_ctx(desc); | ||
79 | |||
80 | sctx->finalize = 0; | ||
78 | kernel_neon_begin_partial(28); | 81 | kernel_neon_begin_partial(28); |
79 | sha256_base_do_finalize(desc, (sha256_block_fn *)sha2_ce_transform); | 82 | sha256_base_do_finalize(desc, (sha256_block_fn *)sha2_ce_transform); |
80 | kernel_neon_end(); | 83 | kernel_neon_end(); |