2019-05-04 18:55:32 +08:00
|
|
|
/*
|
2021-03-11 21:27:36 +08:00
|
|
|
* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2019-05-04 18:55:32 +08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "internal/cryptlib.h"
|
|
|
|
|
|
|
|
typedef struct ossl_namemap_st OSSL_NAMEMAP;
|
|
|
|
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_NAMEMAP *ossl_namemap_stored(OSSL_LIB_CTX *libctx);
|
2019-05-04 18:55:32 +08:00
|
|
|
|
|
|
|
OSSL_NAMEMAP *ossl_namemap_new(void);
|
|
|
|
void ossl_namemap_free(OSSL_NAMEMAP *namemap);
|
2019-05-23 09:27:37 +08:00
|
|
|
int ossl_namemap_empty(OSSL_NAMEMAP *namemap);
|
2019-05-04 18:55:32 +08:00
|
|
|
|
2019-11-09 07:18:05 +08:00
|
|
|
int ossl_namemap_add_name(OSSL_NAMEMAP *namemap, int number, const char *name);
|
2019-05-23 09:18:04 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The number<->name relationship is 1<->many
|
|
|
|
* Therefore, the name->number mapping is a simple function, while the
|
|
|
|
* number->name mapping is an iterator.
|
|
|
|
*/
|
|
|
|
int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name);
|
2019-05-23 09:36:21 +08:00
|
|
|
int ossl_namemap_name2num_n(const OSSL_NAMEMAP *namemap,
|
|
|
|
const char *name, size_t name_len);
|
In provider implemented methods, save the name number, not the name string
Multiple names per implementation is already supported in the namemap,
but hasn't been used yet. However, as soon as we have multiple names,
we will get an issue with what name should be saved in the method.
The solution is to not save the name itself, but rather the number
it's associated with. This number is supposed to be unique for each
set of names, and we assume that algorithm names are globally unique,
i.e. there can be no name overlap between different algorithm types.
Incidently, it was also found that the 'get' function used by
ossl_construct_method() doesn't need all the parameters it was given;
most of what it needs, it can now get through the data structure given
by the caller of ossl_construct_method(). As a consequence,
ossl_construct_method() itself doesn't need all the parameters it was
given either.
There are some added internal functions that are expected to disappear
as soon as legacy code is removed, such as evp_first_name() and
ossl_namemap_num2name().
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9897)
2019-09-14 22:22:19 +08:00
|
|
|
const char *ossl_namemap_num2name(const OSSL_NAMEMAP *namemap, int number,
|
|
|
|
size_t idx);
|
2021-02-20 01:03:43 +08:00
|
|
|
int ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number,
|
|
|
|
void (*fn)(const char *name, void *data),
|
|
|
|
void *data);
|
2019-11-09 07:18:05 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A utility that handles several names in a string, divided by a given
|
|
|
|
* separator.
|
|
|
|
*/
|
|
|
|
int ossl_namemap_add_names(OSSL_NAMEMAP *namemap, int number,
|
|
|
|
const char *names, const char separator);
|