WriteEncoded() public method

public WriteEncoded ( int tag, byte bytes ) : void
tag int
bytes byte
return void
Esempio n. 1
0
		internal override void Encode(
			DerOutputStream derOut)
		{
			lock (this)
			{
				if (encoded == null)
				{
					base.Encode(derOut);
				}
				else
				{
					derOut.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, encoded);
				}
			}
		}
Esempio n. 2
0
		/*
		 * A note on the implementation:
		 * <p>
		 * As Der requires the constructed, definite-length model to
		 * be used for structured types, this varies slightly from the
		 * ASN.1 descriptions given. Rather than just outputing Sequence,
		 * we also have to specify Constructed, and the objects length.
		 */
		internal override void Encode(
			DerOutputStream derOut)
		{
			// TODO Intermediate buffer could be avoided if we could calculate expected length
			MemoryStream bOut = new MemoryStream();
			DerOutputStream dOut = new DerOutputStream(bOut);

			foreach (Asn1Encodable obj in this)
			{
				dOut.WriteObject(obj);
			}

			dOut.Dispose();

			byte[] bytes = bOut.ToArray();

			derOut.WriteEncoded(Asn1Tags.Sequence | Asn1Tags.Constructed, bytes);
		}
Esempio n. 3
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.GeneralizedTime, GetOctets());
 }
Esempio n. 4
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.VisibleString, GetOctets());
 }
Esempio n. 5
0
		internal override void Encode(
			DerOutputStream derOut)
		{
			derOut.WriteEncoded(Asn1Tags.Null, zeroBytes);
		}
Esempio n. 6
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     // TODO Should we make sure the byte value is one of '0' or '0xff' here?
     derOut.WriteEncoded(Asn1Tags.Boolean, new byte[]{ value });
 }
Esempio n. 7
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.ObjectIdentifier, GetBody());
 }
Esempio n. 8
0
		internal override void Encode(
			DerOutputStream derOut)
		{
			byte[] bytes = new byte[GetBytes().Length + 1];

			bytes[0] = (byte) PadBits;
			Array.Copy(GetBytes(), 0, bytes, 1, bytes.Length - 1);

			derOut.WriteEncoded(Asn1Tags.BitString, bytes);
		}
Esempio n. 9
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.GeneralizedTime, GetOctets());
 }
Esempio n. 10
0
		internal override void Encode(
            DerOutputStream derOut)
        {
            derOut.WriteEncoded(Asn1Tags.VisibleString, GetOctets());
        }
Esempio n. 11
0
		internal override void Encode(
            DerOutputStream derOut)
        {
            derOut.WriteEncoded(Asn1Tags.UniversalString, this.str);
        }
Esempio n. 12
0
		internal override void Encode(
            DerOutputStream derOut)
        {
            char[] c = str.ToCharArray();
            byte[] b = new byte[c.Length * 2];

			for (int i = 0; i != c.Length; i++)
            {
                b[2 * i] = (byte)(c[i] >> 8);
                b[2 * i + 1] = (byte)c[i];
            }

            derOut.WriteEncoded(Asn1Tags.BmpString, b);
        }
Esempio n. 13
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     // TODO Should we make sure the byte value is one of '0' or '0xff' here?
     derOut.WriteEncoded(Asn1Tags.Boolean, new byte[] { value });
 }
Esempio n. 14
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.ObjectIdentifier, GetBody());
 }
Esempio n. 15
0
		internal override void Encode(
			DerOutputStream derOut)
        {
            derOut.WriteEncoded(Asn1Tags.Utf8String, Encoding.UTF8.GetBytes(str));
        }
Esempio n. 16
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Enumerated, bytes);
 }
Esempio n. 17
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Enumerated, bytes);
 }
Esempio n. 18
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Null, zeroBytes);
 }
Esempio n. 19
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Integer, bytes);
 }
Esempio n. 20
0
		internal override void Encode(DerOutputStream derOut)
		{
			MemoryStream ms = new MemoryStream();
			WriteEncodable(ms, directReference);
			WriteEncodable(ms, indirectReference);
			WriteEncodable(ms, dataValueDescriptor);
			WriteEncodable(ms, new DerTaggedObject(Asn1Tags.External, externalContent));

			derOut.WriteEncoded(Asn1Tags.Constructed, Asn1Tags.External, ms.ToArray());
		}
Esempio n. 21
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Integer, bytes);
 }
		internal override void Encode(
			DerOutputStream derOut)
        {
			int classBits = Asn1Tags.Application;
			if (isConstructed)
			{
				classBits |= Asn1Tags.Constructed; 
			}

			derOut.WriteEncoded(classBits, tag, octets);
		}
Esempio n. 23
0
 internal override void Encode(
     DerOutputStream derOut)
 {
     derOut.WriteEncoded(Asn1Tags.Utf8String, Encoding.UTF8.GetBytes(str));
 }