13 enum class ChallengeResponseResult : std::uint8_t
18 UNKNOWN_CHALLENGE = 3u,
19 PWD_NOT_CHANGABLE = 4u,
32 const std::string& password,
37 std::string passwordPrefix{};
43 passwordPrefix =
"Run";
48 passwordPrefix =
"Operator";
53 passwordPrefix =
"Maintenance";
58 passwordPrefix =
"AuthorizedClient";
63 passwordPrefix =
"Service";
73 std::string separator =
":";
74 std::string passwordWithPrefix = passwordPrefix +
":SICK Sensor:" + password;
80 reinterpret_cast<const uint8_t*
>(passwordWithPrefix.c_str()),
81 static_cast<ulong32>(passwordWithPrefix.size()));
82 if (protocolType ==
SUL2)
85 &hashState,
reinterpret_cast<const uint8_t*
>(separator.c_str()),
static_cast<ulong32>(separator.size()));
94 const std::string& password,
108 return challengeResponse;
112 const std::string& password,
116 bool isLoginSuccessful =
false;
119 if (
static_cast<ChallengeResponseResult
>(coLaParameterReader.
readUSInt()) == ChallengeResponseResult::SUCCESS)
122 for (std::uint32_t byteCounter = 0u; byteCounter <
sizeof(challengeRequest.challenge); byteCounter++)
126 if (protocolType ==
SUL2)
128 for (std::uint32_t byteCounter = 0u; byteCounter <
sizeof(challengeRequest.salt); byteCounter++)
130 challengeRequest.salt[byteCounter] = coLaParameterReader.
readUSInt();
139 for (
unsigned char b : challengeResponse)
150 if (
static_cast<ChallengeResponseResult
>(coLaParameterReader.
readUSInt()) == ChallengeResponseResult::SUCCESS)
152 isLoginSuccessful =
true;
157 return isLoginSuccessful;
162 bool isLoginSuccessful{
false};
172 const auto errorCode = getChallengeResponse.
getError();
175 isLoginSuccessful =
loginImpl(userLevel, password, getChallengeResponse,
SUL1);
193 isLoginSuccessful =
loginImpl(userLevel, password, getChallengeResponse,
SUL2);
196 return isLoginSuccessful;