Exemplo n.º 1
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     if (Value != null)
     {
         outs.Write(Value);
     }
 }
Exemplo n.º 2
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     if (Value != null)
     {
         outs.Write(Value);
     }
 }
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            int num;

            if (((Value.Length < 2) || (Value[0] > 2)) || ((Value[0] != 2) && (Value[1] > 0x27)))
            {
                throw ExceptionUtility.CryptographicException(Resources.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]);
            }
        }
Exemplo n.º 4
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (((OidValue.Items.Length < 2) || (OidValue.Items[0] > 2)) || ((OidValue.Items[0] != 2) && (OidValue.Items[1] > 0x27)))
            {
                throw ExceptionUtility.CryptographicException(Resources.Asn1InvalidObjectIdException);
            }

            var len = 1;

            for (var i = 2; i < OidValue.Items.Length; i++)
            {
                len += Asn1RunTime.GetIdentBytesCount(OidValue.Items[i]);
            }

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

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

            outs.EncodeIdentifier(ident);

            for (var i = 2; i < OidValue.Items.Length; i++)
            {
                outs.EncodeIdentifier(OidValue.Items[i]);
            }
        }
Exemplo n.º 5
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeIntValue(Value, true);
        }
Exemplo n.º 6
0
		public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
		{
			if (explicitTagging)
			{
				outs.EncodeTag(Tag);
			}

			outs.EncodeLength(0);
		}
Exemplo n.º 7
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeIntValue(Value, true);
        }
Exemplo n.º 8
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeLength(0);
        }
Exemplo n.º 9
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     foreach (Asn1OpenType type in Value)
     {
         if (type != null)
         {
             type.Encode(outs, false);
         }
     }
 }
Exemplo n.º 10
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeLength(1);
            outs.WriteByte(Value ? -1 : 0);
        }
Exemplo n.º 11
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     foreach (Asn1OpenType type in Value)
     {
         if (type != null)
         {
             type.Encode(outs, false);
         }
     }
 }
Exemplo n.º 12
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            outs.EncodeLength(1);
            outs.WriteByte(Value ? -1 : 0);
        }
Exemplo n.º 13
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            var buffer = new Asn1BerEncodeBuffer();
            var len    = EncodeValue(buffer, _value, true);

            outs.EncodeLength(len);
            outs.Write(buffer.MsgCopy);
        }
Exemplo n.º 14
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            try
            {
                var bytes = Encoding.UTF8.GetBytes(Value);

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

                outs.EncodeLength(bytes.Length);
                outs.Write(bytes);
            }
            catch (IOException exception)
            {
                Console.Out.WriteLine("This JVM does not support UTF-8 encoding");
                Asn1Util.WriteStackTrace(exception, Console.Error);
            }
        }
Exemplo n.º 15
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            try
            {
                var bytes = Encoding.UTF8.GetBytes(Value);

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

                outs.EncodeLength(bytes.Length);
                outs.Write(bytes);
            }
            catch (IOException exception)
            {
                Console.Out.WriteLine("This JVM does not support UTF-8 encoding");
                Asn1Util.WriteStackTrace(exception, Console.Error);
            }
        }
Exemplo n.º 16
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            var len = 0;

            foreach (var i in OidValue.Items)
            {
                len += Asn1RunTime.GetIdentBytesCount(i);
            }

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

            outs.EncodeLength(len);

            foreach (var i in OidValue.Items)
            {
                outs.EncodeIdentifier(i);
            }
        }
Exemplo n.º 17
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            int num;
            var len = 0;

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

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

            outs.EncodeLength(len);

            for (num = 0; num < Value.Length; num++)
            {
                outs.EncodeIdentifier(Value[num]);
            }
        }
Exemplo n.º 18
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            int num;
            var len = 0;

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

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

            outs.EncodeLength(len);

            for (num = 0; num < Value.Length; num++)
            {
                outs.EncodeIdentifier(Value[num]);
            }
        }
Exemplo n.º 19
0
		public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
		{
			outs.EncodeCharString(Value, explicitTagging, Tag);
		}
Exemplo n.º 20
0
 public virtual void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
 }
Exemplo n.º 21
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     Encode(outs, explicitTagging, Tag);
 }
