From: "plaisthos (Code Review)" Date: Tue, 2 Apr 2024 12:15:12 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Ux94t8coo8I="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Remove redundant call of EVP_CipherInit before EVP_CipherInit_Ex List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --Ux94t8coo8I= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld,=20 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 (#2). Change subject: Remove redundant call of EVP_CipherInit before EVP_CipherIn= it_Ex ...................................................................... Remove 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 so this call does not do anything useful. 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, 0 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/552/2 diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index bfc5e37..13dfa8c 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -846,10 +846,6 @@ 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)) { 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: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --Ux94t8coo8I= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos uploaded patch set #2 to this change.

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

Remove redundant call of EVP_CipherInit before EVP_CipherInit_Ex
<= br>EVP_CipherInit basically is the same EVP_CipherInit_ex except that itin some instances it resets/inits the ctx parameter first. We already
c= all EVP_CIPHER_CTX_reset to reset/init the ctx before so this call does
= not do anything useful.

OpenSSL 1.0.2:

https://github.com/ope= nssl/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

O= penSSL 3.0:

https://github.com/openssl/openssl/blob/openssl-3.2/cryp= to/evp/evp_enc.c#L450

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

Change-Id: I911e25949a8647b567fd4178683534d= 4404ab469
Signed-off-by: Arne Schwabe <arne@...1227...>
---
= M src/openvpn/crypto_openssl.c
1 file changed, 0 insertions(+), 4 deleti= ons(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/chang=
es/52/552/2
diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn=
/crypto_openssl.c
index bfc5e37..13dfa8c 100644
<= span>--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/c= rypto_openssl.c
@@ -846,10 +846,6 @@
e= vp_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 i= nit #1");
- }
if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, enc)= )
{
crypto_msg(M_FATAL, "= ;EVP cipher init #2");

To view, vi= sit chang= e 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: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--Ux94t8coo8I=--