Пример #1
0
        public DerApplicationSpecific(bool isExplicit, int tag, Asn1Encodable obj)
        {
            Asn1Object asn1Object = obj.ToAsn1Object();

            byte[] derEncoded = asn1Object.GetDerEncoded();
            this.isConstructed = (isExplicit || asn1Object is Asn1Set || asn1Object is Asn1Sequence);
            this.tag           = tag;
            if (isExplicit)
            {
                this.octets = derEncoded;
                return;
            }
            int lengthOfHeader = this.GetLengthOfHeader(derEncoded);

            byte[] array = new byte[derEncoded.Length - lengthOfHeader];
            Array.Copy(derEncoded, lengthOfHeader, array, 0, array.Length);
            this.octets = array;
        }
Пример #2
0
        public DerApplicationSpecific(bool isExplicit, int tag, Asn1Encodable obj)
        {
            Asn1Object asn1Object = obj.ToAsn1Object();

            byte[] derEncoded = asn1Object.GetDerEncoded();
            isConstructed = Asn1TaggedObject.IsConstructed(isExplicit, asn1Object);
            this.tag      = tag;
            if (isExplicit)
            {
                octets = derEncoded;
                return;
            }
            int lengthOfHeader = GetLengthOfHeader(derEncoded);

            byte[] array = new byte[derEncoded.Length - lengthOfHeader];
            global::System.Array.Copy((global::System.Array)derEncoded, lengthOfHeader, (global::System.Array)array, 0, array.Length);
            octets = array;
        }
        public DerApplicationSpecific(bool isExplicit, int tag, Asn1Encodable obj)
        {
            Asn1Object obj2 = obj.ToAsn1Object();

            byte[] derEncoded = obj2.GetDerEncoded();
            this.isConstructed = Asn1TaggedObject.IsConstructed(isExplicit, obj2);
            this.tag           = tag;
            if (isExplicit)
            {
                this.octets = derEncoded;
            }
            else
            {
                int    lengthOfHeader   = this.GetLengthOfHeader(derEncoded);
                byte[] destinationArray = new byte[derEncoded.Length - lengthOfHeader];
                Array.Copy(derEncoded, lengthOfHeader, destinationArray, 0, destinationArray.Length);
                this.octets = destinationArray;
            }
        }
Пример #4
0
        public DerApplicationSpecific(
            bool isExplicit,
            int tag,
            Asn1Encodable obj)
        {
            Asn1Object asn1Obj = obj.ToAsn1Object();

            byte[] data = asn1Obj.GetDerEncoded();

            this.isConstructed = isExplicit || asn1Obj is Asn1Set || asn1Obj is Asn1Sequence;
            this.tag           = tag;

            if (isExplicit)
            {
                this.octets = data;
            }
            else
            {
                int    lenBytes = GetLengthOfHeader(data);
                byte[] tmp      = new byte[data.Length - lenBytes];
                Array.Copy(data, lenBytes, tmp, 0, tmp.Length);
                this.octets = tmp;
            }
        }