public void ShouldGfSBoxCorrectlyWithEachKeySize(int keyLen) { foreach (var test in KatDataCtr.GetGfSBox(keyLen)) { _mockCounter.Setup(s => s.GetNextIV()).Returns(test.IV); var param = new ModeBlockCipherParameters( BlockCipherDirections.Encrypt, test.Key, test.PlainText ); var result = _subject.ProcessPayload(param); Assert.IsTrue(result.Success, nameof(result.Success)); Assert.AreEqual(test.CipherText, result.Result, test.CipherText.ToHex()); } }
public void ShouldEncryptCorrectlyNewEngine(string keyHex, string ivHex, string ptHex, string ctHex) { var key = new BitString(keyHex); var iv = new BitString(ivHex); var pt = new BitString(ptHex); var ct = new BitString(ctHex); _mockCounter.Setup(s => s.GetNextIV()).Returns(iv); var param = new ModeBlockCipherParameters( BlockCipherDirections.Encrypt, key, pt ); var result = _subject.ProcessPayload(param); Assert.IsTrue(result.Success); Assert.AreEqual(ct, result.Result); }