internal override void Encode(
            DerOutputStream derOut)
        {
            if (!IsEmpty())
            {
                byte[] bytes = obj.GetDerEncoded();

                if (explicitly)
                {
                    derOut.WriteEncoded((int)(Asn1Tags.Constructed | Asn1Tags.Tagged) | tagNo, bytes);
                }
                else
                {
                    //
                    // need to mark constructed types...
                    //
                    if ((bytes[0] & (byte)Asn1Tags.Constructed) != 0)
                    {
                        bytes[0] = (byte)((int)(Asn1Tags.Constructed | Asn1Tags.Tagged) | tagNo);
                    }
                    else
                    {
                        bytes[0] = (byte)((int)(Asn1Tags.Tagged) | tagNo);
                    }

                    derOut.Write(bytes, 0, bytes.Length);
                }
            }
            else
            {
                derOut.WriteEncoded((int)(Asn1Tags.Constructed | Asn1Tags.Tagged) | tagNo, new byte[0]);
            }
        }
Ejemplo n.º 2
0
        internal override void Encode(DerOutputStream derOut)
        {
            if (base.IsEmpty())
            {
                derOut.WriteEncoded(160, this.tagNo, new byte[0]);
                return;
            }
            byte[] derEncoded = this.obj.GetDerEncoded();
            if (this.explicitly)
            {
                derOut.WriteEncoded(160, this.tagNo, derEncoded);
                return;
            }
            int flags = (int)((derEncoded[0] & 32) | 128);

            derOut.WriteTag(flags, this.tagNo);
            derOut.Write(derEncoded, 1, derEncoded.Length - 1);
        }
Ejemplo n.º 3
0
 internal override void Encode(DerOutputStream derOut)
 {
     if (!base.IsEmpty())
     {
         byte[] derEncoded = base.obj.GetDerEncoded();
         if (base.explicitly)
         {
             derOut.WriteEncoded(160, base.tagNo, derEncoded);
         }
         else
         {
             int flags = (derEncoded[0] & 0x20) | 0x80;
             derOut.WriteTag(flags, base.tagNo);
             derOut.Write(derEncoded, 1, derEncoded.Length - 1);
         }
     }
     else
     {
         derOut.WriteEncoded(160, base.tagNo, new byte[0]);
     }
 }