Example #1
0
        public virtual void EncodeIdentifier(long ident)
        {
            var number          = 0x7fL;
            var identBytesCount = Asn1RunTime.GetIdentBytesCount(ident);

            number = number << (7 * identBytesCount);

            if (identBytesCount > 0)
            {
                while (identBytesCount > 0)
                {
                    number = Asn1Util.UrShift(number, 7);
                    identBytesCount--;

                    var num3 = Asn1Util.UrShift(ident & number, identBytesCount * 7);

                    if (identBytesCount != 0)
                    {
                        num3 |= 0x80L;
                    }

                    OutputStream.WriteByte((byte)num3);
                }
            }
            else
            {
                OutputStream.WriteByte(0);
            }
        }
Example #2
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            int num;

            if (((Value.Length < 2) || (Value[0] > 2)) || ((Value[0] != 2) && (Value[1] > 0x27)))
            {
                throw new Exception("Asn1InvalidObjectIdException");
            }

            var len = 1;

            for (num = 2; num < Value.Length; num++)
            {
                len += Asn1RunTime.GetIdentBytesCount(Value[num]);
            }

            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeLength(len);
            var ident = (Value[0] * 40) + Value[1];

            outs.EncodeIdentifier(ident);

            for (num = 2; num < Value.Length; num++)
            {
                outs.EncodeIdentifier(Value[num]);
            }
        }