2020-03-23 20:00:09 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020, Sangoma Technologies Corporation
|
|
|
|
*
|
|
|
|
* Kevin Harwell <kharwell@sangoma.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
#ifndef _STIR_SHAKEN_CERTIFICATE_H
|
|
|
|
#define _STIR_SHAKEN_CERTIFICATE_H
|
|
|
|
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
|
|
|
|
struct ast_sorcery;
|
|
|
|
|
2020-03-26 18:34:47 +00:00
|
|
|
struct stir_shaken_certificate;
|
|
|
|
|
2020-05-13 21:37:25 +00:00
|
|
|
/*!
|
|
|
|
* \brief Get a STIR/SHAKEN certificate by caller ID number
|
|
|
|
*
|
2021-11-19 08:54:42 +00:00
|
|
|
* \param caller_id_number The caller ID number
|
2020-05-13 21:37:25 +00:00
|
|
|
*
|
|
|
|
* \retval NULL if not found
|
2021-11-19 08:54:42 +00:00
|
|
|
* \return The certificate on success
|
2020-05-13 21:37:25 +00:00
|
|
|
*/
|
2020-03-26 18:34:47 +00:00
|
|
|
struct stir_shaken_certificate *stir_shaken_certificate_get_by_caller_id_number(const char *caller_id_number);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Get the public key URL associated with a certificate
|
|
|
|
*
|
|
|
|
* \param cert The certificate to get the public key URL from
|
|
|
|
*
|
|
|
|
* \retval NULL on failure
|
2021-11-19 08:54:42 +00:00
|
|
|
* \return The public key URL on success
|
2020-03-26 18:34:47 +00:00
|
|
|
*/
|
2021-04-21 16:12:55 +00:00
|
|
|
const char *stir_shaken_certificate_get_public_cert_url(struct stir_shaken_certificate *cert);
|
2020-03-26 18:34:47 +00:00
|
|
|
|
res_stir_shaken: Add outbound INVITE support.
Integrated STIR/SHAKEN support with outgoing INVITEs. When an INVITE is
sent, the caller ID will be checked to see if there is a certificate
that corresponds to it. If so, that information will be retrieved and an
Identity header will be added to the SIP message. The format is:
header.payload.signature;info=<public_key_url>alg=ES256;ppt=shaken
Header, payload, and signature are all BASE64 encoded. The public key
URL is retrieved from the certificate. Currently the algorithm and ppt
are ES256 and shaken, respectively. This message is signed and can be
used for verification on the receiving end.
Two new configuration options have been added to the certificate object:
attestation and origid. The attestation is required and must be A, B, or
C. origid is the origination identifier.
A new utility function has been added as well that takes a string,
allocates space, BASE64 encodes it, then returns it, eliminating the
need to calculate the size yourself.
Change-Id: I1f84d6a5839cb2ed152ef4255b380cfc2de662b4
2020-06-02 14:04:23 +00:00
|
|
|
/*!
|
|
|
|
* \brief Get the attestation level associated with a certificate
|
|
|
|
*
|
|
|
|
* \param cert The certificate
|
|
|
|
*
|
|
|
|
* \retval NULL on failure
|
|
|
|
* \retval The attestation on success
|
|
|
|
*/
|
|
|
|
const char *stir_shaken_certificate_get_attestation(struct stir_shaken_certificate *cert);
|
|
|
|
|
2020-03-23 20:00:09 +00:00
|
|
|
/*!
|
2020-03-26 18:34:47 +00:00
|
|
|
* \brief Get the private key associated with a certificate
|
2020-03-23 20:00:09 +00:00
|
|
|
*
|
2020-03-26 18:34:47 +00:00
|
|
|
* \param cert The certificate to get the private key from
|
2020-03-23 20:00:09 +00:00
|
|
|
*
|
|
|
|
* \retval NULL on failure
|
2021-11-19 08:54:42 +00:00
|
|
|
* \return The private key on success
|
2020-03-23 20:00:09 +00:00
|
|
|
*/
|
2020-03-26 18:34:47 +00:00
|
|
|
EVP_PKEY *stir_shaken_certificate_get_private_key(struct stir_shaken_certificate *cert);
|
2020-03-23 20:00:09 +00:00
|
|
|
|
2020-05-13 21:37:25 +00:00
|
|
|
#ifdef TEST_FRAMEWORK
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Clean up the certificate and mappings set up in test_stir_shaken_init
|
|
|
|
*
|
|
|
|
* \param caller_id_number The caller ID of the certificate to clean up
|
|
|
|
*
|
|
|
|
* \retval non-zero on failure
|
|
|
|
* \retval 0 on success
|
|
|
|
*/
|
|
|
|
int test_stir_shaken_cleanup_cert(const char *caller_id_number);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Initialize a test certificate through wizard mappings
|
|
|
|
*
|
|
|
|
* \note test_stir_shaken_cleanup should be called when done with this certificate
|
|
|
|
*
|
|
|
|
* \param caller_id_number The caller ID of the certificate to create
|
|
|
|
* \param file_path The path to the private key for this certificate
|
|
|
|
*
|
|
|
|
* \retval non-zero on failure
|
|
|
|
* \retval 0 on success
|
|
|
|
*/
|
|
|
|
int test_stir_shaken_create_cert(const char *caller_id_number, const char *file_path);
|
|
|
|
|
|
|
|
#endif /* TEST_FRAMEWORK */
|
|
|
|
|
2020-03-23 20:00:09 +00:00
|
|
|
/*!
|
|
|
|
* \brief Load time initialization for the stir/shaken 'certificate' configuration
|
|
|
|
*
|
2021-11-19 08:54:42 +00:00
|
|
|
* \retval 0 on success
|
|
|
|
* \retval -1 on error
|
2020-03-23 20:00:09 +00:00
|
|
|
*/
|
|
|
|
int stir_shaken_certificate_load(void);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Unload time cleanup for the stir/shaken 'certificate' configuration
|
|
|
|
*
|
2021-11-19 08:54:42 +00:00
|
|
|
* \retval 0 on success
|
|
|
|
* \retval -1 on error
|
2020-03-23 20:00:09 +00:00
|
|
|
*/
|
|
|
|
int stir_shaken_certificate_unload(void);
|
|
|
|
|
|
|
|
#endif /* _STIR_SHAKEN_CERTIFICATE_H */
|
|
|
|
|