blob: cc1b38e74b51ecce033f9010354b1ea96fbca03c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#ifndef HYBBX_PASSWORD_H
#define HYBBX_PASSWORD_H
#include "hybbx/types.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Stored password prefix for SHA-256 (default, tinysha256). */
#define HYBBX_PASSWORD_SHA256_PREFIX "{sha256}"
/** Stored password prefix for legacy MD5 (verify-only fallback). */
#define HYBBX_PASSWORD_MD5_PREFIX "{md5}"
/** Max stored password field: prefix + 64 hex digits + NUL. */
#define HYBBX_PASSWORD_STORED_MAX 96
/** Non-zero when @p stored is a hashed password (sha256 or md5 prefix). */
int hybbx_password_is_hashed(const char *stored);
/** Non-zero when @p stored is plain text and should be upgraded on load. */
int hybbx_password_is_plain(const char *stored);
/**
* Hash @p plain into @p out as {sha256}<hex> using the configured backend
* (default: bundled tinysha256; see [crypto] password_hash in hybbx.ini).
*/
hybbx_result_t hybbx_password_hash_sha256(const char *plain,
char *out,
size_t out_size);
/** Hash @p plain with the configured default algorithm (SHA-256). */
hybbx_result_t hybbx_password_hash(const char *plain, char *out, size_t out_size);
/** Return non-zero when @p provided matches @p stored (plain, sha256, or md5). */
int hybbx_password_match(const char *stored, const char *provided);
/**
* Fill @p out with a random password of length @p min_len … @p max_len using
* characters a-z and 0-9 only.
*/
hybbx_result_t hybbx_password_generate_alnum(char *out,
size_t out_size,
size_t min_len,
size_t max_len);
#ifdef __cplusplus
}
#endif
#endif /* HYBBX_PASSWORD_H */
|