1 // SPDX-License-Identifier: MIT
2 
3 #include <assert.h>
4 #include <stdlib.h>
5 #if defined(_WIN32)
6 #include <string.h>
7 #define strcasecmp _stricmp
8 #else
9 #include <strings.h>
10 #endif
11 
12 #include <oqs/oqs.h>
13 
OQS_KEM_alg_identifier(size_t i)14 OQS_API const char *OQS_KEM_alg_identifier(size_t i) {
15 	// EDIT-WHEN-ADDING-KEM
16 	const char *a[OQS_KEM_algs_length] = {
17 		OQS_KEM_alg_bike_l1,
18 		OQS_KEM_alg_bike_l3,
19 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALG_IDENTIFIER_START
20 		OQS_KEM_alg_classic_mceliece_348864,
21 		OQS_KEM_alg_classic_mceliece_348864f,
22 		OQS_KEM_alg_classic_mceliece_460896,
23 		OQS_KEM_alg_classic_mceliece_460896f,
24 		OQS_KEM_alg_classic_mceliece_6688128,
25 		OQS_KEM_alg_classic_mceliece_6688128f,
26 		OQS_KEM_alg_classic_mceliece_6960119,
27 		OQS_KEM_alg_classic_mceliece_6960119f,
28 		OQS_KEM_alg_classic_mceliece_8192128,
29 		OQS_KEM_alg_classic_mceliece_8192128f,
30 		OQS_KEM_alg_hqc_128,
31 		OQS_KEM_alg_hqc_192,
32 		OQS_KEM_alg_hqc_256,
33 		OQS_KEM_alg_kyber_512,
34 		OQS_KEM_alg_kyber_768,
35 		OQS_KEM_alg_kyber_1024,
36 		OQS_KEM_alg_kyber_512_90s,
37 		OQS_KEM_alg_kyber_768_90s,
38 		OQS_KEM_alg_kyber_1024_90s,
39 		OQS_KEM_alg_ntru_hps2048509,
40 		OQS_KEM_alg_ntru_hps2048677,
41 		OQS_KEM_alg_ntru_hps4096821,
42 		OQS_KEM_alg_ntru_hrss701,
43 		OQS_KEM_alg_ntruprime_ntrulpr653,
44 		OQS_KEM_alg_ntruprime_ntrulpr761,
45 		OQS_KEM_alg_ntruprime_ntrulpr857,
46 		OQS_KEM_alg_ntruprime_sntrup653,
47 		OQS_KEM_alg_ntruprime_sntrup761,
48 		OQS_KEM_alg_ntruprime_sntrup857,
49 		OQS_KEM_alg_saber_lightsaber,
50 		OQS_KEM_alg_saber_saber,
51 		OQS_KEM_alg_saber_firesaber,
52 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ALG_IDENTIFIER_END
53 		OQS_KEM_alg_frodokem_640_aes,
54 		OQS_KEM_alg_frodokem_640_shake,
55 		OQS_KEM_alg_frodokem_976_aes,
56 		OQS_KEM_alg_frodokem_976_shake,
57 		OQS_KEM_alg_frodokem_1344_aes,
58 		OQS_KEM_alg_frodokem_1344_shake,
59 		OQS_KEM_alg_sidh_p434,
60 		OQS_KEM_alg_sidh_p503,
61 		OQS_KEM_alg_sidh_p610,
62 		OQS_KEM_alg_sidh_p751,
63 		OQS_KEM_alg_sidh_p434_compressed,
64 		OQS_KEM_alg_sidh_p503_compressed,
65 		OQS_KEM_alg_sidh_p610_compressed,
66 		OQS_KEM_alg_sidh_p751_compressed,
67 		OQS_KEM_alg_sike_p434,
68 		OQS_KEM_alg_sike_p503,
69 		OQS_KEM_alg_sike_p610,
70 		OQS_KEM_alg_sike_p751,
71 		OQS_KEM_alg_sike_p434_compressed,
72 		OQS_KEM_alg_sike_p503_compressed,
73 		OQS_KEM_alg_sike_p610_compressed,
74 		OQS_KEM_alg_sike_p751_compressed,
75 	};
76 	if (i >= OQS_KEM_algs_length) {
77 		return NULL;
78 	} else {
79 		return a[i];
80 	}
81 }
82 
OQS_KEM_alg_count()83 OQS_API int OQS_KEM_alg_count() {
84 	return OQS_KEM_algs_length;
85 }
86 
OQS_KEM_alg_is_enabled(const char * method_name)87 OQS_API int OQS_KEM_alg_is_enabled(const char *method_name) {
88 	if (method_name == NULL) {
89 		return 0;
90 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike_l1)) {
91 #ifdef OQS_ENABLE_KEM_bike_l1
92 		return 1;
93 #else
94 		return 0;
95 #endif
96 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike_l3)) {
97 #ifdef OQS_ENABLE_KEM_bike_l3
98 		return 1;
99 #else
100 		return 0;
101 #endif
102 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ENABLED_CASE_START
103 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_348864)) {
104 #ifdef OQS_ENABLE_KEM_classic_mceliece_348864
105 		return 1;
106 #else
107 		return 0;
108 #endif
109 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_348864f)) {
110 #ifdef OQS_ENABLE_KEM_classic_mceliece_348864f
111 		return 1;
112 #else
113 		return 0;
114 #endif
115 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_460896)) {
116 #ifdef OQS_ENABLE_KEM_classic_mceliece_460896
117 		return 1;
118 #else
119 		return 0;
120 #endif
121 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_460896f)) {
122 #ifdef OQS_ENABLE_KEM_classic_mceliece_460896f
123 		return 1;
124 #else
125 		return 0;
126 #endif
127 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6688128)) {
128 #ifdef OQS_ENABLE_KEM_classic_mceliece_6688128
129 		return 1;
130 #else
131 		return 0;
132 #endif
133 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6688128f)) {
134 #ifdef OQS_ENABLE_KEM_classic_mceliece_6688128f
135 		return 1;
136 #else
137 		return 0;
138 #endif
139 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6960119)) {
140 #ifdef OQS_ENABLE_KEM_classic_mceliece_6960119
141 		return 1;
142 #else
143 		return 0;
144 #endif
145 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6960119f)) {
146 #ifdef OQS_ENABLE_KEM_classic_mceliece_6960119f
147 		return 1;
148 #else
149 		return 0;
150 #endif
151 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_8192128)) {
152 #ifdef OQS_ENABLE_KEM_classic_mceliece_8192128
153 		return 1;
154 #else
155 		return 0;
156 #endif
157 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_8192128f)) {
158 #ifdef OQS_ENABLE_KEM_classic_mceliece_8192128f
159 		return 1;
160 #else
161 		return 0;
162 #endif
163 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_128)) {
164 #ifdef OQS_ENABLE_KEM_hqc_128
165 		return 1;
166 #else
167 		return 0;
168 #endif
169 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_192)) {
170 #ifdef OQS_ENABLE_KEM_hqc_192
171 		return 1;
172 #else
173 		return 0;
174 #endif
175 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_256)) {
176 #ifdef OQS_ENABLE_KEM_hqc_256
177 		return 1;
178 #else
179 		return 0;
180 #endif
181 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_512)) {
182 #ifdef OQS_ENABLE_KEM_kyber_512
183 		return 1;
184 #else
185 		return 0;
186 #endif
187 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_768)) {
188 #ifdef OQS_ENABLE_KEM_kyber_768
189 		return 1;
190 #else
191 		return 0;
192 #endif
193 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_1024)) {
194 #ifdef OQS_ENABLE_KEM_kyber_1024
195 		return 1;
196 #else
197 		return 0;
198 #endif
199 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_512_90s)) {
200 #ifdef OQS_ENABLE_KEM_kyber_512_90s
201 		return 1;
202 #else
203 		return 0;
204 #endif
205 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_768_90s)) {
206 #ifdef OQS_ENABLE_KEM_kyber_768_90s
207 		return 1;
208 #else
209 		return 0;
210 #endif
211 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_1024_90s)) {
212 #ifdef OQS_ENABLE_KEM_kyber_1024_90s
213 		return 1;
214 #else
215 		return 0;
216 #endif
217 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048509)) {
218 #ifdef OQS_ENABLE_KEM_ntru_hps2048509
219 		return 1;
220 #else
221 		return 0;
222 #endif
223 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048677)) {
224 #ifdef OQS_ENABLE_KEM_ntru_hps2048677
225 		return 1;
226 #else
227 		return 0;
228 #endif
229 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps4096821)) {
230 #ifdef OQS_ENABLE_KEM_ntru_hps4096821
231 		return 1;
232 #else
233 		return 0;
234 #endif
235 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hrss701)) {
236 #ifdef OQS_ENABLE_KEM_ntru_hrss701
237 		return 1;
238 #else
239 		return 0;
240 #endif
241 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr653)) {
242 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr653
243 		return 1;
244 #else
245 		return 0;
246 #endif
247 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr761)) {
248 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr761
249 		return 1;
250 #else
251 		return 0;
252 #endif
253 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr857)) {
254 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr857
255 		return 1;
256 #else
257 		return 0;
258 #endif
259 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup653)) {
260 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup653
261 		return 1;
262 #else
263 		return 0;
264 #endif
265 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup761)) {
266 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup761
267 		return 1;
268 #else
269 		return 0;
270 #endif
271 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup857)) {
272 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup857
273 		return 1;
274 #else
275 		return 0;
276 #endif
277 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_lightsaber)) {
278 #ifdef OQS_ENABLE_KEM_saber_lightsaber
279 		return 1;
280 #else
281 		return 0;
282 #endif
283 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_saber)) {
284 #ifdef OQS_ENABLE_KEM_saber_saber
285 		return 1;
286 #else
287 		return 0;
288 #endif
289 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_firesaber)) {
290 #ifdef OQS_ENABLE_KEM_saber_firesaber
291 		return 1;
292 #else
293 		return 0;
294 #endif
295 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_ENABLED_CASE_END
296 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_aes)) {
297 #ifdef OQS_ENABLE_KEM_frodokem_640_aes
298 		return 1;
299 #else
300 		return 0;
301 #endif
302 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_shake)) {
303 #ifdef OQS_ENABLE_KEM_frodokem_640_shake
304 		return 1;
305 #else
306 		return 0;
307 #endif
308 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_aes)) {
309 #ifdef OQS_ENABLE_KEM_frodokem_976_aes
310 		return 1;
311 #else
312 		return 0;
313 #endif
314 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_shake)) {
315 #ifdef OQS_ENABLE_KEM_frodokem_976_shake
316 		return 1;
317 #else
318 		return 0;
319 #endif
320 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_aes)) {
321 #ifdef OQS_ENABLE_KEM_frodokem_1344_aes
322 		return 1;
323 #else
324 		return 0;
325 #endif
326 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_shake)) {
327 #ifdef OQS_ENABLE_KEM_frodokem_1344_shake
328 		return 1;
329 #else
330 		return 0;
331 #endif
332 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p434)) {
333 #ifdef OQS_ENABLE_KEM_sidh_p434
334 		return 1;
335 #else
336 		return 0;
337 #endif
338 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p503)) {
339 #ifdef OQS_ENABLE_KEM_sidh_p503
340 		return 1;
341 #else
342 		return 0;
343 #endif
344 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p610)) {
345 #ifdef OQS_ENABLE_KEM_sidh_p610
346 		return 1;
347 #else
348 		return 0;
349 #endif
350 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p751)) {
351 #ifdef OQS_ENABLE_KEM_sidh_p751
352 		return 1;
353 #else
354 		return 0;
355 #endif
356 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p434)) {
357 #ifdef OQS_ENABLE_KEM_sike_p434
358 		return 1;
359 #else
360 		return 0;
361 #endif
362 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p503)) {
363 #ifdef OQS_ENABLE_KEM_sike_p503
364 		return 1;
365 #else
366 		return 0;
367 #endif
368 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p610)) {
369 #ifdef OQS_ENABLE_KEM_sike_p610
370 		return 1;
371 #else
372 		return 0;
373 #endif
374 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p751)) {
375 #ifdef OQS_ENABLE_KEM_sike_p751
376 		return 1;
377 #else
378 		return 0;
379 #endif
380 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p434_compressed)) {
381 #ifdef OQS_ENABLE_KEM_sidh_p434_compressed
382 		return 1;
383 #else
384 		return 0;
385 #endif
386 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p503_compressed)) {
387 #ifdef OQS_ENABLE_KEM_sidh_p503_compressed
388 		return 1;
389 #else
390 		return 0;
391 #endif
392 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p610_compressed)) {
393 #ifdef OQS_ENABLE_KEM_sidh_p610_compressed
394 		return 1;
395 #else
396 		return 0;
397 #endif
398 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p751_compressed)) {
399 #ifdef OQS_ENABLE_KEM_sidh_p751_compressed
400 		return 1;
401 #else
402 		return 0;
403 #endif
404 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p434_compressed)) {
405 #ifdef OQS_ENABLE_KEM_sike_p434_compressed
406 		return 1;
407 #else
408 		return 0;
409 #endif
410 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p503_compressed)) {
411 #ifdef OQS_ENABLE_KEM_sike_p503_compressed
412 		return 1;
413 #else
414 		return 0;
415 #endif
416 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p610_compressed)) {
417 #ifdef OQS_ENABLE_KEM_sike_p610_compressed
418 		return 1;
419 #else
420 		return 0;
421 #endif
422 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p751_compressed)) {
423 #ifdef OQS_ENABLE_KEM_sike_p751_compressed
424 		return 1;
425 #else
426 		return 0;
427 #endif
428 		// EDIT-WHEN-ADDING-KEM
429 	} else {
430 		return 0;
431 	}
432 }
433 
OQS_KEM_new(const char * method_name)434 OQS_API OQS_KEM *OQS_KEM_new(const char *method_name) {
435 	if (method_name == NULL) {
436 		return NULL;
437 	}
438 	if (0 == strcasecmp(method_name, OQS_KEM_alg_bike_l1)) {
439 #ifdef OQS_ENABLE_KEM_bike_l1
440 		return OQS_KEM_bike_l1_new();
441 #else
442 		return NULL;
443 #endif
444 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_bike_l3)) {
445 #ifdef OQS_ENABLE_KEM_bike_l3
446 		return OQS_KEM_bike_l3_new();
447 #else
448 		return NULL;
449 #endif
450 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_NEW_CASE_START
451 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_348864)) {
452 #ifdef OQS_ENABLE_KEM_classic_mceliece_348864
453 		return OQS_KEM_classic_mceliece_348864_new();
454 #else
455 		return NULL;
456 #endif
457 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_348864f)) {
458 #ifdef OQS_ENABLE_KEM_classic_mceliece_348864f
459 		return OQS_KEM_classic_mceliece_348864f_new();
460 #else
461 		return NULL;
462 #endif
463 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_460896)) {
464 #ifdef OQS_ENABLE_KEM_classic_mceliece_460896
465 		return OQS_KEM_classic_mceliece_460896_new();
466 #else
467 		return NULL;
468 #endif
469 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_460896f)) {
470 #ifdef OQS_ENABLE_KEM_classic_mceliece_460896f
471 		return OQS_KEM_classic_mceliece_460896f_new();
472 #else
473 		return NULL;
474 #endif
475 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6688128)) {
476 #ifdef OQS_ENABLE_KEM_classic_mceliece_6688128
477 		return OQS_KEM_classic_mceliece_6688128_new();
478 #else
479 		return NULL;
480 #endif
481 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6688128f)) {
482 #ifdef OQS_ENABLE_KEM_classic_mceliece_6688128f
483 		return OQS_KEM_classic_mceliece_6688128f_new();
484 #else
485 		return NULL;
486 #endif
487 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6960119)) {
488 #ifdef OQS_ENABLE_KEM_classic_mceliece_6960119
489 		return OQS_KEM_classic_mceliece_6960119_new();
490 #else
491 		return NULL;
492 #endif
493 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_6960119f)) {
494 #ifdef OQS_ENABLE_KEM_classic_mceliece_6960119f
495 		return OQS_KEM_classic_mceliece_6960119f_new();
496 #else
497 		return NULL;
498 #endif
499 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_8192128)) {
500 #ifdef OQS_ENABLE_KEM_classic_mceliece_8192128
501 		return OQS_KEM_classic_mceliece_8192128_new();
502 #else
503 		return NULL;
504 #endif
505 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_classic_mceliece_8192128f)) {
506 #ifdef OQS_ENABLE_KEM_classic_mceliece_8192128f
507 		return OQS_KEM_classic_mceliece_8192128f_new();
508 #else
509 		return NULL;
510 #endif
511 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_128)) {
512 #ifdef OQS_ENABLE_KEM_hqc_128
513 		return OQS_KEM_hqc_128_new();
514 #else
515 		return NULL;
516 #endif
517 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_192)) {
518 #ifdef OQS_ENABLE_KEM_hqc_192
519 		return OQS_KEM_hqc_192_new();
520 #else
521 		return NULL;
522 #endif
523 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_hqc_256)) {
524 #ifdef OQS_ENABLE_KEM_hqc_256
525 		return OQS_KEM_hqc_256_new();
526 #else
527 		return NULL;
528 #endif
529 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_512)) {
530 #ifdef OQS_ENABLE_KEM_kyber_512
531 		return OQS_KEM_kyber_512_new();
532 #else
533 		return NULL;
534 #endif
535 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_768)) {
536 #ifdef OQS_ENABLE_KEM_kyber_768
537 		return OQS_KEM_kyber_768_new();
538 #else
539 		return NULL;
540 #endif
541 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_1024)) {
542 #ifdef OQS_ENABLE_KEM_kyber_1024
543 		return OQS_KEM_kyber_1024_new();
544 #else
545 		return NULL;
546 #endif
547 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_512_90s)) {
548 #ifdef OQS_ENABLE_KEM_kyber_512_90s
549 		return OQS_KEM_kyber_512_90s_new();
550 #else
551 		return NULL;
552 #endif
553 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_768_90s)) {
554 #ifdef OQS_ENABLE_KEM_kyber_768_90s
555 		return OQS_KEM_kyber_768_90s_new();
556 #else
557 		return NULL;
558 #endif
559 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_kyber_1024_90s)) {
560 #ifdef OQS_ENABLE_KEM_kyber_1024_90s
561 		return OQS_KEM_kyber_1024_90s_new();
562 #else
563 		return NULL;
564 #endif
565 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048509)) {
566 #ifdef OQS_ENABLE_KEM_ntru_hps2048509
567 		return OQS_KEM_ntru_hps2048509_new();
568 #else
569 		return NULL;
570 #endif
571 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps2048677)) {
572 #ifdef OQS_ENABLE_KEM_ntru_hps2048677
573 		return OQS_KEM_ntru_hps2048677_new();
574 #else
575 		return NULL;
576 #endif
577 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hps4096821)) {
578 #ifdef OQS_ENABLE_KEM_ntru_hps4096821
579 		return OQS_KEM_ntru_hps4096821_new();
580 #else
581 		return NULL;
582 #endif
583 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntru_hrss701)) {
584 #ifdef OQS_ENABLE_KEM_ntru_hrss701
585 		return OQS_KEM_ntru_hrss701_new();
586 #else
587 		return NULL;
588 #endif
589 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr653)) {
590 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr653
591 		return OQS_KEM_ntruprime_ntrulpr653_new();
592 #else
593 		return NULL;
594 #endif
595 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr761)) {
596 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr761
597 		return OQS_KEM_ntruprime_ntrulpr761_new();
598 #else
599 		return NULL;
600 #endif
601 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_ntrulpr857)) {
602 #ifdef OQS_ENABLE_KEM_ntruprime_ntrulpr857
603 		return OQS_KEM_ntruprime_ntrulpr857_new();
604 #else
605 		return NULL;
606 #endif
607 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup653)) {
608 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup653
609 		return OQS_KEM_ntruprime_sntrup653_new();
610 #else
611 		return NULL;
612 #endif
613 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup761)) {
614 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup761
615 		return OQS_KEM_ntruprime_sntrup761_new();
616 #else
617 		return NULL;
618 #endif
619 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_ntruprime_sntrup857)) {
620 #ifdef OQS_ENABLE_KEM_ntruprime_sntrup857
621 		return OQS_KEM_ntruprime_sntrup857_new();
622 #else
623 		return NULL;
624 #endif
625 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_lightsaber)) {
626 #ifdef OQS_ENABLE_KEM_saber_lightsaber
627 		return OQS_KEM_saber_lightsaber_new();
628 #else
629 		return NULL;
630 #endif
631 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_saber)) {
632 #ifdef OQS_ENABLE_KEM_saber_saber
633 		return OQS_KEM_saber_saber_new();
634 #else
635 		return NULL;
636 #endif
637 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_saber_firesaber)) {
638 #ifdef OQS_ENABLE_KEM_saber_firesaber
639 		return OQS_KEM_saber_firesaber_new();
640 #else
641 		return NULL;
642 #endif
643 		///// OQS_COPY_FROM_UPSTREAM_FRAGMENT_NEW_CASE_END
644 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_aes)) {
645 #ifdef OQS_ENABLE_KEM_frodokem_640_aes
646 		return OQS_KEM_frodokem_640_aes_new();
647 #else
648 		return NULL;
649 #endif
650 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_640_shake)) {
651 #ifdef OQS_ENABLE_KEM_frodokem_640_shake
652 		return OQS_KEM_frodokem_640_shake_new();
653 #else
654 		return NULL;
655 #endif
656 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_aes)) {
657 #ifdef OQS_ENABLE_KEM_frodokem_976_aes
658 		return OQS_KEM_frodokem_976_aes_new();
659 #else
660 		return NULL;
661 #endif
662 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_976_shake)) {
663 #ifdef OQS_ENABLE_KEM_frodokem_976_shake
664 		return OQS_KEM_frodokem_976_shake_new();
665 #else
666 		return NULL;
667 #endif
668 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_aes)) {
669 #ifdef OQS_ENABLE_KEM_frodokem_1344_aes
670 		return OQS_KEM_frodokem_1344_aes_new();
671 #else
672 		return NULL;
673 #endif
674 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_frodokem_1344_shake)) {
675 #ifdef OQS_ENABLE_KEM_frodokem_1344_shake
676 		return OQS_KEM_frodokem_1344_shake_new();
677 #else
678 		return NULL;
679 #endif
680 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p434)) {
681 #ifdef OQS_ENABLE_KEM_sidh_p434
682 		return OQS_KEM_sidh_p434_new();
683 #else
684 		return NULL;
685 #endif
686 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p503)) {
687 #ifdef OQS_ENABLE_KEM_sidh_p503
688 		return OQS_KEM_sidh_p503_new();
689 #else
690 		return NULL;
691 #endif
692 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p610)) {
693 #ifdef OQS_ENABLE_KEM_sidh_p610
694 		return OQS_KEM_sidh_p610_new();
695 #else
696 		return NULL;
697 #endif
698 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p751)) {
699 #ifdef OQS_ENABLE_KEM_sidh_p751
700 		return OQS_KEM_sidh_p751_new();
701 #else
702 		return NULL;
703 #endif
704 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p434)) {
705 #ifdef OQS_ENABLE_KEM_sike_p434
706 		return OQS_KEM_sike_p434_new();
707 #else
708 		return NULL;
709 #endif
710 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p503)) {
711 #ifdef OQS_ENABLE_KEM_sike_p503
712 		return OQS_KEM_sike_p503_new();
713 #else
714 		return NULL;
715 #endif
716 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p610)) {
717 #ifdef OQS_ENABLE_KEM_sike_p610
718 		return OQS_KEM_sike_p610_new();
719 #else
720 		return NULL;
721 #endif
722 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p751)) {
723 #ifdef OQS_ENABLE_KEM_sike_p751
724 		return OQS_KEM_sike_p751_new();
725 #else
726 		return NULL;
727 #endif
728 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p434_compressed)) {
729 #ifdef OQS_ENABLE_KEM_sidh_p434_compressed
730 		return OQS_KEM_sidh_p434_compressed_new();
731 #else
732 		return NULL;
733 #endif
734 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p503_compressed)) {
735 #ifdef OQS_ENABLE_KEM_sidh_p503_compressed
736 		return OQS_KEM_sidh_p503_compressed_new();
737 #else
738 		return NULL;
739 #endif
740 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p610_compressed)) {
741 #ifdef OQS_ENABLE_KEM_sidh_p610_compressed
742 		return OQS_KEM_sidh_p610_compressed_new();
743 #else
744 		return NULL;
745 #endif
746 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sidh_p751_compressed)) {
747 #ifdef OQS_ENABLE_KEM_sidh_p751_compressed
748 		return OQS_KEM_sidh_p751_compressed_new();
749 #else
750 		return NULL;
751 #endif
752 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p434_compressed)) {
753 #ifdef OQS_ENABLE_KEM_sike_p434_compressed
754 		return OQS_KEM_sike_p434_compressed_new();
755 #else
756 		return NULL;
757 #endif
758 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p503_compressed)) {
759 #ifdef OQS_ENABLE_KEM_sike_p503_compressed
760 		return OQS_KEM_sike_p503_compressed_new();
761 #else
762 		return NULL;
763 #endif
764 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p610_compressed)) {
765 #ifdef OQS_ENABLE_KEM_sike_p610_compressed
766 		return OQS_KEM_sike_p610_compressed_new();
767 #else
768 		return NULL;
769 #endif
770 	} else if (0 == strcasecmp(method_name, OQS_KEM_alg_sike_p751_compressed)) {
771 #ifdef OQS_ENABLE_KEM_sike_p751_compressed
772 		return OQS_KEM_sike_p751_compressed_new();
773 #else
774 		return NULL;
775 #endif
776 		// EDIT-WHEN-ADDING-KEM
777 	} else {
778 		return NULL;
779 	}
780 }
781 
OQS_KEM_keypair(const OQS_KEM * kem,uint8_t * public_key,uint8_t * secret_key)782 OQS_API OQS_STATUS OQS_KEM_keypair(const OQS_KEM *kem, uint8_t *public_key, uint8_t *secret_key) {
783 	if (kem == NULL) {
784 		return OQS_ERROR;
785 	} else {
786 		return kem->keypair(public_key, secret_key);
787 	}
788 }
789 
OQS_KEM_encaps(const OQS_KEM * kem,uint8_t * ciphertext,uint8_t * shared_secret,const uint8_t * public_key)790 OQS_API OQS_STATUS OQS_KEM_encaps(const OQS_KEM *kem, uint8_t *ciphertext, uint8_t *shared_secret, const uint8_t *public_key) {
791 	if (kem == NULL) {
792 		return OQS_ERROR;
793 	} else {
794 		return kem->encaps(ciphertext, shared_secret, public_key);
795 	}
796 }
797 
OQS_KEM_decaps(const OQS_KEM * kem,uint8_t * shared_secret,const uint8_t * ciphertext,const uint8_t * secret_key)798 OQS_API OQS_STATUS OQS_KEM_decaps(const OQS_KEM *kem, uint8_t *shared_secret, const uint8_t *ciphertext, const uint8_t *secret_key) {
799 	if (kem == NULL) {
800 		return OQS_ERROR;
801 	} else {
802 		return kem->decaps(shared_secret, ciphertext, secret_key);
803 	}
804 }
805 
OQS_KEM_free(OQS_KEM * kem)806 OQS_API void OQS_KEM_free(OQS_KEM *kem) {
807 	OQS_MEM_insecure_free(kem);
808 }
809