]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/plugins/ntru/ntru_param_set.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / plugins / ntru / ntru_param_set.h
1 /*
2 * Copyright (C) 2014 Andreas Steffen
3 *
4 * Copyright (C) 2009-2013 Security Innovation
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 ntru_param_set ntru_param_set
19 * @{ @ingroup ntru_p
20 */
21
22 #ifndef NTRU_PARAM_SET_H_
23 #define NTRU_PARAM_SET_H_
24
25 typedef enum ntru_param_set_id_t ntru_param_set_id_t;
26 typedef struct ntru_param_set_t ntru_param_set_t;
27
28 #include <library.h>
29
30 /**
31 * Encoding types for NTRU encryption public/private key blobs
32 */
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
37
38 /**
39 * Size in octets of the OID designating the NTRU encryption parameter set
40 */
41 #define NTRU_OID_LEN 3
42
43 /**
44 * Packing types for NTRU encryption public/private keys
45 */
46 #define NTRU_KEY_PACKED_COEFFICIENTS 0x01
47 #define NTRU_KEY_PACKED_INDICES 0x02
48 #define NTRU_KEY_PACKED_TRITS 0x03
49
50 /**
51 * NTRU encryption parameter set ID list
52 */
53 enum ntru_param_set_id_t {
54 /* X9.98/IEEE 1363.1 parameter sets for best bandwidth (smallest size) */
55 NTRU_EES401EP1,
56 NTRU_EES449EP1,
57 NTRU_EES677EP1,
58 NTRU_EES1087EP2,
59 /* X9.98/IEEE 1363.1 parameter sets balancing speed and bandwidth */
60 NTRU_EES541EP1,
61 NTRU_EES613EP1,
62 NTRU_EES887EP1,
63 NTRU_EES1171EP1,
64 /* X9.98/IEEE 1363.1 parameter sets for best speed */
65 NTRU_EES659EP1,
66 NTRU_EES761EP1,
67 NTRU_EES1087EP1,
68 NTRU_EES1499EP1,
69 /* Best bandwidth and speed, no X9.98 compatibility */
70 NTRU_EES401EP2,
71 NTRU_EES439EP1,
72 NTRU_EES593EP1,
73 NTRU_EES743EP1,
74 };
75
76 extern enum_name_t *ntru_param_set_id_names;
77
78 /**
79 * NTRU encryption parameter set definitions
80 */
81 struct ntru_param_set_t {
82
83 /**
84 * NTRU parameter set ID
85 */
86 const ntru_param_set_id_t id;
87
88 /**
89 * pointer to OID
90 */
91 const uint8_t oid[NTRU_OID_LEN];
92
93 /**
94 * parameter-set DER id
95 */
96 const uint8_t der_id;
97
98 /**
99 * no. of bits in N (i.e. in an index
100 */
101 const uint8_t N_bits;
102
103 /**
104 * ring dimension
105 */
106 const uint16_t N;
107
108 /**
109 * no. of octets of security strength
110 */
111 const uint16_t sec_strength_len;
112
113 /**
114 * big modulus
115 */
116 const uint16_t q;
117
118 /**
119 * no. of bits in q (i.e. in a coefficient)
120 */
121 const uint8_t q_bits;
122
123 /**
124 * if product form used
125 */
126 const bool is_product_form;
127
128 /**
129 * no. of +1 or -1 coefficients in ring elements F, r
130 */
131 const uint32_t dF_r;
132
133 /**
134 * no. - 1 of +1 coefficients or no. of -1 coefficients in ring element g
135 */
136 const uint16_t dg;
137
138 /**
139 * max no. of plaintext octets
140 */
141 const uint16_t m_len_max;
142
143 /**
144 * min. message representative weight
145 */
146 const uint16_t min_msg_rep_wt;
147
148 /**
149 * no. bits in candidate for deriving an index
150 */
151 const uint8_t c_bits;
152
153 /**
154 * no. of octets to hold mLenOctets
155 */
156 const uint8_t m_len_len;
157 };
158
159 /**
160 * Get NTRU encryption parameter set by NTRU parameter set ID
161 *
162 * @param id NTRU parameter set ID
163 * @return NTRU parameter set
164 */
165 const ntru_param_set_t* ntru_param_set_get_by_id(ntru_param_set_id_t id);
166
167 /**
168 * Get NTRU encryption parameter set by NTRU parameter set OID
169 *
170 * @param oid NTRU parameter set OID
171 * @return NTRU parameter set
172 */
173 const ntru_param_set_t* ntru_param_set_get_by_oid(uint8_t const *oid);
174
175 #endif /** NTRU_PARAM_SET_H_ @}*/