2 * Copyright (C) 2014 Andreas Steffen
4 * Copyright (C) 2009-2013 Security Innovation
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 ntru_param_set ntru_param_set
22 #ifndef NTRU_PARAM_SET_H_
23 #define NTRU_PARAM_SET_H_
25 typedef enum ntru_param_set_id_t ntru_param_set_id_t
;
26 typedef struct ntru_param_set_t ntru_param_set_t
;
31 * Encoding types for NTRU encryption public/private key blobs
33 #define NTRU_PUBKEY_TAG 0x01
34 #define NTRU_PRIVKEY_DEFAULT_TAG 0x02
35 #define NTRU_PRIVKEY_TRITS_TAG 0xfe
36 #define NTRU_PRIVKEY_INDICES_TAG 0xff
39 * Size in octets of the OID designating the NTRU encryption parameter set
41 #define NTRU_OID_LEN 3
44 * Packing types for NTRU encryption public/private keys
46 #define NTRU_KEY_PACKED_COEFFICIENTS 0x01
47 #define NTRU_KEY_PACKED_INDICES 0x02
48 #define NTRU_KEY_PACKED_TRITS 0x03
51 * NTRU encryption parameter set ID list
53 enum ntru_param_set_id_t
{
54 /* X9.98/IEEE 1363.1 parameter sets for best bandwidth (smallest size) */
59 /* X9.98/IEEE 1363.1 parameter sets balancing speed and bandwidth */
64 /* X9.98/IEEE 1363.1 parameter sets for best speed */
69 /* Best bandwidth and speed, no X9.98 compatibility */
76 extern enum_name_t
*ntru_param_set_id_names
;
79 * NTRU encryption parameter set definitions
81 struct ntru_param_set_t
{
84 * NTRU parameter set ID
86 const ntru_param_set_id_t id
;
91 const uint8_t oid
[NTRU_OID_LEN
];
94 * parameter-set DER id
99 * no. of bits in N (i.e. in an index
101 const uint8_t N_bits
;
109 * no. of octets of security strength
111 const uint16_t sec_strength_len
;
119 * no. of bits in q (i.e. in a coefficient)
121 const uint8_t q_bits
;
124 * if product form used
126 const bool is_product_form
;
129 * no. of +1 or -1 coefficients in ring elements F, r
134 * no. - 1 of +1 coefficients or no. of -1 coefficients in ring element g
139 * max no. of plaintext octets
141 const uint16_t m_len_max
;
144 * min. message representative weight
146 const uint16_t min_msg_rep_wt
;
149 * no. bits in candidate for deriving an index
151 const uint8_t c_bits
;
154 * no. of octets to hold mLenOctets
156 const uint8_t m_len_len
;
160 * Get NTRU encryption parameter set by NTRU parameter set ID
162 * @param id NTRU parameter set ID
163 * @return NTRU parameter set
165 const ntru_param_set_t
* ntru_param_set_get_by_id(ntru_param_set_id_t id
);
168 * Get NTRU encryption parameter set by NTRU parameter set OID
170 * @param oid NTRU parameter set OID
171 * @return NTRU parameter set
173 const ntru_param_set_t
* ntru_param_set_get_by_oid(uint8_t const *oid
);
175 #endif /** NTRU_PARAM_SET_H_ @}*/