diff options
author | suryaprakash.konduru <suryaprakash.konduru@nxp.com> | 2024-01-12 21:57:52 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-12 21:57:52 +0000 |
commit | 0ebd362694d570395ff7ce3595f0902653945ea3 (patch) | |
tree | 8d1235fb07cbb62b8eb5d1ab18ee5b8c53b64eb8 | |
parent | dbf90fc26d26cb02f330f586dcebffd4c9235c3a (diff) | |
parent | 21db193682e9b7ae7d67399efaff190feda74412 (diff) | |
download | keymint-0ebd362694d570395ff7ce3595f0902653945ea3.tar.gz |
Timeout extraction logic cleanup am: c3b501b0c1 am: 21db193682
Original change: https://android-review.googlesource.com/c/platform/hardware/nxp/keymint/+/2901461
Change-Id: I626d5f4c490b9308734e593bc9be9d425418b265
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | KM300/authsecret/AuthSecretHelper.cpp | 15 | ||||
-rw-r--r-- | KM300/authsecret/AuthSecretHelper.h | 5 |
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 |