Beispiel #1
0
        /**
         * Parse a {@link CertificateUrl} from a {@link Stream}.
         *
         * @param context
         *            the {@link TlsContext} of the current connection.
         * @param input
         *            the {@link Stream} to parse from.
         * @return a {@link CertificateUrl} object.
         * @throws IOException
         */
        public static CertificateUrl parse(TlsContext context, Stream input)
        {
            byte type = TlsUtilities.ReadUint8(input);

            if (!CertChainType.IsValid(type))
            {
                throw new TlsFatalAlert(AlertDescription.decode_error);
            }

            int totalLength = TlsUtilities.ReadUint16(input);

            if (totalLength < 1)
            {
                throw new TlsFatalAlert(AlertDescription.decode_error);
            }

            byte[] urlAndHashListData = TlsUtilities.ReadFully(totalLength, input);

            MemoryStream buf = new MemoryStream(urlAndHashListData, false);

            IList url_and_hash_list = Platform.CreateArrayList();

            while (buf.Position < buf.Length)
            {
                UrlAndHash url_and_hash = UrlAndHash.Parse(context, buf);
                url_and_hash_list.Add(url_and_hash);
            }

            return(new CertificateUrl(type, url_and_hash_list));
        }
Beispiel #2
0
        public static CertificateUrl parse(TlsContext context, Stream input)
        {
            //IL_0034: Unknown result type (might be due to invalid IL or missing references)
            //IL_003a: Expected O, but got Unknown
            byte b = TlsUtilities.ReadUint8(input);

            if (!CertChainType.IsValid(b))
            {
                throw new TlsFatalAlert(50);
            }
            int num = TlsUtilities.ReadUint16(input);

            if (num < 1)
            {
                throw new TlsFatalAlert(50);
            }
            byte[]       array = TlsUtilities.ReadFully(num, input);
            MemoryStream val   = new MemoryStream(array, false);

            global::System.Collections.IList list = Platform.CreateArrayList();
            while (((Stream)val).get_Position() < ((Stream)val).get_Length())
            {
                UrlAndHash urlAndHash = UrlAndHash.Parse(context, (Stream)(object)val);
                list.Add((object)urlAndHash);
            }
            return(new CertificateUrl(b, list));
        }
Beispiel #3
0
        public static CertificateUrl parse(TlsContext context, Stream input)
        {
            byte b = TlsUtilities.ReadUint8(input);

            if (!CertChainType.IsValid(b))
            {
                throw new TlsFatalAlert(50);
            }
            int num = TlsUtilities.ReadUint16(input);

            if (num < 1)
            {
                throw new TlsFatalAlert(50);
            }
            byte[]       buffer       = TlsUtilities.ReadFully(num, input);
            MemoryStream memoryStream = new MemoryStream(buffer, false);
            IList        list         = Platform.CreateArrayList();

            while (memoryStream.Position < memoryStream.Length)
            {
                UrlAndHash value = UrlAndHash.Parse(context, memoryStream);
                list.Add(value);
            }
            return(new CertificateUrl(b, list));
        }
Beispiel #4
0
        public virtual void Encode(Stream output)
        {
            TlsUtilities.WriteUint8(mType, output);
            ListBuffer16 listBuffer = new ListBuffer16();

            global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)mUrlAndHashList).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    UrlAndHash urlAndHash = (UrlAndHash)enumerator.get_Current();
                    urlAndHash.Encode((Stream)(object)listBuffer);
                }
            }
            finally
            {
                global::System.IDisposable disposable = enumerator as global::System.IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            listBuffer.EncodeTo(output);
        }