30 enum class ChallengeResponseResult : std::uint8_t
35 UNKNOWN_CHALLENGE = 3u,
36 PWD_NOT_CHANGABLE = 4u,
42 : m_VisionaryControl(vctrl)
49 const std::string& password,
53 std::string passwordPrefix{};
58 passwordPrefix =
"Run";
62 passwordPrefix =
"Operator";
66 passwordPrefix =
"Maintenance";
70 passwordPrefix =
"AuthorizedClient";
74 passwordPrefix =
"Service";
83 std::string separator =
":";
84 std::string passwordWithPrefix = passwordPrefix +
":SICK Sensor:" + password;
90 reinterpret_cast<const uint8_t*
>(passwordWithPrefix.c_str()),
91 static_cast<std::uint32_t
>(passwordWithPrefix.size()));
93 reinterpret_cast<const uint8_t*
>(separator.c_str()),
94 static_cast<std::uint32_t
>(separator.size()));
96 challengeRequest.
salt.data(),
97 static_cast<std::uint32_t
>(challengeRequest.
salt.size()));
111 sha256_process(&hashState, passwordHash.data(),
static_cast<std::uint32_t
>(passwordHash.size()));
114 static_cast<std::uint32_t
>(challengeRequest.
challenge.size()));
117 return challengeResponse;
122 bool isLoginSuccessful{
false};
138 if (
static_cast<ChallengeResponseResult
>(coLaParameterReader.
readUSInt()) ==
139 ChallengeResponseResult::SUCCESS)
142 for (std::uint32_t byteCounter = 0u; byteCounter <
sizeof(challengeRequest.challenge);
147 for (std::uint32_t byteCounter = 0u; byteCounter <
sizeof(challengeRequest.salt);
150 challengeRequest.salt[byteCounter] = coLaParameterReader.
readUSInt();
160 for (std::uint32_t byteCounter = 0u; byteCounter < challengeResponse.size(); byteCounter++)
162 coLaParameterWriter.
parameterUSInt(challengeResponse[byteCounter]);
172 if (
static_cast<ChallengeResponseResult
>(coLaParameterReader.
readUSInt()) ==
173 ChallengeResponseResult::SUCCESS)
175 isLoginSuccessful =
true;
180 return isLoginSuccessful;