res_stir_shaken: Implemented signing of JSON payload.

This change provides functions that take in a JSON payload, verify that
the contents contain all the mandatory fields and required values (if
any), and signs the payload with the private key. Four fields are added
to the payload: x5u, attest, iat, and origid. As of now, these are just
placeholder values that will be set to actual values once the logic is
implemented for what to do when an actual payload is received, but the
functions to add these values have all been implemented and are ready to
use. Upon successful signing and the addition of those four values, a
ast_stir_shaken_payload is returned, containing other useful information
such as the algorithm and signature.

Change-Id: I74fa41c0640ab2a64a1a80110155bd7062f13393
This commit is contained in:
Ben Ford
2020-03-26 13:34:47 -05:00
committed by Friendly Automation
parent 3c345ec56d
commit 57a457c26c
4 changed files with 421 additions and 17 deletions

View File

@@ -21,6 +21,10 @@
#include <openssl/evp.h>
#include <openssl/pem.h>
struct ast_stir_shaken_payload;
struct ast_json;
/*!
* \brief Retrieve the stir/shaken sorcery context
*
@@ -29,12 +33,15 @@
struct ast_sorcery *ast_stir_shaken_sorcery(void);
/*!
* \brief Get the private key associated with a caller id
*
* \param caller_id_number The caller id used to look up the private key
*
* \retval The private key
* \brief Free a STIR/SHAKEN payload
*/
EVP_PKEY *ast_stir_shaken_get_private_key(const char *caller_id_number);
void ast_stir_shaken_payload_free(struct ast_stir_shaken_payload *payload);
/*!
* \brief Sign a JSON STIR/SHAKEN payload
*
* \note This function will automatically add the "attest", "iat", and "origid" fields.
*/
struct ast_stir_shaken_payload *ast_stir_shaken_sign(struct ast_json *json);
#endif /* _RES_STIR_SHAKEN_H */