public byte[] GenerateServerKeyExchange()
        {
            if (this.mDHParameters == null)
            {
                throw new TlsFatalAlert(AlertDescription.internal_error);
            }

            DigestInputBuffer buf = new DigestInputBuffer();

            this.mDHAgreePrivateKey = TlsDHUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, this.mDHParameters, buf);

            /*
             * RFC 5246 4.7. digitally-signed element needs SignatureAndHashAlgorithm from TLS 1.2
             */
            SignatureAndHashAlgorithm signatureAndHashAlgorithm = TlsUtilities.GetSignatureAndHashAlgorithm(
                mContext, mServerCredentials);

            IDigest d = TlsUtilities.CreateHash(signatureAndHashAlgorithm);

            SecurityParameters securityParameters = mContext.SecurityParameters;

            d.BlockUpdate(securityParameters.ClientRandom, 0, securityParameters.ClientRandom.Length);
            d.BlockUpdate(securityParameters.ServerRandom, 0, securityParameters.ServerRandom.Length);
            buf.UpdateDigest(d);

            byte[] hash = DigestUtilities.DoFinal(d);

            byte[] signature = mServerCredentials.GenerateCertificateSignature(hash);

            DigitallySigned signed_params = new DigitallySigned(signatureAndHashAlgorithm, signature);

            signed_params.Encode(buf);

            return(buf.ToArray());
        }
        public override byte[] GenerateServerKeyExchange()
        {
            DigestInputBuffer buf = new DigestInputBuffer();

            this.mECAgreePrivateKey = GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mNamedCurves,
                                                                         mClientECPointFormats, buf);

            /*
             * RFC 5246 4.7. digitally-signed element needs SignatureAndHashAlgorithm from TLS 1.2
             */
            SignatureAndHashAlgorithm signatureAndHashAlgorithm = TlsUtilities.GetSignatureAndHashAlgorithm(
                mContext, mServerCredentials);

            IDigest d = TlsUtilities.CreateHash(signatureAndHashAlgorithm);

            SecurityParameters securityParameters = mContext.SecurityParameters;

            d.BlockUpdate(securityParameters.ClientRandom, 0, securityParameters.ClientRandom.Length);
            d.BlockUpdate(securityParameters.ServerRandom, 0, securityParameters.ServerRandom.Length);
            buf.UpdateDigest(d);

            byte[] hash = DigestUtilities.DoFinal(d);

            byte[] signature = mServerCredentials.GenerateCertificateSignature(hash);

            DigitallySigned signed_params = new DigitallySigned(signatureAndHashAlgorithm, signature);

            signed_params.Encode(buf);

            return(buf.ToArray());
        }
    public override byte[] GenerateServerKeyExchange()
    {
        DigestInputBuffer digestInputBuffer = new DigestInputBuffer();

        mECAgreePrivateKey = TlsEccUtilities.GenerateEphemeralServerKeyExchange(mContext.SecureRandom, mNamedCurves, mClientECPointFormats, digestInputBuffer);
        SignatureAndHashAlgorithm signatureAndHashAlgorithm = TlsUtilities.GetSignatureAndHashAlgorithm(mContext, mServerCredentials);
        IDigest            digest             = TlsUtilities.CreateHash(signatureAndHashAlgorithm);
        SecurityParameters securityParameters = mContext.SecurityParameters;

        digest.BlockUpdate(securityParameters.clientRandom, 0, securityParameters.clientRandom.Length);
        digest.BlockUpdate(securityParameters.serverRandom, 0, securityParameters.serverRandom.Length);
        digestInputBuffer.UpdateDigest(digest);
        byte[]          hash            = DigestUtilities.DoFinal(digest);
        byte[]          signature       = mServerCredentials.GenerateCertificateSignature(hash);
        DigitallySigned digitallySigned = new DigitallySigned(signatureAndHashAlgorithm, signature);

        digitallySigned.Encode(digestInputBuffer);
        return(digestInputBuffer.ToArray());
    }
    public override byte[] GenerateServerKeyExchange()
    {
        mSrpServer.Init(mSrpGroup, mSrpVerifier, TlsUtilities.CreateHash(2), mContext.SecureRandom);
        BigInteger        b = mSrpServer.GenerateServerCredentials();
        ServerSrpParams   serverSrpParams   = new ServerSrpParams(mSrpGroup.N, mSrpGroup.G, mSrpSalt, b);
        DigestInputBuffer digestInputBuffer = new DigestInputBuffer();

        serverSrpParams.Encode(digestInputBuffer);
        if (mServerCredentials != null)
        {
            SignatureAndHashAlgorithm signatureAndHashAlgorithm = TlsUtilities.GetSignatureAndHashAlgorithm(mContext, mServerCredentials);
            IDigest            digest             = TlsUtilities.CreateHash(signatureAndHashAlgorithm);
            SecurityParameters securityParameters = mContext.SecurityParameters;
            digest.BlockUpdate(securityParameters.clientRandom, 0, securityParameters.clientRandom.Length);
            digest.BlockUpdate(securityParameters.serverRandom, 0, securityParameters.serverRandom.Length);
            digestInputBuffer.UpdateDigest(digest);
            byte[] array = new byte[digest.GetDigestSize()];
            digest.DoFinal(array, 0);
            byte[]          signature       = mServerCredentials.GenerateCertificateSignature(array);
            DigitallySigned digitallySigned = new DigitallySigned(signatureAndHashAlgorithm, signature);
            digitallySigned.Encode(digestInputBuffer);
        }
        return(digestInputBuffer.ToArray());
    }