public void ShouldCorrectlyDeriveKey(MacModes mac, CounterLocations ctrLocation, int rLen, int outLen, string kI, string fixedInput, string kO) { var keyIn = new BitString(kI); var fixedInputData = new BitString(fixedInput); var expectedKey = new BitString(kO); var kdf = _factory.GetKdfInstance(KdfModes.Pipeline, mac, ctrLocation, rLen); var result = kdf.DeriveKey(keyIn, fixedInputData, outLen); Assert.IsTrue(result.Success, result.ErrorMessage); Assert.AreEqual(expectedKey, result.DerivedKey); }
public IKdf GetKdfInstance(KdfModes kdfMode, MacModes macMode, CounterLocations counterLocation, int counterLength = 0) { var mac = GetMacInstance(macMode); switch (kdfMode) { case KdfModes.Counter: return(new CounterKdf(mac, counterLocation, counterLength)); case KdfModes.Feedback: return(new FeedbackKdf(mac, counterLocation, counterLength)); case KdfModes.Pipeline: return(new PipelineKdf(mac, counterLocation, counterLength)); default: throw new ArgumentException("KDF Mode not supported"); } }
public FeedbackKdf(IMac mac, CounterLocations counterLocation, int counterLength = 0) : base(mac) { _counterLocation = counterLocation; _counterLength = counterLength; }
public PipelineKdf(IMac mac, CounterLocations counterLocation, int counterLength) : base(mac) { _counterLocation = counterLocation; _counterLength = counterLength; }
public void ShouldCorrectlyDeriveKeyNoTestNameMessingUpTestRunner(string label, MacModes mac, CounterLocations ctrLocation, int rLen, int outLen, string kI, string fixedInput, string kO, int breakLocation = 0) { var keyIn = new BitString(kI); var fixedInputData = new BitString(fixedInput); var expectedKey = new BitString(kO); var kdf = _factory.GetKdfInstance(KdfModes.Counter, mac, ctrLocation, rLen); var result = kdf.DeriveKey(keyIn, fixedInputData, outLen, breakLocation: breakLocation); Assert.IsTrue(result.Success, result.ErrorMessage); Assert.AreEqual(expectedKey, result.DerivedKey); }