SecurePasswd_MGMT 2026.03.19
A modern, cross-platform password manager and two-factor authenticator (TOTP) designed with state-of-the-art security.
Loading...
Searching...
No Matches
key_derivation.h File Reference
#include <stdint.h>
Include dependency graph for key_derivation.h:
This graph shows which files directly or indirectly include this file:

Macros

#define SALT_LEN   16
#define KEY_LEN   32

Functions

int derive_key (const char *password, const uint8_t *salt, uint8_t *key)
 Derives a key from a password and salt using Argon2id.
int load_or_generate_salt (const char *path, uint8_t *salt)
 Loads the salt from the specified path, or generates a new one if it doesn't exist.
int save_salt (const char *path, const uint8_t *salt)
 Saves the salt to the specified path.

Macro Definition Documentation

◆ KEY_LEN

#define KEY_LEN   32

◆ SALT_LEN

#define SALT_LEN   16

Function Documentation

◆ derive_key()

int derive_key ( const char * password,
const uint8_t * salt,
uint8_t * key )

Derives a key from a password and salt using Argon2id.

Parameters
passwordThe password to derive the key from.
saltThe salt to use for key derivation.
keyThe buffer to store the derived key in. Must be KEY_LEN bytes.
Returns
0 on success, -1 on error.

◆ load_or_generate_salt()

int load_or_generate_salt ( const char * path,
uint8_t * salt )

Loads the salt from the specified path, or generates a new one if it doesn't exist.

Parameters
pathThe path to the salt file.
saltThe buffer to store the loaded or generated salt in. Must be SALT_LEN bytes.
Returns
0 on success, -1 on error.

◆ save_salt()

int save_salt ( const char * path,
const uint8_t * salt )

Saves the salt to the specified path.

Parameters
pathThe path to the salt file.
saltThe salt to save. Must be SALT_LEN bytes.
Returns
0 on success, -1 on error.