Debian Codegraph @

res/res_stir_shaken/common_config.h

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2023, Sangoma Technologies Corporation
5 *
6 * George Joseph <[email protected]>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19 #ifndef COMMON_CONFIG_H_
20 #define COMMON_CONFIG_H_
21
22 #include <openssl/evp.h>
23
24 #include "asterisk.h"
25 #include "asterisk/paths.h"
26 #include "asterisk/sorcery.h"
27 #include "asterisk/stringfields.h"
28
29 /*!
30 * \brief Boolean field to/from string prototype generator
31 *
32 * Most of the boolean fields that appear in the verification and
33 * attestation objects can be ovrridden in the profile object;
34 * "use_rfc9410_responses" for instance. If they were registered as
35 * normal YESNO types, we couldn't tell if a "0" value in the profile
36 * object meant the user set it to "no" to override a value of "yes"
37 * in the verification object, or it just defaulted to "0". By making
38 * the _NOT_SET enum a non-0/1 and making it the default value, we can
39 * tell the difference. The _UNKNOWN enum gets set if the string value
40 * provided to the _from_str function wasn't recognized as one of the
41 * values acceptable to ast_true() or ast_false().
42 *
43 * The result of calling the generator for a field will look like:
44 *
45 \code
46 enum use_rfc9410_responses_enum {
47 use_rfc9410_responses_UNKNOWN = -1,
48 use_rfc9410_responses_NO = 0,
49 use_rfc9410_responses_YES,
50 use_rfc9410_responses_NOT_SET,
51 };
52 enum use_rfc9410_responses_enum
53 use_rfc9410_responses_from_str(const char *value);
54 const char *use_rfc9410_responses_to_str(enum use_rfc9410_responses_enum value);
55 \endcode
56
57 Most of the macros that follow depend on enum values formatted
58 as <param_name>_SOMETHING and their defaults as DEFAULT_<param_name>.
59 */
60 #define generate_bool_string_prototypes(param_name) \
61 enum param_name ## _enum { \
62 param_name ## _UNKNOWN = -1, \
63 param_name ## _NO = 0, \
64 param_name ## _YES, \
65 param_name ## _NOT_SET, \
66 }; \
67 enum param_name ## _enum \
68 param_name ## _from_str(const char *value); \
69 const char *param_name ## _to_str(enum param_name ## _enum value);
70
71 /*
72 * Run the generators
73 */
74 generate_bool_string_prototypes(use_rfc9410_responses);
75
76 generate_bool_string_prototypes(relax_x5u_port_scheme_restrictions);
77
78 generate_bool_string_prototypes(relax_x5u_path_restrictions);
79
80 generate_bool_string_prototypes(load_system_certs);
81
82 generate_bool_string_prototypes(ignore_sip_date_header);
83
84 generate_bool_string_prototypes(check_tn_cert_public_url);
85
86 generate_bool_string_prototypes(send_mky);
87
88 /*!
89 * \brief Enum field to/from string prototype generator
90 *
91 * This operates like the bool generator except you supply
92 * a list of the enum values. The first one MUST be
93 * param_name_UNKNOWN with a value of -1 and the rest running
94 * sequentially with the last being param_name_NOT_SET.
95 */
96 #define generate_enum_string_prototypes(param_name, ...) \
97 enum param_name ## _enum { \
98 __VA_ARGS__ \
99 }; \
100 enum param_name ## _enum \
101 param_name ## _from_str(const char *value); \
102 const char *param_name ## _to_str(enum param_name ## _enum value);
103
104 generate_enum_string_prototypes(endpoint_behavior,
105 endpoint_behavior_UNKNOWN = -1,
106 endpoint_behavior_OFF = 0,
107 endpoint_behavior_ATTEST,
108 endpoint_behavior_VERIFY,
109 endpoint_behavior_ON,
110 endpoint_behavior_NOT_SET
111 );
112
113 generate_enum_string_prototypes(attest_level,
114 attest_level_UNKNOWN = -1,
115 attest_level_NOT_SET = 0,
116 attest_level_A,
117 attest_level_B,
118 attest_level_C,
119 );
120
121 /*
122 * unknown_tn_attest_level uses the same enum as attest_level.
123 */
124 enum attest_level_enum unknown_tn_attest_level_from_str(const char *value);
125 const char *unknown_tn_attest_level_to_str(enum attest_level_enum value);
126
127 /*
128 * enum stir_shaken_failure_action is defined in
129 * res_stir_shaken.h because res_pjsip_stir_shaken needs it
130 * we we need to just declare the function prototypes.
131 */
132
133 enum stir_shaken_failure_action_enum
134 stir_shaken_failure_action_from_str(const char *action_str);
135
136 const char *stir_shaken_failure_action_to_str(
137 enum stir_shaken_failure_action_enum action);
138
139 /*!
140 * \brief Enum sorcery handler generator
141 *
142 * These macros can create the two functions needed to
143 * register an enum field with sorcery as long as there
144 * are _to_str and _from_str functions defined elsewhere.
145 *
146 */
147 #define generate_sorcery_enum_to_str_ex(__struct, __substruct, __lc_param, __base_enum) \
148 static int sorcery_ ## __lc_param ## _to_str(const void *obj, const intptr_t *args, char **buf) \
149 { \
150 const struct __struct *cfg = obj; \
151 *buf = ast_strdup(__base_enum ## _to_str(cfg->__substruct __lc_param)); \
152 return *buf ? 0 : -1; \
153 }
154
155 #define generate_sorcery_enum_to_str(__struct, __substruct, __lc_param) \
156 generate_sorcery_enum_to_str_ex(__struct, __substruct, __lc_param, __lc_param)
157
158 #define generate_sorcery_enum_from_str_ex(__struct, __substruct, __lc_param, __base_enum, __unknown) \
159 static int sorcery_ ## __lc_param ## _from_str(const struct aco_option *opt, struct ast_variable *var, void *obj) \
160 { \
161 struct __struct *cfg = obj; \
162 cfg->__substruct __lc_param = __base_enum ## _from_str (var->value); \
163 if (cfg->__substruct __lc_param == __base_enum ## _ ## __unknown) { \
164 ast_log(LOG_WARNING, "Unknown value '%s' specified for %s\n", \
165 var->value, var->name); \
166 return -1; \
167 } \
168 return 0; \
169 }
170
171 #define generate_sorcery_enum_from_str(__struct, __substruct, __lc_param, __unknown) \
172 generate_sorcery_enum_from_str_ex(__struct, __substruct, __lc_param, __lc_param, __unknown) \
173
174
175 #define generate_sorcery_acl_to_str(__struct, __lc_param) \
176 static int sorcery_acl_to_str(const void *obj, const intptr_t *args, char **buf) \
177 { \
178 const struct __struct *cfg = obj; \
179 struct ast_acl *first_acl; \
180 if (!ast_acl_list_is_empty(cfg->vcfg_common.acl)) { \
181 AST_LIST_LOCK(cfg->vcfg_common.acl); \
182 first_acl = AST_LIST_FIRST(cfg->vcfg_common.acl); \
183 if (ast_strlen_zero(first_acl->name)) { \
184 *buf = "deny/permit"; \
185 } else { \
186 *buf = first_acl->name; \
187 } \
188 AST_LIST_UNLOCK(cfg->vcfg_common.acl); \
189 } \
190 *buf = ast_strdup(*buf); \
191 return 0; \
192 }
193
194 #define generate_sorcery_acl_from_str(__struct, __lc_param, __unknown) \
195 static int sorcery_acl_from_str(const struct aco_option *opt, struct ast_variable *var, void *obj) \
196 { \
197 struct __struct *cfg = obj; \
198 int error = 0; \
199 int ignore; \
200 const char *name = var->name + strlen("x5u_"); \
201 if (ast_strlen_zero(var->value)) { \
202 return 0; \
203 } \
204 ast_append_acl(name, var->value, &cfg->vcfg_common.acl, &error, &ignore); \
205 return error; \
206 }
207
208 struct ast_acl_list *get_default_acl_list(void);
209
210 #define EFFECTIVE_ENUM(__enum1, __enum2, __field, __default) \
211 ( __enum1 != ( __field ## _ ## NOT_SET ) ? __enum1 : \
212 (__enum2 != __field ## _ ## NOT_SET ? \
213 __enum2 : __default ))
214
215 #define EFFECTIVE_ENUM_BOOL(__enum1, __enum2, __field, __default) \
216 (( __enum1 != ( __field ## _ ## NOT_SET ) ? __enum1 : \
217 (__enum2 != __field ## _ ## NOT_SET ? \
218 __enum2 : __field ## _ ## __default )) == __field ## _ ## YES)
219
220 #define ENUM_BOOL(__enum1, __field) \
221 (__enum1 == ( __field ## _ ## YES ))
222
223 /*!
224 * \brief Common config copy utilities
225 *
226 * These macros are designed to be called from as_copy_cfg_common
227 * and vs_copy_cfg_common only. They'll only copy a field if the
228 * field contains a vaild value. Thus a NOT_SET value in the source
229 * won't override a pre-existing good value in the dest. A good
230 * value in the source WILL overwrite a good value in the dest.
231 *
232 */
233 #define cfg_stringfield_copy(__cfg_dst, __cfg_src, __field) \
234 ({ \
235 int __res = 0; \
236 if (!ast_strlen_zero(__cfg_src->__field)) { \
237 __res = ast_string_field_set(__cfg_dst, __field, __cfg_src->__field); \
238 } \
239 __res; \
240 })
241
242 /*!
243 * \brief cfg_copy_wrapper
244 *
245 * Invoke cfg_stringfield_copy and cause the calling runction to
246 * return a -1 of the copy fails.
247 */
248 #define cfg_sf_copy_wrapper(id, __cfg_dst, __cfg_src, __field) \
249 { \
250 int rc = cfg_stringfield_copy(__cfg_dst, __cfg_src, __field); \
251 if (rc != 0) { \
252 ast_log(LOG_ERROR, "%s: Unable to copy field %s from %s to %s\n", \
253 id, #__field, #__cfg_src, #__cfg_dst); \
254 return -1; \
255 } \
256 }
257
258 /*!
259 * \brief cfg_uint_copy
260 *
261 * Copy a uint from the source to the dest only if the source > 0.
262 * For stir-shaken, 0 isn't a valid value for any uint fields.
263 */
264 #define cfg_uint_copy(__cfg_dst, __cfg_src, __field) \
265 ({ \
266 if (__cfg_src->__field > 0) { \
267 __cfg_dst->__field = __cfg_src->__field; \
268 } \
269 })
270
271 /*!
272 * \brief cfg_enum_copy
273 *
274 * Copy an enum from the source to the dest only if the source is
275 * neither NOT_SET nor UNKNOWN
276 */
277 #define cfg_enum_copy_ex(__cfg_dst, __cfg_src, __field, __not_set, __unknown) \
278 ({ \
279 if (__cfg_src->__field != __not_set \
280 && __cfg_src->__field != __unknown) { \
281 __cfg_dst->__field = __cfg_src->__field; \
282 } \
283 })
284
285 #define cfg_enum_copy(__cfg_dst, __cfg_src, __field) \
286 cfg_enum_copy_ex(__cfg_dst, __cfg_src, __field, __field ## _NOT_SET, __field ## _UNKNOWN)
287
288
289 /*!
290 * \brief Attestation Service configuration for stir/shaken
291 *
292 * The common structure also appears in profile_cfg.
293 */
294 struct attestation_cfg_common {
295 AST_DECLARE_STRING_FIELDS(
296 AST_STRING_FIELD(private_key_file);
297 AST_STRING_FIELD(public_cert_url);
298 );
299 enum attest_level_enum attest_level;
300 enum check_tn_cert_public_url_enum check_tn_cert_public_url;
301 enum send_mky_enum send_mky;
302 unsigned char *raw_key;
303 size_t raw_key_length;
304 };
305
306 #define generate_acfg_common_sorcery_handlers(object) \
307 generate_sorcery_enum_from_str(object, acfg_common., check_tn_cert_public_url, UNKNOWN); \
308 generate_sorcery_enum_to_str(object, acfg_common., check_tn_cert_public_url); \
309 generate_sorcery_enum_from_str(object, acfg_common., send_mky, UNKNOWN); \
310 generate_sorcery_enum_to_str(object, acfg_common., send_mky); \
311 generate_sorcery_enum_from_str(object, acfg_common., attest_level, UNKNOWN); \
312 generate_sorcery_enum_to_str(object, acfg_common., attest_level);
313
314 int as_check_common_config(const char *id,
315 struct attestation_cfg_common *acfg_common);
316
317 int as_copy_cfg_common(const char *id, struct attestation_cfg_common *cfg_dst,
318 struct attestation_cfg_common *cfg_src);
319
320 void acfg_cleanup(struct attestation_cfg_common *cfg);
321
322 struct attestation_cfg {
323 SORCERY_OBJECT(details);
324 /*
325 * We need an empty AST_DECLARE_STRING_FIELDS() here
326 * because when STRFLDSET is used with sorcery, the
327 * memory for all sub-structures that have stringfields
328 * is allocated from the parent's stringfield pool.
329 */
330 AST_DECLARE_STRING_FIELDS();
331 struct attestation_cfg_common acfg_common;
332 enum attest_level_enum unknown_tn_attest_level;
333 int global_disable;
334 };
335
336 struct attestation_cfg *as_get_cfg(void);
337 int as_is_config_loaded(void);
338 int as_config_load(void);
339 int as_config_reload(void);
340 int as_config_unload(void);
341
342 /*!
343 * \brief Verification Service configuration for stir/shaken
344 *
345 * The common structure also appears in profile_cfg.
346 */
347 struct verification_cfg_common {
348 AST_DECLARE_STRING_FIELDS(
349 AST_STRING_FIELD(ca_file);
350 AST_STRING_FIELD(ca_path);
351 AST_STRING_FIELD(crl_file);
352 AST_STRING_FIELD(crl_path);
353 AST_STRING_FIELD(untrusted_cert_file);
354 AST_STRING_FIELD(untrusted_cert_path);
355 AST_STRING_FIELD(cert_cache_dir);
356 );
357 unsigned int curl_timeout;
358 unsigned int max_iat_age;
359 unsigned int max_date_header_age;
360 unsigned int max_cache_entry_age;
361 unsigned int max_cache_size;
362 enum stir_shaken_failure_action_enum
363 stir_shaken_failure_action;
364 enum use_rfc9410_responses_enum use_rfc9410_responses;
365 enum relax_x5u_port_scheme_restrictions_enum
366 relax_x5u_port_scheme_restrictions;
367 enum relax_x5u_path_restrictions_enum
368 relax_x5u_path_restrictions;
369 enum load_system_certs_enum load_system_certs;
370 enum ignore_sip_date_header_enum ignore_sip_date_header;
371 struct ast_acl_list *acl;
372 struct crypto_cert_store *tcs;
373 };
374
375 #define generate_vcfg_common_sorcery_handlers(object) \
376 generate_sorcery_enum_from_str(object, vcfg_common.,use_rfc9410_responses, UNKNOWN); \
377 generate_sorcery_enum_to_str(object, vcfg_common.,use_rfc9410_responses); \
378 generate_sorcery_enum_from_str(object, vcfg_common.,stir_shaken_failure_action, UNKNOWN); \
379 generate_sorcery_enum_to_str(object, vcfg_common.,stir_shaken_failure_action); \
380 generate_sorcery_enum_from_str(object, vcfg_common.,relax_x5u_port_scheme_restrictions, UNKNOWN); \
381 generate_sorcery_enum_to_str(object, vcfg_common.,relax_x5u_port_scheme_restrictions); \
382 generate_sorcery_enum_from_str(object, vcfg_common.,relax_x5u_path_restrictions, UNKNOWN); \
383 generate_sorcery_enum_to_str(object, vcfg_common.,relax_x5u_path_restrictions); \
384 generate_sorcery_enum_from_str(object, vcfg_common.,load_system_certs, UNKNOWN); \
385 generate_sorcery_enum_to_str(object, vcfg_common.,load_system_certs); \
386 generate_sorcery_enum_from_str(object, vcfg_common.,ignore_sip_date_header, UNKNOWN); \
387 generate_sorcery_enum_to_str(object, vcfg_common.,ignore_sip_date_header); \
388 generate_sorcery_acl_from_str(object, acl, NULL); \
389 generate_sorcery_acl_to_str(object, acl);
390
391 int vs_check_common_config(const char *id,
392 struct verification_cfg_common *vcfg_common);
393
394 int vs_copy_cfg_common(const char *id, struct verification_cfg_common *cfg_dst,
395 struct verification_cfg_common *cfg_src);
396
397 void vcfg_cleanup(struct verification_cfg_common *cfg);
398
399 struct verification_cfg {
400 SORCERY_OBJECT(details);
401 /*
402 * We need an empty AST_DECLARE_STRING_FIELDS() here
403 * because when STRFLDSET is used with sorcery, the
404 * memory for all sub-structures that have stringfields
405 * is allocated from the parent's stringfield pool.
406 */
407 AST_DECLARE_STRING_FIELDS();
408 struct verification_cfg_common vcfg_common;
409 int global_disable;
410 };
411
412 struct verification_cfg *vs_get_cfg(void);
413 int vs_is_config_loaded(void);
414 int vs_config_load(void);
415 int vs_config_reload(void);
416 int vs_config_unload(void);
417
418 /*!
419 * \brief Profile configuration for stir/shaken
420 */
421 struct profile_cfg {
422 SORCERY_OBJECT(details);
423 /*
424 * We need an empty AST_DECLARE_STRING_FIELDS() here
425 * because when STRFLDSET is used with sorcery, the
426 * memory for all sub-structures that have stringfields
427 * is allocated from the parent's stringfield pool.
428 */
429 AST_DECLARE_STRING_FIELDS();
430 struct attestation_cfg_common acfg_common;
431 struct verification_cfg_common vcfg_common;
432 enum endpoint_behavior_enum endpoint_behavior;
433 enum attest_level_enum unknown_tn_attest_level;
434 struct profile_cfg *eprofile;
435 };
436
437 struct profile_cfg *profile_get_cfg(const char *id);
438 struct ao2_container *profile_get_all(void);
439 struct profile_cfg *eprofile_get_cfg(const char *id);
440 struct ao2_container *eprofile_get_all(void);
441 int profile_load(void);
442 int profile_reload(void);
443 int profile_unload(void);
444
445 #define PROFILE_ALLOW_ATTEST(__profile) \
446 (__profile->endpoint_behavior == endpoint_behavior_ON || \
447 __profile->endpoint_behavior == endpoint_behavior_ATTEST)
448
449 #define PROFILE_ALLOW_VERIFY(__profile) \
450 (__profile->endpoint_behavior == endpoint_behavior_ON || \
451 __profile->endpoint_behavior == endpoint_behavior_VERIFY)
452
453 /*!
454 * \brief TN configuration for stir/shaken
455 *
456 * TN-specific attestation_cfg.
457 */
458
459 struct tn_cfg {
460 SORCERY_OBJECT(details);
461 /*
462 * We need an empty AST_DECLARE_STRING_FIELDS() here
463 * because when STRFLDSET is used with sorcery, the
464 * memory for all sub-structures that have stringfields
465 * is allocated from the parent's stringfield pool.
466 */
467 AST_DECLARE_STRING_FIELDS();
468 struct attestation_cfg_common acfg_common;
469 };
470
471 struct tn_cfg *tn_get_cfg(const char *tn);
472 struct tn_cfg *tn_get_etn(const char *tn,
473 struct profile_cfg *eprofile);
474 int tn_config_load(void);
475 int tn_config_reload(void);
476 int tn_config_unload(void);
477
478 /*!
479 * \brief Sorcery fields register helpers
480 *
481 * Most of the fields on attestation_cfg and verification_cfg are also
482 * in profile_cfg. To prevent having to maintain duplicate sets of
483 * sorcery register statements, we can do this once here and call
484 * register_common_verification_fields() from both profile_config and
485 * verification_config and call register_common_attestation_fields()
486 * from profile_cfg and attestation_config.
487 *
488 * Most of the fields in question are in sub-structures like
489 * verification_cfg.vcfg_common which is why there are separate name
490 * and field parameters. For verification_cfg.vcfg_common.ca_file
491 * for instance, name would be ca_file and field would be
492 * vcfg_common.ca_file.
493 *
494 *\note These macros depend on default values being defined
495 * in the 4 _config.c files as DEFAULT_<field_name>.
496 *
497 */
498 #define stringfield_option_register(sorcery, CONFIG_TYPE, object, name, field, nodoc) \
499 ast_sorcery_object_field_register ## nodoc(sorcery, CONFIG_TYPE, #name, \
500 DEFAULT_ ## name, OPT_STRINGFIELD_T, 0, \
501 STRFLDSET(struct object, field))
502
503 #define uint_option_register(sorcery, CONFIG_TYPE, object, name, field, nodoc) \
504 ast_sorcery_object_field_register ## nodoc(sorcery, CONFIG_TYPE, #name, \
505 __stringify(DEFAULT_ ## name), OPT_UINT_T, 0, \
506 FLDSET(struct object, field))
507
508 #define enum_option_register_ex(sorcery, CONFIG_TYPE, name, field, function_prefix, nodoc) \
509 ast_sorcery_object_field_register_custom ## nodoc(sorcery, CONFIG_TYPE, \
510 #name, function_prefix ## _to_str(DEFAULT_ ## field), \
511 sorcery_ ## field ## _from_str, sorcery_ ## field ## _to_str, NULL, 0, 0)
512
513 #define enum_option_register(sorcery, CONFIG_TYPE, name, nodoc) \
514 enum_option_register_ex(sorcery, CONFIG_TYPE, name, name, name, nodoc)
515
516 #define register_common_verification_fields(sorcery, object, CONFIG_TYPE, nodoc) \
517 ({ \
518 stringfield_option_register(sorcery, CONFIG_TYPE, object, ca_file, vcfg_common.ca_file, nodoc); \
519 stringfield_option_register(sorcery, CONFIG_TYPE, object, ca_path, vcfg_common.ca_path, nodoc); \
520 stringfield_option_register(sorcery, CONFIG_TYPE, object, crl_file, vcfg_common.crl_file, nodoc); \
521 stringfield_option_register(sorcery, CONFIG_TYPE, object, crl_path, vcfg_common.crl_path, nodoc); \
522 stringfield_option_register(sorcery, CONFIG_TYPE, object, untrusted_cert_file, vcfg_common.untrusted_cert_file, nodoc); \
523 stringfield_option_register(sorcery, CONFIG_TYPE, object, untrusted_cert_path, vcfg_common.untrusted_cert_path, nodoc); \
524 stringfield_option_register(sorcery, CONFIG_TYPE, object, cert_cache_dir, vcfg_common.cert_cache_dir, nodoc); \
525 \
526 uint_option_register(sorcery, CONFIG_TYPE, object, curl_timeout, vcfg_common.curl_timeout, nodoc);\
527 uint_option_register(sorcery, CONFIG_TYPE, object, max_iat_age, vcfg_common.max_iat_age, nodoc);\
528 uint_option_register(sorcery, CONFIG_TYPE, object, max_date_header_age, vcfg_common.max_date_header_age, nodoc);\
529 uint_option_register(sorcery, CONFIG_TYPE, object, max_cache_entry_age, vcfg_common.max_cache_entry_age, nodoc);\
530 uint_option_register(sorcery, CONFIG_TYPE, object, max_cache_size, vcfg_common.max_cache_size, nodoc);\
531 \
532 enum_option_register_ex(sorcery, CONFIG_TYPE, failure_action, stir_shaken_failure_action, stir_shaken_failure_action, nodoc); \
533 enum_option_register(sorcery, CONFIG_TYPE, use_rfc9410_responses, nodoc); \
534 enum_option_register(sorcery, CONFIG_TYPE, \
535 relax_x5u_port_scheme_restrictions, nodoc); \
536 enum_option_register(sorcery, CONFIG_TYPE, \
537 relax_x5u_path_restrictions, nodoc); \
538 enum_option_register(sorcery, CONFIG_TYPE, \
539 load_system_certs, nodoc); \
540 enum_option_register(sorcery, CONFIG_TYPE, ignore_sip_date_header, nodoc); \
541 \
542 ast_sorcery_object_field_register_custom ## nodoc(sorcery, CONFIG_TYPE, "x5u_deny", "", sorcery_acl_from_str, NULL, NULL, 0, 0); \
543 ast_sorcery_object_field_register_custom ## nodoc(sorcery, CONFIG_TYPE, "x5u_permit", "", sorcery_acl_from_str, NULL, NULL, 0, 0); \
544 ast_sorcery_object_field_register_custom ## nodoc(sorcery, CONFIG_TYPE, "x5u_acl", "", sorcery_acl_from_str, sorcery_acl_to_str, NULL, 0, 0); \
545 })
546
547 #define register_common_attestation_fields(sorcery, object, CONFIG_TYPE, nodoc) \
548 ({ \
549 stringfield_option_register(sorcery, CONFIG_TYPE, object, private_key_file, acfg_common.private_key_file, nodoc); \
550 stringfield_option_register(sorcery, CONFIG_TYPE, object, public_cert_url, acfg_common.public_cert_url, nodoc); \
551 enum_option_register(sorcery, CONFIG_TYPE, attest_level, nodoc); \
552 enum_option_register(sorcery, CONFIG_TYPE, check_tn_cert_public_url, nodoc); \
553 enum_option_register(sorcery, CONFIG_TYPE, send_mky, nodoc); \
554 })
555
556 int common_config_load(void);
557 int common_config_unload(void);
558 int common_config_reload(void);
559
560 enum config_object_type {
561 config_object_type_attestation = 0,
562 config_object_type_verification,
563 config_object_type_profile,
564 config_object_type_tn,
565 };
566
567 struct config_object_cli_data {
568 const char *title;
569 enum config_object_type object_type;
570 };
571
572 /*!
573 * \brief Output configuration settings to the Asterisk CLI
574 *
575 * \param obj A sorcery object containing configuration data
576 * \param arg Asterisk CLI argument object
577 * \param flags ao2 container flags
578 *
579 * \retval 0
580 */
581 int config_object_cli_show(void *obj, void *arg, void *data, int flags);
582
583 /*!
584 * \brief Tab completion for name matching with STIR/SHAKEN CLI commands
585 *
586 * \param word The word to tab complete on
587 * \param container The sorcery container to iterate through
588 *
589 * \retval The tab completion options
590 */
591 char *config_object_tab_complete_name(const char *word, struct ao2_container *container);
592
593 /*!
594 * \brief Canonicalize a TN
595 *
596 * \param tn TN to canonicalize
597 * \param dest_tn Pointer to destination buffer to receive the new TN
598 *
599 * \retval dest_tn or NULL on failure
600 */
601 char *canonicalize_tn(const char *tn, char *dest_tn);
602
603 /*!
604 * \brief Canonicalize a TN into nre buffer
605 *
606 * \param tn TN to canonicalize
607 *
608 * \retval dest_tn (which must be freed with ast_free) or NULL on failure
609 */
610 char *canonicalize_tn_alloc(const char *tn);
611
612 #endif /* COMMON_CONFIG_H_ */