summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuryaprakash.konduru <suryaprakash.konduru@nxp.com>2024-01-10 16:20:10 +0530
committerSuryaprakash Konduru <suryaprakash.konduru@nxp.com>2024-01-12 07:24:34 +0000
commitc3b501b0c148c9fbedd556708576a240647e0b96 (patch)
tree8d1235fb07cbb62b8eb5d1ab18ee5b8c53b64eb8
parent58107963ca532926fdd3f1c68962bb1085294f8a (diff)
downloadkeymint-c3b501b0c148c9fbedd556708576a240647e0b96.tar.gz
Timeout extraction logic cleanup
- Removed timeout check since it is always true - moved print statement before return statement Bug: 303346066 Test: Build ok Change-Id: I2c48a824b822042764daacb16b6cc5f2cb4507fa
-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