| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
/* |
| 5 |
* fsprg v0.1 - (seekable) forward-secure pseudorandom generator |
| 6 |
* Copyright © 2012 B. Poettering |
| 7 |
* Contact: [email protected] |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "sd-forward.h" |
| 11 |
|
| 12 |
#ifdef __cplusplus |
| 13 |
extern "C" { |
| 14 |
#endif |
| 15 |
|
| 16 |
#define FSPRG_RECOMMENDED_SECPAR 1536 |
| 17 |
#define FSPRG_RECOMMENDED_SEEDLEN (96/8) |
| 18 |
|
| 19 |
size_t FSPRG_mskinbytes(unsigned secpar) _const_; |
| 20 |
size_t FSPRG_mpkinbytes(unsigned secpar) _const_; |
| 21 |
size_t FSPRG_stateinbytes(unsigned secpar) _const_; |
| 22 |
|
| 23 |
/* Setup msk and mpk. Providing seed != NULL makes this algorithm deterministic. */ |
| 24 |
int FSPRG_GenMK(void *msk, void *mpk, const void *seed, size_t seedlen, unsigned secpar); |
| 25 |
|
| 26 |
/* Initialize state deterministically in dependence on seed. */ |
| 27 |
/* Note: in case one wants to run only one GenState0 per GenMK it is safe to use |
| 28 |
the same seed for both GenMK and GenState0. |
| 29 |
*/ |
| 30 |
int FSPRG_GenState0(void *state, const void *mpk, const void *seed, size_t seedlen); |
| 31 |
|
| 32 |
int FSPRG_Evolve(void *state); |
| 33 |
|
| 34 |
uint64_t FSPRG_GetEpoch(const void *state) _pure_; |
| 35 |
|
| 36 |
/* Seek to any arbitrary state (by providing msk together with seed from GenState0). */ |
| 37 |
int FSPRG_Seek(void *state, uint64_t epoch, const void *msk, const void *seed, size_t seedlen); |
| 38 |
|
| 39 |
int FSPRG_GetKey(const void *state, void *key, size_t keylen, uint32_t idx); |
| 40 |
|
| 41 |
#ifdef __cplusplus |
| 42 |
} |
| 43 |
#endif |