Asterisk - The Open Source Telephony Project  18.5.0
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 <[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 #ifndef _RES_STIR_SHAKEN_H
19 #define _RES_STIR_SHAKEN_H
20 
21 #define STIR_SHAKEN_ENCRYPTION_ALGORITHM "ES256"
22 #define STIR_SHAKEN_PPT "shaken"
23 #define STIR_SHAKEN_TYPE "passport"
24 
26  AST_STIR_SHAKEN_VERIFY_NOT_PRESENT, /*! No STIR/SHAKEN information was available */
27  AST_STIR_SHAKEN_VERIFY_SIGNATURE_FAILED, /*! Signature verification failed */
28  AST_STIR_SHAKEN_VERIFY_MISMATCH, /*! Contents of the signaling and the STIR/SHAKEN payload did not match */
29  AST_STIR_SHAKEN_VERIFY_PASSED, /*! Signature verified and contents match signaling */
30 };
31 
33 
34 struct ast_json;
35 
36 /*!
37  * \brief Retrieve the value for 'signature' from an ast_stir_shaken_payload
38  *
39  * \param payload The payload
40  *
41  * \retval The signature
42  */
43 unsigned char *ast_stir_shaken_payload_get_signature(const struct ast_stir_shaken_payload *payload);
44 
45 /*!
46  * \brief Retrieve the value for 'public_cert_url' from an ast_stir_shaken_payload
47  *
48  * \param payload The payload
49  *
50  * \retval The public key URL
51  */
53 
54 /*!
55  * \brief Retrieve the value for 'signature_timeout' from 'general' config object
56  *
57  * \retval The signature timeout
58  */
59 unsigned int ast_stir_shaken_get_signature_timeout(void);
60 
61 /*!
62  * \brief Add a STIR/SHAKEN verification result to a channel
63  *
64  * \param chan The channel
65  * \param identity The identity
66  * \param attestation The attestation
67  * \param result The verification result
68  *
69  * \retval -1 on failure
70  * \retval 0 on success
71  */
72 int ast_stir_shaken_add_verification(struct ast_channel *chan, const char *identity, const char *attestation,
74 
75 /*!
76  * \brief Verify a JSON STIR/SHAKEN payload
77  *
78  * \param header The payload header
79  * \param payload The payload section
80  * \param signature The payload signature
81  * \param algorithm The signature algorithm
82  * \param public_cert_url The public key URL
83  *
84  * \retval ast_stir_shaken_payload on success
85  * \retval NULL on failure
86  */
87 struct ast_stir_shaken_payload *ast_stir_shaken_verify(const char *header, const char *payload, const char *signature,
88  const char *algorithm, const char *public_cert_url);
89 
90 /*!
91  * \brief Retrieve the stir/shaken sorcery context
92  *
93  * \retval The stir/shaken sorcery context
94  */
96 
97 /*!
98  * \brief Free a STIR/SHAKEN payload
99  */
101 
102 /*!
103  * \brief Sign a JSON STIR/SHAKEN payload
104  *
105  * \note This function will automatically add the "attest", "iat", and "origid" fields.
106  *
107  * \param json The JWT to sign
108  *
109  * \retval ast_stir_shaken_payload on success
110  * \retval NULL on failure
111  */
113 
114 #endif /* _RES_STIR_SHAKEN_H */
Main Channel structure associated with a channel.
unsigned char * signature
unsigned int ast_stir_shaken_get_signature_timeout(void)
Retrieve the value for &#39;signature_timeout&#39; from &#39;general&#39; config object.
Full structure for sorcery.
Definition: sorcery.c:230
char * ast_stir_shaken_payload_get_public_cert_url(const struct ast_stir_shaken_payload *payload)
Retrieve the value for &#39;public_cert_url&#39; from an ast_stir_shaken_payload.
struct ast_stir_shaken_payload * ast_stir_shaken_sign(struct ast_json *json)
Sign a JSON STIR/SHAKEN payload.
ast_stir_shaken_verification_result
struct ast_stir_shaken_payload * ast_stir_shaken_verify(const char *header, const char *payload, const char *signature, const char *algorithm, const char *public_cert_url)
Verify a JSON STIR/SHAKEN payload.
int ast_stir_shaken_add_verification(struct ast_channel *chan, const char *identity, const char *attestation, enum ast_stir_shaken_verification_result result)
Add a STIR/SHAKEN verification result to a channel.
unsigned char * ast_stir_shaken_payload_get_signature(const struct ast_stir_shaken_payload *payload)
Retrieve the value for &#39;signature&#39; from an ast_stir_shaken_payload.
struct ast_sorcery * ast_stir_shaken_sorcery(void)
Retrieve the stir/shaken sorcery context.
struct ast_json * payload
static PGresult * result
Definition: cel_pgsql.c:88
Abstract JSON element (object, array, string, int, ...).
void ast_stir_shaken_payload_free(struct ast_stir_shaken_payload *payload)
Free a STIR/SHAKEN payload.