public void TestSignAndVerifyMessage(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.VerifiedMessage(signedoutput), Is.EqualTo(input)); Expect(verifier.VerifiedMessage(signedoutput), Is.EqualTo(input)); } }
public void TestSignAndVerifyMessageBad(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.VerifiedMessage(badoutput), Throws.InstanceOf <InvalidCryptoDataException>()); Expect(() => verifier.VerifiedMessage(badoutput), Throws.InstanceOf <InvalidCryptoDataException>()); } }
public void TestSignAndVerifyMessageBad(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.VerifiedMessage(badoutput), Throws.InstanceOf<InvalidCryptoDataException>()); Expect(() => verifier.VerifiedMessage(badoutput), Throws.InstanceOf<InvalidCryptoDataException>()); } }