]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/fsprg.h
tree-wide: drop empty lines in comments
[thirdparty/systemd.git] / src / journal / fsprg.h
CommitLineData
d9215cd8
ZJS
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
7560fffc
LP
3#ifndef __fsprgh__
4#define __fsprgh__
5
6/*
7 * fsprg v0.1 - (seekable) forward-secure pseudorandom generator
810adae9 8 * Copyright © 2012 B. Poettering
7560fffc
LP
9 * Contact: fsprg@point-at-infinity.org
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * 02110-1301 USA
7560fffc
LP
25 */
26
7560fffc 27#include <inttypes.h>
71d35b6b 28#include <sys/types.h>
7560fffc 29
44a6b1b6 30#include "macro.h"
7d50b32a 31#include "util.h"
44a6b1b6 32
7560fffc
LP
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define FSPRG_RECOMMENDED_SECPAR 1536
38#define FSPRG_RECOMMENDED_SEEDLEN (96/8)
39
44a6b1b6
ZJS
40size_t FSPRG_mskinbytes(unsigned secpar) _const_;
41size_t FSPRG_mpkinbytes(unsigned secpar) _const_;
42size_t FSPRG_stateinbytes(unsigned secpar) _const_;
7560fffc
LP
43
44/* Setup msk and mpk. Providing seed != NULL makes this algorithm deterministic. */
45void FSPRG_GenMK(void *msk, void *mpk, const void *seed, size_t seedlen, unsigned secpar);
46
47/* Initialize state deterministically in dependence on seed. */
48/* Note: in case one wants to run only one GenState0 per GenMK it is safe to use
49 the same seed for both GenMK and GenState0.
50*/
51void FSPRG_GenState0(void *state, const void *mpk, const void *seed, size_t seedlen);
52
53void FSPRG_Evolve(void *state);
54
44a6b1b6 55uint64_t FSPRG_GetEpoch(const void *state) _pure_;
7560fffc
LP
56
57/* Seek to any arbitrary state (by providing msk together with seed from GenState0). */
58void FSPRG_Seek(void *state, uint64_t epoch, const void *msk, const void *seed, size_t seedlen);
59
60void FSPRG_GetKey(const void *state, void *key, size_t keylen, uint32_t idx);
61
62#ifdef __cplusplus
63}
64#endif
65
66#endif