STIR/SHAKEN: Switch to base64 URL encoding.

STIR/SHAKEN encodes using base64 URL format. Currently, we just use
base64. New functions have been added that convert to and from base64
encoding.

The origid field should also be an UUID. This means there's no reason to
have it as an option in stir_shaken.conf, as we can simply generate one
when creating the Identity header.

https://wiki.asterisk.org/wiki/display/AST/OpenSIPit+2021

Change-Id: Icf094a2a54e87db91d6b12244c9f5ba4fc2e0b8c
This commit is contained in:
Ben Ford
2021-04-26 17:00:11 -05:00
committed by Joshua Colp
parent d00bedba81
commit 0b4b207076
8 changed files with 214 additions and 46 deletions

View File

@@ -276,6 +276,66 @@ int ast_base64decode(unsigned char *dst, const char *src, int max);
*/
char *ast_base64decode_string(const char *src);
/*!
* \brief Decode data from base64 URL
*
* \param dst The destination buffer
* \param src The source buffer
* \param max The maximum number of bytes to write into the destination
* buffer. Note that this function will not ensure that the
* destination buffer is NULL terminated. So, in general,
* this parameter should be sizeof(dst) - 1
*/
int ast_base64url_decode(unsigned char *dst, const char *src, int max);
/*!
* \brief Same as ast_base64encode_full but for base64 URL
*
* \param dst The destination buffer
* \param src The source buffer
* \param srclen The number of bytes present in the source buffer
* \param max The maximum number of bytes to write into the destination
* buffer, *including* the terminating NULL character.
* \param linebreaks Set to 1 if there should be linebreaks inserted
* in the result
*/
int ast_base64url_encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks);
/*!
* \brief Encode data in base64 URL
*
* \param dst The destination buffer
* \param src The source data to be encoded
* \param srclen The number of bytes present in the source buffer
* \param max The maximum number of bytes to write into the destination
* buffer, including the terminating NULL character
*/
int ast_base64url_encode(char *dst, const unsigned char *src, int srclen, int max);
/*!
* \brief Decode string from base64 URL
*
* \note The returned string will need to be freed later
*
* \param src The source buffer
*
* \retval NULL on failure
* \retval Decoded string on success
*/
char *ast_base64url_decode_string(const char *src);
/*!
* \brief Encode string in base64 URL
*
* \note The returned string will need to be freed later
*
* \param src The source data to be encoded
*
* \retval NULL on failure
* \retval Encoded string on success
*/
char *ast_base64url_encode_string(const char *src);
#define AST_URI_ALPHANUM (1 << 0)
#define AST_URI_MARK (1 << 1)
#define AST_URI_UNRESERVED (AST_URI_ALPHANUM | AST_URI_MARK)