Exemple #1
0
        /**
         * Encode this {@link Certificate} to a {@link Stream}.
         *
         * @param output the {@link Stream} to encode to.
         * @throws IOException
         */
        public virtual void Encode(Stream output)
        {
            IList derEncodings = Platform.CreateArrayList(mCertificateList.Length);

            int totalLength = 0;

            foreach (Asn1Encodable asn1Cert in mCertificateList)
            {
                byte[] derEncoding = asn1Cert.GetEncoded(Asn1Encodable.Der);
                derEncodings.Add(derEncoding);
                totalLength += derEncoding.Length + 3;
            }

            TlsUtilities.CheckUint24(totalLength);
            TlsUtilities.WriteUint24(totalLength, output);

            foreach (byte[] derEncoding in derEncodings)
            {
                TlsUtilities.WriteOpaque24(derEncoding, output);
            }
        }
Exemple #2
0
 internal HandshakeMessage(byte handshakeType, int length)
     : base(length + 4)
 {
     TlsUtilities.WriteUint8(handshakeType, this);
     TlsUtilities.WriteUint24(0, this);
 }