Skip to content

Commit

Permalink
Delete Decrypt_Pkcs1_ErrorsForInvalidPadding
Browse files Browse the repository at this point in the history
This test has a small random chance of failure because of non-determinism. The test Decrypt_Pkcs1_BadPadding covers this scenario and is properly deterministic, so let's go ahead and delete the test that has a chance of failing.

Co-authored-by: Kevin Jones <kevin@vcsjones.com>
  • Loading branch information
github-actions[bot] and vcsjones committed Mar 13, 2024
1 parent bc5e878 commit 6355683
Showing 1 changed file with 0 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,26 +694,6 @@ public void NotSupportedValueMethods()
}
}

[ConditionalTheory]
[InlineData(new byte[] { 1, 2, 3, 4 })]
[InlineData(new byte[0])]
public void Decrypt_Pkcs1_ErrorsForInvalidPadding(byte[] data)
{
if (data.Length == 0 && !PlatformSupportsEmptyRSAEncryption)
{
throw new SkipTestException("Platform does not support RSA encryption of empty data.");
}

using (RSA rsa = RSAFactory.Create(TestData.RSA2048Params))
{
byte[] encrypted = Encrypt(rsa, data, RSAEncryptionPadding.Pkcs1);
encrypted[1] ^= 0xFF;

// PKCS#1, the data, and the key are all deterministic so this should always throw an exception.
Assert.ThrowsAny<CryptographicException>(() => Decrypt(rsa, encrypted, RSAEncryptionPadding.Pkcs1));
}
}

[Fact]
public void Decrypt_Pkcs1_BadPadding()
{
Expand Down

0 comments on commit 6355683

Please sign in to comment.