summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-11-27 07:16:01 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-03 02:21:20 -0800
commit3e73320f4dd9da2d693cbeded3c48f59f058adb0 (patch)
tree02a1cb01cd3748c08c2c5e0c3893ca0f777669b9
parent898e16bf7b7726b7112b260e5f6734822a6489b0 (diff)
downloadchrome-ec-3e73320f4dd9da2d693cbeded3c48f59f058adb0.tar.gz
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>
-rw-r--r--chip/g/dcrypto/sha256.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/chip/g/dcrypto/sha256.c b/chip/g/dcrypto/sha256.c
index 19025f3503..20d813bc9d 100644
--- a/chip/g/dcrypto/sha256.c
+++ b/chip/g/dcrypto/sha256.c
@@ -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;
}