Commit 3c8d758ab528317ecd6d91f8651170ffd2331899
Committed by
Herbert Xu
1 parent
798eed5d92
Exists in
master
and in
4 other branches
crypto: omap-sham - hash-in-progress is stored in hw format
Hash-in-progress is now stored in hw format. Only on final call, hash is converted to correct format. Speedup copy procedure and will allow to use OMAP burst mode. Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@nokia.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 24 additions and 14 deletions Side-by-side Diff
drivers/crypto/omap-sham.c
... | ... | @@ -204,24 +204,35 @@ |
204 | 204 | u32 *hash = (u32 *)ctx->digest; |
205 | 205 | int i; |
206 | 206 | |
207 | + /* MD5 is almost unused. So copy sha1 size to reduce code */ | |
208 | + for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++) { | |
209 | + if (out) | |
210 | + hash[i] = omap_sham_read(ctx->dd, | |
211 | + SHA_REG_DIGEST(i)); | |
212 | + else | |
213 | + omap_sham_write(ctx->dd, | |
214 | + SHA_REG_DIGEST(i), hash[i]); | |
215 | + } | |
216 | +} | |
217 | + | |
218 | +static void omap_sham_copy_ready_hash(struct ahash_request *req) | |
219 | +{ | |
220 | + struct omap_sham_reqctx *ctx = ahash_request_ctx(req); | |
221 | + u32 *in = (u32 *)ctx->digest; | |
222 | + u32 *hash = (u32 *)req->result; | |
223 | + int i; | |
224 | + | |
225 | + if (!hash) | |
226 | + return; | |
227 | + | |
207 | 228 | if (likely(ctx->flags & FLAGS_SHA1)) { |
208 | 229 | /* SHA1 results are in big endian */ |
209 | 230 | for (i = 0; i < SHA1_DIGEST_SIZE / sizeof(u32); i++) |
210 | - if (out) | |
211 | - hash[i] = be32_to_cpu(omap_sham_read(ctx->dd, | |
212 | - SHA_REG_DIGEST(i))); | |
213 | - else | |
214 | - omap_sham_write(ctx->dd, SHA_REG_DIGEST(i), | |
215 | - cpu_to_be32(hash[i])); | |
231 | + hash[i] = be32_to_cpu(in[i]); | |
216 | 232 | } else { |
217 | 233 | /* MD5 results are in little endian */ |
218 | 234 | for (i = 0; i < MD5_DIGEST_SIZE / sizeof(u32); i++) |
219 | - if (out) | |
220 | - hash[i] = le32_to_cpu(omap_sham_read(ctx->dd, | |
221 | - SHA_REG_DIGEST(i))); | |
222 | - else | |
223 | - omap_sham_write(ctx->dd, SHA_REG_DIGEST(i), | |
224 | - cpu_to_le32(hash[i])); | |
235 | + hash[i] = le32_to_cpu(in[i]); | |
225 | 236 | } |
226 | 237 | } |
227 | 238 | |
... | ... | @@ -474,8 +485,7 @@ |
474 | 485 | spin_unlock_irqrestore(&dd->lock, flags); |
475 | 486 | |
476 | 487 | if (ctx->digcnt) |
477 | - memcpy(req->result, ctx->digest, (ctx->flags & FLAGS_SHA1) ? | |
478 | - SHA1_DIGEST_SIZE : MD5_DIGEST_SIZE); | |
488 | + omap_sham_copy_ready_hash(req); | |
479 | 489 | |
480 | 490 | dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt); |
481 | 491 | } |