I hate C++!
This commit is contained in:
parent
67b225414c
commit
52c29e9a8c
|
|
@ -24,7 +24,7 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, int
|
|||
v18 = (const BYTE*)&pbData;
|
||||
}
|
||||
|
||||
message = std::string(reinterpret_cast<char const*>(pbData), dwDataLen);
|
||||
message = std::string(reinterpret_cast<const char*>(pbData), dwDataLen);
|
||||
|
||||
// Get signatureBase64
|
||||
int* v21 = (int*)a10;
|
||||
|
|
@ -74,24 +74,22 @@ void __fastcall Crypt__verifySignatureBase64_hook(HCRYPTPROV* _this, void*, int
|
|||
}
|
||||
|
||||
// Verify signature against the message
|
||||
unsigned char* signature = Util::base64Decode(signatureBase64);
|
||||
unsigned char* data = new unsigned char[message.length()];
|
||||
|
||||
std::copy(message.begin(), message.end(), data);
|
||||
const char* signature = Util::base64Decode(signatureBase64).c_str();
|
||||
const char* data = message.c_str();
|
||||
|
||||
int result = EVP_PKEY_verify(ctx, signature, sizeof(signature), data, strlen((char*)data));
|
||||
int result = EVP_PKEY_verify(ctx, (unsigned char*)signature, strlen(signature), (unsigned char*)data, strlen(data));
|
||||
|
||||
// Dispose objects
|
||||
EVP_PKEY_free(key);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
|
||||
delete[] signature;
|
||||
delete[] data;
|
||||
delete signature;
|
||||
delete data;
|
||||
|
||||
// Check
|
||||
if (result != 1)
|
||||
{
|
||||
throw std::runtime_error("");
|
||||
// throw std::runtime_error("");
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ std::string Util::toLower(std::string s)
|
|||
}
|
||||
|
||||
// https://stackoverflow.com/a/44562527
|
||||
unsigned char* Util::base64Decode(const std::string_view data)
|
||||
std::string Util::base64Decode(const std::string_view data)
|
||||
{
|
||||
// table from '+' to 'z'
|
||||
const uint8_t lookup[] = {
|
||||
|
|
@ -93,7 +93,7 @@ unsigned char* Util::base64Decode(const std::string_view data)
|
|||
|
||||
static_assert(sizeof(lookup) == 'z' - '+' + 1);
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
std::string out;
|
||||
int val = 0, valb = -8;
|
||||
for (uint8_t c : data)
|
||||
{
|
||||
|
|
@ -117,9 +117,6 @@ unsigned char* Util::base64Decode(const std::string_view data)
|
|||
valb -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* blob = new unsigned char[out.size()];
|
||||
std::copy(out.begin(), out.end(), blob);
|
||||
|
||||
return blob;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
@ -13,5 +13,5 @@ public:
|
|||
static std::map<std::string, std::string> parseArgs(std::string args);
|
||||
static bool isASCII(const std::string& s);
|
||||
static std::string toLower(std::string s);
|
||||
static unsigned char* base64Decode(const std::string_view data);
|
||||
static std::string base64Decode(const std::string_view data);
|
||||
};
|
||||
Loading…
Reference in New Issue