From: "plaisthos (Code Review)" Date: Wed, 22 Apr 2026 13:21:08 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Lx1sGIZvpSw="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: AWS-LC: Add casts and openssl_opt_t typdef to allow AWS-LC with -Werror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openvpn-devel --Lx1sGIZvpSw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/= c/openvpn/+/1637?usp=3Demail ) Change subject: AWS-LC: Add casts and openssl_opt_t typdef to allow AWS-LC = with -Werror ...................................................................... AWS-LC: Add casts and openssl_opt_t typdef to allow AWS-LC with -Werror Change-Id: I88254e985d67234d827b92908079795df23daf20 --- M .github/workflows/build.yaml M src/openvpn/crypto_openssl.c M src/openvpn/openssl_compat.h M src/openvpn/ssl_openssl.c M src/openvpn/ssl_verify_openssl.c 5 files changed, 16 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/37/1637/1 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e4cb799..5cc1a7d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -347,6 +347,4 @@ gitref: v1.70.0 libconfigure: cmake -B build -GNinja -DCMAKE_BUILD_TYPE=3DRelease -D= CMAKE_INSTALL_PREFIX=3D"$LIBPREFIX" -DBUILD_SHARED_LIBS=3D1 libmake: cmake --build build - libinstall: sudo cmake --install build - # not ready for --enable-werror - ovpnconfigureflags: + libinstall: sudo cmake --install build \ No newline at end of file diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index c11cfd8..fa9eb67 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -425,7 +425,7 @@ print_digest(EVP_MD *digest, void *unused) { printf("%s %d bit digest size\n", md_kt_name(EVP_MD_get0_name(digest)), - EVP_MD_size(digest) * 8); + (int)EVP_MD_size(digest) * 8); } void @@ -1025,7 +1025,7 @@ "Message hash algorithm '%s' uses a default hash " "size (%d bytes) which is larger than " PACKAGE_NAME "'= s current " "maximum hash size (%d bytes)", - digest, EVP_MD_size(md), MAX_HMAC_KEY_LENGTH); + digest, (int)EVP_MD_size(md), MAX_HMAC_KEY_LENGTH); } return md; } @@ -1144,7 +1144,7 @@ int md_ctx_size(const EVP_MD_CTX *ctx) { - return EVP_MD_CTX_size(ctx); + return (int)EVP_MD_CTX_size(ctx); } void @@ -1188,7 +1188,7 @@ evp_md_type *kt =3D md_get(mdname); ASSERT(NULL !=3D kt && NULL !=3D ctx); - int key_len =3D EVP_MD_size(kt); + int key_len =3D (int)EVP_MD_size(kt); HMAC_CTX_reset(ctx); if (!HMAC_Init_ex(ctx, key, key_len, kt, NULL)) { diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index ec059ac..b61bcbf 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -51,10 +51,14 @@ typedef uint32_t openssl_err_t; typedef size_t openssl_stack_size_t; #define PRI_OPENSSL_STACK "zu" +typedef uint32_t openssl_opt_t; #else typedef unsigned long openssl_err_t; typedef int openssl_stack_size_t; #define PRI_OPENSSL_STACK "d" +/* OpenSSL 4.0 actually uses bits in the upper half of the uint64_t (e.g. + * SSL_OP_PREFER_NO_DHE_KEX), so we really should use an uint64_t here */ +typedef uint64_t openssl_opt_t; #endif diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 6ce5f3f..ef99b22 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -328,7 +328,7 @@ ASSERT(NULL !=3D ctx); /* process SSL options */ - uint64_t sslopt =3D SSL_OP_SINGLE_DH_USE | SSL_OP_NO_TICKET; + openssl_opt_t sslopt =3D SSL_OP_SINGLE_DH_USE | SSL_OP_NO_TICKET; #ifdef SSL_OP_CIPHER_SERVER_PREFERENCE sslopt |=3D SSL_OP_CIPHER_SERVER_PREFERENCE; #endif @@ -1656,7 +1656,7 @@ ecdsa_sign(int type, const unsigned char *dgst, int dgstlen, unsigned char= *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_K= EY *ec) { - int capacity =3D ECDSA_size(ec); + int capacity =3D (int)ECDSA_size(ec); /* * ECDSA does not seem to have proper constants for paddings since * there are only signatures without padding at the moment, use @@ -1672,12 +1672,14 @@ return 0; } +#ifndef OPENSSL_IS_AWSLC /* EC_KEY_METHOD callback: sign_setup(). We do no precomputations */ static int ecdsa_sign_setup(EC_KEY *ec, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { return 1; } +#endif /* EC_KEY_METHOD callback: sign_sig(). * Sign the hash and return the result as a newly allocated ECDS_SIG @@ -1688,7 +1690,7 @@ EC_KEY *ec) { ECDSA_SIG *ecsig =3D NULL; - unsigned int len =3D ECDSA_size(ec); + unsigned int len =3D (unsigned int)ECDSA_size(ec); struct gc_arena gc =3D gc_new(); unsigned char *buf =3D gc_malloc(len, false, &gc); diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 6bb61b6..b8648fd 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -357,7 +357,7 @@ const EVP_MD *sha1 =3D EVP_sha1(); struct buffer hash =3D alloc_buf_gc((size_t)EVP_MD_size(sha1), gc); X509_digest(cert, EVP_sha1(), BPTR(&hash), NULL); - ASSERT(buf_inc_len(&hash, EVP_MD_size(sha1))); + ASSERT(buf_inc_len(&hash, (int)EVP_MD_size(sha1))); return hash; } @@ -367,7 +367,7 @@ const EVP_MD *sha256 =3D EVP_sha256(); struct buffer hash =3D alloc_buf_gc((size_t)EVP_MD_size(sha256), gc); X509_digest(cert, EVP_sha256(), BPTR(&hash), NULL); - ASSERT(buf_inc_len(&hash, EVP_MD_size(sha256))); + ASSERT(buf_inc_len(&hash, (int)EVP_MD_size(sha256))); return hash; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1637?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I88254e985d67234d827b92908079795df23daf20 Gerrit-Change-Number: 1637 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-CC: openvpn-devel --Lx1sGIZvpSw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

