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) ); }
public void ShouldMonteCarloTestEncrypt128BitKey() { BitString key = new BitString("71cdc0006a5de45e31a56ddab56e5595"); BitString plainText = new BitString("0333cf639a8e98b4e5383d21c659d0c7"); var param = new ModeBlockCipherParameters( BlockCipherDirections.Encrypt, null, key, plainText); var result = _subject.ProcessMonteCarloTest(param); var firstExpectedCipherText = new BitString("cec42be01aa7918cd7d563407324bcbb"); var lastExpectedCipherText = new BitString("9da00f60c0724427108eff09f2888d7f"); var firstCipherText = result.Response[0].CipherText.ToHex(); var lastCipherText = result.Response[result.Response.Count - 1].CipherText.ToHex(); Assert.AreEqual(firstExpectedCipherText.ToHex(), firstCipherText); Assert.AreEqual(lastExpectedCipherText.ToHex(), lastCipherText); Assert.IsTrue(result.Success); }