Пример #1
0
        public void Transform_Throws_On_Null_Buffer()
        {
            var algorithm = Mock.Of <ICryptoAlgorithm>();
            var rollingIv = new RollingIv(algorithm, new byte[] { 0x12, 0x34, 0x56, 0x78 }, 0x1234);

            rollingIv
            .Invoking(iv => iv.Transform(null))
            .ShouldThrow <ArgumentNullException>();
        }
Пример #2
0
        public void ValidateHeader_Throws_On_Null_Segment()
        {
            var algorithm = new Mock <ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
            .Invoking(iv => iv.ValidateHeader(null))
            .ShouldThrow <ArgumentNullException>();
        }
Пример #3
0
        public void ConstructHeader_Throws_For_Packets_Shorter_Than_2_Bytes()
        {
            var algorithm = new Mock <ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
            .Invoking(iv => iv.ConstructHeader(1).Whatever())
            .ShouldThrow <ArgumentOutOfRangeException>()
            .WithMessagePrefix(CommonStrings.PacketLengthMustBeMoreThan2Bytes);
        }
Пример #4
0
        public void ValidateHeader_Throws_When_Segment_Shorter_Than_4_Bytes()
        {
            var algorithm = new Mock <ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
            .Invoking(iv => iv.ValidateHeader(new byte[] { 0x01, 0x02, 0x03 }))
            .ShouldThrow <ArgumentException>()
            .WithMessagePrefix(SegmentMustBeLongerThan4());
        }
Пример #5
0
        public void ConstructHeader_Throws_For_Packets_Shorter_Than_2_Bytes()
        {
            var algorithm = new Mock<ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
                .Invoking(iv => iv.ConstructHeader(1).Whatever())
                .ShouldThrow<ArgumentOutOfRangeException>()
                .WithMessagePrefix(CommonStrings.PacketLengthMustBeMoreThan2Bytes);
        }
Пример #6
0
 public void Transform_Throws_On_Null_Buffer()
 {
     var algorithm = Mock.Of<ICryptoAlgorithm>();
     var rollingIv = new RollingIv(algorithm, new byte[] { 0x12, 0x34, 0x56, 0x78 }, 0x1234);
     rollingIv
         .Invoking(iv => iv.Transform(null))
         .ShouldThrow<ArgumentNullException>();
 }
Пример #7
0
        public void ValidateHeader_Throws_When_Segment_Shorter_Than_4_Bytes()
        {
            var algorithm = new Mock<ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
                .Invoking(iv => iv.ValidateHeader(new byte[] { 0x01, 0x02, 0x03 }))
                .ShouldThrow<ArgumentException>()
                .WithMessagePrefix(SegmentMustBeLongerThan4());
        }
Пример #8
0
        public void ValidateHeader_Throws_On_Null_Segment()
        {
            var algorithm = new Mock<ICryptoAlgorithm>(MockBehavior.Loose);
            var initialIv = new byte[] { 0x12, 0x34, 0x56, 0x78 };
            var rollingIv = new RollingIv(algorithm.Object, initialIv, 0x1234);

            rollingIv
                .Invoking(iv => iv.ValidateHeader(null))
                .ShouldThrow<ArgumentNullException>();
        }