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