summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuryaprakash.konduru <suryaprakash.konduru@nxp.com>2024-01-12 23:19:54 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-12 23:19:54 +0000
commitc10f3efa0543c99ef42f1d95de405817b060a062 (patch)
tree8d1235fb07cbb62b8eb5d1ab18ee5b8c53b64eb8
parent5e81efa8166947755c1060c62572fac9991da424 (diff)
parent0ebd362694d570395ff7ce3595f0902653945ea3 (diff)
downloadkeymint-c10f3efa0543c99ef42f1d95de405817b060a062.tar.gz
Timeout extraction logic cleanup am: c3b501b0c1 am: 21db193682 am: 0ebd362694
Original change: https://android-review.googlesource.com/c/platform/hardware/nxp/keymint/+/2901461 Change-Id: I3cf97bd2779a26cc32cc4b4621b78e2c0e3b5b69 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--KM300/authsecret/AuthSecretHelper.cpp15
-rw-r--r--KM300/authsecret/AuthSecretHelper.h5
2 files changed, 9 insertions, 11 deletions
diff --git a/KM300/authsecret/AuthSecretHelper.cpp b/KM300/authsecret/AuthSecretHelper.cpp
index 604371d..70f8e8f 100644
--- a/KM300/authsecret/AuthSecretHelper.cpp
+++ b/KM300/authsecret/AuthSecretHelper.cpp
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,34 +66,29 @@ bool AuthSecretHelper::constructApdu(Instruction ins,
uint64_t AuthSecretHelper::extractTimeoutValue(std::vector<uint8_t> data) {
LOG(INFO) << StringPrintf("%s: Enter", __func__);
- uint64_t timeout = 0x00;
-
auto [parsedData, _, errMsg] = cppbor::parse(data);
if (!parsedData) {
LOG(ERROR) << StringPrintf("parsedData is null");
- return timeout;
+ return INVALID_DATA_STATUS_TIMER_VALUE;
}
auto dataArray = parsedData->asArray();
if (!dataArray) {
LOG(ERROR) << StringPrintf("parsedData is not proper CBOR Array");
- return timeout;
+ return INVALID_DATA_STATUS_TIMER_VALUE;
}
+ uint64_t timeout = CLEAR_APPROVE_STATUS_TIMER_VALUE;
if ((dataArray->size() > 1) && (dataArray->get(INDEX_TIMER_VAL)->asBstr())) {
std::vector<uint8_t> timeoutVector =
dataArray->get(INDEX_TIMER_VAL)->asBstr()->value();
if (timeoutVector.size() == TIMEOUT_VECTOR_SIZE) {
timeout = (((timeoutVector[0] << 8) | (timeoutVector[1])) * 60 * 60) +
((timeoutVector[2] << 8) | timeoutVector[3]);
- } else {
- timeout = CLEAR_APPROVE_STATUS_TIMER_VALUE;
}
- } else if (!timeout) {
- timeout = CLEAR_APPROVE_STATUS_TIMER_VALUE;
}
- return timeout;
LOG(INFO) << StringPrintf("%s:Exit", __func__);
+ return timeout;
}
bool AuthSecretHelper::checkVerifyStatus(std::vector<uint8_t> resp) {
diff --git a/KM300/authsecret/AuthSecretHelper.h b/KM300/authsecret/AuthSecretHelper.h
index cf565cb..f47ef73 100644
--- a/KM300/authsecret/AuthSecretHelper.h
+++ b/KM300/authsecret/AuthSecretHelper.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright 2023 NXP
+ * Copyright 2023-2024 NXP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,9 @@
#include <cppbor.h>
#include <cppbor_parse.h>
+// Timeout value in seconds for invalid data status
+#define INVALID_DATA_STATUS_TIMER_VALUE 0
+
// Default timeout value in seconds for clear approved status.
#define CLEAR_APPROVE_STATUS_TIMER_VALUE 60