From: "plaisthos (Code Review)" Date: Tue, 2 Apr 2024 12:56:41 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <91611df18fe69f0342fceb20855598b6fea3f633-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/u8msTZRfUU="; 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: cron2 , flichtenheld Cc: openvpn-devel --/u8msTZRfUU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos. Hello cron2, flichtenheld, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/552?usp=3Demail to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review-1 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 --- 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/3 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: 3 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --/u8msTZRfUU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: cron2, flichtenheld, plaisthos. <= /p>

plaisthos uploaded patch set #3 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/552?usp=3Demail">View Chang= e

The following approvals got outdated and were removed: Code-Review-1 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>---
M src/openvpn/crypto_openssl.c
1 file changed, 1 insertion(+),= 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn r=
efs/changes/52/552/3
diff --git a/src/openvpn/crypto_openssl.c b/sr=
c/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_C= ipherInit_ex(ctx, NULL, NULL, key, NULL, enc))
+ if (!EVP_CipherInit_ex(ctx, kt, NULL, key, N= ULL, enc))
{
crypto_msg(M_FAT= AL, "EVP cipher init #2");
}

To view, visit change 552. To unsubscribe, or for help writ= ing mail filters, visit sett= ings.

<= link itemprop=3D"url" href=3D"http://gerrit.openvpn.net/c/openvpn/+/552?usp= =3Demail"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I911e25949a8647b567fd4178683= 534d4404ab469
Gerrit-Change-Number: 552
Gerrit-PatchSet: 3
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-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--/u8msTZRfUU=--