From: "cron2 (Code Review)" Date: Tue, 2 Apr 2024 14:56:50 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <794d6bd3d5dc26a7a40c7153a87405581c2fee0a-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="mZaDTln1Hvc="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Remove/combine redundant call of EVP_CipherInit before EVP_CipherInit_Ex List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --mZaDTln1Hvc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#4) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/552?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Remove/combine redundant call of EVP_CipherInit before EVP_= CipherInit_Ex ...................................................................... Remove/combine redundant call of EVP_CipherInit before EVP_CipherInit_Ex EVP_CipherInit basically is the same EVP_CipherInit_ex except that it in some instances it resets/inits the ctx parameter first. We already call EVP_CIPHER_CTX_reset to reset/init the ctx before. Also ensure that EVP_CipherInit_Ex gets the cipher to actually be able to initialise the context. OpenSSL 1.0.2: https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/evp/evp= _enc.c#L94 EVP_CipherInit calls first EVP_CIPHER_CTX_init and then EVP_CipherInit_ex Our openssl_compat.h has for these older OpenSSL versions OpenSSL 3.0: https://github.com/openssl/openssl/blob/openssl-3.2/crypto/evp/evp_enc.c#L4= 50 basically the same as 1.0.2. Just that method names have been changed. Change-Id: I911e25949a8647b567fd4178683534d4404ab469 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20240402134909.6340-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 523.html Signed-off-by: Gert Doering --- M src/openvpn/crypto_openssl.c 1 file changed, 1 insertion(+), 5 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/552/4 diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index bfc5e37..b2c4eb6 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -846,11 +846,7 @@ evp_cipher_type *kt =3D cipher_get(ciphername); EVP_CIPHER_CTX_reset(ctx); - if (!EVP_CipherInit(ctx, kt, NULL, NULL, enc)) - { - crypto_msg(M_FATAL, "EVP cipher init #1"); - } - if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc)) + if (!EVP_CipherInit_ex(ctx, kt, NULL, key, NULL, enc)) { crypto_msg(M_FATAL, "EVP cipher init #2"); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/552?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I911e25949a8647b567fd4178683534d4404ab469 Gerrit-Change-Number: 552 Gerrit-PatchSet: 4 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --mZaDTln1Hvc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #4 to the change originally cr= eated by plaisthos.

View Change

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

Remove/combine redundant call of EVP_CipherInit befo=
re EVP_CipherInit_Ex

EVP_CipherInit basically is the same EVP_Cipher= Init_ex except that it
in some instances it resets/inits the ctx paramet= er first. We already
call EVP_CIPHER_CTX_reset to reset/init the ctx bef= ore. Also ensure that
EVP_CipherInit_Ex gets the cipher to actually be a= ble to initialise the
context.

OpenSSL 1.0.2:

https://gith= ub.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/evp/evp_enc.c#L94
EVP_CipherInit calls first EVP_CIPHER_CTX_init and then EVP_CipherIni= t_ex

Our openssl_compat.h has

for these older OpenSSL version= s

OpenSSL 3.0:

https://github.com/openssl/openssl/blob/openss= l-3.2/crypto/evp/evp_enc.c#L450

basically the same as 1.0.2. Just th= at method names have been changed.

Change-Id: I911e25949a8647b567fd4= 178683534d4404ab469
Signed-off-by: Arne Schwabe <arne@...1227...><= br>Acked-by: Gert Doering <gert@...1296...>
Message-Id: <202404= 02134909.6340-1-gert@...1296...>
URL: https://www.mail-archive.com/op= envpn-devel@lists.sourceforge.net/msg28523.html
Signed-off-by: Gert Doer= ing <gert@...1296...>
---
M src/openvpn/crypto_openssl.c
1 f= ile changed, 1 insertion(+), 5 deletions(-)

git pull ssh://gerrit=
.openvpn.net:29418/openvpn refs/changes/52/552/4
diff --git a/src/o=
penvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
inde= x bfc5e37..b2c4eb6 100644
--- a/src/openvpn/crypto_openssl.= c
+++ b/src/openvpn/crypto_openssl.c
@@ -84= 6,11 +846,7 @@
evp_cipher_type *kt =3D cipher_get(ciph= ername);

EVP_CIPHER_CTX_reset(ctx);<= /span>
- if (!EVP_CipherIni= t(ctx, kt, NULL, NULL, enc))
- {
- c= rypto_msg(M_FATAL, "EVP cipher init #1");
- }
- if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc)= )
+ if (!EVP_Ciphe= rInit_ex(ctx, kt, NULL, key, NULL, enc))
{
<= span> crypto_msg(M_FATAL, "EVP cipher init #2");
}

To view, visit change 552. = To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I911e25949a8647b567fd4178683= 534d4404ab469
Gerrit-Change-Number: 552
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--mZaDTln1Hvc=--