Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <sys/stat.h>
#include "asterisk/cli.h"
#include "asterisk/sorcery.h"
#include "stir_shaken.h"
#include "certificate.h"
#include "asterisk/res_stir_shaken.h"
Go to the source code of this file.
Data Structures | |
struct | stir_shaken_certificate |
Macros | |
#define | CONFIG_TYPE "certificate" |
#define | TEST_CONFIG_NAME "test_stir_shaken_certificate" |
#define | TEST_CONFIG_URL "http://testing123" |
Functions | |
static int | attestation_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | on_load_attestation (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | on_load_path (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | on_load_public_cert_url (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | path_to_str (const void *obj, const intptr_t *args, char **buf) |
static int | public_cert_url_to_str (const void *obj, const intptr_t *args, char **buf) |
static void * | stir_shaken_certificate_alloc (const char *name) |
static int | stir_shaken_certificate_apply (const struct ast_sorcery *sorcery, void *obj) |
static void | stir_shaken_certificate_destructor (void *obj) |
static struct stir_shaken_certificate * | stir_shaken_certificate_get (const char *id) |
static struct ao2_container * | stir_shaken_certificate_get_all (void) |
const char * | stir_shaken_certificate_get_attestation (struct stir_shaken_certificate *cert) |
Get the attestation level associated with a certificate. More... | |
struct stir_shaken_certificate * | stir_shaken_certificate_get_by_caller_id_number (const char *caller_id_number) |
Get a STIR/SHAKEN certificate by caller ID number. More... | |
EVP_PKEY * | stir_shaken_certificate_get_private_key (struct stir_shaken_certificate *cert) |
Get the private key associated with a certificate. More... | |
const char * | stir_shaken_certificate_get_public_cert_url (struct stir_shaken_certificate *cert) |
Get the public key URL associated with a certificate. More... | |
int | stir_shaken_certificate_load (void) |
Load time initialization for the stir/shaken 'certificate' configuration. More... | |
static char * | stir_shaken_certificate_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | stir_shaken_certificate_show_all (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
int | stir_shaken_certificate_unload (void) |
Unload time cleanup for the stir/shaken 'certificate' configuration. More... | |
int | test_stir_shaken_cleanup_cert (const char *caller_id_number) |
int | test_stir_shaken_create_cert (const char *caller_id_number, const char *file_path) |
Variables | |
static struct ast_cli_entry | stir_shaken_certificate_cli [] |
#define CONFIG_TYPE "certificate" |
Definition at line 30 of file certificate.c.
Referenced by stir_shaken_certificate_get(), stir_shaken_certificate_get_all(), stir_shaken_certificate_load(), test_stir_shaken_cleanup_cert(), and test_stir_shaken_create_cert().
#define TEST_CONFIG_NAME "test_stir_shaken_certificate" |
Definition at line 276 of file certificate.c.
Referenced by test_stir_shaken_create_cert().
#define TEST_CONFIG_URL "http://testing123" |
Definition at line 278 of file certificate.c.
Referenced by test_stir_shaken_create_cert().
|
static |
Definition at line 264 of file certificate.c.
References ast_strdup, and stir_shaken_certificate::attestation.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 251 of file certificate.c.
References ast_log, ast_sorcery_object_get_id(), ast_string_field_set, stir_shaken_certificate::attestation, LOG_ERROR, and ast_variable::value.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 203 of file certificate.c.
References ast_log, ast_string_field_set, LOG_ERROR, stir_shaken_certificate::path, and ast_variable::value.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 230 of file certificate.c.
References ast_begins_with(), ast_log, ast_string_field_set, LOG_ERROR, stir_shaken_certificate::public_cert_url, and ast_variable::value.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 221 of file certificate.c.
References ast_strdup, and stir_shaken_certificate::path.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 242 of file certificate.c.
References ast_strdup, and stir_shaken_certificate::public_cert_url.
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 67 of file certificate.c.
References ao2_ref, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, and stir_shaken_certificate_destructor().
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 111 of file certificate.c.
References ast_log, ast_strlen_zero, stir_shaken_certificate::attestation, stir_shaken_certificate::caller_id_number, LOG_ERROR, stir_shaken_certificate::path, stir_shaken_certificate::private_key, and stir_shaken_read_key().
Referenced by stir_shaken_certificate_load().
|
static |
Definition at line 59 of file certificate.c.
References ast_string_field_free_memory, and stir_shaken_certificate::private_key.
Referenced by stir_shaken_certificate_alloc().
|
static |
Definition at line 48 of file certificate.c.
References ast_sorcery_retrieve_by_id(), ast_stir_shaken_sorcery(), and CONFIG_TYPE.
Referenced by stir_shaken_certificate_show().
|
static |
Definition at line 53 of file certificate.c.
References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), ast_stir_shaken_sorcery(), CONFIG_TYPE, and NULL.
Referenced by stir_shaken_certificate_show(), and stir_shaken_certificate_show_all().
const char* stir_shaken_certificate_get_attestation | ( | struct stir_shaken_certificate * | cert | ) |
Get the attestation level associated with a certificate.
cert | The certificate |
NULL | on failure |
The | attestation on success |
Definition at line 101 of file certificate.c.
References stir_shaken_certificate::attestation, and NULL.
Referenced by ast_stir_shaken_sign().
struct stir_shaken_certificate* stir_shaken_certificate_get_by_caller_id_number | ( | const char * | caller_id_number | ) |
Get a STIR/SHAKEN certificate by caller ID number.
callier_id_number | The caller ID number |
NULL | if not found |
The | certificate on success |
Definition at line 84 of file certificate.c.
References AST_RETRIEVE_FLAG_DEFAULT, ast_sorcery_retrieve_by_fields(), ast_stir_shaken_sorcery(), stir_shaken_certificate::caller_id_number, ast_variable::name, and NULL.
Referenced by ast_stir_shaken_sign(), and test_stir_shaken_cleanup_cert().
EVP_PKEY* stir_shaken_certificate_get_private_key | ( | struct stir_shaken_certificate * | cert | ) |
Get the private key associated with a certificate.
cert | The certificate to get the private key from |
NULL | on failure |
The | private key on success |
Definition at line 106 of file certificate.c.
References NULL, and stir_shaken_certificate::private_key.
Referenced by ast_stir_shaken_sign().
const char* stir_shaken_certificate_get_public_cert_url | ( | struct stir_shaken_certificate * | cert | ) |
Get the public key URL associated with a certificate.
cert | The certificate to get the public key URL from |
NULL | on failure |
The | public key URL on success |
Definition at line 96 of file certificate.c.
References NULL, and stir_shaken_certificate::public_cert_url.
Referenced by ast_stir_shaken_sign().
int stir_shaken_certificate_load | ( | void | ) |
Load time initialization for the stir/shaken 'certificate' configuration.
0 | on success, -1 on error |
Definition at line 355 of file certificate.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_log, ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, ast_stir_shaken_sorcery(), attestation_to_str(), stir_shaken_certificate::caller_id_number, CONFIG_TYPE, LOG_ERROR, NULL, on_load_attestation(), on_load_path(), on_load_public_cert_url(), OPT_NOOP_T, OPT_STRINGFIELD_T, path_to_str(), public_cert_url_to_str(), sorcery, stir_shaken_certificate_alloc(), stir_shaken_certificate_apply(), and STRFLDSET.
Referenced by load_module().
|
static |
Definition at line 136 of file certificate.c.
References ao2_cleanup, ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, ast_cli_args::pos, stir_shaken_certificate_get(), stir_shaken_certificate_get_all(), stir_shaken_cli_show(), stir_shaken_tab_complete_name(), ast_cli_entry::usage, and ast_cli_args::word.
|
static |
Definition at line 166 of file certificate.c.
References ao2_callback, ao2_cleanup, ao2_container_count(), ao2_ref, ast_cli_args::argc, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, container, ast_cli_args::fd, NULL, OBJ_NODATA, stir_shaken_certificate_get_all(), stir_shaken_cli_show(), and ast_cli_entry::usage.
int stir_shaken_certificate_unload | ( | void | ) |
Unload time cleanup for the stir/shaken 'certificate' configuration.
0 | on success, -1 on error |
Definition at line 347 of file certificate.c.
References ARRAY_LEN, and ast_cli_unregister_multiple().
Referenced by unload_module().
int test_stir_shaken_cleanup_cert | ( | const char * | caller_id_number | ) |
Definition at line 280 of file certificate.c.
References ao2_cleanup, ast_log, ast_sorcery_delete(), ast_sorcery_remove_wizard_mapping, ast_stir_shaken_sorcery(), CONFIG_TYPE, LOG_ERROR, sorcery, and stir_shaken_certificate_get_by_caller_id_number().
Referenced by AST_TEST_DEFINE(), and test_stir_shaken_create_cert().
int test_stir_shaken_create_cert | ( | const char * | caller_id_number, |
const char * | file_path | ||
) |
Definition at line 306 of file certificate.c.
References ast_log, ast_sorcery_alloc(), ast_sorcery_create(), ast_sorcery_insert_wizard_mapping, ast_stir_shaken_sorcery(), ast_string_field_set, CONFIG_TYPE, LOG_ERROR, stir_shaken_certificate::path, stir_shaken_certificate::private_key, stir_shaken_certificate::public_cert_url, sorcery, stir_shaken_read_key(), TEST_CONFIG_NAME, TEST_CONFIG_URL, and test_stir_shaken_cleanup_cert().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 198 of file certificate.c.