Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
res_stir_shaken.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2020, Sangoma Technologies Corporation
5 *
6 * Kevin Harwell <kharwell@sangoma.com>
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#ifndef _RES_STIR_SHAKEN_H
19#define _RES_STIR_SHAKEN_H
20
21#include "asterisk/sorcery.h"
22
60};
61
77};
78
80 /*! Unknown value */
82 /*! Continue and let dialplan decide action */
84 /*! Reject request with respone codes defined in RFC8224 */
86 /*! Continue but return a Reason header in next provisional response */
88 /*! Not set in config */
90};
91
93
94/*!
95 * \brief Create Attestation Service Context
96 *
97 * \param caller_id The caller_id for the outgoing call
98 * \param dest_tn Canonicalized destination tn
99 * \param chan The outgoing channel
100 * \param profile_name The profile name on the endpoint
101 * May be NULL.
102 * \param tag Identifying string to output in log and trace messages.
103 * \param ctxout Receives a pointer to the newly created context
104 * The caller must release with ao2_ref or ao2_cleanup.
105
106 * \retval AST_STIR_SHAKEN_AS_SUCCESS if successful.
107 * \retval AST_STIR_SHAKEN_AS_DISABLED if attestation is disabled
108 * by the endpoint itself, the profile or globally.
109 * \retval Other AST_STIR_SHAKEN_AS errors.
110 */
112 ast_stir_shaken_as_ctx_create(const char *caller_id,
113 const char *dest_tn, struct ast_channel *chan,
114 const char *profile_name,
115 const char *tag, struct ast_stir_shaken_as_ctx **ctxout);
116
117/*!
118 * \brief Indicates if the AS context needs DTLS fingerprints
119 *
120 * \param ctx AS Context
121 *
122 * \retval 0 Not needed
123 * \retval 1 Needed
124 */
126
127/*!
128 * \brief Add DTLS fingerprints to AS context
129 *
130 * \param ctx AS context
131 * \param alg Fingerprint algorithm ("sha-1" or "sha-256")
132 * \param fingerprint Fingerprint
133 *
134 * \retval AST_STIR_SHAKEN_AS_SUCCESS if successful
135 * \retval Other AST_STIR_SHAKEN_AS errors.
136 */
138 struct ast_stir_shaken_as_ctx *ctx, const char *alg, const char *fingerprint);
139
140/*!
141 * \brief Attest and return Identity header value
142 *
143 * \param ctx AS Context
144 * \param header Pointer to buffer to receive the header value
145 * Must be freed with ast_free when done
146 *
147 * \retval AST_STIR_SHAKEN_AS_SUCCESS if successful
148 * \retval Other AST_STIR_SHAKEN_AS errors.
149 */
151 struct ast_stir_shaken_as_ctx *ctx, char **header);
152
153
155
156/*!
157 * \brief Create Verification Service context
158 *
159 * \param caller_id Incoming caller id
160 * \param chan Incoming channel
161 * \param profile_name The profile name on the endpoint
162 * May be NULL.
163 * \param endpoint_behavior Behavior associated to the specific
164 * endpoint
165 * \param tag Identifying string to output in log and trace messages.
166 * \param ctxout Receives a pointer to the newly created context
167 * The caller must release with ao2_ref or ao2_cleanup.
168 *
169 * \retval AST_STIR_SHAKEN_VS_SUCCESS if successful.
170 * \retval AST_STIR_SHAKEN_VS_DISABLED if verification is disabled
171 * by the endpoint itself, the profile or globally.
172 * \retval Other AST_STIR_SHAKEN_VS errors.
173 */
176 struct ast_channel *chan, const char *profile_name,
177 const char *tag, struct ast_stir_shaken_vs_ctx **ctxout);
178
179/*!
180 * \brief Sets response code on VS context
181 *
182 * \param ctx VS context
183 * \param vs_rc ast_stir_shaken_vs_response_code to set
184 */
186 struct ast_stir_shaken_vs_ctx *ctx,
188
189/*!
190 * \brief Add the received Identity header value to the VS context
191 *
192 * \param ctx VS context
193 * \param identity_hdr Identity header value
194 *
195 * \retval AST_STIR_SHAKEN_VS_SUCCESS if successful
196 * \retval Other AST_STIR_SHAKEN_VS errors.
197 */
200 const char *identity_hdr);
201
202/*!
203 * \brief Add the received Date header value to the VS context
204 *
205 * \param ctx VS context
206 * \param date_hdr Date header value
207 *
208 * \retval AST_STIR_SHAKEN_VS_SUCCESS if successful
209 * \retval Other AST_STIR_SHAKEN_VS errors.
210 */
213 const char *date_hdr);
214
215/*!
216 * \brief Get failure_action from context
217 *
218 * \param ctx VS context
219 *
220 * \retval ast_stir_shaken_failure_action
221 */
224 struct ast_stir_shaken_vs_ctx *ctx);
225
226/*!
227 * \brief Get use_rfc9410_responses from context
228 *
229 * \param ctx VS context
230 *
231 * \retval 1 if true
232 * \retval 0 if false
233 */
235 struct ast_stir_shaken_vs_ctx *ctx);
236
237/*!
238 * \brief Get caller_id from context
239 *
240 * \param ctx VS context
241 *
242 * \retval Caller ID or NULL
243 */
245 struct ast_stir_shaken_vs_ctx *ctx);
246
247/*!
248 * \brief Add a STIR/SHAKEN verification result to a channel
249 *
250 * \param ctx VS context
251 *
252 * \retval -1 on failure
253 * \retval 0 on success
254 */
256 struct ast_stir_shaken_vs_ctx *ctx);
257
258/*!
259 * \brief Perform incoming call verification
260 *
261 * \param ctx VS context
262 *
263 * \retval AST_STIR_SHAKEN_AS_SUCCESS if successful
264 * \retval Other AST_STIR_SHAKEN_AS errors.
265 */
268
269#endif /* _RES_STIR_SHAKEN_H */
enum ast_stir_shaken_vs_response_code ast_stir_shaken_vs_ctx_add_date_hdr(struct ast_stir_shaken_vs_ctx *ctx, const char *date_hdr)
Add the received Date header value to the VS context.
Definition: verification.c:613
int ast_stir_shaken_add_result_to_channel(struct ast_stir_shaken_vs_ctx *ctx)
Add a STIR/SHAKEN verification result to a channel.
const char * ast_stir_shaken_vs_get_caller_id(struct ast_stir_shaken_vs_ctx *ctx)
Get caller_id from context.
Definition: verification.c:633
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.
Definition: attestation.c:206
ast_stir_shaken_as_response_code
@ AST_STIR_SHAKEN_AS_NO_TN_FOR_CALLERID
@ AST_STIR_SHAKEN_AS_INVALID_ARGUMENTS
@ AST_STIR_SHAKEN_AS_TO_HDR_BAD_URI
@ AST_STIR_SHAKEN_AS_MISSING_PARAMETERS
@ AST_STIR_SHAKEN_AS_NO_PRIVATE_KEY_AVAIL
@ AST_STIR_SHAKEN_AS_DISABLED
@ AST_STIR_SHAKEN_AS_SIGN_ENCODE_FAILURE
@ AST_STIR_SHAKEN_AS_NO_TO_HDR
@ AST_STIR_SHAKEN_AS_NO_PUBLIC_CERT_URL_AVAIL
@ AST_STIR_SHAKEN_AS_SUCCESS
@ AST_STIR_SHAKEN_AS_RESPONSE_CODE_MAX
@ AST_STIR_SHAKEN_AS_INTERNAL_ERROR
@ AST_STIR_SHAKEN_AS_IDENTITY_HDR_EXISTS
@ AST_STIR_SHAKEN_AS_NO_ATTEST_LEVEL
enum stir_shaken_failure_action_enum ast_stir_shaken_vs_get_failure_action(struct ast_stir_shaken_vs_ctx *ctx)
Get failure_action from context.
Definition: verification.c:621
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.
Definition: attestation.c:66
enum ast_stir_shaken_vs_response_code ast_stir_shaken_vs_verify(struct ast_stir_shaken_vs_ctx *ctx)
Perform incoming call verification.
Definition: verification.c:884
int ast_stir_shaken_vs_get_use_rfc9410_responses(struct ast_stir_shaken_vs_ctx *ctx)
Get use_rfc9410_responses from context.
Definition: verification.c:627
enum ast_stir_shaken_vs_response_code ast_stir_shaken_vs_ctx_create(const char *caller_id, struct ast_channel *chan, const char *profile_name, const char *tag, struct ast_stir_shaken_vs_ctx **ctxout)
Create Verification Service context.
Definition: verification.c:657
enum ast_stir_shaken_vs_response_code ast_stir_shaken_vs_ctx_add_identity_hdr(struct ast_stir_shaken_vs_ctx *ctx, const char *identity_hdr)
Add the received Identity header value to the VS context.
Definition: verification.c:605
ast_stir_shaken_vs_response_code
@ AST_STIR_SHAKEN_VS_CERT_DATE_INVALID
@ AST_STIR_SHAKEN_VS_NO_DATE_HDR
@ AST_STIR_SHAKEN_VS_SUCCESS
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_ATTEST
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_TYP
@ AST_STIR_SHAKEN_VS_CID_ORIG_TN_MISMATCH
@ AST_STIR_SHAKEN_VS_NO_JWT_HDR
@ AST_STIR_SHAKEN_VS_NO_DEST_TN
@ AST_STIR_SHAKEN_VS_IAT_EXPIRED
@ AST_STIR_SHAKEN_VS_NO_IDENTITY_HDR
@ AST_STIR_SHAKEN_VS_NO_RAW_KEY
@ AST_STIR_SHAKEN_VS_DATE_HDR_EXPIRED
@ AST_STIR_SHAKEN_VS_INVALID_ARGUMENTS
@ AST_STIR_SHAKEN_VS_SIGNATURE_VALIDATION
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_ALG
@ AST_STIR_SHAKEN_VS_CERT_CONTENTS_INVALID
@ AST_STIR_SHAKEN_VS_NO_ORIGID
@ AST_STIR_SHAKEN_VS_INVALID_HEADER
@ AST_STIR_SHAKEN_VS_CERT_CACHE_INVALID
@ AST_STIR_SHAKEN_VS_INVALID_GRANT
@ AST_STIR_SHAKEN_VS_DISABLED
@ AST_STIR_SHAKEN_VS_CERT_CACHE_MISS
@ AST_STIR_SHAKEN_VS_CERT_CACHE_EXPIRED
@ AST_STIR_SHAKEN_VS_NO_IAT
@ AST_STIR_SHAKEN_VS_NO_ORIG_TN
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_PPT
@ AST_STIR_SHAKEN_VS_CERT_NOT_TRUSTED
@ AST_STIR_SHAKEN_VS_DATE_HDR_PARSE_FAILURE
@ AST_STIR_SHAKEN_VS_INTERNAL_ERROR
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_CID
@ AST_STIR_SHAKEN_VS_CERT_NO_SPC_IN_TN_AUTH_EXT
@ AST_STIR_SHAKEN_VS_RESPONSE_CODE_MAX
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_GRANTS
@ AST_STIR_SHAKEN_VS_INVALID_OR_NO_X5U
@ AST_STIR_SHAKEN_VS_CERT_RETRIEVAL_FAILURE
@ AST_STIR_SHAKEN_VS_CERT_NO_TN_AUTH_EXT
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.
Definition: attestation.c:364
int ast_stir_shaken_as_ctx_wants_fingerprints(struct ast_stir_shaken_as_ctx *ctx)
Indicates if the AS context needs DTLS fingerprints.
Definition: attestation.c:200
void ast_stir_shaken_vs_ctx_set_response_code(struct ast_stir_shaken_vs_ctx *ctx, enum ast_stir_shaken_vs_response_code vs_rc)
Sets response code on VS context.
Definition: verification.c:639
stir_shaken_failure_action_enum
@ stir_shaken_failure_action_CONTINUE
@ stir_shaken_failure_action_CONTINUE_RETURN_REASON
@ stir_shaken_failure_action_UNKNOWN
@ stir_shaken_failure_action_NOT_SET
@ stir_shaken_failure_action_REJECT_REQUEST
Sorcery Data Access Layer API.
Main Channel structure associated with a channel.
const ast_string_field dest_tn
Definition: attestation.h:29
const ast_string_field tag
Definition: attestation.h:29
struct ast_channel * chan
Definition: attestation.h:30
const ast_string_field tag
Definition: verification.h:39
const ast_string_field date_hdr
Definition: verification.h:39
const ast_string_field identity_hdr
Definition: verification.h:39
struct ast_channel * chan
Definition: verification.h:41
const ast_string_field caller_id
Definition: verification.h:39