summaryrefslogtreecommitdiff
path: root/chip/g/dcrypto/dcrypto.h
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-11-27 07:19:10 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-03 02:21:57 -0800
commitd1f1e7722dac34b29a3942919cba8150e9838866 (patch)
treeda7f2d702b7ed8024e722a91cc989529439f0cdc /chip/g/dcrypto/dcrypto.h
parent25b573bdae39087b93481b29ca5d8c721f59608b (diff)
downloadchrome-ec-d1f1e7722dac34b29a3942919cba8150e9838866.tar.gz
cr50: reduce hash implementation stack requirements
Stack space is pretty tight on cr50, and since there is no need to support SHA digest sizes in excess of 256 bits, the digest buffer size should be reduced. This patch makes the maximum expected digest size dependent on the set of configured hash algorithms, moves hash size related asserts from run time to compile time, and passes compile time definition to the TPM2 library to increase its hash state container (it became too small when SHA384 was disabled). The sw context requirements should be reduced, but this is a task for another day. We also do not have to store a local digest copy if the API allowed reading a partial digest. CQ-DEPEND=CL:314883 BRANCH=none BUG=chrome-os-partner:43025, chromium:564862 TEST=all tests pass: $ ./test/tpm_test/tpmtest.py Starting MPSSE at 800 kHz Connected to device vid:did:rid of 1ae0:0028:00 SUCCESS: AES:ECB common SUCCESS: AES:ECB128 1 SUCCESS: AES:ECB192 1 SUCCESS: AES:ECB256 1 SUCCESS: AES:ECB256 2 SUCCESS: AES:CTR128I 1 SUCCESS: AES:CTR256I 1 SUCCESS: sha1:single 0 SUCCESS: sha256:single 0 /New max timeout: 1 s SUCCESS: sha256:finish 1 SUCCESS: sha1:finish 3 SUCCESS: sha256:finish 2 Change-Id: Iaef3a230469de129e72418814e1d113b447c0137 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314695 Reviewed-by: Nagendra Modadugu <ngm@google.com>
Diffstat (limited to 'chip/g/dcrypto/dcrypto.h')
-rw-r--r--chip/g/dcrypto/dcrypto.h11
1 files changed, 0 insertions, 11 deletions
diff --git a/chip/g/dcrypto/dcrypto.h b/chip/g/dcrypto/dcrypto.h
index 7cafb224da..a39350fd13 100644
--- a/chip/g/dcrypto/dcrypto.h
+++ b/chip/g/dcrypto/dcrypto.h
@@ -26,17 +26,6 @@ enum encrypt_mode {
ENCRYPT_MODE = 1
};
-#define SHA1_DIGEST_BYTES 20
-#define SHA256_DIGEST_BYTES 32
-#define SHA384_DIGEST_BYTES 48
-#define SHA512_DIGEST_BYTES 64
-#define SHA_DIGEST_MAX_BYTES SHA512_DIGEST_BYTES
-
-#define SHA1_DIGEST_WORDS (SHA1_DIGEST_BYTES / sizeof(uint32_t))
-#define SHA256_DIGEST_WORDS (SHA256_DIGEST_BYTES / sizeof(uint32_t))
-#define SHA384_DIGEST_WORDS (SHA384_DIGEST_BYTES / sizeof(uint32_t))
-#define SHA512_DIGEST_WORDS (SHA512_DIGEST_BYTES / sizeof(uint32_t))
-
struct HASH_CTX; /* Forward declaration. */
typedef struct HASH_CTX SHA1_CTX;