1 /* 2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #include <string.h> /* for memcpy() */ 11 #include <openssl/core_names.h> 12 #include <openssl/crypto.h> 13 #include "eckem.h" 14 15 typedef struct { 16 unsigned int id; 17 const char *mode; 18 } KEM_MODE; 19 20 static const KEM_MODE eckem_modename_id_map[] = { 21 { KEM_MODE_DHKEM, OSSL_KEM_PARAM_OPERATION_DHKEM }, 22 { 0, NULL } 23 }; 24 ossl_eckem_modename2id(const char * name)25int ossl_eckem_modename2id(const char *name) 26 { 27 size_t i; 28 29 if (name == NULL) 30 return KEM_MODE_UNDEFINED; 31 32 for (i = 0; eckem_modename_id_map[i].mode != NULL; ++i) { 33 if (OPENSSL_strcasecmp(name, eckem_modename_id_map[i].mode) == 0) 34 return eckem_modename_id_map[i].id; 35 } 36 return KEM_MODE_UNDEFINED; 37 } 38