fsprg.h revision 7d50b32a129e781401cf897475f388f682de1368
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * fsprg v0.1 - (seekable) forward-secure pseudorandom generator
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * Copyright (C) 2012 B. Poettering
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * Contact: fsprg@point-at-infinity.org
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * This library is free software; you can redistribute it and/or
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * modify it under the terms of the GNU Lesser General Public
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * License as published by the Free Software Foundation; either
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * version 2.1 of the License, or (at your option) any later version.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * This library is distributed in the hope that it will be useful,
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * Lesser General Public License for more details.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * You should have received a copy of the GNU Lesser General Public
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * License along with this library; if not, write to the Free Software
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering * 02110-1301 USA
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringsize_t FSPRG_mskinbytes(unsigned secpar) _const_;
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringsize_t FSPRG_mpkinbytes(unsigned secpar) _const_;
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringsize_t FSPRG_stateinbytes(unsigned secpar) _const_;
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/* Setup msk and mpk. Providing seed != NULL makes this algorithm deterministic. */
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringvoid FSPRG_GenMK(void *msk, void *mpk, const void *seed, size_t seedlen, unsigned secpar);
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/* Initialize state deterministically in dependence on seed. */
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/* Note: in case one wants to run only one GenState0 per GenMK it is safe to use
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering the same seed for both GenMK and GenState0.
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringvoid FSPRG_GenState0(void *state, const void *mpk, const void *seed, size_t seedlen);
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringuint64_t FSPRG_GetEpoch(const void *state) _pure_;
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poettering/* Seek to any arbitrary state (by providing msk together with seed from GenState0). */
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringvoid FSPRG_Seek(void *state, uint64_t epoch, const void *msk, const void *seed, size_t seedlen);
4f5dd3943bef8a04be7e3b838b822bb9a7ad6cb3Lennart Poetteringvoid FSPRG_GetKey(const void *state, void *key, size_t keylen, uint32_t idx);