summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagendra modadugu <ngm@google.com>2016-03-07 10:09:42 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-03-07 20:03:30 -0800
commit6e0309ffa9019680bb9294d5b154fe14bebc5f22 (patch)
tree4db9c5e1b28b7698330df069183f9362cd9e448e
parent86d94fa3b579f5e6e5119153de932ccc9ba31cd1 (diff)
downloadchrome-ec-6e0309ffa9019680bb9294d5b154fe14bebc5f22.tar.gz
CR50: set result size in _cpri__GenerateKeyEcc, _cpri__GetEphemeralEcc
_cpri__GenerateKeyEcc, and _cpri__GetEphemeralEcc are expected to set the size of the result in accordance with the curve being used. BRANCH=none BUG=chrome-os-partner:43025,chrome-os-partner:47524 TEST=tests in test/tpm/tpmtest.py, test CPCTPM_TC2_2_14_02_05 passes Change-Id: I558cc56f689c2d33c12876ddbfde7e9659613d2c Signed-off-by: nagendra modadugu <ngm@google.com> Reviewed-on: https://chromium-review.googlesource.com/331210 Commit-Ready: Nagendra Modadugu <ngm@google.com> Tested-by: Nagendra Modadugu <ngm@google.com> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--board/cr50/tpm2/ecc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/board/cr50/tpm2/ecc.c b/board/cr50/tpm2/ecc.c
index d3ca3069f8..79687244df 100644
--- a/board/cr50/tpm2/ecc.c
+++ b/board/cr50/tpm2/ecc.c
@@ -114,8 +114,12 @@ CRYPT_RESULT _cpri__GenerateKeyEcc(
if (DCRYPTO_p256_key_from_bytes(
(p256_int *) q->x.b.buffer,
(p256_int *) q->y.b.buffer,
- (p256_int *) d->b.buffer, key_bytes))
+ (p256_int *) d->b.buffer, key_bytes)) {
+ q->x.b.size = sizeof(p256_int);
+ q->y.b.size = sizeof(p256_int);
+ d->b.size = sizeof(p256_int);
break;
+ }
}
if (count == 0)
@@ -203,10 +207,14 @@ CRYPT_RESULT _cpri__GetEphemeralEcc(TPMS_ECC_POINT *q, TPM2B_ECC_PARAMETER *d,
if (DCRYPTO_p256_key_from_bytes((p256_int *) q->x.b.buffer,
(p256_int *) q->y.b.buffer,
(p256_int *) d->b.buffer,
- key_bytes))
+ key_bytes)) {
+ q->x.b.size = sizeof(p256_int);
+ q->y.b.size = sizeof(p256_int);
+ d->b.size = sizeof(p256_int);
return CRYPT_SUCCESS;
- else
+ } else {
return CRYPT_FAIL;
+ }
}
#ifdef CRYPTO_TEST_SETUP