plaisthos has upl= oaded this change for review.

View Change

AWS-LC: Add casts and openssl_opt_t typdef to allow AWS-LC with -Werror=


Change-Id: I88254e985d67234d827b92908079795df23daf20
---
M .g= ithub/workflows/build.yaml
M src/openvpn/crypto_openssl.c
M src/openv= pn/openssl_compat.h
M src/openvpn/ssl_openssl.c
M src/openvpn/ssl_ver= ify_openssl.c
5 files changed, 16 insertions(+), 12 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/ch=
anges/37/1637/1
diff --git a/.github/workflows/build.yaml b/.github=
/workflows/build.yaml
index e4cb799..5cc1a7d 100644<= br>--- a/.github/workflows/build.yaml
+++ b/.github/w= orkflows/build.yaml
@@ -347,6 +347,4 @@
= gitref: v1.70.0
libconfigure: cmake -B build -GN= inja -DCMAKE_BUILD_TYPE=3DRelease -DCMAKE_INSTALL_PREFIX=3D"$LIBPREFIX= " -DBUILD_SHARED_LIBS=3D1
libmake: cmake --buil= d build
- libinsta= ll: sudo cmake --install build
- # not ready for --enable-werror
- ovpnconfigureflags:
+ libinstall: sudo cmake --install build=
\ No newline at end of file
diff --git a/s= rc/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c
= index c11cfd8..fa9eb67 100644
--- a/src/openvpn/crypto_open= ssl.c
+++ b/src/openvpn/crypto_openssl.c
@@= -425,7 +425,7 @@
print_digest(EVP_MD *digest, void *unuse= d)
{
printf("%s %d bit digest si= ze\n", md_kt_name(EVP_MD_get0_name(digest)),
- EVP_MD_size(digest) * 8);
= + (int)EVP_MD_size(di= gest) * 8);
}

void
@@ -1025,7 +1025,7 @@
"= ;Message hash algorithm '%s' uses a default hash "
<= span> "size (%d bytes) which is larger than " = PACKAGE_NAME "'s current "

= "maximum hash size (%d bytes)",
- digest, EVP_MD_size(md), MAX_HMAC_= KEY_LENGTH);
+ = digest, (int)EVP_MD_size(md), MAX_HMAC_KEY_LENGTH);
<= span> }
return md;
}
@@ -1144,7 +1144,7 @@
int
md_ctx_size= (const EVP_MD_CTX *ctx)
{
- return EVP_MD_CTX_size(ctx);
+ return (int)EVP_MD_CTX_size(ctx);
}

void
@@ = -1188,7 +1188,7 @@
evp_md_type *kt =3D md_get(mdname);=
ASSERT(NULL !=3D kt && NULL !=3D ctx);=

