summaryrefslogtreecommitdiff
path: root/board/cr50/fips.c
Commit message (Collapse)AuthorAgeFilesLines
* cr50: drop cryptoc for SHA1/SHA2 supportstabilize-14150.882.B-cr50_stabstabilize-14150.881.B-cr50_stabstabilize-14150.74.B-cr50_stabstabilize-14150.734.B-cr50_stabstabilize-14150.64.B-cr50_stabstabilize-14150.43.B-cr50_stabstabilize-14150.376.B-cr50_stabrelease-R94-14150.B-cr50_stabrelease-R94-14150.49.B-cr50_stabVadim Sukhomlinov2021-08-121-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To implement FIPS module we need to bring many crypto functions in the module boundary. Unfortunately, cryptoc is a third-party library used by dcrypto code in cr50. Cryptoc is also not well-maintained and shared with other projects. While just making local copy of cryptoc would solve an issue, it's suboptimal as prevents from many optimizations and improvements. Provided SHA & HMAC implementations from Ti50 project. This provides better performance (500us vs. 670us earlier for HMAC DRBG) and reduce code size. This implementation also enables stack use savings when only specific digest is needed. Earlier SHA512 context was allocated when only SHA256 is needed greatly increasing stack consumption for code using HMAC_DRBG and others. However, it introduce subtle API changes which require handling. As for tests, since core implementation is hardware-independent, make it available for BOARD=host too. Before change (with cryptoc): *** 12368 bytes in flash and 5784 bytes in RAM After: *** 13136 bytes in flash and 5796 bytes in RAM BUG=b:138578318 TEST=make BOARD=cr50 CRYPTO_TEST=1; test/tpm_test/tpmtest.py Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I2ff5362aee9078ce83dc1f8081943a5101d5f666 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3064201 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* cr50: fix CRYPTO_TEST=1 broken due to FIPS codeVadim Sukhomlinov2021-08-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Linker script used by FIPS module broke several extension commands used for testing due to section name used (no wildcards support). FIPS self-integrity tests broke access to crypto commands as until there is no correct digest it fails and prevents access to crypto. This is temporary fix until digest computation is done. TPM tests requires GCM for testing - adding this module when built with CRYPTO_TEST=1. U2F test status made a bit clearer (printing success) and hex dumps of key handles, signatures only printed in debug mode now. BUG=none TEST=make BOARD=cr50 CRYPTO_TEST=1; test/tpm_test/tpmtest.py Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I7c974abf8ac71de2949b35a4411f77a03d9048a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3082325 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* cr50: add FIPS module self-integrity checkVadim Sukhomlinov2021-07-281-0/+28
| | | | | | | | | | | | | | | | | Added computation of FIPS module SHA256 digest and comparison with precomputed value. BUG=b:138578318 TEST=make BOARD=cr50, check console output Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I3aaac07ff460b5021f2b7dab4f6df2710325c60b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3045839 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* fips: prevent turning FIPS on (yet)Vadim Sukhomlinov2020-07-301-3/+13
| | | | | | | | | | | | | | | | | | | | | | Since FIPS-compliant U2F code is not yet ready, make sure that new devices won't switch to FIPS-approved by default when there are no U2F keys. This CL puts the logic that checks if the U2F seed exists and turns FIPS mode on when it doesn't under compile-time switch, and for now turns this switch off. As a result, FIPS mode is always off. BUG=b:138577491 TEST=make BOARD=cr50, then check FIPS mode in CCD Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I33b559c3f348f34115263fd3fedc8b7a2fbeab31 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2328113 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* fips: move FIPS error injection under CR50_DEVVadim Sukhomlinov2020-07-291-7/+8
| | | | | | | | | | | | | | | | | | | Prevent access to FIPS CCD commands which can inject errors due to unclear security impact. Instead, made them available only in CR50_DEV builts. Same with vendor commands - moved them from CRYPTO_TEST to under CR50_DEV. BUG=b:138577491 TEST=help fips, fips sha/trng - ignored Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: Ic86db02f2c9c5abbea8f3f23ee56a5f5f570e177 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321344 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
* fips: introduce FIPS & policy power-up known-answer testsVadim Sukhomlinov2020-07-021-0/+847
Add invocation of power-up known-answer tests (KATs) on power-on and after failures, while avoiding power-up tests on wake from sleep. Added console & vendor commands to report FIPS status, run tests, simulate errors. BUG=b:138577539 TEST=manual; check console fips on, fips test, fips sha, fips trng will add tpmtest for vendor command Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I58790d0637fda683c4b6187ba091edf08757f8ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2262055 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>