Module: kamailio Branch: 5.7 Commit: 1cf389829bebad2013a6cf3b4ab919fa6b78a7c2 URL: https://github.com/kamailio/kamailio/commit/1cf389829bebad2013a6cf3b4ab919fa...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2023-08-29T16:11:54+02:00
crypto: SHA1_Init deprecated at openssl 3.0
From https://www.openssl.org/docs/man3.0/man7/migration_guide.html
Use of low-level digest functions such as SHA1_Init(3) have been informally discouraged from use for a long time. Applications should instead use the high level EVP APIs EVP_DigestInit_ex(3), EVP_DigestUpdate(3) and EVP_DigestFinal_ex(3), or the quick one-shot EVP_Q_digest(3).
related to #3502
(cherry picked from commit e55a6ed0f24c9b81d8d3ad27ba25d4d88c474483)
---
Modified: src/modules/crypto/crypto_uuid.c
---
Diff: https://github.com/kamailio/kamailio/commit/1cf389829bebad2013a6cf3b4ab919fa... Patch: https://github.com/kamailio/kamailio/commit/1cf389829bebad2013a6cf3b4ab919fa...
---
diff --git a/src/modules/crypto/crypto_uuid.c b/src/modules/crypto/crypto_uuid.c index a4049e62821..63a9db07df6 100644 --- a/src/modules/crypto/crypto_uuid.c +++ b/src/modules/crypto/crypto_uuid.c @@ -169,14 +169,33 @@ static inline int crypto_format_rfc4122_uuid(char *sbuf, size_t sbuf_len, */ void crypto_generate_callid(str* callid) { +#if OPENSSL_VERSION_NUMBER > 0x030000000L + EVP_MD_CTX *crypto_ctx = NULL; +#else static SHA_CTX crypto_ctx = {0}; +#endif static unsigned char crypto_buf[SHA_DIGEST_LENGTH] = {0}; static char crypto_sbuf[UUID_LEN] = {0}; crypto_inc_counter(crypto_callid_counter, CTR_LEN); + +#if OPENSSL_VERSION_NUMBER > 0x030000000L + if((crypto_ctx = EVP_MD_CTX_new()) == NULL) { + LM_ERR("can't get new context\n"); + callid->s = NULL; + callid->len = 0; + return; + } + EVP_DigestInit_ex(crypto_ctx, EVP_sha1(), NULL); + EVP_DigestUpdate(crypto_ctx, crypto_callid_seed, SEED_LEN); + EVP_DigestUpdate(crypto_ctx, crypto_callid_counter, CTR_LEN); + EVP_DigestFinal_ex(crypto_ctx, crypto_buf, NULL); + EVP_MD_CTX_free(crypto_ctx); +#else SHA1_Init(&crypto_ctx); SHA1_Update(&crypto_ctx, crypto_callid_seed, SEED_LEN); SHA1_Update(&crypto_ctx, crypto_callid_counter, CTR_LEN); SHA1_Final(crypto_buf, &crypto_ctx); +#endif crypto_format_rfc4122_uuid(crypto_sbuf, sizeof(crypto_sbuf), crypto_buf, sizeof(crypto_buf)); callid->s = crypto_sbuf;