コード例 #1
0
        public void ShouldRunEncryptOperation100000TimesForTestCase(int keySize, BlockCipherDirections direction)
        {
            BitString iv      = new BitString(128);
            BitString key     = new BitString(keySize);
            BitString payload = new BitString(128);

            var p = new ModeBlockCipherParameters(
                direction,
                iv,
                key,
                payload
                );

            var result = _subject.ProcessMonteCarloTest(p);

            Assert.IsTrue(result.Success, nameof(result.Success));
            _algo.Verify(v => v.ProcessPayload(
                             It.IsAny <ModeBlockCipherParameters>()),
                         Times.Exactly(100000),
                         nameof(_algo.Object.ProcessPayload)
                         );
        }
コード例 #2
0
ファイル: MCTs.cs プロジェクト: usnistgov/ACVP-Server
        public void ShouldMonteCarloTestEncrypt128BitKey()
        {
            BitString key       = new BitString("b36e1af187632167caf1bd04db427bf5");
            BitString iv        = new BitString("a4b61dc718672a8090549cbe5aadb44f");
            BitString plainText = new BitString("2cfd639111e327220f1d2660e1402c3a");

            var param = new ModeBlockCipherParameters(
                BlockCipherDirections.Encrypt,
                iv,
                key,
                plainText
                );
            var result = _subject.ProcessMonteCarloTest(param);
            var firstExpectedCipherText = new BitString("76156cacb09a34d6d7d9511ad1d8e92e");
            var lastExpectedCipherText  = new BitString("11541400b5ef0b588f2ce9df5e74f45e");

            var firstCipherText = result.Response[0].CipherText.ToHex();
            var lastCipherText  = result.Response[result.Response.Count - 1].CipherText.ToHex();

            Assert.AreEqual(firstExpectedCipherText.ToHex(), firstCipherText, nameof(firstCipherText));
            Assert.AreEqual(lastExpectedCipherText.ToHex(), lastCipherText, nameof(lastCipherText));

            Assert.IsTrue(result.Success);
        }