mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Fixes #1
This commit is contained in:
11
Config.cpp
11
Config.cpp
@ -96,17 +96,16 @@ void Config::SetPassword(const char *password) {
|
|||||||
|
|
||||||
bool Config::CheckAuth(const char *response) {
|
bool Config::CheckAuth(const char *response) {
|
||||||
size_t challengeLength = strlen(this->Challenge);
|
size_t challengeLength = strlen(this->Challenge);
|
||||||
size_t responseLength = strlen(response);
|
|
||||||
|
|
||||||
// Concatenate challenge and auth response
|
// Concatenate challenge with itself
|
||||||
char *challengeAndResponse = (char*)bzalloc(challengeLength + responseLength);
|
char *challengeAndResponse = (char*)bzalloc(challengeLength * 2);
|
||||||
memcpy(challengeAndResponse, this->Challenge, challengeLength);
|
memcpy(challengeAndResponse, this->Challenge, challengeLength);
|
||||||
memcpy(challengeAndResponse + challengeLength, response, responseLength);
|
memcpy(challengeAndResponse + challengeLength, this->Challenge, challengeLength);
|
||||||
challengeAndResponse[challengeLength + responseLength] = 0; // Null-terminate the string
|
challengeAndResponse[challengeLength * 2] = 0; // Null-terminate the string
|
||||||
|
|
||||||
// Generate a SHA256 hash of challengeAndResponse
|
// Generate a SHA256 hash of challengeAndResponse
|
||||||
unsigned char *hash = (unsigned char*)bzalloc(32);
|
unsigned char *hash = (unsigned char*)bzalloc(32);
|
||||||
mbedtls_sha256((unsigned char*)challengeAndResponse, challengeLength + responseLength, hash, 0);
|
mbedtls_sha256((unsigned char*)challengeAndResponse, challengeLength * 2, hash, 0);
|
||||||
|
|
||||||
// Encode the SHA256 hash to Base64
|
// Encode the SHA256 hash to Base64
|
||||||
unsigned char *expected_response = (unsigned char*)bzalloc(64);
|
unsigned char *expected_response = (unsigned char*)bzalloc(64);
|
||||||
|
Reference in New Issue
Block a user