GenerateEncryptedPreMasterSecret() public static méthode

public static GenerateEncryptedPreMasterSecret ( SecureRandom random, RsaKeyParameters rsaServerPublicKey, Stream output ) : byte[]
random Org.BouncyCastle.Security.SecureRandom
rsaServerPublicKey Org.BouncyCastle.Crypto.Parameters.RsaKeyParameters
output Stream
Résultat byte[]
 public override void GenerateClientKeyExchange(Stream output)
 {
     if (mPskIdentityHint == null)
     {
         mPskIdentity.SkipIdentityHint();
     }
     else
     {
         mPskIdentity.NotifyIdentityHint(mPskIdentityHint);
     }
     byte[] pskIdentity = mPskIdentity.GetPskIdentity();
     if (pskIdentity == null)
     {
         throw new TlsFatalAlert(80);
     }
     mPsk = mPskIdentity.GetPsk();
     if (mPsk == null)
     {
         throw new TlsFatalAlert(80);
     }
     TlsUtilities.WriteOpaque16(pskIdentity, output);
     mContext.SecurityParameters.pskIdentity = pskIdentity;
     if (mKeyExchange == 14)
     {
         mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralClientKeyExchange(mContext.SecureRandom, mDHParameters, output);
     }
     else if (mKeyExchange == 24)
     {
         mECAgreePrivateKey = TlsEccUtilities.GenerateEphemeralClientKeyExchange(mContext.SecureRandom, mServerECPointFormats, mECAgreePublicKey.Parameters, output);
     }
     else if (mKeyExchange == 15)
     {
         mPremasterSecret = TlsRsaUtilities.GenerateEncryptedPreMasterSecret(mContext, mRsaServerPublicKey, output);
     }
 }
Exemple #2
0
        public virtual void GenerateClientKeyExchange(Stream output)
        {
            if (psk_identity_hint == null || psk_identity_hint.Length == 0)
            {
                pskIdentity.SkipIdentityHint();
            }
            else
            {
                pskIdentity.NotifyIdentityHint(psk_identity_hint);
            }

            byte[] psk_identity = pskIdentity.GetPskIdentity();

            TlsUtilities.WriteOpaque16(psk_identity, output);

            if (this.keyExchange == KeyExchangeAlgorithm.RSA_PSK)
            {
                this.premasterSecret = TlsRsaUtilities.GenerateEncryptedPreMasterSecret(
                    context.SecureRandom, this.rsaServerPublicKey, output);
            }
            else if (this.keyExchange == KeyExchangeAlgorithm.DHE_PSK)
            {
                this.dhAgreeClientPrivateKey = TlsDHUtilities.GenerateEphemeralClientKeyExchange(
                    context.SecureRandom, this.dhAgreeServerPublicKey.Parameters, output);
            }
        }
Exemple #3
0
        public override void GenerateClientKeyExchange(Stream output)
        {
            if (mPskIdentityHint == null)
            {
                mPskIdentity.SkipIdentityHint();
            }
            else
            {
                mPskIdentity.NotifyIdentityHint(mPskIdentityHint);
            }

            byte[] psk_identity = mPskIdentity.GetPskIdentity();

            TlsUtilities.WriteOpaque16(psk_identity, output);

            if (this.mKeyExchange == KeyExchangeAlgorithm.DHE_PSK)
            {
                this.mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralClientKeyExchange(context.SecureRandom,
                                                                                            mDHAgreePublicKey.Parameters, output);
            }
            else if (this.mKeyExchange == KeyExchangeAlgorithm.ECDHE_PSK)
            {
                // TODO[RFC 5489]
                throw new TlsFatalAlert(AlertDescription.internal_error);
            }
            else if (this.mKeyExchange == KeyExchangeAlgorithm.RSA_PSK)
            {
                this.mPremasterSecret = TlsRsaUtilities.GenerateEncryptedPreMasterSecret(context,
                                                                                         this.mRsaServerPublicKey, output);
            }
        }
 public override void GenerateClientKeyExchange(Stream output)
 {
     this.mPremasterSecret = TlsRsaUtilities.GenerateEncryptedPreMasterSecret(mContext, mRsaServerPublicKey, output);
 }
 public virtual void GenerateClientKeyExchange(Stream output)
 {
     this.premasterSecret = TlsRsaUtilities.GenerateEncryptedPreMasterSecret(
         context.SecureRandom, this.rsaServerPublicKey, output);
 }