cr50: fix cryptography problems

A couple of issues were uncovered when testing hash implementation
more extensively (with multiple overlapping streams of data). This
patch fixes the problems.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=the previously failing hash tests got not fail any more:
  $ ./test/tpm_test/tpmtest.py
  Starting MPSSE at 800 kHz
  Connected to device vid:did:rid of 1ae0:0028:00
  [...]
  SUCCESS: sha1:single 0
  SUCCESS: sha256:single 0
  SUCCESS: sha256:finish 1
  SUCCESS: sha1:finish 3
  SUCCESS: sha256:finish 2

Change-Id: I7ee857eec2dac2d9312df7db3b27e5a69ac55ad9
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/314694
Reviewed-by: Nagendra Modadugu <ngm@google.com>
This commit is contained in:
Vadim Bendebury
2015-11-27 07:16:01 -08:00
committed by chrome-bot
parent 898e16bf7b
commit 3e73320f4d

View File

@@ -187,7 +187,7 @@ void DCRYPTO_SHA256_init(SHA256_CTX *ctx, uint32_t sw_required)
{
if (!sw_required && dcrypto_grab_sha_hw()) {
ctx->vtab = &HW_SHA256_VTAB;
dcrypto_sha_init(SHA1_MODE);
dcrypto_sha_init(SHA256_MODE);
}
#ifndef SECTION_IS_RO
else
@@ -198,7 +198,6 @@ void DCRYPTO_SHA256_init(SHA256_CTX *ctx, uint32_t sw_required)
static const uint8_t *dcrypto_sha256_final(SHA256_CTX *ctx)
{
dcrypto_sha_wait(SHA256_MODE, (uint32_t *) ctx->u.buf);
dcrypto_release_sha_hw();
return ctx->u.buf;
}