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