Skip to content

Commit 8da0ed4

Browse files
authored
Always tamper the signature in the data area
When tests such as System.Security.Cryptography.X509Certificates.Tests.RevocationTests.DynamicRevocationTests.RevokeEndEntityWithInvalidRevocationSignature ran on EC-DSA with secp384r1, there is a roughly 50% chance that flipping all of the bits in signature[5] will produce a signature value that is not structurally valid DER by making the first 9 bits of an INTEGER all have the same value. OpenSSL bubbles up this error differently from "it is structurally valid, but the signature is wrong", which makes our tests fail. While there is some value in making these sorts of tamper look the same on Windows and Linux, the most important tamper is "the data was tampered with, invalidating the unchanged signature". That's the scenario these tests are trying to test (by making the signature wrong), so instead do the tamper at the second-to-last byte of the signature, which is always going to be in the "data" segment of a signature, never "structure" (for any known algorithm).
1 parent 2471117 commit 8da0ed4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/CertificateAuthority.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ private byte[] BuildCrlManually(
488488

489489
if (CorruptRevocationSignature)
490490
{
491-
signature[5] ^= 0xFF;
491+
signature[^2] ^= 0xFF;
492492
}
493493

494494
// CertificateList
@@ -643,7 +643,7 @@ certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
643643

644644
if (CorruptRevocationSignature)
645645
{
646-
signature[5] ^= 0xFF;
646+
signature[^2] ^= 0xFF;
647647
}
648648

649649
writer.WriteBitString(signature);

0 commit comments

Comments
 (0)