diff options
author | CHLin <CHLin56@nuvoton.com> | 2020-09-29 14:23:59 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-13 11:29:46 +0000 |
commit | 0f12014ad53ddfd0063a733a1357f81478136dc8 (patch) | |
tree | b8a4e3b500ed7b9d28ae67588b8ceba42879503c /chip/npcx/sha256_chip.h | |
parent | 44435d3b9c447ad25edaa8aece42f1cff0dd6df9 (diff) | |
download | chrome-ec-0f12014ad53ddfd0063a733a1357f81478136dc8.tar.gz |
npcx9: support SHA256 hardware accelerator
There is the hardware accelerator for SHA computation inside npcx9. This
CL wraps the Nuvoton SHA library APIs (which are in the ROM) to Chromium
EC's SHA256_* APIs to speed up the SHA256 computation.
With the help of the hardware accelerator, the hash computation runs
several times faster than the software method (see b:155771688 for more
detailed evaluation data.) Also, we can gain ~840 bytes of code size.
BRANCH=none
BUG=b:165777478
BUG=b:155771688
TEST=pass "make buildall"
TEST=flash the same RW image; #define/#undef CONFIG_SHA256_HW_ACCELERATE
; verify the RW hash value is the same in the console message.
TEST=with the following test CL, move test patterns in test/sha256.c
to board/npcx9_evb/test_sha256.c; pass all test patterns.
Signed-off-by: CHLin <CHLin56@nuvoton.com>
Change-Id: I45ca609889bd73573d67d15f3e561614201e60f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2455021
Tested-by: CH Lin <chlin56@nuvoton.com>
Auto-Submit: CH Lin <chlin56@nuvoton.com>
Reviewed-by: caveh jalali <caveh@chromium.org>
Commit-Queue: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'chip/npcx/sha256_chip.h')
-rw-r--r-- | chip/npcx/sha256_chip.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/chip/npcx/sha256_chip.h b/chip/npcx/sha256_chip.h new file mode 100644 index 0000000000..3b9586d962 --- /dev/null +++ b/chip/npcx/sha256_chip.h @@ -0,0 +1,25 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_SHA256_CHIP_H +#define __CROS_EC_SHA256_CHIP_H + +#include "common.h" + +#define NPCX_SHA256_HANDLE_SIZE 212 +struct sha256_ctx { + /* the context handle required for SHA256 API */ + uint8_t handle[NPCX_SHA256_HANDLE_SIZE]; + /* + * This is used to buffer: + * 1. the result (digest) of the SHA256 computation. + * 2. the 1st block input data (the key padding) for hmac_SHA256_step. + */ + uint8_t buf[SHA256_BLOCK_SIZE]; +} __aligned(4); + +void SHA256_abort(struct sha256_ctx *ctx); + +#endif /* __CROS_EC_SHA256_CHIP_H */ |