]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/fsprg.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7 * fsprg v0.1 - (seekable) forward-secure pseudorandom generator
8 * Copyright (C) 2012 B. Poettering
9 * Contact: fsprg@point-at-infinity.org
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.
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.
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
28 #include <sys/types.h>
35 #define FSPRG_RECOMMENDED_SECPAR 1536
36 #define FSPRG_RECOMMENDED_SEEDLEN (96/8)
38 size_t FSPRG_mskinbytes(unsigned secpar
);
39 size_t FSPRG_mpkinbytes(unsigned secpar
);
40 size_t FSPRG_stateinbytes(unsigned secpar
);
42 /* Setup msk and mpk. Providing seed != NULL makes this algorithm deterministic. */
43 void FSPRG_GenMK(void *msk
, void *mpk
, const void *seed
, size_t seedlen
, unsigned secpar
);
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.
49 void FSPRG_GenState0(void *state
, const void *mpk
, const void *seed
, size_t seedlen
);
51 void FSPRG_Evolve(void *state
);
53 uint64_t FSPRG_GetEpoch(const void *state
);
55 /* Seek to any arbitrary state (by providing msk together with seed from GenState0). */
56 void FSPRG_Seek(void *state
, uint64_t epoch
, const void *msk
, const void *seed
, size_t seedlen
);
58 void FSPRG_GetKey(const void *state
, void *key
, size_t keylen
, uint32_t idx
);