57 lines
1.5 KiB
C
57 lines
1.5 KiB
C
#ifndef PASSGENY_H_INCLUDED
|
|
#define PASSGENY_H_INCLUDED
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
typedef struct passgeny passgeny_t;
|
|
|
|
struct passgeny
|
|
{
|
|
uint8_t pg_master_hash[32]; /* SHA256 of the master password */
|
|
char *pg_pattern; /* Password pattern */
|
|
double pg_last_bits_total; /* Total bits that were available for generating the last password */
|
|
double pg_last_bits_used; /* Bits consumed when calculating the last password */
|
|
};
|
|
|
|
/*
|
|
* Initialize a new passgeny instance
|
|
*
|
|
* Note: The master password is hashed and remembered. The raw password is never
|
|
* stored in memory.
|
|
*/
|
|
bool passgeny_init(passgeny_t *passgeny, const char *master_password);
|
|
|
|
/*
|
|
* Destroy a passgeny instance
|
|
*/
|
|
void passgeny_fini(passgeny_t *passgeny);
|
|
|
|
/*
|
|
* Set the current pattern
|
|
*/
|
|
void passgeny_set_pattern(passgeny_t *passgeny, const char *pattern);
|
|
|
|
/*
|
|
* Generate a new passgeny password using `domain`, `username` and optional
|
|
* tokens.
|
|
*
|
|
* The password is stored in the `out` string, where `out_sz` represents the
|
|
* maximum size of the string including '\0'
|
|
*/
|
|
bool passgeny_generate(
|
|
passgeny_t *passgeny,
|
|
char *out,
|
|
size_t out_sz,
|
|
const char *domain,
|
|
const char *username,
|
|
const char * const toknes[],
|
|
int ntokens);
|
|
|
|
/*
|
|
* Dump some statistics
|
|
*/
|
|
void passgeny_dump_verbose(const passgeny_t *passgeny);
|
|
|
|
#endif /* PASSGENY_H_INCLUDED */
|