Streamlined DRBG and MGF1 debug output
[strongswan.git] / src / libstrongswan / plugins / ntru / ntru_drbg.h
1 /*
2 * Copyright (C) 2013 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup ntru_drbg ntru_drbg
18 * @{ @ingroup ntru_p
19 */
20
21 #ifndef NTRU_DRBG_H_
22 #define NTRU_DRBG_H_
23
24 typedef struct ntru_drbg_t ntru_drbg_t;
25
26 #include <library.h>
27
28 /**
29 * Implements a HMAC Deterministic Random Bit Generator (HMAC_DRBG)
30 * compliant with NIST SP 800-90A
31 */
32 struct ntru_drbg_t {
33
34 /**
35 * Reseed the instantiated DRBG
36 *
37 * @return configured security strength in bits
38 */
39 u_int32_t (*get_strength)(ntru_drbg_t *this);
40
41 /**
42 * Reseed the instantiated DRBG
43 *
44 * @return TRUE if successful
45 */
46 bool (*reseed)(ntru_drbg_t *this);
47
48 /**
49 * Generate pseudorandom bytes.
50 * If the maximum number of requests has been reached, reseeding occurs
51 *
52 * @param strength requested security strength in bits
53 * @param len number of octets to generate
54 * @param out address of output buffer
55 * @return TRUE if successful
56 */
57 bool (*generate)(ntru_drbg_t *this, u_int32_t strength, u_int32_t len,
58 u_int8_t *out);
59
60 /**
61 * Uninstantiate and destroy the DRBG object
62 */
63 void (*destroy)(ntru_drbg_t *this);
64 };
65
66 /**
67 * Create and instantiate a new DRBG objet.
68 *
69 * @param strength security strength in bits
70 * @param pers_str personalization string
71 * @param entropy entropy source to use
72 */
73 ntru_drbg_t *ntru_drbg_create(u_int32_t strength, chunk_t pers_str,
74 rng_t *entropy);
75
76 #endif /** NTRU_DRBG_H_ @}*/
77