mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add specific pubkey to hex converter for used with new key pair classes
This commit is contained in:
parent
c8c6667331
commit
5060fd97f0
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user