2 * Copyright (C) 2014 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup mgf1_bitspender mgf1_bitspender
21 #ifndef MGF1_BITSPENDER_H_
22 #define MGF1_BITSPENDER_H_
25 #include <crypto/hashers/hasher.h>
27 typedef struct mgf1_bitspender_t mgf1_bitspender_t
;
29 #define MGF1_BITSPENDER_ERROR 0xffffffff
32 * Generates a given number of pseudo-random bits at a time using MFG1
34 struct mgf1_bitspender_t
{
37 * Get pseudo-random bits
39 * @param bits_needed Number of needed bits (1..31)
40 * @result Return between 1 and 31 pseudo-random bits
42 uint32_t (*get_bits
)(mgf1_bitspender_t
*this, int bits_needed
);
45 * Destroy mgf1_bitspender_t object
47 void (*destroy
)(mgf1_bitspender_t
*this);
51 * Create a mgf1_bitspender_t object
53 * @param alg Hash algorithm to be used with MGF1
54 * @param seed Seed used to initialize MGF1
55 * @param hash_seed Hash seed before using it as a seed for MFG1
57 mgf1_bitspender_t
*mgf1_bitspender_create(hash_algorithm_t alg
, chunk_t seed
,
60 #endif /** MGF1_BITSPENDER_H_ @}*/