summaryrefslogtreecommitdiff
path: root/crypto/conf
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-05-27 11:00:35 +0200
committerPauli <pauli@openssl.org>2021-06-02 12:40:02 +1000
commitb3c2ed7043233bd738957a7fcdf9e0734bfea937 (patch)
tree6ac0121007843e1bea0b0bf3fed25e8415221689 /crypto/conf
parent6b750b89ee9ad3952b1b25e47b848abc8b60e7dd (diff)
downloadopenssl-new-b3c2ed7043233bd738957a7fcdf9e0734bfea937.tar.gz
Add NCONF_get_section_names()
And a few additional fixups to make the no-deprecated configuration to build. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15466)
Diffstat (limited to 'crypto/conf')
-rw-r--r--crypto/conf/conf_api.c5
-rw-r--r--crypto/conf/conf_lib.c32
2 files changed, 32 insertions, 5 deletions
diff --git a/crypto/conf/conf_api.c b/crypto/conf/conf_api.c
index 2d72a6ab32..e4e305c714 100644
--- a/crypto/conf/conf_api.c
+++ b/crypto/conf/conf_api.c
@@ -20,11 +20,6 @@
static void value_free_hash(const CONF_VALUE *a, LHASH_OF(CONF_VALUE) *conf);
static void value_free_stack_doall(CONF_VALUE *a);
-OSSL_LIB_CTX *NCONF_get0_libctx(CONF *conf)
-{
- return conf->libctx;
-}
-
CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section)
{
CONF_VALUE vv;
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
index 99a33765ad..b07d075b23 100644
--- a/crypto/conf/conf_lib.c
+++ b/crypto/conf/conf_lib.c
@@ -215,6 +215,38 @@ void NCONF_free_data(CONF *conf)
conf->meth->destroy_data(conf);
}
+OSSL_LIB_CTX *NCONF_get0_libctx(const CONF *conf)
+{
+ return conf->libctx;
+}
+
+typedef STACK_OF(OPENSSL_CSTRING) SECTION_NAMES;
+
+IMPLEMENT_LHASH_DOALL_ARG_CONST(CONF_VALUE, SECTION_NAMES);
+
+static void collect_section_name(const CONF_VALUE *v, SECTION_NAMES *names)
+{
+ /* A section is a CONF_VALUE with name == NULL */
+ if (v->name == NULL)
+ sk_OPENSSL_CSTRING_push(names, v->section);
+}
+
+static int section_name_cmp(OPENSSL_CSTRING const *a, OPENSSL_CSTRING const *b)
+{
+ return strcmp(*a, *b);
+}
+
+STACK_OF(OPENSSL_CSTRING) *NCONF_get_section_names(const CONF *cnf)
+{
+ SECTION_NAMES *names;
+
+ if ((names = sk_OPENSSL_CSTRING_new(section_name_cmp)) == NULL)
+ return NULL;
+ lh_CONF_VALUE_doall_SECTION_NAMES(cnf->data, collect_section_name, names);
+ sk_OPENSSL_CSTRING_sort(names);
+ return names;
+}
+
int NCONF_load(CONF *conf, const char *file, long *eline)
{
if (conf == NULL) {