Commit 0ffc3f3fd6 for strongswan.org
commit 0ffc3f3fd6f4377e5ec2d76ab7ff8bc36e19e727
Author: Tobias Brunner <tobias@strongswan.org>
Date: Mon Jul 13 17:25:08 2026 +0200
gcrypt: Fix zeroing padding when extracting RSA value from S-expression
When left-padding a value shorter than the RSA key, the code previously
calculated the length incorrectly so that some bytes might have been
cleared if the value was shorter than half the required length.
Fixes: a2f1bb238ecc ("enforce correct RSA signature lenght in gcrypt")
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c
index 2ab4283654..1d6fe459c2 100644
--- a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c
+++ b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c
@@ -78,7 +78,7 @@ chunk_t gcrypt_rsa_find_token(gcry_sexp_t sexp, char *name, gcry_sexp_t key)
{
tmp = chunk_alloc(len);
len -= data.len;
- memset(tmp.ptr, 0, tmp.len - len);
+ memset(tmp.ptr, 0, len);
memcpy(tmp.ptr + len, data.ptr, data.len);
data = tmp;
}