Org.BouncyCastle.Asn1.DefiniteLengthInputStream.ToArray C# (CSharp) Méthode

ToArray() private méthode

private ToArray ( ) : byte[]
Résultat byte[]
        internal byte[] ToArray()
		{
			if (_remaining == 0)
				return EmptyBytes;

			byte[] bytes = new byte[_remaining];
			if ((_remaining -= Streams.ReadFully(_in, bytes)) != 0)
				throw new EndOfStreamException("DEF length " + _originalLength + " object truncated by " + _remaining);
			SetParentEofDetect(true);
			return bytes;
		}
    }

Usage Example

        private Asn1Object BuildObject(int tag, int tagNo, int length)
        {
            bool flag = (tag & 0x20) != 0;
            DefiniteLengthInputStream definiteLengthInputStream = new DefiniteLengthInputStream(s, length);

            if ((tag & 0x40) != 0)
            {
                return(new DerApplicationSpecific(flag, tagNo, definiteLengthInputStream.ToArray()));
            }
            if ((tag & 0x80) != 0)
            {
                return(new Asn1StreamParser(definiteLengthInputStream).ReadTaggedObject(flag, tagNo));
            }
            if (flag)
            {
                switch (tagNo)
                {
                case 4:
                    return(new BerOctetString(BuildDerEncodableVector(definiteLengthInputStream)));

                case 16:
                    return(CreateDerSequence(definiteLengthInputStream));

                case 17:
                    return(CreateDerSet(definiteLengthInputStream));

                case 8:
                    return(new DerExternal(BuildDerEncodableVector(definiteLengthInputStream)));

                default:
                    throw new IOException("unknown tag " + tagNo + " encountered");
                }
            }
            return(CreatePrimitiveDerObject(tagNo, definiteLengthInputStream, tmpBuffers));
        }
All Usage Examples Of Org.BouncyCastle.Asn1.DefiniteLengthInputStream::ToArray