Annotation of embedaddon/strongswan/src/libstrongswan/plugins/ntru/ntru_poly.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2014-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 ntru_poly ntru_poly
                     18:  * @{ @ingroup ntru_p
                     19:  */
                     20: 
                     21: #ifndef NTRU_POLY_H_
                     22: #define NTRU_POLY_H_
                     23: 
                     24: typedef struct ntru_poly_t ntru_poly_t;
                     25: 
                     26: #include <library.h>
                     27: #include <crypto/xofs/xof.h>
                     28: 
                     29: /**
                     30:  * Implements a trinary polynomial storing the indices of non-zero coefficients
                     31:  */
                     32: struct ntru_poly_t {
                     33: 
                     34:        /**
                     35:         * Get the size of the indices array
                     36:         *
                     37:         * @return                      number of indices
                     38:         */
                     39:        size_t (*get_size)(ntru_poly_t *this);
                     40: 
                     41:        /**
                     42:         * @return                      array containing the indices of the non-zero coefficients
                     43:         */
                     44:        uint16_t* (*get_indices)(ntru_poly_t *this);
                     45: 
                     46:        /**
                     47:         * @param array         array containing all N coefficients of the polynomial
                     48:         */
                     49:        void (*get_array)(ntru_poly_t *this, uint16_t *array);
                     50: 
                     51:        /**
                     52:         * Multiply polynomial a with ntru_poly_t object b having sparse coefficients
                     53:         * to form result polynomial c = a * b
                     54:         *
                     55:         * @param a                     input polynomial a
                     56:         * @param b                     output polynomial c
                     57:         */
                     58:        void (*ring_mult)(ntru_poly_t *this, uint16_t *a, uint16_t *c);
                     59: 
                     60:        /**
                     61:         * Destroy ntru_poly_t object
                     62:         */
                     63:        void (*destroy)(ntru_poly_t *this);
                     64: };
                     65: 
                     66: /**
                     67:  * Create a trits polynomial from a seed using MGF1
                     68:  *
                     69:  * @param alg                          MGF1 algorithm used(XOF_MGF1_SHA1 or XOF_MGF_SHA256)
                     70:  * @param seed                         seed used by MGF1 to generate trits from
                     71:  * @param N                                    ring dimension, number of polynomial coefficients
                     72:  * @param q                                    large modulus
                     73:  * @param c_bits                       number of bits for candidate index
                     74:  * @param indices_len_p                number of indices for +1 coefficients
                     75:  * @param indices_len_m                number of indices for -1 coefficients
                     76:  * @param is_product_form      generate multiple polynomials
                     77:  */
                     78: ntru_poly_t *ntru_poly_create_from_seed(ext_out_function_t alg,        chunk_t seed,
                     79:                                                                                uint8_t c_bits, uint16_t N, uint16_t q,
                     80:                                                                                uint32_t indices_len_p,
                     81:                                                                                uint32_t indices_len_m,
                     82:                                                                                bool is_product_form);
                     83: 
                     84: /**
                     85:  * Create a trits polynomial from an array of indices of non-zero coefficients
                     86:  *
                     87:  * @param data                         array of indices of non-zero coefficients
                     88:  * @param N                                    ring dimension, number of polynomial coefficients
                     89:  * @param q                                    large modulus
                     90:  * @param indices_len_p                number of indices for +1 coefficients
                     91:  * @param indices_len_m                number of indices for -1 coefficients
                     92:  * @param is_product_form      generate multiple polynomials
                     93:  */
                     94: ntru_poly_t *ntru_poly_create_from_data(uint16_t *data, uint16_t N, uint16_t q,
                     95:                                                                                uint32_t indices_len_p,
                     96:                                                                                uint32_t indices_len_m,
                     97:                                                                                bool is_product_form);
                     98: 
                     99: #endif /** NTRU_POLY_H_ @}*/
                    100: 

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