示例#1
0
        protected override BitString ComputeSharedSecret(ISecretKeyingMaterial otherPartyKeyingMaterial)
        {
            var domainParameters = (EccDomainParameters)ThisPartyKeyingMaterial.DomainParameters;

            // static secret composed of both parties static key parts
            var staticSecret = _diffieHellman.GenerateSharedSecretZ(
                domainParameters,
                (EccKeyPair)ThisPartyKeyingMaterial.StaticKeyPair,
                (EccKeyPair)otherPartyKeyingMaterial.StaticKeyPair
                ).SharedSecretZ;

            // differing ephemeralSecret logic depending on key agreement role
            BitString ephemeralSecret;

            if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU)
            {
                ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                    domainParameters,
                    (EccKeyPair)ThisPartyKeyingMaterial.EphemeralKeyPair,
                    (EccKeyPair)otherPartyKeyingMaterial.StaticKeyPair
                    ).SharedSecretZ;
            }
            else
            {
                ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                    domainParameters,
                    (EccKeyPair)ThisPartyKeyingMaterial.StaticKeyPair,
                    (EccKeyPair)otherPartyKeyingMaterial.EphemeralKeyPair
                    ).SharedSecretZ;
            }

            // Shared secret is composed (Z_e || Z_s)
            return(BitString.ConcatenateBits(ephemeralSecret, staticSecret));
        }
        protected override BitString ComputeSharedSecret(OtherPartySharedInformation <EccDomainParameters, EccKeyPair> otherPartyInformation)
        {
            // static secret composed of both parties static key parts
            var staticSecret = _diffieHellman.GenerateSharedSecretZ(
                DomainParameters,
                StaticKeyPair,
                otherPartyInformation.StaticPublicKey
                ).SharedSecretZ;

            // differing ephemeralSecret logic depending on key agreement role
            BitString ephemeralSecret;

            if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU)
            {
                ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                    DomainParameters,
                    EphemeralKeyPair,
                    otherPartyInformation.StaticPublicKey
                    ).SharedSecretZ;
            }
            else
            {
                ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                    DomainParameters,
                    StaticKeyPair,
                    otherPartyInformation.EphemeralPublicKey
                    ).SharedSecretZ;
            }

            // Shared secret is composed (Z_e || Z_s)
            return(BitString.ConcatenateBits(ephemeralSecret, staticSecret));
        }
示例#3
0
        protected override BitString ComputeSharedSecret(OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> otherPartyInformation)
        {
            if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU)
            {
                return(_diffieHellman.GenerateSharedSecretZ(
                           DomainParameters,
                           EphemeralKeyPair,
                           otherPartyInformation.StaticPublicKey
                           ).SharedSecretZ);
            }

            return(_diffieHellman.GenerateSharedSecretZ(
                       DomainParameters,
                       StaticKeyPair,
                       otherPartyInformation.EphemeralPublicKey
                       ).SharedSecretZ);
        }
示例#4
0
        protected override BitString ComputeSharedSecret(OtherPartySharedInformation <FfcDomainParameters, FfcKeyPair> otherPartyInformation)
        {
            var staticSecret = _diffieHellman.GenerateSharedSecretZ(
                DomainParameters,
                StaticKeyPair,
                otherPartyInformation.StaticPublicKey
                ).SharedSecretZ;

            var ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                DomainParameters,
                EphemeralKeyPair,
                otherPartyInformation.EphemeralPublicKey
                ).SharedSecretZ;

            // Shared secret is composed (Z_e || Z_s)
            return(BitString.ConcatenateBits(ephemeralSecret, staticSecret));
        }
示例#5
0
        protected override BitString ComputeSharedSecret(ISecretKeyingMaterial otherPartyKeyingMaterial)
        {
            if (SchemeParameters.KeyAgreementRole == KeyAgreementRole.InitiatorPartyU)
            {
                return(_diffieHellman.GenerateSharedSecretZ(
                           (FfcDomainParameters)ThisPartyKeyingMaterial.DomainParameters,
                           (FfcKeyPair)ThisPartyKeyingMaterial.EphemeralKeyPair,
                           (FfcKeyPair)otherPartyKeyingMaterial.StaticKeyPair
                           ).SharedSecretZ);
            }

            return(_diffieHellman.GenerateSharedSecretZ(
                       (FfcDomainParameters)ThisPartyKeyingMaterial.DomainParameters,
                       (FfcKeyPair)ThisPartyKeyingMaterial.StaticKeyPair,
                       (FfcKeyPair)otherPartyKeyingMaterial.EphemeralKeyPair
                       ).SharedSecretZ);
        }
 protected override BitString ComputeSharedSecret(ISecretKeyingMaterial otherPartyKeyingMaterial)
 {
     return(_diffieHellman.GenerateSharedSecretZ(
                (EccDomainParameters)ThisPartyKeyingMaterial.DomainParameters,
                (EccKeyPair)ThisPartyKeyingMaterial.StaticKeyPair,
                (EccKeyPair)otherPartyKeyingMaterial.StaticKeyPair
                ).SharedSecretZ);
 }
 protected override BitString ComputeSharedSecret(OtherPartySharedInformation <EccDomainParameters, EccKeyPair> otherPartyInformation)
 {
     return(_diffieHellman.GenerateSharedSecretZ(
                DomainParameters,
                StaticKeyPair,
                otherPartyInformation.StaticPublicKey
                ).SharedSecretZ);
 }
 /// <inheritdoc />
 /// <summary>
 /// Generates the shared secret.  
 /// Shared secret Z is made up of this party's private key along with the other parties public key, 
 /// run through the DiffieHellman primitive.
 /// </summary>
 /// <param name="otherPartyInformation"></param>
 /// <returns></returns>
 protected override BitString ComputeSharedSecret(OtherPartySharedInformation<FfcDomainParameters, FfcKeyPair> otherPartyInformation)
 {
     return _diffieHellman.GenerateSharedSecretZ(
         DomainParameters,
         EphemeralKeyPair,
         otherPartyInformation.EphemeralPublicKey
     ).SharedSecretZ;
 }
示例#9
0
        protected override BitString ComputeSharedSecret(ISecretKeyingMaterial otherPartyKeyingMaterial)
        {
            var domainParameters = (EccDomainParameters)ThisPartyKeyingMaterial.DomainParameters;

            var staticSecret = _diffieHellman.GenerateSharedSecretZ(
                domainParameters,
                (EccKeyPair)ThisPartyKeyingMaterial.StaticKeyPair,
                (EccKeyPair)otherPartyKeyingMaterial.StaticKeyPair
                ).SharedSecretZ;

            var ephemeralSecret = _diffieHellman.GenerateSharedSecretZ(
                domainParameters,
                (EccKeyPair)ThisPartyKeyingMaterial.EphemeralKeyPair,
                (EccKeyPair)otherPartyKeyingMaterial.EphemeralKeyPair
                ).SharedSecretZ;

            // Shared secret is composed (Z_e || Z_s)
            return(BitString.ConcatenateBits(ephemeralSecret, staticSecret));
        }
示例#10
0
 public SharedSecretResponse GenerateSharedSecret(EccDomainParameters domainParameters, EccKeyPair privateKeyPartyA, EccKeyPair publicKeyPartyB)
 {
     return(_diffieHellman.GenerateSharedSecretZ(domainParameters, privateKeyPartyA, publicKeyPartyB));
 }