Exemplo n.º 1
0
        public SchemeFfcDhHybrid1(
            IDsaFfc dsa,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesFfc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IDiffieHellman <FfcDomainParameters, FfcKeyPair> diffieHellman
            ) :
            base(
                dsa,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _diffieHellman = diffieHellman;

            if (SchemeParameters.KasAlgoAttributes.Scheme != FfcScheme.DhHybrid1)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }
        }
Exemplo n.º 2
0
        public SchemeFfcMqv2(
            IDsaFfc dsa,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesFfc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IMqv <FfcDomainParameters, FfcKeyPair> mqv
            ) :
            base(
                dsa,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _mqv = mqv;

            if (SchemeParameters.KasAlgoAttributes.Scheme != FfcScheme.Mqv2)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }
        }
Exemplo n.º 3
0
        public SchemeEccFullMqv(
            IDsaEcc dsa,
            IEccCurveFactory curveFactory,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IMqv <EccDomainParameters, EccKeyPair> mqv
            ) :
            base(
                dsa,
                curveFactory,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _mqv = mqv;

            if (SchemeParameters.KasAlgoAttributes.Scheme != EccScheme.FullMqv)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }
        }
        public SchemeEccOnePassUnified(
            IDsaEcc dsa,
            IEccCurveFactory curveFactory,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IDiffieHellman <EccDomainParameters, EccKeyPair> diffieHellman
            )
            : base(
                dsa,
                curveFactory,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _diffieHellman = diffieHellman;

            if (SchemeParameters.KasAlgoAttributes.Scheme != EccScheme.OnePassUnified)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }
        }
 public SchemeEccStaticUnified(
     IDsaEcc dsa,
     IEccCurveFactory eccCurveFactory,
     IKdfOneStepFactory kdfFactory,
     IKeyConfirmationFactory keyConfirmationFactory,
     INoKeyConfirmationFactory noKeyConfirmationFactory,
     IOtherInfoFactory otherInfoFactory,
     IEntropyProvider entropyProvider,
     SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
     KdfParameters kdfParameters,
     MacParameters macParameters,
     IDiffieHellman <EccDomainParameters, EccKeyPair> diffieHellman
     )
     : base(
         dsa,
         eccCurveFactory,
         kdfFactory,
         keyConfirmationFactory,
         noKeyConfirmationFactory,
         otherInfoFactory,
         entropyProvider,
         schemeParameters,
         kdfParameters,
         macParameters
         )
 {
     _diffieHellman = diffieHellman;
 }
        public SchemeFfcDiffieHellmanEphemeral(
            IDsaFfc dsa,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase<KasDsaAlgoAttributesFfc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IDiffieHellman<FfcDomainParameters, FfcKeyPair> dh
        )
            : base(dsa, kdfFactory, keyConfirmationFactory, noKeyConfirmationFactory, otherInfoFactory, entropyProvider, schemeParameters, kdfParameters, macParameters)
        {
            _diffieHellman = dh;

            if (SchemeParameters.KasAlgoAttributes.Scheme != FfcScheme.DhEphem)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }

            if (SchemeParameters.KasMode == KasMode.KdfKc)
            {
                throw new ArgumentException($"{SchemeParameters.KasMode} not possible with {SchemeParameters.KasAlgoAttributes.Scheme}");
            }
        }
Exemplo n.º 7
0
 protected SchemeBaseEcc(
     IDsaEcc dsa,
     IEccCurveFactory eccCurveFactory,
     IKdfOneStepFactory kdfFactory,
     IKeyConfirmationFactory keyConfirmationFactory,
     INoKeyConfirmationFactory noKeyConfirmationFactory,
     IOtherInfoFactory otherInfoFactory,
     IEntropyProvider entropyProvider,
     SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
     KdfParameters kdfParameters,
     MacParameters macParameters
     )
     : base(
         kdfFactory,
         keyConfirmationFactory,
         noKeyConfirmationFactory,
         otherInfoFactory,
         entropyProvider,
         schemeParameters,
         kdfParameters,
         macParameters
         )
 {
     Dsa             = dsa;
     EccCurveFactory = eccCurveFactory;
 }
Exemplo n.º 8
0
        public SchemeEccOnePassDh(
            IDsaEcc dsa,
            IEccCurveFactory curveFactory,
            IKdfOneStepFactory kdfFactory,
            IKeyConfirmationFactory keyConfirmationFactory,
            INoKeyConfirmationFactory noKeyConfirmationFactory,
            IOtherInfoFactory otherInfoFactory,
            IEntropyProvider entropyProvider,
            SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            IDiffieHellman <EccDomainParameters, EccKeyPair> diffieHellman
            ) :
            base(
                dsa,
                curveFactory,
                kdfFactory,
                keyConfirmationFactory,
                noKeyConfirmationFactory,
                otherInfoFactory,
                entropyProvider,
                schemeParameters,
                kdfParameters,
                macParameters
                )
        {
            _diffieHellman = diffieHellman;

            if (SchemeParameters.KasAlgoAttributes.Scheme != EccScheme.OnePassDh)
            {
                throw new ArgumentException(nameof(SchemeParameters.KasAlgoAttributes.Scheme));
            }

            if (SchemeParameters.KeyConfirmationDirection == KeyConfirmationDirection.Bilateral ||
                (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU &&
                 SchemeParameters.KeyConfirmationRole == KeyConfirmationRole.Provider) ||
                (SchemeParameters.KeyAgreementRole == KeyAgreementRole.ResponderPartyV &&
                 SchemeParameters.KeyConfirmationRole == KeyConfirmationRole.Recipient))
            {
                throw new ArgumentException("Only unilateral Key confirmation possible party V to U");
            }
        }
