예제 #1
0
        public void ShouldReturnNullWhenCurrentIsNull()
        {
            var subject = new Random800_90();
            var result  = subject.GetDifferentBitStringOfSameSize(null);

            Assert.IsNull(result);
        }
예제 #2
0
        public void ShouldReturnNullWhenCurrentIsZeroLength()
        {
            var subject             = new Random800_90();
            var zeroLengthBitString = new BitString(0);
            var result = subject.GetDifferentBitStringOfSameSize(zeroLengthBitString);

            Assert.IsNull(result);
        }
예제 #3
0
        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");
        }