summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-01-28 09:25:51 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-01-28 14:16:19 -0800
commit26bbc59b4629f44a93b87ed8c21e5f80699c7779 (patch)
tree854955a3e08d0fcea5d4d5e5a7dfed3ba03ae27a /chip
parentd60d263b83181aee7544f6e24afa13e441a45177 (diff)
downloadchrome-ec-26bbc59b4629f44a93b87ed8c21e5f80699c7779.tar.gz
Fix bug in software sha256_hash()
The implementation for sha256_hash() copied and incorrect number of bytes to the output. This change provides a fix and a test. TEST=added test case BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 Change-Id: I74e98c6f5005a14dd5c0ca19ea7540622dd6c7d7 Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/324391 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/g/dcrypto/sha256.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/chip/g/dcrypto/sha256.c b/chip/g/dcrypto/sha256.c
index 20d813bc9d..c884ff2a4a 100644
--- a/chip/g/dcrypto/sha256.c
+++ b/chip/g/dcrypto/sha256.c
@@ -61,10 +61,7 @@ static const uint8_t *sha256_hash(const uint8_t *data, uint32_t len,
sha256_init(&ctx);
sha256_update(&ctx, data, len);
- sha256_final(&ctx);
-
- memcpy(digest, ctx.u.sw_sha256.buf, SHA256_DIGEST_WORDS);
-
+ memcpy(digest, sha256_final(&ctx), SHA256_DIGEST_BYTES);
return digest;
}