diff options
author | Andrey Pronin <apronin@chromium.org> | 2019-06-26 10:16:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-27 20:43:57 +0000 |
commit | 2f9c8090dcb6f3b2e6afa0a5cca119cdfc5613d3 (patch) | |
tree | c24f011a12c5d30a0f68f1ea43c9a622db14e4bf /common/rma_auth.c | |
parent | 700b0ef9d5533d3650d58ca4e4ad4344b197d605 (diff) | |
download | chrome-ec-2f9c8090dcb6f3b2e6afa0a5cca119cdfc5613d3.tar.gz |
rma: handle unexpected sizes in get_rma_device_id
This CL adds checks to handle unexpected chip ID sizes in
get_rma_device_id() to make sure we always end up with deterministic
device ID and handle possible errors.
BRANCH=none
BUG=b:136091350
TEST=Verify that RSU Device ID reported through vNVRAM that uses this
new method mathes the same ID calculated from device ID in G2FA
certificate. See CL:1677238 for the exact method.
Change-Id: I288ef84d8fdc164df6b6b6c3a350c754a418be0a
Signed-off-by: Andrey Pronin <apronin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1678252
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'common/rma_auth.c')
-rw-r--r-- | common/rma_auth.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/rma_auth.c b/common/rma_auth.c index 6a4430f8b8..24c30bbe52 100644 --- a/common/rma_auth.c +++ b/common/rma_auth.c @@ -172,10 +172,16 @@ void get_rma_device_id(uint8_t rma_device_id[RMA_DEVICE_ID_SIZE]) uint8_t *chip_unique_id; int chip_unique_id_size = system_get_chip_unique_id(&chip_unique_id); + if (chip_unique_id_size < 0) + chip_unique_id_size = 0; /* Smaller unique chip IDs will fill rma_device_id only partially. */ if (chip_unique_id_size <= RMA_DEVICE_ID_SIZE) { /* The size matches, let's just copy it as is. */ memcpy(rma_device_id, chip_unique_id, chip_unique_id_size); + if (chip_unique_id_size < RMA_DEVICE_ID_SIZE) { + memset(rma_device_id + chip_unique_id_size, 0, + RMA_DEVICE_ID_SIZE - chip_unique_id_size); + } } else { /* * The unique chip ID size exceeds space allotted in |