NBitcoin.BouncyCastle.Asn1.Asn1InputStream.ReadObject C# (CSharp) Method

ReadObject() public method

public ReadObject ( ) : Asn1Object
return Asn1Object
		public Asn1Object ReadObject()
		{
			int tag = ReadByte();
			if(tag <= 0)
			{
				if(tag == 0)
					throw new IOException("unexpected end-of-contents marker");

				return null;
			}

			//
			// calculate tag number
			//
			int tagNo = ReadTagNumber(this.s, tag);

			bool isConstructed = (tag & Asn1Tags.Constructed) != 0;

			//
			// calculate length
			//
			int length = ReadLength(this.s, limit);

			if(length < 0) // indefinite length method
			{
				throw new IOException("indefinite length primitive encoding encountered");
			}
			else
			{
				try
				{
					return BuildObject(tag, tagNo, length);
				}
				catch(ArgumentException e)
				{
					throw new Asn1Exception("corrupted stream detected", e);
				}
			}
		}

Usage Example

示例#1
0
 public ECDSASignature(byte[] derSig)
 {
     try
     {
         var decoder = new Asn1InputStream(derSig);
         var seq = decoder.ReadObject() as DerSequence;
         if ((seq == null) || (seq.Count != 2))
             throw new FormatException(InvalidDERSignature);
         R = ((DerInteger) seq[0]).Value;
         S = ((DerInteger) seq[1]).Value;
     }
     catch (Exception ex)
     {
         throw new FormatException(InvalidDERSignature, ex);
     }
 }
All Usage Examples Of NBitcoin.BouncyCastle.Asn1.Asn1InputStream::ReadObject