Module: kamailio Branch: master Commit: 2c2c58598626e36245da1b0eb5442d92de194b79 URL: https://github.com/kamailio/kamailio/commit/2c2c58598626e36245da1b0eb5442d92de194b79
Author: Xenofon Karamanos <x...@gilawa.com> Committer: Henning Westerholt <h...@gilawa.com> Date: 2025-09-09T13:26:25+02:00 rtpengine: Replace sha1 generation - Remove dep on crypto module - Use core implementation --- Modified: src/modules/rtpengine/rtpengine.c --- Diff: https://github.com/kamailio/kamailio/commit/2c2c58598626e36245da1b0eb5442d92de194b79.diff Patch: https://github.com/kamailio/kamailio/commit/2c2c58598626e36245da1b0eb5442d92de194b79.patch --- diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c index 8f32a0d04cd..9a254196015 100644 --- a/src/modules/rtpengine/rtpengine.c +++ b/src/modules/rtpengine/rtpengine.c @@ -58,6 +58,7 @@ #include "../../core/fmsg.h" #include "../../core/forward.h" #include "../../core/mem/mem.h" +#include "../../core/crypto/shautils.h" #include "../../core/parser/parse_from.h" #include "../../core/parser/parse_to.h" #include "../../core/parser/parse_uri.h" @@ -85,7 +86,6 @@ #include "../../core/cfg/cfg_struct.h" #include "../../core/rand/fastrand.h" #include "../../modules/tm/tm_load.h" -#include "../../modules/crypto/api.h" #include "../../modules/lwsc/api.h" #include "rtpengine.h" #include "rtpengine_funcs.h" @@ -441,8 +441,6 @@ static pv_elem_t *extra_id_pv = NULL; static struct minmax_mos_label_stats global_mos_stats, side_A_mos_stats, side_B_mos_stats; int got_any_mos_pvs; -struct crypto_binds rtpengine_cb; - /* clang-format off */ static cmd_export_t cmds[] = { @@ -2601,13 +2599,6 @@ static int mod_init(void) return -1; } - if(hash_algo == RTP_HASH_SHA1_CALLID) { - if(load_crypto_api(&rtpengine_cb) != 0) { - LM_ERR("Crypto module required in order to have SHA1 hashing!\n"); - return -1; - } - } - /* Enable ping timer if interval is positive */ if(rtpengine_ping_interval > 0) { register_timer(rtpengine_ping_check_timer, 0, rtpengine_ping_interval); @@ -3181,7 +3172,7 @@ static char *gencookie(void) static char cook[35]; // 11 + 1 + 10 + 1 + 10 + 1 + 1 snprintf(cook, 35, "%" PRId32 "_%" PRIu32 "_%" PRIu32 " ", - (int32_t) server_id, (uint32_t) fastrand(), (uint32_t) myseqn); + (int32_t)server_id, (uint32_t)fastrand(), (uint32_t)myseqn); myseqn++; return cook; } @@ -4556,8 +4547,8 @@ static struct rtpp_node *select_rtpp_node_new(str callid, str viabranch, struct rtpp_node *node; unsigned i, sum, sumcut, weight_sum; int was_forced = 0; - - str hash_data; + unsigned char sha1[SHA1_DIGEST_LENGTH]; + str hash_data = STR_NULL; switch(hash_algo) { case RTP_HASH_CALLID: @@ -4565,18 +4556,13 @@ static struct rtpp_node *select_rtpp_node_new(str callid, str viabranch, break; case RTP_HASH_SHA1_CALLID: - if(rtpengine_cb.SHA1 == NULL) { - /* don't throw warning here; there is already a warni*/ - LM_BUG("SHA1 algo set but crypto not loaded! Program shouldn't " - "have started!"); + if(callid.len <= 0 || callid.s == NULL) { + LM_ERR("Invalid callid for SHA1 hashing\n"); return NULL; } - - if(rtpengine_cb.SHA1(&callid, &hash_data) < 0) { - LM_ERR("SHA1 hash in crypto module failed!\n"); - return NULL; - } - + compute_sha1_raw(sha1, (u_int8_t *)callid.s, callid.len); + hash_data.s = (char *)sha1; + hash_data.len = SHA1_DIGEST_LENGTH; break; case RTP_HASH_CRC32_CALLID: crc32_uint(&callid, &sum); _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-le...@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!