Exemplo n.º 9
0
        BuildScheme(
            SchemeParametersBase <KasDsaAlgoAttributesFfc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            bool backToOriginalState = true
            )
        {
            IScheme <
                SchemeParametersBase <KasDsaAlgoAttributesFfc>,
                KasDsaAlgoAttributesFfc,
                OtherPartySharedInformation <
                    FfcDomainParameters,
                    FfcKeyPair
                    >,
                FfcDomainParameters,
                FfcKeyPair
                > scheme = null;

            var dsa = _dsaFfcFactory.GetInstance(_withHashFunction);

            switch (schemeParameters.KasAlgoAttributes.Scheme)
            {
            case FfcScheme.DhHybrid1:
                scheme = new SchemeFfcDhHybrid1(dsa, _withKdfFactory,
                                                _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case FfcScheme.Mqv2:
                scheme = new SchemeFfcMqv2(dsa, _withKdfFactory,
                                           _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                           _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv);
                break;

            case FfcScheme.DhEphem:
                scheme = new SchemeFfcDiffieHellmanEphemeral(dsa, _withKdfFactory,
                                                             _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                             _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case FfcScheme.DhHybridOneFlow:
                scheme = new SchemeFfcDhHybridOneFlow(dsa, _withKdfFactory,
                                                      _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                      _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case FfcScheme.Mqv1:
                scheme = new SchemeFfcMqv1(dsa, _withKdfFactory,
                                           _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                           _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv);
                break;

            case FfcScheme.DhOneFlow:
                scheme = new SchemeFfcDhOneFlow(dsa, _withKdfFactory,
                                                _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case FfcScheme.DhStatic:
                scheme = new SchemeFfcDhStatic(dsa, _withKdfFactory,
                                               _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                               _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            default:
                throw new ArgumentException(nameof(schemeParameters.KasAlgoAttributes.Scheme));
            }

            if (backToOriginalState)
            {
                SetWithInjectablesToConstructionState();
            }

            return(scheme);
        }
Exemplo n.º 10
0
 BuildScheme(
     SchemeParametersBase <TKasDsaAlgoAttributes> schemeParameters,
     KdfParameters kdfParameters,
     MacParameters macParameters,
     bool backToOriginalState = true
     );
Exemplo n.º 11
0
        BuildScheme(
            SchemeParametersBase <KasDsaAlgoAttributesEcc> schemeParameters,
            KdfParameters kdfParameters,
            MacParameters macParameters,
            bool backToOriginalState = true
            )
        {
            IScheme <
                SchemeParametersBase <KasDsaAlgoAttributesEcc>,
                KasDsaAlgoAttributesEcc,
                OtherPartySharedInformation <
                    EccDomainParameters,
                    EccKeyPair
                    >,
                EccDomainParameters,
                EccKeyPair
                > scheme = null;

            var dsa = _dsaEccFactory.GetInstance(_withHashFunction);

            switch (schemeParameters.KasAlgoAttributes.Scheme)
            {
            case EccScheme.FullUnified:
                scheme = new SchemeEccFullUnified(dsa, _eccCurveFactory, _withKdfFactory,
                                                  _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                  _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case EccScheme.FullMqv:
                scheme = new SchemeEccFullMqv(dsa, _eccCurveFactory, _withKdfFactory,
                                              _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                              _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv);
                break;

            case EccScheme.EphemeralUnified:
                scheme = new SchemeEccEphemeralUnified(dsa, _eccCurveFactory, _withKdfFactory,
                                                       _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                       _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case EccScheme.OnePassUnified:
                scheme = new SchemeEccOnePassUnified(dsa, _eccCurveFactory, _withKdfFactory,
                                                     _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                     _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case EccScheme.OnePassMqv:
                scheme = new SchemeEccOnePassMqv(dsa, _eccCurveFactory, _withKdfFactory,
                                                 _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                 _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withMqv);
                break;

            case EccScheme.OnePassDh:
                scheme = new SchemeEccOnePassDh(dsa, _eccCurveFactory, _withKdfFactory,
                                                _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            case EccScheme.StaticUnified:
                scheme = new SchemeEccStaticUnified(dsa, _eccCurveFactory, _withKdfFactory,
                                                    _withKeyConfirmationFactory, _withNoKeyConfirmationFactory, _withOtherInfoFactory,
                                                    _withEntropyProvider, schemeParameters, kdfParameters, macParameters, _withDiffieHellman);
                break;

            default:
                throw new ArgumentException(nameof(schemeParameters.KasAlgoAttributes.Scheme));
            }

            if (backToOriginalState)
            {
                SetWithInjectablesToConstructionState();
            }

            return(scheme);
        }