]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-journal/fsprg.h
Merge pull request #31648 from neighbourhoodie/review-content
[thirdparty/systemd.git] / src / libsystemd / sd-journal / fsprg.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
7a3c343c 2#pragma once
7560fffc
LP
3
4/*
5 * fsprg v0.1 - (seekable) forward-secure pseudorandom generator
810adae9 6 * Copyright © 2012 B. Poettering
7560fffc 7 * Contact: fsprg@point-at-infinity.org
7560fffc
LP
8 */
9
7560fffc 10#include <inttypes.h>
71d35b6b 11#include <sys/types.h>
7560fffc 12
44a6b1b6
ZJS
13#include "macro.h"
14
7560fffc
LP
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#define FSPRG_RECOMMENDED_SECPAR 1536
20#define FSPRG_RECOMMENDED_SEEDLEN (96/8)
21
44a6b1b6
ZJS
22size_t FSPRG_mskinbytes(unsigned secpar) _const_;
23size_t FSPRG_mpkinbytes(unsigned secpar) _const_;
24size_t FSPRG_stateinbytes(unsigned secpar) _const_;
7560fffc
LP
25
26/* Setup msk and mpk. Providing seed != NULL makes this algorithm deterministic. */
8707c9b2 27int FSPRG_GenMK(void *msk, void *mpk, const void *seed, size_t seedlen, unsigned secpar);
7560fffc
LP
28
29/* Initialize state deterministically in dependence on seed. */
30/* Note: in case one wants to run only one GenState0 per GenMK it is safe to use
31 the same seed for both GenMK and GenState0.
32*/
8707c9b2 33int FSPRG_GenState0(void *state, const void *mpk, const void *seed, size_t seedlen);
7560fffc 34
8707c9b2 35int FSPRG_Evolve(void *state);
7560fffc 36
44a6b1b6 37uint64_t FSPRG_GetEpoch(const void *state) _pure_;
7560fffc
LP
38
39/* Seek to any arbitrary state (by providing msk together with seed from GenState0). */
8707c9b2 40int FSPRG_Seek(void *state, uint64_t epoch, const void *msk, const void *seed, size_t seedlen);
7560fffc 41
8707c9b2 42int FSPRG_GetKey(const void *state, void *key, size_t keylen, uint32_t idx);
7560fffc
LP
43
44#ifdef __cplusplus
45}
46#endif