示例#1
0
        public KdfResult Kdf(KdfParameterIkeV2 param, BitString fixedInfo = null)
        {
            var result      = _kdfVisitor.Kdf(param, fixedInfo);
            var dkmBytesLen = result.DerivedKey.BitLength.CeilingDivide(BitString.BITSINBYTE);

            // Modify a random byte within DKM
            result.DerivedKey[_random.GetRandomInt(0, dkmBytesLen)] += 2;

            return(result);
        }
示例#2
0
        public KdfResult Kdf(KdfParameterIkeV2 param, BitString fixedInfo = null)
        {
            var hashFunction = ShaAttributes.GetHashFunctionFromEnum(param.HashFunction);

            var kdf = _ikeV2Factory.GetInstance(hashFunction);

            var result = kdf.GenerateDkmIke(
                param.InitiatorEphemeralData,
                param.ResponderEphemeralData,
                param.Z,
                param.AdditionalInitiatorNonce,
                param.AdditionalResponderNonce,
                param.L);

            return(new KdfResult(result));
        }
示例#3
0
        public KdfResult Kdf(KdfParameterIkeV2 param, BitString fixedInfo = null)
        {
            var zBytesLen = param.Z.BitLength.CeilingDivide(BitString.BITSINBYTE);

            var modifiedParam = new KdfParameterIkeV1()
            {
                L            = param.L,
                Z            = param.Z.GetDeepCopy(),
                HashFunction = param.HashFunction
            };

            // Modify a random byte within Z
            modifiedParam.Z[_random.GetRandomInt(0, zBytesLen)] += 2;

            return(_kdfVisitor.Kdf(modifiedParam, fixedInfo));
        }