CalculateDHBasicAgreement() public static method

public static CalculateDHBasicAgreement ( DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey ) : byte[]
publicKey DHPublicKeyParameters
privateKey DHPrivateKeyParameters
return byte[]
Beispiel #1
0
        protected virtual byte[] GenerateOtherSecret(int pskLength)
        {
            if (this.mKeyExchange == KeyExchangeAlgorithm.DHE_PSK)
            {
                if (mDHAgreePrivateKey != null)
                {
                    return(TlsDHUtilities.CalculateDHBasicAgreement(mDHAgreePublicKey, mDHAgreePrivateKey));
                }

                throw new TlsFatalAlert(AlertDescription.internal_error);
            }

            if (this.mKeyExchange == KeyExchangeAlgorithm.ECDHE_PSK)
            {
                if (mECAgreePrivateKey != null)
                {
                    return(TlsEccUtilities.CalculateECDHBasicAgreement(mECAgreePublicKey, mECAgreePrivateKey));
                }

                throw new TlsFatalAlert(AlertDescription.internal_error);
            }

            if (this.mKeyExchange == KeyExchangeAlgorithm.RSA_PSK)
            {
                return(this.mPremasterSecret);
            }

            return(new byte[pskLength]);
        }
 protected virtual byte[] GenerateOtherSecret(int pskLength)
 {
     if (this.mKeyExchange == 14)
     {
         if (this.mDHAgreePrivateKey != null)
         {
             return(TlsDHUtilities.CalculateDHBasicAgreement(this.mDHAgreePublicKey, this.mDHAgreePrivateKey));
         }
         throw new TlsFatalAlert(80);
     }
     else if (this.mKeyExchange == 24)
     {
         if (this.mECAgreePrivateKey != null)
         {
             return(TlsEccUtilities.CalculateECDHBasicAgreement(this.mECAgreePublicKey, this.mECAgreePrivateKey));
         }
         throw new TlsFatalAlert(80);
     }
     else
     {
         if (this.mKeyExchange == 15)
         {
             return(this.mPremasterSecret);
         }
         return(new byte[pskLength]);
     }
 }
Beispiel #3
0
 public override byte[] GeneratePremasterSecret()
 {
     if (this.mAgreementCredentials != null)
     {
         return(this.mAgreementCredentials.GenerateAgreement(this.mDHAgreePublicKey));
     }
     if (this.mDHAgreePrivateKey == null)
     {
         throw new TlsFatalAlert(80);
     }
     return(TlsDHUtilities.CalculateDHBasicAgreement(this.mDHAgreePublicKey, this.mDHAgreePrivateKey));
 }
Beispiel #4
0
        public override byte[] GeneratePremasterSecret()
        {
            if (mAgreementCredentials != null)
            {
                return(mAgreementCredentials.GenerateAgreement(mDHAgreePublicKey));
            }

            if (mDHAgreePrivateKey != null)
            {
                return(TlsDHUtilities.CalculateDHBasicAgreement(mDHAgreePublicKey, mDHAgreePrivateKey));
            }

            throw new TlsFatalAlert(AlertDescription.internal_error);
        }
Beispiel #5
0
        protected virtual byte[] GenerateOtherSecret(int pskLength)
        {
            if (this.keyExchange == KeyExchangeAlgorithm.DHE_PSK)
            {
                return(TlsDHUtilities.CalculateDHBasicAgreement(dhAgreeServerPublicKey, dhAgreeClientPrivateKey));
            }

            if (this.keyExchange == KeyExchangeAlgorithm.RSA_PSK)
            {
                return(this.premasterSecret);
            }

            return(new byte[pskLength]);
        }
Beispiel #6
0
 protected virtual byte[] CalculateDHBasicAgreement(DHPublicKeyParameters publicKey,
                                                    DHPrivateKeyParameters privateKey)
 {
     return(TlsDHUtilities.CalculateDHBasicAgreement(publicKey, privateKey));
 }