summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVadim Sukhomlinov <sukhomlinov@google.com>2021-09-23 10:08:49 -0700
committerCommit Bot <commit-bot@chromium.org>2021-09-24 00:14:58 +0000
commit5044b81a4c797a058a21e95349437f04ab33e2ed (patch)
tree73a3592d60e2acaf46cd0a8bfb027b4b49f79a2d /test
parent78d460f72b65a2a01f81c2bc115da96bc331f5df (diff)
downloadchrome-ec-5044b81a4c797a058a21e95349437f04ab33e2ed.tar.gz
cr50: switch ECDSA to use enum dcrypto_result, added FIPS checks
We have to block access to crypto functions when FIPS errors occurred. To achieve this: 1. Provide wrappers for ECDSA P-256 sign and verify functions a) DCRYPTO_p256_ecdsa_verify as wrapper for dcrypto_p256_ecdsa_verify b) DCRYPTO_p256_ecdsa_sign as wrapper for dcrypto_p256_fips_sign_internal with additional check for FIPS DRBG initialization which is needed for signing. 2. Switch all ECDSA functions, both internal and external to use enum dcrypto_result instead of inconsistent 0/1 values. 3. Added warning for unused result code for ECDSA functions. 4. Updated documentation for public APIs 5. In DCRYPTO_p256_key_from_bytes() implemented clear distinction between bad candidate and failures due to FIPS or pair-wise consistency. 6. U2F, rma_auth, TPM ecc, etc updated to use new return codes. BUG=b:197893750 TEST=make BOARD=cr50 CRYPTO_TEST=1; rma_auth, u2f_test, etc. test/tpm_test/tpmtest.py TCG tests ----------------------------- Test Result Summary ---------------------- Test executed on: Thu Sep 23 09:56:42 2021 Performed Tests: 248 Passed Tests: 248 Failed Tests: 0 Errors: 0 Warnings: 0 ======================================================================== Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: I0251bf511771c1c1fd281f6db706d1dedac3e8b8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3179708 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Auto-Submit: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/u2f.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/test/u2f.c b/test/u2f.c
index 36c1b5a1d4..21c5d6ea69 100644
--- a/test/u2f.c
+++ b/test/u2f.c
@@ -54,33 +54,33 @@ int DCRYPTO_x509_gen_u2f_cert_name(const p256_int *d, const p256_int *pk_x,
return 0;
}
-int DCRYPTO_p256_key_from_bytes(p256_int *x, p256_int *y, p256_int *d,
- const uint8_t key_bytes[P256_NBYTES])
+enum dcrypto_result DCRYPTO_p256_key_from_bytes(p256_int *x, p256_int *y,
+ p256_int *d, const uint8_t key_bytes[P256_NBYTES])
{
p256_int key;
p256_from_bin(key_bytes, &key);
if (p256_lt_blinded(&key, &SECP256r1_nMin2) >= 0)
- return 0;
+ return DCRYPTO_RETRY;
p256_add_d(&key, 1, d);
if (x == NULL || y == NULL)
- return 1;
+ return DCRYPTO_OK;
memset(x, 0, P256_NBYTES);
memset(y, 0, P256_NBYTES);
- return 1;
+ return DCRYPTO_OK;
}
-int dcrypto_p256_ecdsa_sign(struct drbg_ctx *drbg, const p256_int *key,
- const p256_int *message, p256_int *r, p256_int *s)
+enum dcrypto_result dcrypto_p256_ecdsa_sign(struct drbg_ctx *drbg,
+ const p256_int *key,
+ const p256_int *message,
+ p256_int *r, p256_int *s)
{
memset(r, 0, sizeof(p256_int));
memset(s, 0, sizeof(p256_int));
- /* Return 1 for success, 0 for error. */
- return 1;
+ return DCRYPTO_OK;
}
-
/******************************************************************************/
/* Mock implementations of U2F functionality.
*/