public override byte[] GenerateServerKeyExchange()
        {
            //IL_0023: Unknown result type (might be due to invalid IL or missing references)
            //IL_0029: Expected O, but got Unknown
            mPskIdentityHint = mPskIdentityManager.GetHint();
            if (mPskIdentityHint == null && !RequiresServerKeyExchange)
            {
                return(null);
            }
            MemoryStream val = new MemoryStream();

            if (mPskIdentityHint == null)
            {
                TlsUtilities.WriteOpaque16(TlsUtilities.EmptyBytes, (Stream)(object)val);
            }
            else
            {
                TlsUtilities.WriteOpaque16(mPskIdentityHint, (Stream)(object)val);
            }
            if (mKeyExchange == 14)
            {
                if (mDHParameters == null)
                {
                    throw new TlsFatalAlert(80);
                }
                mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mDHParameters, (Stream)(object)val);
            }
            else if (mKeyExchange == 24)
            {
                mECAgreePrivateKey = TlsEccUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mNamedCurves, mClientECPointFormats, (Stream)(object)val);
            }
            return(val.ToArray());
        }
    public override byte[] GenerateServerKeyExchange()
    {
        mPskIdentityHint = mPskIdentityManager.GetHint();
        if (mPskIdentityHint == null && !RequiresServerKeyExchange)
        {
            return(null);
        }
        MemoryStream memoryStream = new MemoryStream();

        if (mPskIdentityHint == null)
        {
            TlsUtilities.WriteOpaque16(TlsUtilities.EmptyBytes, memoryStream);
        }
        else
        {
            TlsUtilities.WriteOpaque16(mPskIdentityHint, memoryStream);
        }
        if (mKeyExchange == 14)
        {
            if (mDHParameters == null)
            {
                throw new TlsFatalAlert(80);
            }
            mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mDHParameters, memoryStream);
        }
        else if (mKeyExchange == 24)
        {
            mECAgreePrivateKey = TlsEccUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mNamedCurves, mClientECPointFormats, memoryStream);
        }
        return(memoryStream.ToArray());
    }
示例#3
0
        public override byte[] GenerateServerKeyExchange()
        {
            this.mPskIdentityHint = mPskIdentityManager.GetHint();

            if (this.mPskIdentityHint == null && !RequiresServerKeyExchange)
            {
                return(null);
            }

            MemoryStream buf = new MemoryStream();

            if (this.mPskIdentityHint == null)
            {
                TlsUtilities.WriteOpaque16(TlsUtilities.EmptyBytes, buf);
            }
            else
            {
                TlsUtilities.WriteOpaque16(this.mPskIdentityHint, buf);
            }

            if (this.mKeyExchange == KeyExchangeAlgorithm.DHE_PSK)
            {
                if (this.mDHParameters == null)
                {
                    throw new TlsFatalAlert(AlertDescription.internal_error);
                }

                this.mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom,
                                                                                            this.mDHParameters, buf);
            }
            else if (this.mKeyExchange == KeyExchangeAlgorithm.ECDHE_PSK)
            {
                this.mECAgreePrivateKey = TlsEccUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom,
                                                                                             mNamedCurves, mClientECPointFormats, buf);
            }

            return(buf.ToArray());
        }