PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
privmx::endpoint::crypto::CryptoApi Class Reference

#include <privmx/endpoint/crypto/CryptoApi.hpp>

Public Member Functions

 CryptoApi ()=default
core::Buffer signData (const core::Buffer &data, const std::string &privateKey)
bool verifySignature (const core::Buffer &data, const core::Buffer &signature, const std::string &publicKey)
std::string generatePrivateKey (const std::optional< std::string > &randomSeed)
std::string derivePrivateKey (const std::string &password, const std::string &salt)
std::string derivePrivateKey2 (const std::string &password, const std::string &salt)
std::string derivePublicKey (const std::string &privateKey)
core::Buffer generateKeySymmetric ()
core::Buffer encryptDataSymmetric (const core::Buffer &data, const core::Buffer &symmetricKey)
core::Buffer decryptDataSymmetric (const core::Buffer &data, const core::Buffer &symmetricKey)
std::string convertPEMKeytoWIFKey (const std::string &pemKey)
std::string convertPGPAsn1KeyToBase58DERKey (const std::string &pgpKey)
BIP39_t generateBip39 (std::size_t strength, const std::string &password=std::string())
BIP39_t fromMnemonic (const std::string &mnemonic, const std::string &password=std::string())
BIP39_t fromEntropy (const core::Buffer &entropy, const std::string &password=std::string())
std::string entropyToMnemonic (const core::Buffer &entropy)
core::Buffer mnemonicToEntropy (const std::string &mnemonic)
core::Buffer mnemonicToSeed (const std::string &mnemonic, const std::string &password=std::string())

Static Public Member Functions

static CryptoApi create ()

Detailed Description

'CryptoApi' is a class representing Endpoint's API for cryptographic operations.

Constructor & Destructor Documentation

◆ CryptoApi()

privmx::endpoint::crypto::CryptoApi::CryptoApi ( )
default

//doc-gen:ignore

Member Function Documentation

◆ convertPEMKeytoWIFKey()

std::string privmx::endpoint::crypto::CryptoApi::convertPEMKeytoWIFKey ( const std::string & pemKey)

Converts given private key in PEM format to its WIF format.

Parameters
pemKeyprivate key to convert
Returns
private key in WIF format

◆ convertPGPAsn1KeyToBase58DERKey()

std::string privmx::endpoint::crypto::CryptoApi::convertPGPAsn1KeyToBase58DERKey ( const std::string & pgpKey)

Converts given public key in PGP format to its base58DER format.

Parameters
pemKeypublic key to convert
Returns
public key in base58DER format

◆ create()

CryptoApi privmx::endpoint::crypto::CryptoApi::create ( )
static

Creates instance of 'CryptoApi'.

Returns
CryptoApi object

◆ decryptDataSymmetric()

core::Buffer privmx::endpoint::crypto::CryptoApi::decryptDataSymmetric ( const core::Buffer & data,
const core::Buffer & symmetricKey )

Decrypts buffer with a given key using AES.

Parameters
databuffer to decrypt
symmetricKeykey used to decrypt data
Returns
plain (decrypted) data buffer

◆ derivePrivateKey()

std::string privmx::endpoint::crypto::CryptoApi::derivePrivateKey ( const std::string & password,
const std::string & salt )

Generates a new private ECC key from a password using pbkdf2.

Parameters
passwordthe password used to generate the new key
saltrandom string (additional input for the hashing function)
Returns
generated ECC key in WIF format

◆ derivePrivateKey2()

std::string privmx::endpoint::crypto::CryptoApi::derivePrivateKey2 ( const std::string & password,
const std::string & salt )

Generates a new private ECC key from a password using pbkdf2. This version of the derive function has a rounds count increased to 200k. This makes using this function a safer choice, but it makes the received key different than in the original version.

Parameters
passwordthe password used to generate the new key
saltrandom string (additional input for the hashing function)
Returns
generated ECC key in WIF format

◆ derivePublicKey()

std::string privmx::endpoint::crypto::CryptoApi::derivePublicKey ( const std::string & privateKey)

