Skip to content

Commit 397ee5f

Browse files
github-actions[bot]rcatolinovcsjonesbartonjs
authored
fix(#114260): in rsa signatures, configure digest before padding mode (#115695)
Co-authored-by: Raphael Catolino <[email protected]> Co-authored-by: Kevin Jones <[email protected]> Co-authored-by: Jeremy Barton <[email protected]>
1 parent bbe2762 commit 397ee5f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/native/libs/System.Security.Cryptography.Native/pal_evp_pkey_rsa.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ int32_t CryptoNative_RsaEncrypt(EVP_PKEY* pkey,
215215

216216
static bool ConfigureSignature(EVP_PKEY_CTX* ctx, RsaPaddingMode padding, const EVP_MD* digest)
217217
{
218+
219+
#pragma clang diagnostic push
220+
#pragma clang diagnostic ignored "-Wcast-qual"
221+
if (EVP_PKEY_CTX_set_signature_md(ctx, digest) <= 0)
222+
#pragma clang diagnostic pop
223+
{
224+
return false;
225+
}
226+
218227
if (padding == RsaPaddingPkcs1)
219228
{
220229
if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING) <= 0)
@@ -233,14 +242,6 @@ static bool ConfigureSignature(EVP_PKEY_CTX* ctx, RsaPaddingMode padding, const
233242
}
234243
}
235244

236-
#pragma clang diagnostic push
237-
#pragma clang diagnostic ignored "-Wcast-qual"
238-
if (EVP_PKEY_CTX_set_signature_md(ctx, digest) <= 0)
239-
#pragma clang diagnostic pop
240-
{
241-
return false;
242-
}
243-
244245
return true;
245246
}
246247

0 commit comments

Comments
 (0)