Prepare openssl key export

This commit is contained in:
momo5502 2023-04-21 16:47:50 +02:00
parent 7188c4d2b7
commit eb3fe7ae6f
3 changed files with 20 additions and 3 deletions

View File

@ -9,9 +9,11 @@ namespace discord
{
namespace
{
void ready(const DiscordUser* /*request*/)
void ready(const DiscordUser* request)
{
printf("Discord: Ready\n");
SetEnvironmentVariableA("discord_user", request->userId);
printf("Discord: Ready: %s - %s\n", request->userId, request->username);
DiscordRichPresence discord_presence{};
ZeroMemory(&discord_presence, sizeof(discord_presence));

View File

@ -229,7 +229,20 @@ namespace utils::cryptography
if (ecc_export(buffer, &length, type, &this->key_storage_) == CRYPT_OK)
{
return std::string(cs(buffer), length);
return {cs(buffer), length};
}
return "";
}
std::string ecc::key::get_openssl() const
{
uint8_t buffer[4096] = {0};
unsigned long length = sizeof(buffer);
if (ecc_export_openssl(buffer, &length, PK_PUBLIC, &this->key_storage_) == CRYPT_OK)
{
return {cs(buffer), length};
}
return "";

View File

@ -31,6 +31,8 @@ namespace utils::cryptography
std::string serialize(int type = PK_PRIVATE) const;
std::string get_openssl() const;
void free();
bool operator==(key& key) const;