Asterisk - The Open Source Telephony Project  18.5.0
Functions
certificate.h File Reference
#include <openssl/evp.h>
Include dependency graph for certificate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const char * stir_shaken_certificate_get_attestation (struct stir_shaken_certificate *cert)
 Get the attestation level associated with a certificate. More...
 
struct stir_shaken_certificatestir_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...
 
int stir_shaken_certificate_unload (void)
 Unload time cleanup for the stir/shaken 'certificate' configuration. More...
 

Function Documentation

◆ stir_shaken_certificate_get_attestation()

const char* stir_shaken_certificate_get_attestation ( struct stir_shaken_certificate cert)

Get the attestation level associated with a certificate.

Parameters
certThe certificate
Return values
NULLon failure
Theattestation on success

Definition at line 101 of file certificate.c.

References stir_shaken_certificate::attestation, and NULL.

Referenced by ast_stir_shaken_sign().

102 {
103  return cert ? cert->attestation : NULL;
104 }
#define NULL
Definition: resample.c:96
const ast_string_field attestation
Definition: certificate.c:43

◆ stir_shaken_certificate_get_by_caller_id_number()

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.

Parameters
callier_id_numberThe caller ID number
Return values
NULLif not found
Thecertificate 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().

85 {
86  struct ast_variable fields = {
87  .name = "caller_id_number",
88  .value = caller_id_number,
89  .next = NULL,
90  };
91 
93  "certificate", AST_RETRIEVE_FLAG_DEFAULT, &fields);
94 }
Structure for variables, used for configurations and for channel variables.
#define NULL
Definition: resample.c:96
Default retrieval flags.
Definition: sorcery.h:117
struct ast_sorcery * ast_stir_shaken_sorcery(void)
Retrieve the stir/shaken sorcery context.
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897

◆ stir_shaken_certificate_get_private_key()

EVP_PKEY* stir_shaken_certificate_get_private_key ( struct stir_shaken_certificate cert)

Get the private key associated with a certificate.

Parameters
certThe certificate to get the private key from
Return values
NULLon failure
Theprivate 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().

107 {
108  return cert ? cert->private_key : NULL;
109 }
#define NULL
Definition: resample.c:96

◆ stir_shaken_certificate_get_public_cert_url()

const char* stir_shaken_certificate_get_public_cert_url ( struct stir_shaken_certificate cert)

Get the public key URL associated with a certificate.

Parameters
certThe certificate to get the public key URL from
Return values
NULLon failure
Thepublic 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().

97 {
98  return cert ? cert->public_cert_url : NULL;
99 }
#define NULL
Definition: resample.c:96
const ast_string_field public_cert_url
Definition: certificate.c:43

◆ stir_shaken_certificate_load()

int stir_shaken_certificate_load ( void  )

Load time initialization for the stir/shaken 'certificate' configuration.

Return values
0on 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().

356 {
358 
359  ast_sorcery_apply_default(sorcery, CONFIG_TYPE, "config", "stir_shaken.conf,criteria=type=certificate");
360 
363  ast_log(LOG_ERROR, "stir/shaken - failed to register '%s' sorcery object\n", CONFIG_TYPE);
364  return -1;
365  }
366 
367  ast_sorcery_object_field_register(sorcery, CONFIG_TYPE, "type", "", OPT_NOOP_T, 0, 0);
369  on_load_path, path_to_str, NULL, 0, 0);
370  ast_sorcery_object_field_register_custom(sorcery, CONFIG_TYPE, "public_cert_url", "",
372  ast_sorcery_object_field_register_custom(sorcery, CONFIG_TYPE, "attestation", "",
374  ast_sorcery_object_field_register(sorcery, CONFIG_TYPE, "caller_id_number", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct stir_shaken_certificate, caller_id_number));
375 
378 
379  return 0;
380 }
static int on_load_path(const struct aco_option *opt, struct ast_variable *var, void *obj)
Definition: certificate.c:203
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define CONFIG_TYPE
Definition: certificate.c:30
static int on_load_public_cert_url(const struct aco_option *opt, struct ast_variable *var, void *obj)
Definition: certificate.c:230
Full structure for sorcery.
Definition: sorcery.c:230
Type for a default handler that should do nothing.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define NULL
Definition: resample.c:96
static void * stir_shaken_certificate_alloc(const char *name)
Definition: certificate.c:67
#define ast_log
Definition: astobj2.c:42
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
Definition: sorcery.h:1005
static int public_cert_url_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: certificate.c:242
static struct ast_cli_entry stir_shaken_certificate_cli[]
Definition: certificate.c:198
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:838
#define LOG_ERROR
Definition: logger.h:285
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:477
struct ast_sorcery * ast_stir_shaken_sorcery(void)
Retrieve the stir/shaken sorcery context.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
static int path_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: certificate.c:221
static struct ast_sorcery * sorcery
static int stir_shaken_certificate_apply(const struct ast_sorcery *sorcery, void *obj)
Definition: certificate.c:111
Type for default option handler for stringfields.
static int attestation_to_str(const void *obj, const intptr_t *args, char **buf)
Definition: certificate.c:264
static int on_load_attestation(const struct aco_option *opt, struct ast_variable *var, void *obj)
Definition: certificate.c:251

◆ stir_shaken_certificate_unload()

int stir_shaken_certificate_unload ( void  )

Unload time cleanup for the stir/shaken 'certificate' configuration.

Return values
0on success, -1 on error

Definition at line 347 of file certificate.c.

References ARRAY_LEN, and ast_cli_unregister_multiple().

Referenced by unload_module().

348 {
351 
352  return 0;
353 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ast_cli_entry stir_shaken_certificate_cli[]
Definition: certificate.c:198