Fixed security level calculcation for too long numbers

This commit is contained in:
WolverinDEV 2021-02-05 14:23:52 +01:00
parent 9a523f1525
commit 37b3101561
2 changed files with 4 additions and 4 deletions

View File

@ -58,13 +58,13 @@ command_result VoiceClient::handleCommand(ts::Command &command) {
return SpeakingClient::handleCommand(command);
}
inline bool calculate_security_level(int& result, ecc_key* pubKey, size_t offset) {
inline bool calculate_security_level(int& result, ecc_key* pubKey, const std::string& offset) {
size_t pubLength = 256;
char pubBuffer[256];
if((result = ecc_export(reinterpret_cast<unsigned char *>(pubBuffer), &pubLength, PK_PUBLIC, pubKey)) != CRYPT_OK)
return false;
std::string hashStr = base64_encode(pubBuffer, pubLength) + to_string(offset);
std::string hashStr = base64_encode(pubBuffer, pubLength) + offset;
char shaBuffer[SHA_DIGEST_LENGTH];
SHA1((const unsigned char *) hashStr.data(), hashStr.length(), (unsigned char *) shaBuffer);
@ -89,7 +89,7 @@ command_result VoiceClient::handleCommandClientInit(Command &cmd) {
auto client_identity = this->connection->crypt_setup_handler().identity_key();
int security_level;
if(!calculate_security_level(security_level, &*client_identity, cmd["client_key_offset"])) {
if(!calculate_security_level(security_level, &*client_identity, cmd["client_key_offset"].string())) {
logError(this->getServerId(), "[{}] Failed to calculate security level. Error code: {}", CLIENT_STR_LOG_PREFIX, security_level);
return command_result{error::vs_critical};
}

2
shared

@ -1 +1 @@
Subproject commit c0790984eeea45c2692680fd133e6048cbafe57c
Subproject commit d213c0ade0ea0752eec6ce995e661a49a2818a4e