コード例 #1
0
        public static void GetCiphertextLengthCfb_ThrowsForNonByteFeedbackSize(PaddingMode mode)
        {
            AnySizeAlgorithm alg = new AnySizeAlgorithm();

            AssertExtensions.Throws <ArgumentException>("feedbackSizeInBits", () =>
                                                        alg.GetCiphertextLengthCfb(16, mode, 7));
        }
コード例 #2
0
        public static void GetCiphertextLengthCfb_ThrowsForOverflow(PaddingMode mode)
        {
            AnySizeAlgorithm alg = new AnySizeAlgorithm();

            AssertExtensions.Throws <ArgumentOutOfRangeException>("plaintextLength", () =>
                                                                  alg.GetCiphertextLengthCfb(0x7FFFFFFF, mode, feedbackSizeInBits: 128));
        }
コード例 #3
0
        public static void GetCiphertextLengthCfb_NoPaddingAndPlaintextSizeNotFeedbackAligned()
        {
            AnySizeAlgorithm alg = new AnySizeAlgorithm();

            Assert.Throws <ArgumentException>("plaintextLength", () =>
                                              alg.GetCiphertextLengthCfb(17, PaddingMode.None, feedbackSizeInBits: 128));
        }
コード例 #4
0
        public static void GetCiphertextLengthCfb_ValidInputs(
            PaddingMode mode,
            int plaintextSize,
            int expectedCiphertextSize,
            int alignmentSizeInBits)
        {
            AnySizeAlgorithm alg  = new AnySizeAlgorithm();
            int ciphertextSizeCfb = alg.GetCiphertextLengthCfb(plaintextSize, mode, alignmentSizeInBits);

            Assert.Equal(expectedCiphertextSize, ciphertextSizeCfb);
        }
コード例 #5
0
        public static void GetCiphertextLength_ThrowsForInvalidPaddingMode()
        {
            AnySizeAlgorithm alg = new AnySizeAlgorithm {
                BlockSize = 128
            };
            PaddingMode mode = (PaddingMode)(-1);

            Assert.Throws <ArgumentOutOfRangeException>("paddingMode", () => alg.GetCiphertextLengthCbc(16, mode));
            Assert.Throws <ArgumentOutOfRangeException>("paddingMode", () => alg.GetCiphertextLengthEcb(16, mode));
            Assert.Throws <ArgumentOutOfRangeException>("paddingMode", () => alg.GetCiphertextLengthCfb(16, mode));
        }
コード例 #6
0
        public static void GetCiphertextLength_ThrowsForNegativeInput(PaddingMode mode)
        {
            AnySizeAlgorithm alg = new AnySizeAlgorithm {
                BlockSize = 128
            };

            AssertExtensions.Throws <ArgumentOutOfRangeException>("plaintextLength", () => alg.GetCiphertextLengthCbc(-1, mode));
            AssertExtensions.Throws <ArgumentOutOfRangeException>("plaintextLength", () => alg.GetCiphertextLengthEcb(-1, mode));
            AssertExtensions.Throws <ArgumentOutOfRangeException>("plaintextLength", () => alg.GetCiphertextLengthCfb(-1, mode));
        }