Example #1
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;
            }
        }
Example #3
0
        public DerApplicationSpecific(
            bool isExplicit,
            int tag,
            Asn1Encodable obj)
        {
            Asn1Object asn1Obj = obj.ToAsn1Object();

            byte[] data = asn1Obj.GetDerEncoded();

            this.isConstructed = Asn1TaggedObject.IsConstructed(isExplicit, asn1Obj);
            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;
            }
        }