예제 #1
0
        public void ShouldMultiExpandSameResult()
        {
            var fixedInfo = new BitString(128);
            var salt      = new BitString(128);
            var z         = new BitString(128);
            var hmacAlg   = HashFunctions.Sha2_d256;
            var l         = 256;

            var hkdfParam = new KdfParameterHkdf()
            {
                L       = l,
                Salt    = salt,
                Z       = z,
                HmacAlg = hmacAlg
            };
            var multiExpandHkdfParam = new KdfMultiExpansionParameterHkdf()
            {
                Salt                = salt,
                Z                   = z,
                HmacAlg             = hmacAlg,
                IterationParameters = new List <KdfMultiExpansionIterationParameter>()
                {
                    new KdfMultiExpansionIterationParameter(l, fixedInfo),
                    new KdfMultiExpansionIterationParameter(l, fixedInfo),
                }
            };

            var hkdfResult            = _kdfVisitor.Kdf(hkdfParam, fixedInfo);
            var multiExpandHkdfResult = _kdfMultiExpansionVisitor.Kdf(multiExpandHkdfParam);

            Assert.True(multiExpandHkdfResult.Results.Count == 2);
            Assert.AreEqual(hkdfResult.DerivedKey, multiExpandHkdfResult.Results[0].DerivedKey);
            Assert.AreEqual(hkdfResult.DerivedKey, multiExpandHkdfResult.Results[1].DerivedKey);
        }
 public KdfMultiExpansionResult AcceptKdf(IKdfMultiExpansionVisitor visitor)
 {
     return(visitor.Kdf(this));
 }