Exemplo n.º 1
0
        public OtherInfo(
            IEntropyProvider entropyProvider,
            string otherInfoPattern,
            int otherInfoLength,
            KeyAgreementRole thisPartyKeyAgreementRole,
            PartyOtherInfo thisPartyOtherInfo,
            PartyOtherInfo otherPartyOtherInfo
            )
        {
            _thisPartyKeyAgreementRole = thisPartyKeyAgreementRole;
            _thisPartyOtherInfo        = thisPartyOtherInfo;
            _otherPartyOtherInfo       = otherPartyOtherInfo;

            // split the pattern into pieces
            var pieces = otherInfoPattern.Split("||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            foreach (var piece in pieces)
            {
                var workingPiece = piece.Replace("||", "");
                _otherInfo = _otherInfo.ConcatenateBits(ConcatenatePieceOntoOtherInfo(workingPiece));
            }

            // Add entropy to hit otherInfoLength
            _otherInfo = _otherInfo.ConcatenateBits(entropyProvider.GetEntropy(otherInfoLength - _otherInfo.BitLength));

            _otherInfo = _otherInfo.GetMostSignificantBits(otherInfoLength);
        }
Exemplo n.º 2
0
        public void OtherInfoProofOfConceptTests(OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> uPartySharedInformation, int otherInfoLength, string otherInfoPattern, BitString expectedBitString)
        {
            var vPartySharedInformation = new OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair>(
                null,
                new BitString(0),
                new FfcKeyPair(0),
                new FfcKeyPair(0),
                new BitString(0),
                new BitString(0),
                new BitString(0)
                );

            var uPartyOtherInfo = new PartyOtherInfo(uPartySharedInformation.PartyId, uPartySharedInformation.DkmNonce);
            var vPartyotherInfo = new PartyOtherInfo(vPartySharedInformation.PartyId, vPartySharedInformation.DkmNonce);

            _subject = new OtherInfo(
                new EntropyProvider(new Random800_90()),
                otherInfoPattern,
                otherInfoLength,
                KeyAgreementRole.InitiatorPartyU,
                uPartyOtherInfo,
                vPartyotherInfo
                );

            var result = _subject.GetOtherInfo();

            Assert.AreEqual(expectedBitString.ToHex(), result.ToHex());
        }
Exemplo n.º 3
0
 public IOtherInfo GetInstance(
     string otherInfoPattern,
     int otherInfoLength,
     KeyAgreementRole thisPartyKeyAgreementRole,
     PartyOtherInfo thisPartySharedInformation,
     PartyOtherInfo otherPartySharedInformation)
 {
     return(new FakeOtherInfo(_otherInfo));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Generate the OtherInformation that is to be plugged into a KDF function.
        /// </summary>
        /// <param name="otherPartyInformation">The other party's public information</param>
        /// <returns></returns>
        protected IOtherInfo GenerateOtherInformation(TOtherPartySharedInfo otherPartyInformation)
        {
            var thisPartyPublicInfo = ReturnPublicInfoThisParty();
            var thisPartyOtherInfo  = new PartyOtherInfo(thisPartyPublicInfo.PartyId, thisPartyPublicInfo.DkmNonce);

            var otherPartyOtherInfo = new PartyOtherInfo(otherPartyInformation.PartyId, otherPartyInformation.DkmNonce);

            return(OtherInfoFactory.GetInstance(
                       KdfParameters.OtherInfoPattern,
                       OtherInputLength,
                       SchemeParameters.KeyAgreementRole,
                       thisPartyOtherInfo,
                       otherPartyOtherInfo
                       ));
        }
Exemplo n.º 5
0
 public IOtherInfo GetInstance(
     string otherInfoPattern,
     int otherInfoLength,
     KeyAgreementRole thisPartyKeyAgreementRole,
     PartyOtherInfo thisPartyOtherInfo,
     PartyOtherInfo otherPartyOtherInfo
     )
 {
     return(new OtherInfo(
                _entropyProvider,
                otherInfoPattern,
                otherInfoLength,
                thisPartyKeyAgreementRole,
                thisPartyOtherInfo,
                otherPartyOtherInfo
                ));
 }
Exemplo n.º 6
0
        public void ShouldReturnCorrectOtherInfoCavsTests(
            KeyAgreementRole iutRole,
            OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> uPartySharedInformation,
            OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> vPartySharedInformation,
            int otherInfoLength,
            BitString expectedOtherInfo
            )
        {
            string otherInfoPattern = "uPartyInfo||vPartyInfo";

            TestableEntropyProvider entropyProvider = new TestableEntropyProvider();

            // u/v party info comprised of ID, and dkmNonce, find the bitlength of both parties contributed information
            // to determine which bits are the "random" bits to inject into the TestableEntropyProvider.
            var composedBitLength = uPartySharedInformation.PartyId.BitLength +
                                    uPartySharedInformation.DkmNonce.BitLength +
                                    vPartySharedInformation.PartyId.BitLength;

            var entropyBits = expectedOtherInfo.GetLeastSignificantBits(expectedOtherInfo.BitLength - composedBitLength);

            entropyProvider.AddEntropy(entropyBits);

            var uPartyOtherInfo = new PartyOtherInfo(uPartySharedInformation.PartyId, uPartySharedInformation.DkmNonce);
            var vPartyOtherInfo = new PartyOtherInfo(vPartySharedInformation.PartyId, vPartySharedInformation.DkmNonce);

            _subject = new OtherInfo(
                entropyProvider,
                otherInfoPattern,
                otherInfoLength,
                KeyAgreementRole.InitiatorPartyU,
                uPartyOtherInfo,
                vPartyOtherInfo
                );

            var result = _subject.GetOtherInfo();

            Assert.AreEqual(expectedOtherInfo.ToHex(), result.ToHex());
        }