public void ShouldReturnNullWhenCurrentIsNull() { var subject = new Random800_90(); var result = subject.GetDifferentBitStringOfSameSize(null); Assert.IsNull(result); }
public void ShouldReturnNullWhenCurrentIsZeroLength() { var subject = new Random800_90(); var zeroLengthBitString = new BitString(0); var result = subject.GetDifferentBitStringOfSameSize(zeroLengthBitString); Assert.IsNull(result); }
public void ShouldGenerateAndVerifySuccessfully(string keyString, string messageString, string expectedMacString) { BitString key = new BitString(keyString); BitString message = new BitString(messageString); BitString expectedMac = new BitString(expectedMacString); int macLength = expectedMac.BitLength; Random800_90 rand = new Random800_90(); var badMac = rand.GetDifferentBitStringOfSameSize(expectedMac); var generateResult = _subject.Generate(key, message, macLength); var goodValidateResult = _subject.Verify(key, message, generateResult.Mac); var badValidateResult = _subject.Verify(key, message, badMac); Assert.IsTrue(generateResult.Success, "Successful generate"); Assert.AreEqual(expectedMac.ToHex(), generateResult.Mac.ToHex(), "Generate MAC"); Assert.IsTrue(goodValidateResult.Success, "Verify success"); Assert.IsFalse(badValidateResult.Success, "Verify failure"); }