Ejemplo n.º 1
0
        public void Setup()
        {
            var engineFactory = new BlockCipherEngineFactory();
            var modeFactory   = new ModeBlockCipherFactory();

            _subject = new Ff1BlockCipher(
                engineFactory.GetSymmetricCipherPrimitive(BlockCipherEngines.Aes),
                modeFactory,
                new AesFfInternals(engineFactory, modeFactory));
        }
Ejemplo n.º 2
0
        public void ShouldEncryptCorrectly(string keyHex, string ptHex, string ctHex)
        {
            var key            = new BitString(keyHex);
            var payload        = new BitString(ptHex);
            var expectedResult = new BitString(ctHex);

            var factory = new BlockCipherEngineFactory();
            var engine  = factory.GetSymmetricCipherPrimitive(BlockCipherEngines.Aes);

            var subject = new ModeBlockCipherFactory().GetStandardCipher(engine, BlockCipherModesOfOperation.CbcMac);

            var param  = new ModeBlockCipherParameters(BlockCipherDirections.Encrypt, BitString.Zeroes(128), key, payload);
            var result = subject.ProcessPayload(param);

            Assert.IsTrue(result.Success, result.ErrorMessage);
            Assert.AreEqual(expectedResult.ToHex(), result.Result.ToHex());
        }