2 * Copyright (C) 2016 Andreas Steffen
4 * Copyright (C) secunet Security Networks AG
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>.
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
18 * @defgroup newhope_noise newhope_noise
19 * @{ @ingroup newhope_p
22 #ifndef NEWHOPE_NOISE_H_
23 #define NEWHOPE_NOISE_H_
25 typedef struct newhope_noise_t newhope_noise_t
;
30 * Generate pseudo random noise using a ChaCha20 stream
31 * initialized with a 256 bit seed and an 8 bit nonce
33 struct newhope_noise_t
{
36 * Return n pseudo random bytes with a uniform distribution
38 * @param nonce Nonce determining the pseudo random stream
39 * @param n Number of pseudo random bytes to be returned
40 * @return Return array with n pseudo random bytes
42 uint8_t* (*get_uniform_bytes
)(newhope_noise_t
*this, uint8_t nonce
,
46 * Return n pseudo random 32-bit words with a Psi16 binomial distribution
48 * @param nonce Nonce determining the pseudo random stream
49 * @param n Number of pseudo random Psi16 words to be returned
50 * @param q Prime number q determining the ring
51 * @return Return array with n pseudo random 32 bit words
53 uint32_t* (*get_binomial_words
)(newhope_noise_t
*this, uint8_t nonce
,
54 uint16_t n
, uint16_t q
);
57 * Destroy a newhope_noise_t object
59 void (*destroy
)(newhope_noise_t
*this);
63 * Creates a new newhope_noise_t object.
65 * @param seed 256 bit seed (32 byte chunk)
66 * @return newhope_noise_t object, NULL if not supported
68 newhope_noise_t
*newhope_noise_create(chunk_t seed
);
70 #endif /** NEWHOPE_NOISE_H_ @}*/