Utilities class.
More...
#include <Utils.h>
|
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) |
|
◆ 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
-
alphabet | the alphabet for the BaseX encoding. |
size | the 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
-
data | data the string to decode. |
alphabet | the alphabet for the BaseX decoding. |
- Exceptions
-
- 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
-
data | the data to encode. |
size | the number of characters to encode from data . |
alphabet | the 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
-
data | the data to encode. |
alphabet | the 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
-
- Exceptions
-
- 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
-
keySize | the size of the key. |
password | the password used to derive the key. |
salt | the salt used to derive the key. |
opsLimit | the maximum amount of computations to perform. |
memLimit | the maximum amount of RAM that the function will use, in bytes. |
- Exceptions
-
- Returns
- the derived key.
◆ derivePublickey()
Derives the public key from a private key.
- Parameters
-
secretkey | the private key. |
- Exceptions
-
- Returns
- the public key.
◆ generateKeypair()
Generates an encryption keypair using libsodium
.
- Parameters
-
[out] | publickey | the public key array. |
[out] | secretkey | the private key array. |
- Exceptions
-
◆ generateRandomBytes()
static BYTE_ARRAY saltpack::Utils::generateRandomBytes |
( |
size_t | size | ) |
|
|
static |
Generates some random bytes using libsodium
.
- Parameters
-
size | the amount of bytes to generate. |
- Exceptions
-
- Returns
- the random bytes.
◆ generateSignKeypair()
Generates a signing keypair using libsodium
.
- Parameters
-
[out] | publickey | the public key array. |
[out] | secretkey | the private key array. |
- Exceptions
-
◆ hexToBin()
static BYTE_ARRAY saltpack::Utils::hexToBin |
( |
const std::string & | hex | ) |
|
|
static |
Hexadecial to binary encoding.
- Parameters
-
hex | the hexadecimal string. |
- Exceptions
-
- Returns
- the binary data.
The documentation for this class was generated from the following file: