From: "cron2 (Code Review)" Date: Sun, 5 Apr 2026 14:27:23 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <761f9d2fe1c5563399550a48ee7df9c62e786cc9-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ttSnkn0O1bo="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: crypto_backend: Remove md_full List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --ttSnkn0O1bo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1612?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: crypto_backend: Remove md_full ...................................................................... crypto_backend: Remove md_full There was only one user for mbedtls < 4.0, so remove all the unused implementations. Identified by cppcheck. Change-Id: Ie2285f5bf52f5c669fb01f9ae36d6aa1674f0929 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1612 Message-Id: <20260405103110.32401-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36= 495.html Signed-off-by: Gert Doering --- M src/openvpn/crypto_backend.h M src/openvpn/crypto_mbedtls.c M src/openvpn/crypto_mbedtls_legacy.c M src/openvpn/crypto_mbedtls_legacy.h M src/openvpn/crypto_openssl.c M src/openvpn/ssl_mbedtls.c 6 files changed, 5 insertions(+), 54 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/12/1612/2 diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index 0bfa8b4..b602ba1 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -549,18 +549,6 @@ * */ -/** - * Calculates the message digest for the given buffer. - * - * @param mdname message digest name - * @param src Buffer to digest. May not be NULL. - * @param src_len The length of the incoming buffer. - * @param dst Buffer to write the message digest to. May not be = NULL. - * - * @return true on success, false on failure - */ -bool md_full(const char *mdname, const uint8_t *src, size_t src_len, uint8= _t *dst); - /* * Allocate a new message digest context * diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index c41daef..6662def 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -696,28 +696,6 @@ return ctx; } -bool -md_full(const char *mdname, const uint8_t *src, size_t src_len, uint8_t *d= st) -{ - const md_info_t *md =3D md_get(mdname); - if (md =3D=3D NULL) - { - return false; - } - - /* We depend on the caller to ensure that dst has enough room for the = hash, - * so we just tell PSA that it can hold the appropriate amount of byte= s. */ - size_t dst_size =3D PSA_HASH_LENGTH(md->psa_alg); - size_t hash_length =3D 0; - - psa_status_t status =3D psa_hash_compute(md->psa_alg, src, src_len, ds= t, dst_size, &hash_length); - if (status !=3D PSA_SUCCESS || hash_length !=3D dst_size) - { - return false; - } - return true; -} - void md_ctx_free(md_ctx_t *ctx) { diff --git a/src/openvpn/crypto_mbedtls_legacy.c b/src/openvpn/crypto_mbedt= ls_legacy.c index 087d94c..debd53d 100644 --- a/src/openvpn/crypto_mbedtls_legacy.c +++ b/src/openvpn/crypto_mbedtls_legacy.c @@ -769,7 +769,7 @@ */ -static const mbedtls_md_info_t * +const mbedtls_md_info_t * md_get(const char *digest) { const mbedtls_md_info_t *md =3D NULL; @@ -825,13 +825,6 @@ * */ -bool -md_full(const char *mdname, const uint8_t *src, size_t src_len, uint8_t *d= st) -{ - const mbedtls_md_info_t *kt =3D md_get(mdname); - return 0 =3D=3D mbedtls_md(kt, src, src_len, dst); -} - mbedtls_md_context_t * md_ctx_new(void) { diff --git a/src/openvpn/crypto_mbedtls_legacy.h b/src/openvpn/crypto_mbedt= ls_legacy.h index 1005057..23113be 100644 --- a/src/openvpn/crypto_mbedtls_legacy.h +++ b/src/openvpn/crypto_mbedtls_legacy.h @@ -137,4 +137,6 @@ */ #define mbed_ok(errval) mbed_log_func_line_lite(D_CRYPT_ERRORS, errval, __= func__, __LINE__) +const mbedtls_md_info_t *md_get(const char *digest); + #endif /* CRYPTO_MBEDTLS_H_ */ diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 9900d06..c11cfd8 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -1107,17 +1107,6 @@ * */ -bool -md_full(const char *mdname, const uint8_t *src, size_t src_len, uint8_t *d= st) -{ - unsigned int in_md_len =3D 0; - evp_md_type *kt =3D md_get(mdname); - - int ret =3D EVP_Digest(src, src_len, dst, &in_md_len, kt, NULL); - EVP_MD_free(kt); - return ret =3D=3D 1; -} - EVP_MD_CTX * md_ctx_new(void) { diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index d0c481e..a62ff76 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -1029,8 +1029,9 @@ if (NULL !=3D ctx->crt_chain) { mbedtls_x509_crt *cert =3D ctx->crt_chain; + const mbedtls_md_info_t *kt =3D md_get("SHA256"); - if (!md_full("SHA256", cert->tbs.p, cert->tbs.len, sha256_hash)) + if (0 !=3D mbedtls_md(kt, cert->tbs.p, cert->tbs.len, sha256_hash)) { msg(M_WARN, "WARNING: failed to personalise random"); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1612?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie2285f5bf52f5c669fb01f9ae36d6aa1674f0929 Gerrit-Change-Number: 1612 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --ttSnkn0O1bo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #2 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by cron2

crypto_backend: Remove md_full
<= br>There was only one user for mbedtls < 4.0,
so remove all the unuse= d implementations.

Identified by cppcheck.

Change-Id: Ie2285f= 5bf52f5c669fb01f9ae36d6aa1674f0929
Signed-off-by: Frank Lichtenheld <= frank@...2641...>
Acked-by: Gert Doering <gert@...1296...>
G= errit URL: https://gerrit.openvpn.net/c/openvpn/+/1612
Message-Id: <2= 0260405103110.32401-1-gert@...1296...>
URL: https://www.mail-archive.= com/openvpn-devel@lists.sourceforge.net/msg36495.html
Signed-off-by: Ger= t Doering <gert@...1296...>
---
M src/openvpn/crypto_backend.h<= br>M src/openvpn/crypto_mbedtls.c
M src/openvpn/crypto_mbedtls_legacy.c<= br>M src/openvpn/crypto_mbedtls_legacy.h
M src/openvpn/crypto_openssl.c<= br>M src/openvpn/ssl_mbedtls.c
6 files changed, 5 insertions(+), 54 dele= tions(-)

git pull ssh://gerrit.openvpn.net:29418=
/openvpn refs/changes/12/1612/2
diff --git a/src/openvpn/crypto_bac=
kend.h b/src/openvpn/crypto_backend.h
index 0bfa8b4..b602ba= 1 100644
--- a/src/openvpn/crypto_backend.h
+++ b/src/openvpn/crypto_backend.h
@@ -549,18 +549,6 @@
*
*/

-/**
- * Calculates the message digest for the given buffer.
- *
- * @param mdname message digest name=
- * @param src = Buffer to digest. May not be NULL.
- * @param src_len The length of the incoming buffer.<= /span>
- * @param dst = Buffer to write the message digest to. May not be NULL.
- *
- * @return true on success, false on failure<= /span>
- */
-bool md_full(const char *mdname, const u= int8_t *src, size_t src_len, uint8_t *dst);
-
/*
* Allocate a n= ew message digest context
*
diff --git a/= src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c
index c41daef..6662def 100644

--- a/src/openvpn/crypto_mbe= dtls.c
+++ b/src/openvpn/crypto_mbedtls.c
@= @ -696,28 +696,6 @@
return ctx;
}

-bool
-md_full(const char *mdna= me, const uint8_t *src, size_t src_len, uint8_t *dst)
-{
- const md_info_t *md =3D md_get(mdname);
- if (md =3D=3D NULL)
- {
- return false;
- }
-
- /* We depend = on the caller to ensure that dst has enough room for the hash,
- * so we just tell PSA that it= can hold the appropriate amount of bytes. */

- size_t dst_size =3D PSA_HASH_LENGTH(md->psa_= alg);
- size_t hash_= length =3D 0;
-<= br>- psa_status_t status =3D p= sa_hash_compute(md->psa_alg, src, src_len, dst, dst_size, &hash_leng= th);
- if (status != =3D PSA_SUCCESS || hash_length !=3D dst_size)
- {
- return false;
- }
- retu= rn true;
-}
<= span style=3D"color: hsl(0, 100%, 40%);">-

void
= md_ctx_free(md_ctx_t *ctx)
{
diff -= -git a/src/openvpn/crypto_mbedtls_legacy.c b/src/openvpn/crypto_mbedtls_leg= acy.c
index 087d94c..debd53d 100644
--- a/s= rc/openvpn/crypto_mbedtls_legacy.c
+++ b/src/openvpn/crypto= _mbedtls_legacy.c
@@ -769,7 +769,7 @@
*/<= /span>


-static const mbedtls_md_info_t *
+const mbedtls_md_info_t *
md_ge= t(const char *digest)
{
const mbedtls= _md_info_t *md =3D NULL;
@@ -825,13 +825,6 @@
*

*/

-bool
-md_full(const char *mdname, const uint8_t *src, size_t src_len, uint= 8_t *dst)
-{
= - const mbedtls_md_info_t *kt = =3D md_get(mdname);
- = return 0 =3D=3D mbedtls_md(kt, src, src_len, dst);
-}
-
mbedtls_md_context_t *
md_ct= x_new(void)
{
diff --git a/src/openvpn/cry= pto_mbedtls_legacy.h b/src/openvpn/crypto_mbedtls_legacy.h
= index 1005057..23113be 100644
--- a/src/openvpn/crypto_mbed= tls_legacy.h
+++ b/src/openvpn/crypto_mbedtls_legacy.h
@@ -137,4 +137,6 @@
*/
#defi= ne mbed_ok(errval) mbed_log_func_line_lite(D_CRYPT_ERRORS, errval, __func__= , __LINE__)

+const mbedtls_md_info_t *md_get(const char *digest);
+

#endif /* CRYP= TO_MBEDTLS_H_ */
diff --git a/src/openvpn/crypto_openssl.c = b/src/openvpn/crypto_openssl.c
index 9900d06..c11cfd8 10064= 4
--- a/src/openvpn/crypto_openssl.c
+++ b/= src/openvpn/crypto_openssl.c
@@ -1107,17 +1107,6 @@<= br> *
*/

-bool
-md_full(const char *mdname, const uint8_t *src, size_t src_l= en, uint8_t *dst)
-{
- unsigned int in_md_l= en =3D 0;
- evp_md_t= ype *kt =3D md_get(mdname);
-
- int ret =3D= EVP_Digest(src, src_len, dst, &in_md_len, kt, NULL);
- EVP_MD_free(kt);
- return ret =3D=3D 1;
-}

-
EVP_MD_CTX *
md_ctx_ne= w(void)
{
diff --git a/src/openvpn/ssl_mbe= dtls.c b/src/openvpn/ssl_mbedtls.c
index d0c481e..a62ff76 1= 00644
--- a/src/openvpn/ssl_mbedtls.c
+++ b= /src/openvpn/ssl_mbedtls.c
@@ -1029,8 +1029,9 @@
= if (NULL !=3D ctx->crt_chain)
{ mbedtls_x509_crt *cert =3D ctx->crt_chain;
+ const mbedtls_md_info_t = *kt =3D md_get("SHA256");


- if (!md_full("SHA256", ce= rt->tbs.p, cert->tbs.len, sha256_hash))
+ if (0 !=3D mbedtls_md(kt, cert->tbs.p,= cert->tbs.len, sha256_hash))
{
msg(M_WARN, "WARNING: failed to personalise random"= );

}

To view, = visit ch= ange 1612. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie2285f5bf52f5c669fb01f9ae36= d6aa1674f0929
Gerrit-Change-Number: 1612
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --ttSnkn0O1bo=--