public void TestSignAndVerify(String subDir, string nestDir) { var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir); using (var signer = new AttachedSigner(subPath)) using (var verifier = new AttachedVerifier(subPath)) { var signedoutput = signer.Sign(input); Expect(signer.Verify(signedoutput), Is.True); Expect(verifier.Verify(signedoutput), Is.True); } }
public void TestSignAndVerifyBad(String subDir, string nestDir) { var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir); using (var signer = new AttachedSigner(subPath)) using (var verifier = new AttachedVerifier(subPath)) { var signedoutput = signer.Sign(input); var badoutput = signedoutput.ToBytes(); badoutput[10] ^= 9; Expect(signer.Verify(badoutput), Is.False); Expect(verifier.Verify(badoutput), Is.False); } }
public void TestSignAndVerifyShort(String subDir, string nestDir) { var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir); using (var signer = new AttachedSigner(subPath)) using (var verifier = new AttachedVerifier(subPath)) { var signedoutput = signer.Sign(input); var badoutput = signedoutput.ToBytes(); badoutput[10] ^= 9; var badlength = new byte[12]; Array.Copy(badoutput, badlength, badlength.Length); Expect(() => signer.Verify(badlength), Throws.InstanceOf <InvalidCryptoDataException>()); Expect(() => verifier.Verify(badlength), Throws.InstanceOf <InvalidCryptoDataException>()); } }
public void TestSignAndVerifyShort(String subDir, string nestDir) { var subPath = Util.TestDataPath(TEST_DATA, subDir, nestDir); using (var signer = new AttachedSigner(subPath)) using (var verifier = new AttachedVerifier(subPath)) { var signedoutput = signer.Sign(input); var badoutput = signedoutput.ToBytes(); badoutput[10] ^= 9; var badlength = new byte[12]; Array.Copy(badoutput, badlength, badlength.Length); Expect(() => signer.Verify(badlength), Throws.InstanceOf<InvalidCryptoDataException>()); Expect(() => verifier.Verify(badlength), Throws.InstanceOf<InvalidCryptoDataException>()); } }