]>
Commit | Line | Data |
---|---|---|
988d4771 | 1 | /* |
188b190a | 2 | * Copyright (C) 2014-2016 Andreas Steffen |
19ef2aec TB |
3 | * |
4 | * Copyright (C) secunet Security Networks AG | |
988d4771 AS |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2 of the License, or (at your | |
9 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 | * for more details. | |
15 | */ | |
16 | ||
17 | /** | |
188b190a | 18 | * @defgroup xof_bitspender xof_bitspender |
f9da7ef8 | 19 | * @{ @ingroup mgf1 |
988d4771 AS |
20 | */ |
21 | ||
188b190a AS |
22 | #ifndef XOF_BITSPENDER_H_ |
23 | #define XOF_BITSPENDER_H_ | |
24 | ||
25 | #include "xof.h" | |
988d4771 AS |
26 | |
27 | #include <library.h> | |
988d4771 | 28 | |
188b190a | 29 | typedef struct xof_bitspender_t xof_bitspender_t; |
988d4771 | 30 | |
988d4771 | 31 | /** |
188b190a AS |
32 | * Generates a given number of pseudo-random bits at a time using an |
33 | * Extended Output Function (XOF) | |
988d4771 | 34 | */ |
188b190a | 35 | struct xof_bitspender_t { |
988d4771 AS |
36 | |
37 | /** | |
38 | * Get pseudo-random bits | |
39 | * | |
72bb7eec AS |
40 | * @param bits_needed Number of needed bits (1..32) |
41 | * @param bits Pseudo-random bits | |
42 | * @result FALSE if internal MGF1 error occurred | |
43 | */ | |
188b190a | 44 | bool (*get_bits)(xof_bitspender_t *this, int bits_needed, uint32_t *bits); |
72bb7eec AS |
45 | |
46 | /** | |
47 | * Get a pseudo-random byte | |
48 | * | |
49 | * @param byte Pseudo-random byte | |
50 | * @result FALSE if internal MGF1 error occurred | |
988d4771 | 51 | */ |
188b190a | 52 | bool (*get_byte)(xof_bitspender_t *this, uint8_t *byte); |
988d4771 AS |
53 | |
54 | /** | |
188b190a | 55 | * Destroy xof_bitspender_t object |
988d4771 | 56 | */ |
188b190a | 57 | void (*destroy)(xof_bitspender_t *this); |
988d4771 AS |
58 | }; |
59 | ||
60 | /** | |
188b190a | 61 | * Create a xof_bitspender_t object |
f9da7ef8 | 62 | * |
188b190a AS |
63 | * @param alg XOF to be used |
64 | * @param seed Seed used to initialize XOF | |
988d4771 AS |
65 | * @param hash_seed Hash seed before using it as a seed for MFG1 |
66 | */ | |
188b190a AS |
67 | xof_bitspender_t *xof_bitspender_create(ext_out_function_t alg, chunk_t seed, |
68 | bool hash_seed); | |
988d4771 | 69 | |
188b190a | 70 | #endif /** XOF_BITSPENDER_H_ @}*/ |