Add SHA-256 and SHA-512-256 as authentication digest algorithms

* Refactored pjproject code to support the new algorithms and
added a patch file to third-party/pjproject/patches

* Added new parameters to the pjsip auth object:
  * password_digest = <algorithm>:<digest>
  * supported_algorithms_uac = List of algorithms to support
    when acting as a UAC.
  * supported_algorithms_uas = List of algorithms to support
    when acting as a UAS.
  See the auth object in pjsip.conf.sample for detailed info.

* Updated both res_pjsip_authenticator_digest.c (for UAS) and
res_pjsip_outbound_authentocator_digest.c (UAC) to suport the
new algorithms.

The new algorithms are only available with the bundled version
of pjproject, or an external version > 2.14.1.  OpenSSL version
1.1.1 or greater is required to support SHA-512-256.

Resolves: #948

UserNote: The SHA-256 and SHA-512-256 algorithms are now available
for authentication as both a UAS and a UAC.

(cherry picked from commit a0987672f0)
This commit is contained in:
George Joseph
2024-10-17 08:02:08 -06:00
committed by Asterisk Development Team
parent b2e81346bb
commit 10664757d2
15 changed files with 1784 additions and 571 deletions

View File

@@ -315,6 +315,26 @@ static char *handle_pjproject_show_buildopts(struct ast_cli_entry *e, int cmd, s
ast_cli(a->fd, "%s\n", AST_VECTOR_GET(&buildopts, i));
}
#ifdef HAVE_PJSIP_AUTH_NEW_DIGESTS
{
struct ast_str *buf = ast_str_alloca(256);
for (i = PJSIP_AUTH_ALGORITHM_NOT_SET + 1; i < PJSIP_AUTH_ALGORITHM_COUNT; i++) {
const pjsip_auth_algorithm *algorithm = pjsip_auth_get_algorithm_by_type(i);
if (!ast_strlen_zero(algorithm->openssl_name)) {
if (pjsip_auth_is_algorithm_supported(i)) {
ast_str_append(&buf, 0, "%.*s/%s, ", (int)algorithm->iana_name.slen,
algorithm->iana_name.ptr, algorithm->openssl_name);
}
}
}
/* Trim off the trailing ", " */
ast_str_truncate(buf, -2);
ast_cli(a->fd, "Supported Digest Algorithms (IANA name/OpenmSSL name): %s\n", ast_str_buffer(buf));
}
#else
ast_cli(a->fd, "Supported Digest Algorithms (IANA name/OpenmSSL name): MD5/MD5\n");
#endif
return CLI_SUCCESS;
}