- int ke= y_len =3D EVP_MD_size(kt);
+ int key_len =3D (int)EVP_MD_size(kt);
HMAC_= CTX_reset(ctx);
if (!HMAC_Init_ex(ctx, key, key_len, k= t, NULL))
{
diff --git a/src/openvpn/o= penssl_compat.h b/src/openvpn/openssl_compat.h
index ec059a= c..b61bcbf 100644
--- a/src/openvpn/openssl_compat.h=
+++ b/src/openvpn/openssl_compat.h
@@ -51,10 +51,= 14 @@
typedef uint32_t openssl_err_t;
typ= edef size_t openssl_stack_size_t;
#define PRI_OPENSSL_STAC= K "zu"
+typ= edef uint32_t openssl_opt_t;
#else
typede= f unsigned long openssl_err_t;
typedef int openssl_stack_s= ize_t;
#define PRI_OPENSSL_STACK "d"
<= span style=3D"color: hsl(120, 100%, 40%);">+/* OpenSSL 4.0 actually uses bi= ts in the upper half of the uint64_t (e.g.

+ * SSL_OP_PREFER_NO_DHE_KEX), so we really should us= e an uint64_t here */
+typedef uint64_t openssl_opt_t;
#endif
=

diff --git a/src/openvpn/ssl_openssl.c b= /src/openvpn/ssl_openssl.c
index 6ce5f3f..ef99b22 100644

--- a/src/openvpn/ssl_openssl.c
+++ b/src/ope= nvpn/ssl_openssl.c
@@ -328,7 +328,7 @@
= ASSERT(NULL !=3D ctx);

/* process S= SL options */
- uint= 64_t sslopt =3D SSL_OP_SINGLE_DH_USE | SSL_OP_NO_TICKET;
+ openssl_opt_t sslopt =3D SSL_OP_SI= NGLE_DH_USE | SSL_OP_NO_TICKET;
#ifdef SSL_OP_CIPHER_SERVE= R_PREFERENCE
sslopt |=3D SSL_OP_CIPHER_SERVER_PREFEREN= CE;
#endif
@@ -1656,7 +1656,7 @@ ecdsa_sign(int type, const unsigned char *dgst, int dgstlen, unsign= ed char *sig,
unsigned int *siglen, const BIGNU= M *kinv, const BIGNUM *r, EC_KEY *ec)
{
- int capacity =3D ECDSA_size(ec);
+ int capacity =3D (i= nt)ECDSA_size(ec);
/*
* ECDSA do= es not seem to have proper constants for paddings since
= * there are only signatures without padding at the moment, use@@ -1672,12 +1672,14 @@
return 0;
}


+#ifndef OPENSSL_IS_AWSLC
/* EC_KEY_METHOD callback: si= gn_setup(). We do no precomputations */
static int<= br> ecdsa_sign_setup(EC_KEY *ec, BN_CTX *ctx_in, BIGNUM **kinvp, BIGN= UM **rp)
{
return 1;
= }
+#endif
=
/* EC_KEY_METHOD callback: sign_sig().
<= span> * Sign the hash and return the result as a newly allocated ECDS_SIG<= /span>
@@ -1688,7 +1690,7 @@
EC_KE= Y *ec)
{
ECDSA_SIG *ecsig =3D NULL;
- unsigned int len = =3D ECDSA_size(ec);
+= unsigned int len =3D (unsigned int)ECDSA_size(ec);
= struct gc_arena gc =3D gc_new();

un= signed char *buf =3D gc_malloc(len, false, &gc);
diff -= -git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c<= /span>
index 6bb61b6..b8648fd 100644
--- a/src/ope= nvpn/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_open= ssl.c
@@ -357,7 +357,7 @@
const EVP_MD= *sha1 =3D EVP_sha1();
struct buffer hash =3D alloc_bu= f_gc((size_t)EVP_MD_size(sha1), gc);
X509_digest(cert,= EVP_sha1(), BPTR(&hash), NULL);
- ASSERT(buf_inc_len(&hash, EVP_MD_size(sha1)));
+ ASSERT(buf_inc_len(&a= mp;hash, (int)EVP_MD_size(sha1)));
return hash;=
}

@@ -367,7 +367,7 @@ const EVP_MD *sha256 =3D EVP_sha256();
st= ruct buffer hash =3D alloc_buf_gc((size_t)EVP_MD_size(sha256), gc);<= br> X509_digest(cert, EVP_sha256(), BPTR(&hash), NULL);
- ASSERT(buf_inc_len(&= ;hash, EVP_MD_size(sha256)));
+ ASSERT(buf_inc_len(&hash, (int)EVP_MD_size(sha256)));
return hash;
}
<= br>

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88254e985d67234d827b9290807= 9795df23daf20
Gerrit-Change-Number: 1637
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --Lx1sGIZvpSw=--