Ejemplo n.º 1
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 1;

            buffer.Copy(Value ? byte.MaxValue : ((byte)0));

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return len;
        }
Ejemplo n.º 2
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 1;

            buffer.Copy(Value ? byte.MaxValue : ((byte)0));

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return(len);
        }
Ejemplo n.º 3
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var length = Value.Length;

            for (var i = length - 1; i >= 0; --i)
            {
                var num3 = Value[i];
                var num = num3 % 0x100;
                var num2 = num3 / 0x100;

                buffer.Copy((byte)num);
                buffer.Copy((byte)num2);
            }

            length *= 2;

            if (explicitTagging)
            {
                length += buffer.EncodeTagAndLength(Tag, length);
            }

            return length;
        }
Ejemplo n.º 4
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 0;

            try
            {
                var bytes = Encoding.UTF8.GetBytes(Value);
                len = bytes.Length;
                buffer.Copy(bytes);
            }
            catch (IOException exception)
            {
                Console.Out.WriteLine("This JVM does not support UTF-8 encoding");
                Asn1Util.WriteStackTrace(exception, Console.Error);
            }

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return len;
        }
Ejemplo n.º 5
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var len = 0;

            if (double.IsNegativeInfinity(Value))
            {
                len = buffer.EncodeIntValue(MinusInfinity);
            }
            else if (double.IsPositiveInfinity(Value))
            {
                len = buffer.EncodeIntValue(PlusInfinity);
            }

            else if (Value != 0.0)
            {
                var num2 = BitConverter.DoubleToInt64Bits(Value);
                var num3 = ((num2 >> RealIso6093Mask) == 0L) ? 1 : -1;
                var num4 = ((int)((num2 >> 0x34) & 0x7ffL)) - 0x433;
                var w = (num4 == 0) ? ((num2 & 0xfffffffffffffL) << 1) : ((num2 & 0xfffffffffffffL) | 0x10000000000000L);

                if (w != 0L)
                {
                    var bits = TrailingZerosCnt(w);
                    w = Asn1Util.UrShift(w, bits);
                    num4 += bits;
                }

                len += buffer.EncodeIntValue(w);

                var num7 = buffer.EncodeIntValue(num4);
                len += num7;

                var num8 = RealBinary;

                if (num3 == -1)
                {
                    num8 |= PlusInfinity;
                }

                switch (num7)
                {
                    case RealExplen2:
                        break;

                    case RealExplen3:
                        num8 |= 1;
                        break;

                    case RealExplenLong:
                        num8 |= 2;
                        break;

                    default:
                        num8 |= 3;
                        len += buffer.EncodeIntValue(num7);
                        break;
                }

                buffer.Copy((byte)num8);
                len++;
            }

            if (explicitTagging)
            {
                len += buffer.EncodeTagAndLength(Tag, len);
            }

            return len;
        }
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            var length = _value.Length;

            for (var i = length - 1; i >= 0; i--)
            {
                var num3 = _value[i];

                for (var j = 0; j < 4; j++)
                {
                    var num = num3 % 0x100;
                    num3 /= 0x100;
                    buffer.Copy((byte)num);
                }
            }

            length *= 4;

            if (explicitTagging)
            {
                length += buffer.EncodeTagAndLength(Tag, length);
            }

            return length;
        }
Ejemplo n.º 7
0
        protected virtual int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging, Asn1Tag tag)
        {
            var length = Value.Length;
            buffer.Copy(Value);

            if (explicitTagging)
            {
                length += buffer.EncodeTagAndLength(tag, length);
            }

            return length;
        }
Ejemplo n.º 8
0
        public override int Encode(Asn1BerEncodeBuffer buffer, bool explicitTagging)
        {
            if (Value == null)
            {
                Value = new byte[0];
            }

            var length = Value.Length;

            if (length != 0)
            {
                buffer.Copy(Value);
            }

            if (explicitTagging)
            {
                length += buffer.EncodeTagAndLength(Tag, length);
            }

            return length;
        }