libsaltpack
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
saltpack::Utils Class Reference

Utilities class. More...

#include <Utils.h>

Static Public Member Functions

static void generateKeypair (BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey)
 
static void generateSignKeypair (BYTE_ARRAY &publickey, BYTE_ARRAY &secretkey)
 
static BYTE_ARRAY derivePublickey (BYTE_ARRAY secretkey)
 
static int baseXblockSize (const std::string &alphabet, int size)
 
static std::string baseXencode (const BYTE_ARRAY &data, std::string alphabet)
 
static std::string baseXencode (BYTE_ARRAY data, size_t size, std::string alphabet)
 
static BYTE_ARRAY baseXdecode (std::string data, const std::string &alphabet)
 
static BYTE_ARRAY hexToBin (const std::string &hex)
 
static std::string binToHex (BYTE_ARRAY bin)
 
static BYTE_ARRAY generateRandomBytes (size_t size)
 
static BYTE_ARRAY deriveKeyFromPassword (unsigned long long int keySize, const std::string &password, BYTE_ARRAY salt, unsigned long long int opsLimit, size_t memLimit)
 

Detailed Description

Utilities class.

Member Function Documentation

◆ baseXblockSize()

static int saltpack::Utils::baseXblockSize ( const std::string & alphabet,
int size )
static

Returns the number of required characters to represent in BaseX, for a given alphabet, size characters.

Parameters
alphabetthe alphabet for the BaseX encoding.
sizethe size of the data to represent.
Returns
the number of characters required to encode size characters.

◆ baseXdecode()

static BYTE_ARRAY saltpack::Utils::baseXdecode ( std::string data,
const std::string & alphabet )
static

Decodes the string from BaseX and the given alphabet.

Parameters
datadata the string to decode.
alphabetthe alphabet for the BaseX decoding.
Exceptions
SaltpackException
Returns
the decoded data.

◆ baseXencode() [1/2]

static std::string saltpack::Utils::baseXencode ( BYTE_ARRAY data,
size_t size,
std::string alphabet )
static

Encodes the data in BaseX using the given alphabet.

Parameters
datathe data to encode.
sizethe number of characters to encode from data.
alphabetthe alphabet for the BaseX encoding.
Returns
the encoded string.

◆ baseXencode() [2/2]

static std::string saltpack::Utils::baseXencode ( const BYTE_ARRAY & data,
std::string alphabet )
static

Encodes the data in BaseX using the given alphabet.

Parameters
datathe data to encode.
alphabetthe alphabet for the BaseX encoding.
Returns
the encoded string.

◆ binToHex()

static std::string saltpack::Utils::binToHex ( BYTE_ARRAY bin)
static

Binary to hexadecimal encoding.

Parameters
binthe binary data.
Exceptions
SaltpackException
Returns
the hexadecimal string.

◆ deriveKeyFromPassword()

static BYTE_ARRAY saltpack::Utils::deriveKeyFromPassword ( unsigned long long int keySize,
const std::string & password,
BYTE_ARRAY salt,
unsigned long long int opsLimit,
size_t memLimit )
static

Wrapper for the crypto_pwhash function from libsodium.

Parameters
keySizethe size of the key.
passwordthe password used to derive the key.
saltthe salt used to derive the key.
opsLimitthe maximum amount of computations to perform.
memLimitthe maximum amount of RAM that the function will use, in bytes.
Exceptions
SaltpackException
Returns
the derived key.

◆ derivePublickey()

static BYTE_ARRAY saltpack::Utils::derivePublickey ( BYTE_ARRAY secretkey)
static

Derives the public key from a private key.

Parameters
secretkeythe private key.
Exceptions
SaltpackException
Returns
the public key.

◆ generateKeypair()

static void saltpack::Utils::generateKeypair ( BYTE_ARRAY & publickey,
BYTE_ARRAY & secretkey )
static

Generates an encryption keypair using libsodium.

Parameters
[out]publickeythe public key array.
[out]secretkeythe private key array.
Exceptions
SaltpackException

◆ generateRandomBytes()

static BYTE_ARRAY saltpack::Utils::generateRandomBytes ( size_t size)
static

Generates some random bytes using libsodium.

Parameters
sizethe amount of bytes to generate.
Exceptions
SaltpackException
Returns
the random bytes.

◆ generateSignKeypair()

static void saltpack::Utils::generateSignKeypair ( BYTE_ARRAY & publickey,
BYTE_ARRAY & secretkey )
static

Generates a signing keypair using libsodium.

Parameters
[out]publickeythe public key array.
[out]secretkeythe private key array.
Exceptions
SaltpackException

◆ hexToBin()

static BYTE_ARRAY saltpack::Utils::hexToBin ( const std::string & hex)
static

Hexadecial to binary encoding.

Parameters
hexthe hexadecimal string.
Exceptions
SaltpackException
Returns
the binary data.

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