Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include <jwt.h>
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/uuid.h"
#include "asterisk/json.h"
#include "asterisk/channel.h"
#include "stir_shaken.h"
Go to the source code of this file.
Macros | |
#define | _TRACE_PREFIX_ "a",__LINE__, "" |
#define | CREATE_JSON_APPEND_ARRAY(__val, __obj) |
#define | CREATE_JSON_SET_OBJ(__val, __obj, __name) |
Functions | |
int | as_load () |
Load the stir/shaken attestation service. More... | |
int | as_reload () |
Load the stir/shaken attestation service. More... | |
const char * | as_response_code_to_str (enum ast_stir_shaken_as_response_code as_rc) |
Return string version of AS response code. More... | |
int | as_unload () |
Load the stir/shaken attestation service. More... | |
enum ast_stir_shaken_as_response_code | ast_stir_shaken_as_ctx_add_fingerprint (struct ast_stir_shaken_as_ctx *ctx, const char *alg, const char *fingerprint) |
Add DTLS fingerprints to AS context. More... | |
enum ast_stir_shaken_as_response_code | ast_stir_shaken_as_ctx_create (const char *orig_tn, const char *dest_tn, struct ast_channel *chan, const char *profile_name, const char *tag, struct ast_stir_shaken_as_ctx **ctxout) |
Create Attestation Service Context. More... | |
int | ast_stir_shaken_as_ctx_wants_fingerprints (struct ast_stir_shaken_as_ctx *ctx) |
Indicates if the AS context needs DTLS fingerprints. More... | |
enum ast_stir_shaken_as_response_code | ast_stir_shaken_attest (struct ast_stir_shaken_as_ctx *ctx, char **header) |
Attest and return Identity header value. More... | |
static void | ctx_destructor (void *obj) |
static enum ast_stir_shaken_as_response_code | pack_payload (struct ast_stir_shaken_as_ctx *ctx, jwt_t *jwt) |
Variables | |
static const char * | as_rc_map [] |
#define _TRACE_PREFIX_ "a",__LINE__, "" |
Definition at line 21 of file attestation.c.
#define CREATE_JSON_APPEND_ARRAY | ( | __val, | |
__obj | |||
) |
Definition at line 273 of file attestation.c.
#define CREATE_JSON_SET_OBJ | ( | __val, | |
__obj, | |||
__name | |||
) |
Definition at line 256 of file attestation.c.
int as_load | ( | void | ) |
Load the stir/shaken attestation service.
0 | on success |
-1 | on error |
Definition at line 440 of file attestation.c.
References as_config_load(), AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.
Referenced by common_config_load().
int as_reload | ( | void | ) |
Load the stir/shaken attestation service.
0 | on success |
-1 | on error |
Definition at line 427 of file attestation.c.
References as_config_reload().
Referenced by common_config_reload().
const char * as_response_code_to_str | ( | enum ast_stir_shaken_as_response_code | as_rc | ) |
Return string version of AS response code.
as_rc |
Definition at line 47 of file attestation.c.
References ARRAY_IN_BOUNDS, as_rc_map, and NULL.
int as_unload | ( | void | ) |
Load the stir/shaken attestation service.
0 | on success |
-1 | on error |
Definition at line 434 of file attestation.c.
References as_config_unload().
Referenced by common_config_unload().
enum ast_stir_shaken_as_response_code ast_stir_shaken_as_ctx_add_fingerprint | ( | struct ast_stir_shaken_as_ctx * | ctx, |
const char * | alg, | ||
const char * | fingerprint | ||
) |
Add DTLS fingerprints to AS context.
ctx | AS context |
alg | Fingerprint algorithm ("sha-1" or "sha-256") |
fingerprint | Fingerprint |
AST_STIR_SHAKEN_AS_SUCCESS | if successful |
Other | AST_STIR_SHAKEN_AS errors. |
Definition at line 206 of file attestation.c.
References tn_cfg::acfg_common, ast_alloca, ast_asprintf, AST_STIR_SHAKEN_AS_DISABLED, AST_STIR_SHAKEN_AS_INTERNAL_ERROR, AST_STIR_SHAKEN_AS_INVALID_ARGUMENTS, AST_STIR_SHAKEN_AS_SUCCESS, ast_strlen_zero(), AST_VECTOR_ADD_SORTED, ENUM_BOOL, ast_stir_shaken_as_ctx::etn, ast_stir_shaken_as_ctx::fingerprints, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, attestation_cfg_common::send_mky, and ast_stir_shaken_as_ctx::tag.
Referenced by add_fingerprints_if_present().
enum ast_stir_shaken_as_response_code ast_stir_shaken_as_ctx_create | ( | const char * | caller_id, |
const char * | dest_tn, | ||
struct ast_channel * | chan, | ||
const char * | profile_name, | ||
const char * | tag, | ||
struct ast_stir_shaken_as_ctx ** | ctxout | ||
) |
Create Attestation Service Context.
caller_id | The caller_id for the outgoing call |
dest_tn | Canonicalized destination tn |
chan | The outgoing channel |
profile_name | The profile name on the endpoint May be NULL. |
tag | Identifying string to output in log and trace messages. |
ctxout | Receives a pointer to the newly created context The caller must release with ao2_ref or ao2_cleanup. |
AST_STIR_SHAKEN_AS_SUCCESS | if successful. |
AST_STIR_SHAKEN_AS_DISABLED | if attestation is disabled by the endpoint itself, the profile or globally. |
Other | AST_STIR_SHAKEN_AS errors. |
Definition at line 66 of file attestation.c.
References tn_cfg::acfg_common, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, as_get_cfg(), ast_channel_name(), ast_channel_ref, ast_free, AST_STIR_SHAKEN_AS_DISABLED, AST_STIR_SHAKEN_AS_INTERNAL_ERROR, AST_STIR_SHAKEN_AS_INVALID_ARGUMENTS, AST_STIR_SHAKEN_AS_MISSING_PARAMETERS, AST_STIR_SHAKEN_AS_NO_PRIVATE_KEY_AVAIL, AST_STIR_SHAKEN_AS_NO_PUBLIC_CERT_URL_AVAIL, AST_STIR_SHAKEN_AS_SUCCESS, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), AST_VECTOR_INIT, attestation_cfg_common::attest_level, canonicalize_tn_alloc(), ast_stir_shaken_as_ctx::chan, ctx_destructor(), ast_stir_shaken_as_ctx::dest_tn, eprofile_get_cfg(), ast_stir_shaken_as_ctx::etn, LOG_ERROR, NULL, ast_stir_shaken_as_ctx::orig_tn, PROFILE_ALLOW_ATTEST, attestation_cfg_common::public_cert_url, RAII_VAR, attestation_cfg_common::raw_key_length, S_COR, S_OR, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, ast_stir_shaken_as_ctx::tag, and tn_get_etn().
Referenced by stir_shaken_outgoing_request().
int ast_stir_shaken_as_ctx_wants_fingerprints | ( | struct ast_stir_shaken_as_ctx * | ctx | ) |
Indicates if the AS context needs DTLS fingerprints.
ctx | AS Context |
0 | Not needed |
1 | Needed |
Definition at line 200 of file attestation.c.
References tn_cfg::acfg_common, ENUM_BOOL, ast_stir_shaken_as_ctx::etn, and attestation_cfg_common::send_mky.
Referenced by add_fingerprints_if_present().
enum ast_stir_shaken_as_response_code ast_stir_shaken_attest | ( | struct ast_stir_shaken_as_ctx * | ctx, |
char ** | header | ||
) |
Attest and return Identity header value.
ctx | AS Context |
header | Pointer to buffer to receive the header value Must be freed with ast_free when done |
AST_STIR_SHAKEN_AS_SUCCESS | if successful |
Other | AST_STIR_SHAKEN_AS errors. |
Definition at line 364 of file attestation.c.
References tn_cfg::acfg_common, ast_asprintf, ast_std_free(), AST_STIR_SHAKEN_AS_INTERNAL_ERROR, AST_STIR_SHAKEN_AS_INVALID_ARGUMENTS, AST_STIR_SHAKEN_AS_SIGN_ENCODE_FAILURE, AST_STIR_SHAKEN_AS_SUCCESS, AST_STIR_SHAKEN_VS_INTERNAL_ERROR, ast_stir_shaken_as_ctx::dest_tn, ast_stir_shaken_as_ctx::etn, LOG_ERROR, NULL, ast_stir_shaken_as_ctx::orig_tn, pack_payload(), attestation_cfg_common::public_cert_url, RAII_VAR, attestation_cfg_common::raw_key, attestation_cfg_common::raw_key_length, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, STIR_SHAKEN_ENCRYPTION_ALGORITHM, STIR_SHAKEN_PPT, STIR_SHAKEN_TYPE, and ast_stir_shaken_as_ctx::tag.
Referenced by stir_shaken_outgoing_request().
|
static |
Definition at line 54 of file attestation.c.
References ao2_cleanup, ast_channel_cleanup, ast_free, ast_string_field_free_memory, AST_VECTOR_FREE, AST_VECTOR_RESET, ast_stir_shaken_as_ctx::chan, ast_stir_shaken_as_ctx::etn, and ast_stir_shaken_as_ctx::fingerprints.
Referenced by ast_stir_shaken_as_ctx_create().
|
static |
Definition at line 290 of file attestation.c.
References tn_cfg::acfg_common, ast_json_array_create(), AST_JSON_COMPACT, ast_json_dump_string_format(), ast_json_free(), ast_json_integer_create(), ast_json_object_create(), ast_json_string_create(), ast_json_unref(), AST_STIR_SHAKEN_AS_SUCCESS, ast_trace, ast_uuid_generate_str(), AST_UUID_STR_LEN, AST_VECTOR_GET, AST_VECTOR_SIZE, attestation_cfg_common::attest_level, CREATE_JSON_APPEND_ARRAY, CREATE_JSON_SET_OBJ, ast_stir_shaken_as_ctx::dest_tn, ENUM_BOOL, ast_stir_shaken_as_ctx::etn, ast_stir_shaken_as_ctx::fingerprints, NULL, ast_stir_shaken_as_ctx::orig_tn, RAII_VAR, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, attestation_cfg_common::send_mky, and ast_stir_shaken_as_ctx::tag.
Referenced by ast_stir_shaken_attest().
|
static |
Definition at line 31 of file attestation.c.
Referenced by as_response_code_to_str().