evp_fetch.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * Copyright 2019-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. #include <stddef.h>
  10. #include <openssl/types.h>
  11. #include <openssl/evp.h>
  12. #include <openssl/core.h>
  13. #include "internal/cryptlib.h"
  14. #include "internal/thread_once.h"
  15. #include "internal/property.h"
  16. #include "internal/core.h"
  17. #include "internal/provider.h"
  18. #include "internal/namemap.h"
  19. #include "crypto/evp.h" /* evp_local.h needs it */
  20. #include "evp_local.h"
  21. #define NAME_SEPARATOR ':'
  22. /* Data to be passed through ossl_method_construct() */
  23. struct evp_method_data_st {
  24. OSSL_LIB_CTX *libctx;
  25. int operation_id; /* For get_evp_method_from_store() */
  26. int name_id; /* For get_evp_method_from_store() */
  27. const char *names; /* For get_evp_method_from_store() */
  28. const char *propquery; /* For get_evp_method_from_store() */
  29. OSSL_METHOD_STORE *tmp_store; /* For get_tmp_evp_method_store() */
  30. unsigned int flag_construct_error_occurred : 1;
  31. void *(*method_from_algorithm)(int name_id, const OSSL_ALGORITHM *,
  32. OSSL_PROVIDER *);
  33. int (*refcnt_up_method)(void *method);
  34. void (*destruct_method)(void *method);
  35. };
  36. /*
  37. * Generic routines to fetch / create EVP methods with ossl_method_construct()
  38. */
  39. static void *get_tmp_evp_method_store(void *data)
  40. {
  41. struct evp_method_data_st *methdata = data;
  42. if (methdata->tmp_store == NULL)
  43. methdata->tmp_store = ossl_method_store_new(methdata->libctx);
  44. return methdata->tmp_store;
  45. }
  46. static void dealloc_tmp_evp_method_store(void *store)
  47. {
  48. if (store != NULL)
  49. ossl_method_store_free(store);
  50. }
  51. static OSSL_METHOD_STORE *get_evp_method_store(OSSL_LIB_CTX *libctx)
  52. {
  53. return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_EVP_METHOD_STORE_INDEX);
  54. }
  55. /*
  56. * To identify the method in the EVP method store, we mix the name identity
  57. * with the operation identity, under the assumption that we don't have more
  58. * than 2^23 names or more than 2^8 operation types.
  59. *
  60. * The resulting identity is a 31-bit integer, composed like this:
  61. *
  62. * +---------23 bits--------+-8 bits-+
  63. * | name identity | op id |
  64. * +------------------------+--------+
  65. *
  66. * We limit this composite number to 31 bits, thus leaving the top uint32_t
  67. * bit always zero, to avoid negative sign extension when downshifting after
  68. * this number happens to be passed to an int (which happens as soon as it's
  69. * passed to ossl_method_store_cache_set(), and it's in that form that it
  70. * gets passed along to filter_on_operation_id(), defined further down.
  71. */
  72. #define METHOD_ID_OPERATION_MASK 0x000000FF
  73. #define METHOD_ID_OPERATION_MAX ((1 << 8) - 1)
  74. #define METHOD_ID_NAME_MASK 0x7FFFFF00
  75. #define METHOD_ID_NAME_OFFSET 8
  76. #define METHOD_ID_NAME_MAX ((1 << 23) - 1)
  77. static uint32_t evp_method_id(int name_id, unsigned int operation_id)
  78. {
  79. if (!ossl_assert(name_id > 0 && name_id <= METHOD_ID_NAME_MAX)
  80. || !ossl_assert(operation_id > 0
  81. && operation_id <= METHOD_ID_OPERATION_MAX))
  82. return 0;
  83. return (((name_id << METHOD_ID_NAME_OFFSET) & METHOD_ID_NAME_MASK)
  84. | (operation_id & METHOD_ID_OPERATION_MASK));
  85. }
  86. static void *get_evp_method_from_store(void *store, const OSSL_PROVIDER **prov,
  87. void *data)
  88. {
  89. struct evp_method_data_st *methdata = data;
  90. void *method = NULL;
  91. int name_id;
  92. uint32_t meth_id;
  93. /*
  94. * get_evp_method_from_store() is only called to try and get the method
  95. * that evp_generic_fetch() is asking for, and the operation id as well
  96. * as the name or name id are passed via methdata.
  97. */
  98. if ((name_id = methdata->name_id) == 0 && methdata->names != NULL) {
  99. OSSL_NAMEMAP *namemap = ossl_namemap_stored(methdata->libctx);
  100. const char *names = methdata->names;
  101. const char *q = strchr(names, NAME_SEPARATOR);
  102. size_t l = (q == NULL ? strlen(names) : (size_t)(q - names));
  103. if (namemap == 0)
  104. return NULL;
  105. name_id = ossl_namemap_name2num_n(namemap, names, l);
  106. }
  107. if (name_id == 0
  108. || (meth_id = evp_method_id(name_id, methdata->operation_id)) == 0)
  109. return NULL;
  110. if (store == NULL
  111. && (store = get_evp_method_store(methdata->libctx)) == NULL)
  112. return NULL;
  113. if (!ossl_method_store_fetch(store, meth_id, methdata->propquery, prov,
  114. &method))
  115. return NULL;
  116. return method;
  117. }
  118. static int put_evp_method_in_store(void *store, void *method,
  119. const OSSL_PROVIDER *prov,
  120. const char *names, const char *propdef,
  121. void *data)
  122. {
  123. struct evp_method_data_st *methdata = data;
  124. OSSL_NAMEMAP *namemap;
  125. int name_id;
  126. uint32_t meth_id;
  127. size_t l = 0;
  128. /*
  129. * put_evp_method_in_store() is only called with an EVP method that was
  130. * successfully created by construct_method() below, which means that
  131. * all the names should already be stored in the namemap with the same
  132. * numeric identity, so just use the first to get that identity.
  133. */
  134. if (names != NULL) {
  135. const char *q = strchr(names, NAME_SEPARATOR);
  136. l = (q == NULL ? strlen(names) : (size_t)(q - names));
  137. }
  138. if ((namemap = ossl_namemap_stored(methdata->libctx)) == NULL
  139. || (name_id = ossl_namemap_name2num_n(namemap, names, l)) == 0
  140. || (meth_id = evp_method_id(name_id, methdata->operation_id)) == 0)
  141. return 0;
  142. if (store == NULL
  143. && (store = get_evp_method_store(methdata->libctx)) == NULL)
  144. return 0;
  145. return ossl_method_store_add(store, prov, meth_id, propdef, method,
  146. methdata->refcnt_up_method,
  147. methdata->destruct_method);
  148. }
  149. /*
  150. * The core fetching functionality passes the name of the implementation.
  151. * This function is responsible to getting an identity number for it.
  152. */
  153. static void *construct_evp_method(const OSSL_ALGORITHM *algodef,
  154. OSSL_PROVIDER *prov, void *data)
  155. {
  156. /*
  157. * This function is only called if get_evp_method_from_store() returned
  158. * NULL, so it's safe to say that of all the spots to create a new
  159. * namemap entry, this is it. Should the name already exist there, we
  160. * know that ossl_namemap_add_name() will return its corresponding
  161. * number.
  162. */
  163. struct evp_method_data_st *methdata = data;
  164. OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
  165. OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
  166. const char *names = algodef->algorithm_names;
  167. int name_id = ossl_namemap_add_names(namemap, 0, names, NAME_SEPARATOR);
  168. void *method;
  169. if (name_id == 0)
  170. return NULL;
  171. method = methdata->method_from_algorithm(name_id, algodef, prov);
  172. /*
  173. * Flag to indicate that there was actual construction errors. This
  174. * helps inner_evp_generic_fetch() determine what error it should
  175. * record on inaccessible algorithms.
  176. */
  177. if (method == NULL)
  178. methdata->flag_construct_error_occurred = 1;
  179. return method;
  180. }
  181. static void destruct_evp_method(void *method, void *data)
  182. {
  183. struct evp_method_data_st *methdata = data;
  184. methdata->destruct_method(method);
  185. }
  186. static void *
  187. inner_evp_generic_fetch(struct evp_method_data_st *methdata,
  188. OSSL_PROVIDER *prov, int operation_id,
  189. const char *name, const char *properties,
  190. void *(*new_method)(int name_id,
  191. const OSSL_ALGORITHM *algodef,
  192. OSSL_PROVIDER *prov),
  193. int (*up_ref_method)(void *),
  194. void (*free_method)(void *))
  195. {
  196. OSSL_METHOD_STORE *store = get_evp_method_store(methdata->libctx);
  197. OSSL_NAMEMAP *namemap = ossl_namemap_stored(methdata->libctx);
  198. const char *const propq = properties != NULL ? properties : "";
  199. uint32_t meth_id = 0;
  200. void *method = NULL;
  201. int unsupported, name_id;
  202. if (store == NULL || namemap == NULL) {
  203. ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_INVALID_ARGUMENT);
  204. return NULL;
  205. }
  206. /*
  207. * If there's ever an operation_id == 0 passed, we have an internal
  208. * programming error.
  209. */
  210. if (!ossl_assert(operation_id > 0)) {
  211. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  212. return NULL;
  213. }
  214. /* If we haven't received a name id yet, try to get one for the name */
  215. name_id = name != NULL ? ossl_namemap_name2num(namemap, name) : 0;
  216. /*
  217. * If we have a name id, calculate a method id with evp_method_id().
  218. *
  219. * evp_method_id returns 0 if we have too many operations (more than
  220. * about 2^8) or too many names (more than about 2^24). In that case,
  221. * we can't create any new method.
  222. * For all intents and purposes, this is an internal error.
  223. */
  224. if (name_id != 0 && (meth_id = evp_method_id(name_id, operation_id)) == 0) {
  225. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  226. return NULL;
  227. }
  228. /*
  229. * If we haven't found the name yet, chances are that the algorithm to
  230. * be fetched is unsupported.
  231. */
  232. unsupported = name_id == 0;
  233. if (meth_id == 0
  234. || !ossl_method_store_cache_get(store, prov, meth_id, propq, &method)) {
  235. OSSL_METHOD_CONSTRUCT_METHOD mcm = {
  236. get_tmp_evp_method_store,
  237. get_evp_method_from_store,
  238. put_evp_method_in_store,
  239. construct_evp_method,
  240. destruct_evp_method
  241. };
  242. methdata->operation_id = operation_id;
  243. methdata->name_id = name_id;
  244. methdata->names = name;
  245. methdata->propquery = propq;
  246. methdata->method_from_algorithm = new_method;
  247. methdata->refcnt_up_method = up_ref_method;
  248. methdata->destruct_method = free_method;
  249. methdata->flag_construct_error_occurred = 0;
  250. if ((method = ossl_method_construct(methdata->libctx, operation_id,
  251. &prov, 0 /* !force_cache */,
  252. &mcm, methdata)) != NULL) {
  253. /*
  254. * If construction did create a method for us, we know that
  255. * there is a correct name_id and meth_id, since those have
  256. * already been calculated in get_evp_method_from_store() and
  257. * put_evp_method_in_store() above.
  258. */
  259. if (name_id == 0)
  260. name_id = ossl_namemap_name2num(namemap, name);
  261. meth_id = evp_method_id(name_id, operation_id);
  262. if (name_id != 0)
  263. ossl_method_store_cache_set(store, prov, meth_id, propq,
  264. method, up_ref_method, free_method);
  265. }
  266. /*
  267. * If we never were in the constructor, the algorithm to be fetched
  268. * is unsupported.
  269. */
  270. unsupported = !methdata->flag_construct_error_occurred;
  271. }
  272. if ((name_id != 0 || name != NULL) && method == NULL) {
  273. int code = unsupported ? ERR_R_UNSUPPORTED : ERR_R_FETCH_FAILED;
  274. if (name == NULL)
  275. name = ossl_namemap_num2name(namemap, name_id, 0);
  276. ERR_raise_data(ERR_LIB_EVP, code,
  277. "%s, Algorithm (%s : %d), Properties (%s)",
  278. ossl_lib_ctx_get_descriptor(methdata->libctx),
  279. name == NULL ? "<null>" : name, name_id,
  280. properties == NULL ? "<null>" : properties);
  281. }
  282. return method;
  283. }
  284. void *evp_generic_fetch(OSSL_LIB_CTX *libctx, int operation_id,
  285. const char *name, const char *properties,
  286. void *(*new_method)(int name_id,
  287. const OSSL_ALGORITHM *algodef,
  288. OSSL_PROVIDER *prov),
  289. int (*up_ref_method)(void *),
  290. void (*free_method)(void *))
  291. {
  292. struct evp_method_data_st methdata;
  293. void *method;
  294. methdata.libctx = libctx;
  295. methdata.tmp_store = NULL;
  296. method = inner_evp_generic_fetch(&methdata, NULL, operation_id,
  297. name, properties,
  298. new_method, up_ref_method, free_method);
  299. dealloc_tmp_evp_method_store(methdata.tmp_store);
  300. return method;
  301. }
  302. /*
  303. * evp_generic_fetch_from_prov() is special, and only returns methods from
  304. * the given provider.
  305. * This is meant to be used when one method needs to fetch an associated
  306. * method.
  307. */
  308. void *evp_generic_fetch_from_prov(OSSL_PROVIDER *prov, int operation_id,
  309. const char *name, const char *properties,
  310. void *(*new_method)(int name_id,
  311. const OSSL_ALGORITHM *algodef,
  312. OSSL_PROVIDER *prov),
  313. int (*up_ref_method)(void *),
  314. void (*free_method)(void *))
  315. {
  316. struct evp_method_data_st methdata;
  317. void *method;
  318. methdata.libctx = ossl_provider_libctx(prov);
  319. methdata.tmp_store = NULL;
  320. method = inner_evp_generic_fetch(&methdata, prov, operation_id,
  321. name, properties,
  322. new_method, up_ref_method, free_method);
  323. dealloc_tmp_evp_method_store(methdata.tmp_store);
  324. return method;
  325. }
  326. int evp_method_store_cache_flush(OSSL_LIB_CTX *libctx)
  327. {
  328. OSSL_METHOD_STORE *store = get_evp_method_store(libctx);
  329. if (store != NULL)
  330. return ossl_method_store_cache_flush_all(store);
  331. return 1;
  332. }
  333. int evp_method_store_remove_all_provided(const OSSL_PROVIDER *prov)
  334. {
  335. OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
  336. OSSL_METHOD_STORE *store = get_evp_method_store(libctx);
  337. if (store != NULL)
  338. return ossl_method_store_remove_all_provided(store, prov);
  339. return 1;
  340. }
  341. static int evp_set_parsed_default_properties(OSSL_LIB_CTX *libctx,
  342. OSSL_PROPERTY_LIST *def_prop,
  343. int loadconfig,
  344. int mirrored)
  345. {
  346. OSSL_METHOD_STORE *store = get_evp_method_store(libctx);
  347. OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx, loadconfig);
  348. if (plp != NULL && store != NULL) {
  349. #ifndef FIPS_MODULE
  350. char *propstr = NULL;
  351. size_t strsz;
  352. if (mirrored) {
  353. if (ossl_global_properties_no_mirrored(libctx))
  354. return 0;
  355. } else {
  356. /*
  357. * These properties have been explicitly set on this libctx, so
  358. * don't allow any mirroring from a parent libctx.
  359. */
  360. ossl_global_properties_stop_mirroring(libctx);
  361. }
  362. strsz = ossl_property_list_to_string(libctx, def_prop, NULL, 0);
  363. if (strsz > 0)
  364. propstr = OPENSSL_malloc(strsz);
  365. if (propstr == NULL) {
  366. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  367. return 0;
  368. }
  369. if (ossl_property_list_to_string(libctx, def_prop, propstr,
  370. strsz) == 0) {
  371. OPENSSL_free(propstr);
  372. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  373. return 0;
  374. }
  375. ossl_provider_default_props_update(libctx, propstr);
  376. OPENSSL_free(propstr);
  377. #endif
  378. ossl_property_free(*plp);
  379. *plp = def_prop;
  380. if (store != NULL)
  381. return ossl_method_store_cache_flush_all(store);
  382. }
  383. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  384. return 0;
  385. }
  386. int evp_set_default_properties_int(OSSL_LIB_CTX *libctx, const char *propq,
  387. int loadconfig, int mirrored)
  388. {
  389. OSSL_PROPERTY_LIST *pl = NULL;
  390. if (propq != NULL && (pl = ossl_parse_query(libctx, propq, 1)) == NULL) {
  391. ERR_raise(ERR_LIB_EVP, EVP_R_DEFAULT_QUERY_PARSE_ERROR);
  392. return 0;
  393. }
  394. if (!evp_set_parsed_default_properties(libctx, pl, loadconfig, mirrored)) {
  395. ossl_property_free(pl);
  396. return 0;
  397. }
  398. return 1;
  399. }
  400. int EVP_set_default_properties(OSSL_LIB_CTX *libctx, const char *propq)
  401. {
  402. return evp_set_default_properties_int(libctx, propq, 1, 0);
  403. }
  404. static int evp_default_properties_merge(OSSL_LIB_CTX *libctx, const char *propq,
  405. int loadconfig)
  406. {
  407. OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx, loadconfig);
  408. OSSL_PROPERTY_LIST *pl1, *pl2;
  409. if (propq == NULL)
  410. return 1;
  411. if (plp == NULL || *plp == NULL)
  412. return evp_set_default_properties_int(libctx, propq, 0, 0);
  413. if ((pl1 = ossl_parse_query(libctx, propq, 1)) == NULL) {
  414. ERR_raise(ERR_LIB_EVP, EVP_R_DEFAULT_QUERY_PARSE_ERROR);
  415. return 0;
  416. }
  417. pl2 = ossl_property_merge(pl1, *plp);
  418. ossl_property_free(pl1);
  419. if (pl2 == NULL) {
  420. ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
  421. return 0;
  422. }
  423. if (!evp_set_parsed_default_properties(libctx, pl2, 0, 0)) {
  424. ossl_property_free(pl2);
  425. return 0;
  426. }
  427. return 1;
  428. }
  429. static int evp_default_property_is_enabled(OSSL_LIB_CTX *libctx,
  430. const char *prop_name)
  431. {
  432. OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx, 1);
  433. return plp != NULL && ossl_property_is_enabled(libctx, prop_name, *plp);
  434. }
  435. int EVP_default_properties_is_fips_enabled(OSSL_LIB_CTX *libctx)
  436. {
  437. return evp_default_property_is_enabled(libctx, "fips");
  438. }
  439. int evp_default_properties_enable_fips_int(OSSL_LIB_CTX *libctx, int enable,
  440. int loadconfig)
  441. {
  442. const char *query = (enable != 0) ? "fips=yes" : "-fips";
  443. return evp_default_properties_merge(libctx, query, loadconfig);
  444. }
  445. int EVP_default_properties_enable_fips(OSSL_LIB_CTX *libctx, int enable)
  446. {
  447. return evp_default_properties_enable_fips_int(libctx, enable, 1);
  448. }
  449. char *evp_get_global_properties_str(OSSL_LIB_CTX *libctx, int loadconfig)
  450. {
  451. OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx, loadconfig);
  452. char *propstr = NULL;
  453. size_t sz;
  454. if (plp == NULL)
  455. return OPENSSL_strdup("");
  456. sz = ossl_property_list_to_string(libctx, *plp, NULL, 0);
  457. if (sz == 0) {
  458. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  459. return NULL;
  460. }
  461. propstr = OPENSSL_malloc(sz);
  462. if (propstr == NULL) {
  463. ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
  464. return NULL;
  465. }
  466. if (ossl_property_list_to_string(libctx, *plp, propstr, sz) == 0) {
  467. ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR);
  468. OPENSSL_free(propstr);
  469. return NULL;
  470. }
  471. return propstr;
  472. }
  473. struct filter_data_st {
  474. int operation_id;
  475. void (*user_fn)(void *method, void *arg);
  476. void *user_arg;
  477. };
  478. static void filter_on_operation_id(int id, void *method, void *arg)
  479. {
  480. struct filter_data_st *data = arg;
  481. if ((id & METHOD_ID_OPERATION_MASK) == data->operation_id)
  482. data->user_fn(method, data->user_arg);
  483. }
  484. void evp_generic_do_all(OSSL_LIB_CTX *libctx, int operation_id,
  485. void (*user_fn)(void *method, void *arg),
  486. void *user_arg,
  487. void *(*new_method)(int name_id,
  488. const OSSL_ALGORITHM *algodef,
  489. OSSL_PROVIDER *prov),
  490. int (*up_ref_method)(void *),
  491. void (*free_method)(void *))
  492. {
  493. struct evp_method_data_st methdata;
  494. struct filter_data_st data;
  495. methdata.libctx = libctx;
  496. methdata.tmp_store = NULL;
  497. (void)inner_evp_generic_fetch(&methdata, NULL, operation_id, NULL, NULL,
  498. new_method, up_ref_method, free_method);
  499. data.operation_id = operation_id;
  500. data.user_fn = user_fn;
  501. data.user_arg = user_arg;
  502. if (methdata.tmp_store != NULL)
  503. ossl_method_store_do_all(methdata.tmp_store, &filter_on_operation_id,
  504. &data);
  505. ossl_method_store_do_all(get_evp_method_store(libctx),
  506. &filter_on_operation_id, &data);
  507. dealloc_tmp_evp_method_store(methdata.tmp_store);
  508. }
  509. int evp_is_a(OSSL_PROVIDER *prov, int number,
  510. const char *legacy_name, const char *name)
  511. {
  512. /*
  513. * For a |prov| that is NULL, the library context will be NULL
  514. */
  515. OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
  516. OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
  517. if (prov == NULL)
  518. number = ossl_namemap_name2num(namemap, legacy_name);
  519. return ossl_namemap_name2num(namemap, name) == number;
  520. }
  521. int evp_names_do_all(OSSL_PROVIDER *prov, int number,
  522. void (*fn)(const char *name, void *data),
  523. void *data)
  524. {
  525. OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
  526. OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
  527. return ossl_namemap_doall_names(namemap, number, fn, data);
  528. }