Skip to content

Commit ab20ece

Browse files
flichtenheldcron2
authored andcommitted
Handle return type of EVP_MD_size
Return type is int, but we often use it in contexts where we expect size_t. So just cast it. Nothing else to do really. Change-Id: I22b93c807f1be99fab450708f686fce4aa6d5cef Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1133 Message-Id: <20250922204059.23226-1-gert@greenie.muc.de> URL: https://sourceforge.net/p/openvpn/mailman/message/59237213/ Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent 38f2ced commit ab20ece

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/openvpn/crypto_openssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ hmac_ctx_init(hmac_ctx_t *ctx, const uint8_t *key, const char *mdname)
12731273

12741274
/* We need to make a copy of the key since the OSSL parameters
12751275
* only reference it */
1276-
memcpy(ctx->key, key, EVP_MD_size(kt));
1276+
memcpy(ctx->key, key, (size_t)EVP_MD_size(kt));
12771277

12781278
/* Lookup/setting of parameters in OpenSSL 3.0 are string based
12791279
*
@@ -1282,7 +1282,7 @@ hmac_ctx_init(hmac_ctx_t *ctx, const uint8_t *key, const char *mdname)
12821282
* the constness away here.
12831283
*/
12841284
ctx->params[0] = OSSL_PARAM_construct_utf8_string("digest", (char *)EVP_MD_get0_name(kt), 0);
1285-
ctx->params[1] = OSSL_PARAM_construct_octet_string("key", ctx->key, EVP_MD_size(kt));
1285+
ctx->params[1] = OSSL_PARAM_construct_octet_string("key", ctx->key, (size_t)EVP_MD_size(kt));
12861286
ctx->params[2] = OSSL_PARAM_construct_end();
12871287

12881288
if (!EVP_MAC_init(ctx->ctx, NULL, 0, ctx->params))

src/openvpn/ssl_verify_openssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ struct buffer
341341
x509_get_sha1_fingerprint(X509 *cert, struct gc_arena *gc)
342342
{
343343
const EVP_MD *sha1 = EVP_sha1();
344-
struct buffer hash = alloc_buf_gc(EVP_MD_size(sha1), gc);
344+
struct buffer hash = alloc_buf_gc((size_t)EVP_MD_size(sha1), gc);
345345
X509_digest(cert, EVP_sha1(), BPTR(&hash), NULL);
346346
ASSERT(buf_inc_len(&hash, EVP_MD_size(sha1)));
347347
return hash;
@@ -351,7 +351,7 @@ struct buffer
351351
x509_get_sha256_fingerprint(X509 *cert, struct gc_arena *gc)
352352
{
353353
const EVP_MD *sha256 = EVP_sha256();
354-
struct buffer hash = alloc_buf_gc(EVP_MD_size(sha256), gc);
354+
struct buffer hash = alloc_buf_gc((size_t)EVP_MD_size(sha256), gc);
355355
X509_digest(cert, EVP_sha256(), BPTR(&hash), NULL);
356356
ASSERT(buf_inc_len(&hash, EVP_MD_size(sha256)));
357357
return hash;

src/openvpn/xkey_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ encode_pkcs1(unsigned char *enc, size_t *enc_len, const char *mdname, const unsi
351351
}
352352
}
353353

354-
if (tbslen != EVP_MD_size(EVP_get_digestbyname(mdname)))
354+
if (tbslen != (size_t)EVP_MD_size(EVP_get_digestbyname(mdname)))
355355
{
356356
msg(M_WARN, "Error: encode_pkcs11: invalid input length <%zu>", tbslen);
357357
goto done;

0 commit comments

Comments
 (0)