diff options
author | Andrey Pronin <apronin@chromium.org> | 2019-06-26 10:16:29 -0700 |
---|---|---|
committer | Vadim Bendebury <vbendeb@chromium.org> | 2019-09-21 19:11:25 -0700 |
commit | ddec2478333a51b66157fe7253788f5edc197f80 (patch) | |
tree | a7313c8857c85a67f86771721c157439938e1bdb | |
parent | 43834b9cbac633b1fcf2c855502f36d774d15ab8 (diff) | |
download | chrome-ec-ddec2478333a51b66157fe7253788f5edc197f80.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>
(cherry picked from commit 2f9c8090dcb6f3b2e6afa0a5cca119cdfc5613d3)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1684235
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
(cherry picked from commit 6f32030053196d67c725c378076504d7625cbe01)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1705744
(cherry picked from commit b3018f6f44ac399be66ecf8a5a6f56a55cbf7c03)
-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 |