summaryrefslogtreecommitdiff
path: root/core/tee/tee_rpmb_fs.c
diff options
context:
space:
mode:
authorVictor Chong <victor.chong@linaro.org>2019-06-25 02:37:58 +0900
committerJérôme Forissier <jerome.forissier@linaro.org>2019-08-06 21:20:28 +0200
commitfcd00ceac7b4b754c40b506fdb0ff204451eb007 (patch)
treeb67a60a02cd9a822af5a669f53f8f61783a480fe /core/tee/tee_rpmb_fs.c
parentc3d1e005dce3f2ad71ead40bd4aa2bac10962650 (diff)
rpmb: fix parsing of op_result
From the eMMC spec, the "Operation result" (Table 19) -- 7 bit quantity -- is the LSB of "Operation Results data structure" -- 16-bit quantity -- minus the high order bit. In other words it is 'rpmb_data_frame::op_result[1] & 0x7F' which is probably what we should be doing here instead of bytes_to_u16(). Signed-off-by: Victor Chong <victor.chong@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Diffstat (limited to 'core/tee/tee_rpmb_fs.c')
-rw-r--r--core/tee/tee_rpmb_fs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/tee/tee_rpmb_fs.c b/core/tee/tee_rpmb_fs.c
index 84baa2a9..c263e919 100644
--- a/core/tee/tee_rpmb_fs.c
+++ b/core/tee/tee_rpmb_fs.c
@@ -322,6 +322,11 @@ static void bytes_to_u16(uint8_t *bytes, uint16_t *u16)
*u16 = (uint16_t) ((*bytes << 8) + *(bytes + 1));
}
+static void get_op_result_bits(uint8_t *bytes, uint8_t *res)
+{
+ *res = *(bytes + 1) & RPMB_RESULT_MASK;
+}
+
static TEE_Result tee_rpmb_mac_calc(uint8_t *mac, uint32_t macsize,
uint8_t *key, uint32_t keysize,
struct rpmb_data_frame *datafrms,
@@ -731,7 +736,7 @@ static TEE_Result tee_rpmb_resp_unpack_verify(struct rpmb_data_frame *datafrm,
uint16_t msg_type;
uint32_t wr_cnt;
uint16_t blk_idx;
- uint16_t op_result;
+ uint8_t op_result;
struct rpmb_data_frame lastfrm;
if (!datafrm || !rawdata || !nbr_frms)
@@ -749,9 +754,7 @@ static TEE_Result tee_rpmb_resp_unpack_verify(struct rpmb_data_frame *datafrm,
memcpy(&lastfrm, &datafrm[nbr_frms - 1], RPMB_DATA_FRAME_SIZE);
/* Handle operation result and translate to TEEC error code. */
- bytes_to_u16(lastfrm.op_result, &op_result);
- if (rawdata->op_result)
- *rawdata->op_result = op_result;
+ get_op_result_bits(lastfrm.op_result, &op_result);
if (op_result == RPMB_RESULT_AUTH_KEY_NOT_PROGRAMMED)
return TEE_ERROR_ITEM_NOT_FOUND;
if (op_result != RPMB_RESULT_OK)