From 0ffc3f3fd6f4377e5ec2d76ab7ff8bc36e19e727 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 13 Jul 2026 17:25:08 +0200 Subject: [PATCH] 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") --- src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c b/src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c index 2ab428365..1d6fe459c 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; }