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

1.1       misho       1: /*
                      2:  * Copyright (C) 2014 Andreas Steffen
                      3:  * HSR Hochschule fuer Technik Rapperswil
                      4:  *
                      5:  * Copyright (C) 2009-2013  Security Innovation
                      6:  *
                      7:  * This program is free software; you can redistribute it and/or modify it
                      8:  * under the terms of the GNU General Public License as published by the
                      9:  * Free Software Foundation; either version 2 of the License, or (at your
                     10:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
                     11:  *
                     12:  * This program is distributed in the hope that it will be useful, but
                     13:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     14:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
                     15:  * for more details.
                     16:  */
                     17: 
                     18: /**
                     19:  * @defgroup ntru_param_set ntru_param_set
                     20:  * @{ @ingroup ntru_p
                     21:  */
                     22: 
                     23: #ifndef NTRU_PARAM_SET_H_
                     24: #define NTRU_PARAM_SET_H_
                     25: 
                     26: typedef enum ntru_param_set_id_t ntru_param_set_id_t;
                     27: typedef struct ntru_param_set_t ntru_param_set_t;
                     28: 
                     29: #include <library.h>
                     30: 
                     31: /**
                     32:  * Encoding types for NTRU encryption public/private key blobs
                     33:  */
                     34: #define NTRU_PUBKEY_TAG           0x01
                     35: #define NTRU_PRIVKEY_DEFAULT_TAG  0x02
                     36: #define NTRU_PRIVKEY_TRITS_TAG    0xfe
                     37: #define NTRU_PRIVKEY_INDICES_TAG  0xff
                     38: 
                     39: /**
                     40:  * Size in octets of the OID designating the NTRU encryption parameter set
                     41:  */
                     42: #define NTRU_OID_LEN   3
                     43: 
                     44: /**
                     45:  * Packing types for NTRU encryption public/private keys
                     46:  */
                     47: #define NTRU_KEY_PACKED_COEFFICIENTS    0x01
                     48: #define NTRU_KEY_PACKED_INDICES         0x02
                     49: #define NTRU_KEY_PACKED_TRITS           0x03
                     50: 
                     51: /**
                     52:  * NTRU encryption parameter set ID list
                     53:  */
                     54: enum ntru_param_set_id_t {
                     55:        /* X9.98/IEEE 1363.1 parameter sets for best bandwidth (smallest size) */
                     56:        NTRU_EES401EP1,
                     57:        NTRU_EES449EP1,
                     58:        NTRU_EES677EP1,
                     59:        NTRU_EES1087EP2,
                     60:        /* X9.98/IEEE 1363.1 parameter sets balancing speed and bandwidth */
                     61:        NTRU_EES541EP1,
                     62:        NTRU_EES613EP1,
                     63:        NTRU_EES887EP1,
                     64:        NTRU_EES1171EP1,
                     65:        /* X9.98/IEEE 1363.1 parameter sets for best speed */
                     66:        NTRU_EES659EP1,
                     67:        NTRU_EES761EP1,
                     68:        NTRU_EES1087EP1,
                     69:        NTRU_EES1499EP1,
                     70:        /* Best bandwidth and speed, no X9.98 compatibility */
                     71:        NTRU_EES401EP2,
                     72:        NTRU_EES439EP1,
                     73:        NTRU_EES593EP1,
                     74:        NTRU_EES743EP1,
                     75: };
                     76: 
                     77: extern enum_name_t *ntru_param_set_id_names;
                     78: 
                     79: /**
                     80:  * NTRU encryption parameter set definitions
                     81:  */
                     82: struct ntru_param_set_t {
                     83: 
                     84:     /**
                     85:         * NTRU parameter set ID
                     86:         */
                     87:        const ntru_param_set_id_t id;
                     88: 
                     89:        /**
                     90:         * pointer to OID
                     91:         */
                     92:        const uint8_t oid[NTRU_OID_LEN];
                     93: 
                     94:        /**
                     95:         * parameter-set DER id
                     96:         */
                     97:        const uint8_t der_id;
                     98: 
                     99:        /**
                    100:         * no. of bits in N (i.e. in an index
                    101:         */
                    102:        const uint8_t N_bits;
                    103: 
                    104:        /**
                    105:         * ring dimension
                    106:         */
                    107:        const uint16_t N;
                    108: 
                    109:        /**
                    110:         * no. of octets of security strength
                    111:         */
                    112:        const uint16_t sec_strength_len;
                    113: 
                    114:        /**
                    115:         * big modulus
                    116:         */
                    117:        const uint16_t q;
                    118: 
                    119:        /**
                    120:         * no. of bits in q (i.e. in a coefficient)
                    121:         */
                    122:        const uint8_t q_bits;
                    123: 
                    124:        /**
                    125:         * if product form used
                    126:         */
                    127:        const bool is_product_form;
                    128: 
                    129:        /**
                    130:         * no. of +1 or -1 coefficients in ring elements F, r
                    131:         */
                    132:        const uint32_t dF_r;
                    133: 
                    134:        /**
                    135:         * no. - 1 of +1 coefficients or no. of -1 coefficients in ring element g
                    136:         */
                    137:        const uint16_t dg;
                    138: 
                    139:        /**
                    140:         * max no. of plaintext octets
                    141:         */
                    142:        const uint16_t m_len_max;
                    143: 
                    144:        /**
                    145:         * min. message representative weight
                    146:         */
                    147:        const uint16_t min_msg_rep_wt;
                    148: 
                    149:        /**
                    150:         * no. bits in candidate for deriving an index
                    151:         */
                    152:        const uint8_t  c_bits;
                    153: 
                    154:        /**
                    155:         * no. of octets to hold mLenOctets
                    156:         */
                    157:        const uint8_t  m_len_len;
                    158: };
                    159: 
                    160: /**
                    161:  * Get NTRU encryption parameter set by NTRU parameter set ID
                    162:  *
                    163:  * @param id   NTRU parameter set ID
                    164:  * @return             NTRU parameter set
                    165: */
                    166: const ntru_param_set_t* ntru_param_set_get_by_id(ntru_param_set_id_t id);
                    167: 
                    168: /**
                    169:  * Get NTRU encryption parameter set by NTRU parameter set OID
                    170:  *
                    171:  * @param oid  NTRU parameter set OID
                    172:  * @return             NTRU parameter set
                    173: */
                    174: const ntru_param_set_t* ntru_param_set_get_by_oid(uint8_t const *oid);
                    175: 
                    176: #endif /** NTRU_PARAM_SET_H_ @}*/

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