Annotation of embedaddon/strongswan/src/libstrongswan/plugins/newhope/newhope_noise.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2016 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 newhope_noise newhope_noise
                     18:  * @{ @ingroup newhope_p
                     19:  */
                     20: 
                     21: #ifndef NEWHOPE_NOISE_H_
                     22: #define NEWHOPE_NOISE_H_
                     23: 
                     24: typedef struct newhope_noise_t newhope_noise_t;
                     25: 
                     26: #include <library.h>
                     27: 
                     28: /**
                     29:  * Generate pseudo random noise using a ChaCha20 stream
                     30:  * initialized with a 256 bit seed and an 8 bit nonce
                     31:  */
                     32: struct newhope_noise_t {
                     33: 
                     34:        /**
                     35:         * Return n pseudo random bytes with a uniform distribution
                     36:         *
                     37:         * @param nonce         Nonce determining the pseudo random stream
                     38:         * @param n                     Number of pseudo random bytes to be returned
                     39:         * @return                      Return array with n pseudo random bytes
                     40:         */
                     41:        uint8_t* (*get_uniform_bytes)(newhope_noise_t *this, uint8_t nonce,
                     42:                                                                  uint16_t n);
                     43: 
                     44:        /**
                     45:         * Return n pseudo random 32-bit words with a Psi16 binomial distribution
                     46:         *
                     47:         * @param nonce         Nonce determining the pseudo random stream
                     48:         * @param n                     Number of pseudo random Psi16 words to be returned
                     49:         * @param q                     Prime number q determining the ring
                     50:         * @return                      Return array with n pseudo random 32 bit words
                     51:         */
                     52:        uint32_t* (*get_binomial_words)(newhope_noise_t *this, uint8_t nonce,
                     53:                                                                        uint16_t n, uint16_t q);
                     54: 
                     55:        /**
                     56:         * Destroy a newhope_noise_t object
                     57:         */
                     58:        void (*destroy)(newhope_noise_t *this);
                     59: };
                     60: 
                     61: /**
                     62:  * Creates a new newhope_noise_t object.
                     63:  *
                     64:  * @param seed                 256 bit seed (32 byte chunk)
                     65:  * @return                             newhope_noise_t object, NULL if not supported
                     66:  */
                     67: newhope_noise_t *newhope_noise_create(chunk_t seed);
                     68: 
                     69: #endif /** NEWHOPE_NOISE_H_ @}*/
                     70: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>