add specific pubkey to hex converter for used with new key pair classes

This commit is contained in:
Dario 2020-06-05 13:26:06 +02:00
parent c8c6667331
commit 5060fd97f0
2 changed files with 20 additions and 0 deletions

View File

@ -109,6 +109,24 @@ std::string convertBinToHex(const MemoryBin* data)
sodium_bin2hex(*hex, hexSize, *data, binSize);
std::string hexString((const char*)*hex, hexSize);
mm->releaseMemory(hex);
return hexString;
}
std::string convertPubkeyToHex(const unsigned char* pubkey)
{
auto mm = MemoryManager::getInstance();
size_t hexSize = crypto_sign_PUBLICKEYBYTES * 2 + 1;
size_t binSize = crypto_sign_PUBLICKEYBYTES;
MemoryBin* hex = mm->getFreeMemory(hexSize);
memset(*hex, 0, hexSize);
size_t resultBinSize = 0;
sodium_bin2hex(*hex, hexSize, pubkey, binSize);
std::string hexString((const char*)*hex, hexSize);
mm->releaseMemory(hex);
return hexString;

View File

@ -9,6 +9,8 @@ MemoryBin* convertBase64ToBin(const std::string& base64String);
std::string convertBinToBase64(const MemoryBin* data);
std::string convertBinToHex(const MemoryBin* data);
//! \param pubkey pointer to array with crypto_sign_PUBLICKEYBYTES size
std::string convertPubkeyToHex(const unsigned char* pubkey);