]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/plugins/newhope/newhope_noise.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / plugins / newhope / newhope_noise.h
1 /*
2 * Copyright (C) 2016 Andreas Steffen
3 *
4 * Copyright (C) secunet Security Networks AG
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 /**
18 * @defgroup newhope_noise newhope_noise
19 * @{ @ingroup newhope_p
20 */
21
22 #ifndef NEWHOPE_NOISE_H_
23 #define NEWHOPE_NOISE_H_
24
25 typedef struct newhope_noise_t newhope_noise_t;
26
27 #include <library.h>
28
29 /**
30 * Generate pseudo random noise using a ChaCha20 stream
31 * initialized with a 256 bit seed and an 8 bit nonce
32 */
33 struct newhope_noise_t {
34
35 /**
36 * Return n pseudo random bytes with a uniform distribution
37 *
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
41 */
42 uint8_t* (*get_uniform_bytes)(newhope_noise_t *this, uint8_t nonce,
43 uint16_t n);
44
45 /**
46 * Return n pseudo random 32-bit words with a Psi16 binomial distribution
47 *
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
52 */
53 uint32_t* (*get_binomial_words)(newhope_noise_t *this, uint8_t nonce,
54 uint16_t n, uint16_t q);
55
56 /**
57 * Destroy a newhope_noise_t object
58 */
59 void (*destroy)(newhope_noise_t *this);
60 };
61
62 /**
63 * Creates a new newhope_noise_t object.
64 *
65 * @param seed 256 bit seed (32 byte chunk)
66 * @return newhope_noise_t object, NULL if not supported
67 */
68 newhope_noise_t *newhope_noise_create(chunk_t seed);
69
70 #endif /** NEWHOPE_NOISE_H_ @}*/
71