From: "flichtenheld (Code Review)"
Date: Wed, 27 Mar 2024 11:05:07 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID: <078d6eb7ac328dd03f435133cf3aeedaf487bf52-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="9wfXTLOWo4E="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: crypto_backend: fix
type of enc parameter
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--9wfXTLOWo4E=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/548?usp=3Demail
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by plaisthos
Change subject: crypto_backend: fix type of enc parameter
......................................................................
crypto_backend: fix type of enc parameter
We had parts of a abstraction, but it wasn't consistent.
GCC 13 now complains about the type mismatch with mbedtls now:
crypto_mbedtls.c:568:1: error:
conflicting types for =E2=80=98cipher_ctx_init=E2=80=99 due to enum/integer=
mismatch;
have =E2=80=98void(mbedtls_cipher_context_t *, const uint8_t *, const char =
*, const mbedtls_operation_t)=E2=80=99
[...] [-Werror=3Denum-int-mismatch]
crypto_backend.h:341:6: note:
previous declaration of =E2=80=98cipher_ctx_init=E2=80=99 with type
=E2=80=98void(cipher_ctx_t *, const uint8_t *, const char *, int)=E2=80=99 =
[...]
Previous compiler versions did not complain.
Change-Id: If0dcdde30879fd6185efb2ad31399c1629c04d22
Signed-off-by: Frank Lichtenheld
---
M src/openvpn/crypto_backend.h
M src/openvpn/crypto_mbedtls.c
M src/openvpn/crypto_mbedtls.h
M src/openvpn/crypto_openssl.h
4 files changed, 8 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/48/548/2
diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h
index 8d37e64..c454c64 100644
--- a/src/openvpn/crypto_backend.h
+++ b/src/openvpn/crypto_backend.h
@@ -336,10 +336,10 @@
* @param key Buffer containing the key to use
* @param ciphername Ciphername of the cipher to use
* @param enc Whether to encrypt or decrypt (either
- * \c MBEDTLS_OP_ENCRYPT or \c MBEDTLS_OP_DECRYPT).
+ * \c OPENVPN_OP_ENCRYPT or \c OPENVPN_OP_DECRYPT).
*/
void cipher_ctx_init(cipher_ctx_t *ctx, const uint8_t *key,
- const char *cipername, int enc);
+ const char *cipername, crypto_operation_t enc);
/**
* Returns the size of the IV used by the cipher, in bytes, or 0 if no IV =
is
diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c
index 1a39752..91485cb 100644
--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/openvpn/crypto_mbedtls.c
@@ -566,11 +566,12 @@
void
cipher_ctx_init(mbedtls_cipher_context_t *ctx, const uint8_t *key,
- const char *ciphername, const mbedtls_operation_t operatio=
n)
+ const char *ciphername, int enc)
{
ASSERT(NULL !=3D ciphername && NULL !=3D ctx);
CLEAR(*ctx);
+ const mbedtls_operation_t operation =3D (mbedtls_operation_t)enc;
const mbedtls_cipher_info_t *kt =3D cipher_get(ciphername);
ASSERT(kt);
size_t key_bitlen =3D mbedtls_cipher_info_get_key_bitlen(kt);
diff --git a/src/openvpn/crypto_mbedtls.h b/src/openvpn/crypto_mbedtls.h
index 46f76e2..48d1e20 100644
--- a/src/openvpn/crypto_mbedtls.h
+++ b/src/openvpn/crypto_mbedtls.h
@@ -63,6 +63,8 @@
/** Cipher is in GCM mode */
#define OPENVPN_MODE_GCM MBEDTLS_MODE_GCM
+typedef mbedtls_operation_t crypto_operation_t;
+
/** Cipher should encrypt */
#define OPENVPN_OP_ENCRYPT MBEDTLS_ENCRYPT
diff --git a/src/openvpn/crypto_openssl.h b/src/openvpn/crypto_openssl.h
index c0e95b4..4cd988a 100644
--- a/src/openvpn/crypto_openssl.h
+++ b/src/openvpn/crypto_openssl.h
@@ -85,6 +85,8 @@
/** Cipher is in GCM mode */
#define OPENVPN_MODE_GCM EVP_CIPH_GCM_MODE
+typedef int crypto_operation_t;
+
/** Cipher should encrypt */
#define OPENVPN_OP_ENCRYPT 1
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/548?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: If0dcdde30879fd6185efb2ad31399c1629c04d22
Gerrit-Change-Number: 548
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
Gerrit-Attention: flichtenheld
Gerrit-MessageType: newpatchset
--9wfXTLOWo4E=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
flichtenheld uploaded patch set #2 to this change.
<=
p>View Ch=
ange
The following approvals got outdated and were removed:
Code-Review-1 by plaisthos
crypto_backend: fix type of enc parameter
We had parts of a abstraction, but it wasn't consistent.
GCC 13 now=
complains about the type mismatch with mbedtls now:
crypto_mbedtls.=
c:568:1: error:
conflicting types for =E2=80=98cipher_ctx_init=E2=80=99 =
due to enum/integer mismatch;
have =E2=80=98void(mbedtls_cipher_context_=
t *, const uint8_t *, const char *, const mbedtls_operation_t)=E2=80=99
=
[...] [-Werror=3Denum-int-mismatch]
crypto_backend.h:341:6: note:
pre=
vious declaration of =E2=80=98cipher_ctx_init=E2=80=99 with type
=E2=80=
=98void(cipher_ctx_t *, const uint8_t *, const char *, int)=E2=80=99 [...]<=
br>
Previous compiler versions did not complain.
Change-Id: If0dc=
dde30879fd6185efb2ad31399c1629c04d22
Signed-off-by: Frank Lichtenheld &l=
t;frank@...2641...>
---
M src/openvpn/crypto_backend.h
M src/op=
envpn/crypto_mbedtls.c
M src/openvpn/crypto_mbedtls.h
M src/openvpn/c=
rypto_openssl.h
4 files changed, 8 insertions(+), 3 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/48/548/2=
diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backen=
d.h
index 8d37e64..c454c64 100644
--- a/src=
/openvpn/crypto_backend.h
+++ b/src/openvpn/crypto_backend.=
h
@@ -336,10 +336,10 @@
* @param key =
Buffer containing the key to use
* @param ciphernam=
e Ciphername of the cipher to use
* @param enc =
Whether to encrypt or decrypt (either
- * \c MBEDTLS_OP_ENCRYPT or \c MBED=
TLS_OP_DECRYPT).
+ * =
\c OPENVPN_OP_ENCRYPT or \c OPENVPN_OP_DECRYPT).
*/
void cipher_ctx_init(cipher_ctx_t *ctx, co=
nst uint8_t *key,
- =
const char *cipername, int enc);
+ const char *cipername, c=
rypto_operation_t enc);
/**
* Returns the size of the IV used by the cipher, in bytes, or 0 if no=
IV is
diff --git a/src/openvpn/crypto_mbedtls.c b/src/open=
vpn/crypto_mbedtls.c
index 1a39752..91485cb 100644--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/openvp=
n/crypto_mbedtls.c
@@ -566,11 +566,12 @@
<=
/span>
void
cipher_ctx_init(mbedtls_cipher_conte=
xt_t *ctx, const uint8_t *key,
- const char *ciphername, const mbedtls_operation_t =
operation)
+ =
const char *ciphername, int enc)
{
=
ASSERT(NULL !=3D ciphername && NULL !=3D ctx);
CLEAR(*ctx);
+ const mbedtls_operation_t operation =3D (mbedtls_opera=
tion_t)enc;
const mbedtls_cipher_info_t *kt =3D cipher=
_get(ciphername);
ASSERT(kt);
siz=
e_t key_bitlen =3D mbedtls_cipher_info_get_key_bitlen(kt);
=
diff --git a/src/openvpn/crypto_mbedtls.h b/src/openvpn/crypto_mbedtls.h
index 46f76e2..48d1e20 100644
--- a/src/openv=
pn/crypto_mbedtls.h
+++ b/src/openvpn/crypto_mbedtls.h
@@ -63,6 +63,8 @@
/** Cipher is in GCM mode */=
#define OPENVPN_MODE_GCM MBEDTLS_MODE_GCM
+typedef mb=
edtls_operation_t crypto_operation_t;
+
/** Cipher should encrypt */
=
#define OPENVPN_OP_ENCRYPT MBEDTLS_ENCRYPT
diff --git a/src/openvpn/crypto_openssl.h b/src/openvpn/crypt=
o_openssl.h
index c0e95b4..4cd988a 100644
-=
-- a/src/openvpn/crypto_openssl.h
+++ b/src/openvpn/crypto_=
openssl.h
@@ -85,6 +85,8 @@
/** Cipher is =
in GCM mode */
#define OPENVPN_MODE_GCM EVP_CIPH_GC=
M_MODE
+typedef int crypto_operation_t;
+
/** Cipher should encrypt */
<=
span> #define OPENVPN_OP_ENCRYPT 1
<=
/span>
To view, visit change 548. To unsubscribe, or for help writin=
g mail filters, visit settin=
gs.
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If0dcdde30879fd6185efb2ad313=
99c1629c04d22
Gerrit-Change-Number: 548
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...=
.>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...=
..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
Gerrit-MessageType: newpatchset
--9wfXTLOWo4E=--