Beispiel #1
0
 public Universal(BERtag t, params Universal[] obs)
 {
     type = t;
     val  = obs;
     e    = true;
     val  = obs;
 }
Beispiel #2
0
 public Universal(string s)
 {
     type = new BERtag(UniversalType.OctetString);
     val  = s;
     e    = true;
     b    = (new ASCIIEncoding()).GetBytes(s);
 }
Beispiel #3
0
        public Universal(ArrayList a)
        {
            type = new BERtag(0, true, 0);
            e    = true;
            ArrayList al = new ArrayList(a.Count);

            val = al;
            for (int j = 0; j < a.Count; j++)
            {
                object o = a[j];
                if (o is bool)
                {
                    al.Add(new Universal((bool)o));
                }
                else if (o is int)
                {
                    al.Add(new Universal((int)o));
                }
                else if (o is BitSet)
                {
                    al.Add(new Universal((BitSet)o));
                }
                else if (o is string)
                {
                    al.Add(new Universal((string)o));
                }
                else if (o is uint[])
                {
                    al.Add(new Universal((uint[])o));
                }
            }
        }
Beispiel #4
0
        public Universal(BitSet a)
        {
            // encoding 8.6.2
            type = new BERtag(UniversalType.BitString);
            val  = a;
            e    = true;
            int  n = (a.Length + 7) / 8;
            byte r = (byte)(8 - a.Length % 8);

            b = new byte[n + 1];
            int ln = 0;

            b[ln++] = r;
            int k = 24;
            int i = 0;

            for (int j = 0; j < n; j++)
            {
                b[ln++] = (byte)(a.bits[i] >> k);
                k      -= 8;
                if (k < 0)
                {
                    i++;
                    k = 24;
                }
            }
        }
Beispiel #5
0
 public Universal(double d)
 {
     type = new BERtag(UniversalType.Real);
     val  = d;
     e    = true;
     b    = new Real(d).octVal;
 }
Beispiel #6
0
 public Universal(int n) // 8.3
 {
     type = new BERtag(UniversalType.Integer);
     val  = n;
     e    = true;
     b    = new Integer(n).octVal;
 }
Beispiel #7
0
 public Universal(bool x) // 8.2
 {
     type = new BERtag(UniversalType.Boolean);
     val  = x;
     e    = true;
     b    = new byte[1];
     b[0] = (byte)(x ? 0xff : 0);
 }
Beispiel #8
0
 public Universal(Stream s)
 {
     e    = false;
     type = new BERtag(s);
     if (Children(s))
     {
         if (type.tag != 0x10)
         {
             CombineValues();
         }
         return;
     }
     s.Read(b, 0, (int)len);
     ValueOf(len);
 }
Beispiel #9
0
        public Universal(uint[] oid)
        {
            type = new BERtag(UniversalType.ObjectIdentifier);
            val  = oid;
            e    = true;
            int ln = 0;
            int j;

            for (j = 1; j < oid.Length; j++)
            {
                ln += LengthOIDEl(oid[j]);
            }
            b = new byte[ln];
            if (oid[0] != 1 || oid[1] != 3)
            {
                throw (new Exception("OID must begin with .1.3"));
            }
            ln = 0;
            PutOIDEl(ref ln, 43);
            for (j = 2; j < oid.Length; j++)
            {
                PutOIDEl(ref ln, oid[j]);
            }
        }