Exemplo n.º 22
0
 public virtual void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
 }
Exemplo n.º 23
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     outs.EncodeUnivString(_value, explicitTagging, Tag);
 }
Exemplo n.º 24
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            var buffer = new Asn1BerEncodeBuffer();
            var len = EncodeValue(buffer, _value, true);

            outs.EncodeLength(len);
            outs.Write(buffer.MsgCopy);
        }
Exemplo n.º 25
0
 public virtual void Encode(Asn1BerOutputStream outs, bool explicitTagging, Asn1Tag tag)
 {
     SafeParseString();
     outs.EncodeCharString(Value, explicitTagging, tag);
 }
Exemplo n.º 26
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     Encode(outs, explicitTagging, Tag);
 }
Exemplo n.º 27
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     base.Encode(outs, false);
 }
Exemplo n.º 28
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     outs.EncodeCharString(base.Value, explicitTagging, Tag);
 }
Exemplo n.º 29
0
 public virtual void Encode(Asn1BerOutputStream outs, bool explicitTagging, Asn1Tag tag)
 {
     SafeParseString();
     outs.EncodeCharString(Value, explicitTagging, tag);
 }
Exemplo n.º 30
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            if (Value == 0.0)
            {
                outs.EncodeLength(0);
            }
            else if (Value == double.NegativeInfinity)
            {
                outs.EncodeIntValue(MinusInfinity, true);
            }
            else if (Value == double.PositiveInfinity)
            {
                outs.EncodeIntValue(PlusInfinity, true);
            }
            else
            {
                var len  = 1;
                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  += Asn1Util.GetUlongBytesCount(w);
                }
                else
                {
                    len++;
                }

                var num7 = RealBinary;

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

                var bytesCount = Asn1Util.GetBytesCount(num4);
                len += bytesCount;

                switch (bytesCount)
                {
                case RealExplen2:
                    break;

                case RealExplen3:
                    num7 |= 1;
                    break;

                case RealExplenLong:
                    num7 |= 2;
                    break;

                default:
                    num7 |= 3;
                    len++;
                    break;
                }

                outs.EncodeLength(len);
                outs.WriteByte((byte)num7);

                if ((num7 & 3) == 3)
                {
                    outs.EncodeIntValue(bytesCount, false);
                }

                outs.EncodeIntValue(num4, false);
                outs.EncodeIntValue(w, false);
            }
        }
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            int num;

            if (((Value.Length < 2) || (Value[0] > 2)) || ((Value[0] != 2) && (Value[1] > 0x27)))
            {
                throw ExceptionUtility.CryptographicException(Resources.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]);
            }
        }
Exemplo n.º 32
0
        public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
        {
            if (explicitTagging)
            {
                outs.EncodeTag(Tag);
            }

            if (Value == 0.0)
            {
                outs.EncodeLength(0);
            }
            else if (Value == double.NegativeInfinity)
            {
                outs.EncodeIntValue(MinusInfinity, true);
            }
            else if (Value == double.PositiveInfinity)
            {
                outs.EncodeIntValue(PlusInfinity, true);
            }
            else
            {
                var len = 1;
                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 += Asn1Util.GetUlongBytesCount(w);
                }
                else
                {
                    len++;
                }

                var num7 = RealBinary;

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

                var bytesCount = Asn1Util.GetBytesCount(num4);
                len += bytesCount;

                switch (bytesCount)
                {
                    case RealExplen2:
                        break;

                    case RealExplen3:
                        num7 |= 1;
                        break;

                    case RealExplenLong:
                        num7 |= 2;
                        break;

                    default:
                        num7 |= 3;
                        len++;
                        break;
                }

                outs.EncodeLength(len);
                outs.WriteByte((byte)num7);

                if ((num7 & 3) == 3)
                {
                    outs.EncodeIntValue(bytesCount, false);
                }

                outs.EncodeIntValue(num4, false);
                outs.EncodeIntValue(w, false);
            }
        }
Exemplo n.º 33
0
 public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
 {
     outs.EncodeBitString(Value, NumBits, explicitTagging, Tag);
 }
Exemplo n.º 34
0
		public override void Encode(Asn1BerOutputStream outs, bool explicitTagging)
		{
			base.Encode(outs, false);
		}