Generates a new public ECC key as a pair for an existing private key.

Parameters
privatekeyprivate ECC key in WIF format
Returns
generated ECC key in BASE58DER format

◆ encryptDataSymmetric()

core::Buffer privmx::endpoint::crypto::CryptoApi::encryptDataSymmetric ( const core::Buffer & data,
const core::Buffer & symmetricKey )

Encrypts buffer with a given key using AES.

Parameters
databuffer to encrypt
symmetricKeykey used to encrypt data
Returns
encrypted data buffer

◆ entropyToMnemonic()

std::string privmx::endpoint::crypto::CryptoApi::entropyToMnemonic ( const core::Buffer & entropy)

Converts BIP-39 entropy to mnemonic.

Parameters
entropyBIP-39 entropy
Returns
BIP-39 mnemonic

◆ fromEntropy()

BIP39_t privmx::endpoint::crypto::CryptoApi::fromEntropy ( const core::Buffer & entropy,
const std::string & password = std::string() )

Generates ECC key using BIP-39 entropy.

Parameters
entropythe BIP-39 entropy used to generate the Key
passwordthe password used to generate the Key
Returns
BIP39_t object containing ECC Key and associated with it BIP-39 mnemonic and entropy

◆ fromMnemonic()

BIP39_t privmx::endpoint::crypto::CryptoApi::fromMnemonic ( const std::string & mnemonic,
const std::string & password = std::string() )

Generates ECC key using BIP-39 mnemonic.

Parameters
mnemonicthe BIP-39 mnemonic used to generate the Key
passwordthe password used to generate the Key
Returns
BIP39_t object containing ECC Key and associated with it BIP-39 mnemonic and entropy

◆ generateBip39()

BIP39_t privmx::endpoint::crypto::CryptoApi::generateBip39 ( std::size_t strength,
const std::string & password = std::string() )

Generates ECC key and BIP-39 mnemonic from a password using BIP-39.

Parameters
strengthsize of BIP-39 entropy, must be a multiple of 32 between 128 and 256.
passwordthe password used to generate the Key
Returns
BIP39_t object containing ECC Key and associated with it BIP-39 mnemonic and entropy

◆ generateKeySymmetric()

core::Buffer privmx::endpoint::crypto::CryptoApi::generateKeySymmetric ( )

Generates a new symmetric key.

Returns
generated key

◆ generatePrivateKey()

std::string privmx::endpoint::crypto::CryptoApi::generatePrivateKey ( const std::optional< std::string > & randomSeed)

Generates a new private ECC key.

Parameters
randomSeedoptional string used as the base to generate the new key
Returns
generated ECC key in WIF format

◆ mnemonicToEntropy()

core::Buffer privmx::endpoint::crypto::CryptoApi::mnemonicToEntropy ( const std::string & mnemonic)

Converts BIP-39 mnemonic to entropy.

Parameters
mnemonicBIP-39 mnemonic
Returns
BIP-39 entropy

◆ mnemonicToSeed()

core::Buffer privmx::endpoint::crypto::CryptoApi::mnemonicToSeed ( const std::string & mnemonic,
const std::string & password = std::string() )

Generates a seed used to generate a key using BIP-39 mnemonic with PBKDF2.

Parameters
mnemonicBIP-39 mnemonic
passwordthe password used to generate the seed
Returns
generated seed

◆ signData()

core::Buffer privmx::endpoint::crypto::CryptoApi::signData ( const core::Buffer & data,
const std::string & privateKey )

Creates a signature of data using given key.

Parameters
databuffer to sign
privateKeykey used to sign data
Returns
signature of data

◆ verifySignature()

bool privmx::endpoint::crypto::CryptoApi::verifySignature ( const core::Buffer & data,
const core::Buffer & signature,
const std::string & publicKey )

Validate a signature of data using given key.

Parameters
databuffer
signaturesignature of data to verify
publicKeypublic ECC key in BASE58DER format used to validate data
Returns
data validation result

The documentation for this class was generated from the following file: