ASN1C C# Runtime Library  7.6
Classes | Public Member Functions | Properties | List of all members
Asn1DecodeBuffer Class Referenceabstract
Inheritance diagram for Asn1DecodeBuffer:
Asn1MessageBuffer Asn1MessageBufferBase Asn1BerDecodeBuffer Asn1DecodeBitBuffer Asn1MderDecodeBuffer Asn1BerInputStream Asn1DerDecodeBuffer Asn1OerDecodeBuffer Asn1PerDecodeBuffer Asn1CerInputStream Asn1DerInputStream Asn1PerInputStream

Classes

struct  BufferPos
 

Public Member Functions

virtual void AddCaptureBuffer (System.IO.MemoryStream buffer)
 
virtual void Capture (int nbytes)
 
virtual long DecodeIntValue (int length, bool signExtend)
 
virtual int [] DecodeOIDContents (int llen)
 
virtual int [] DecodeRelOIDContents (int llen)
 
override System.IO.Stream GetInputStream ()
 
virtual void HexDump ()
 
virtual void Mark ()
 
virtual void MarkPos (ref BufferPos bufferPos)
 
virtual int Read ()
 
virtual void Read (byte[] buffer, int offset, int nbytes)
 
virtual void Read (byte[] buffer)
 
int Read2Bytes ()
 
int Read4Bytes ()
 
abstract int ReadByte ()
 
virtual void RemoveCaptureBuffer (System.IO.MemoryStream buffer)
 
virtual void Reset ()
 
virtual void ResetPos (ref BufferPos bufferPos)
 
virtual void SetInputStream (byte[] msgdata, int offset, int length)
 
virtual long Skip (long nbytes)
 
- Public Member Functions inherited from Asn1MessageBuffer
virtual void AddNamedEventHandler (Asn1NamedEventHandler handler)
 
virtual void InvokeCharacters (System.String svalue)
 
virtual void InvokeEndElement (System.String name, int index)
 
virtual void InvokeStartElement (System.String name, int index)
 
- Public Member Functions inherited from Asn1MessageBufferBase
void SetKey (byte[] rtkey)
 
void SetPermanentKey (byte[] rtkey)
 

Properties

virtual int ByteCount [get]
 
bool LazyOpenTypeDecode [get, set]
 
- Properties inherited from Asn1MessageBuffer
virtual Asn1MessageBuffer EventHandlerList [set]
 
- Properties inherited from Asn1MessageBufferBase
Asn1Context Context [get]
 
virtual short TypeCode [set]
 

Additional Inherited Members

- Static Public Member Functions inherited from Asn1MessageBufferBase
static void HexDump (System.IO.Stream ins, System.IO.StreamWriter outs)
 
static void HexDump (System.IO.Stream ins)
 

Detailed Description

This is the base class to specific Decode buffer classes for the different types of encoding rules (BER, DER and PER).

Member Function Documentation

◆ AddCaptureBuffer()

virtual void AddCaptureBuffer ( System.IO.MemoryStream  buffer)
virtual

This method is used to add a capture buffer to the internal capture buffer list. A capture buffer is used to capture all bytes read from this position forward from the input stream.

Parameters
bufferBuffer into which captured bytes are to be stored

Referenced by Asn1PerDecodeTraceHandler.Enable().

◆ Capture()

virtual void Capture ( int  nbytes)
virtual

This method captures bytes from the input stream to a separate object for later analysis.

Parameters
nbytesNumber of bytes to capture

◆ DecodeIntValue()

virtual long DecodeIntValue ( int  length,
bool  signExtend 
)
virtual

This method decodes the contents of an ASN.1 integer value. It can be used for either BER or PER decoding.

Parameters
lengthLength of encoded contents
signExtendSign-extend the decoded value to form a 2's comp result
Returns
Decoded long integer value

◆ DecodeOIDContents()

virtual int [] DecodeOIDContents ( int  llen)
virtual

This method decodes the contents of an ASN.1 object identifier value. It can be used for either BER or PER decoding.

Parameters
llenLength of encoded contents
Returns
Decoded object identifier value

References Asn1ObjectIdentifier.MAXSUBIDS.

Referenced by Asn1ObjectIdentifier.Append(), and Asn1ObjectIdentifier.Encode().

◆ DecodeRelOIDContents()

virtual int [] DecodeRelOIDContents ( int  llen)
virtual

This method decodes the contents of an ASN.1 relative object identifier value. It can be used for either BER or PER decoding.

Parameters
llenLength of encoded contents
Returns
Decoded object identifier value

References Asn1ObjectIdentifier.MAXSUBIDS.

Referenced by Asn1RelativeOID.Asn1RelativeOID(), and Asn1RelativeOID.Encode().

◆ GetInputStream()

override System.IO.Stream GetInputStream ( )
virtual

This method returns a reference to the current current Decode input stream object.

Returns
New input stream object containing encoded message

Implements Asn1MessageBuffer.

◆ HexDump()

virtual void HexDump ( )
virtual

This method provides a hex dump of the bytes in the message being decoded.

◆ Mark()

virtual void Mark ( )
virtual

This method is used to mark the current position in the input stream for retry processing.

Reimplemented in Asn1PerInputStream, Asn1BerInputStream, and Asn1DerInputStream.

◆ MarkPos()

virtual void MarkPos ( ref BufferPos  bufferPos)
virtual

This method marks the current position and stores it in a user-supplied structure.

Parameters
bufferPosA BufferPos structure to hold the position information.

◆ Read() [1/3]

virtual int Read ( )
virtual

The read method reads a single byte from the current input stream and returns it to the caller. It will also write the byte out to all registered capture buffers.

Throws, Exception thrown by C# System.IO.Stream for I/O error for Stream as input data

Returns
byte that was read from the input stream
Exceptions
Asn1EndOfBufferExceptionThrown if at end-of-stream

References Diag.Prtln(), and Asn1Util.ToHexString().

Referenced by Asn1BMPString.Asn1BMPString(), Asn1Boolean.Asn1Boolean(), Asn1Real10.Asn1Real10(), Asn1UniversalString.Asn1UniversalString(), Asn1BitString.Clear(), Asn1OctetString.CompareTo(), Asn1Real.Decode(), Asn1BMPString.Decode(), Asn1UTF8String.Decode(), Asn1OctetString.Decode(), Asn1BitString.Decode(), Asn1OctetString.Encode(), Asn1BitString.Encode(), Asn1Integer.EncodeUnsigned(), and Asn1CharString.validate().

◆ Read() [2/3]

virtual void Read ( byte []  buffer,
int  offset,
int  nbytes 
)
virtual

This version of the read method reads the given number of bytes from the current input stream and writes them to the specified byte array at the given offset. It also writes the data to all registered capture buffers.

Throws, Exception thrown by C# System.IO.Stream for I/O error for Stream as input data

Parameters
bufferthe buffer into which the data is read
offsetthe start offset of the data
nbytesnumber of bytes to read
Exceptions
Asn1EndOfBufferExceptionThrown if at end-of-stream

References Diag.Prtln().

◆ Read() [3/3]

virtual void Read ( byte []  buffer)
virtual

This version of the read method reads the number of bytes equal to the length of the given input buffer.

Throws, Exception thrown by C# System.IO.Stream for I/O error, for Stream as input data

Parameters
bufferthe buffer into which the data is read
Exceptions
Asn1EndOfBufferExceptionThrown if at end-of-stream

◆ Read2Bytes()

int Read2Bytes ( )

Read the next two bytes from the current input stream into an int, and return that int. The bytes of the int, from lowest to highest, will correspond to the bytes read from the stream, from last to first. The highest two bytes will be 0.

Each byte read will be written to all registered capture buffers.

Returns
an int representing the 2 bytes read, as described above.
Exceptions
Asn1EndOfBufferExceptionif at end-of-stream

Referenced by Asn1OctetString.Decode(), and Asn1Integer.Decode16Bit().

◆ Read4Bytes()

int Read4Bytes ( )

Read the next four bytes from the current input stream into an int, and return that int. The bytes of the int, from lowest to highest, will correspond to the bytes read from the stream, from last to first.

Each byte read will be written to all registered capture buffers.

Returns
an int representing the 4 bytes read, as described above.
Exceptions
Asn1EndOfBufferExceptionif at end-of-stream

Referenced by Asn1Integer.Decode32Bit().

◆ ReadByte()

abstract int ReadByte ( )
pure virtual

This abstract method returns the next available 8-bit value from the input stream. It is implemented differently for BER/DER and PER to take into account odd alignments in PER.

Returns
Next 8-bit byte value from input stream

Implemented in Asn1BerDecodeBuffer, Asn1DecodeBitBuffer, and Asn1MderDecodeBuffer.

Referenced by Asn1Real.Decode(), and Asn1BigInteger.DecodeValue().

◆ RemoveCaptureBuffer()

virtual void RemoveCaptureBuffer ( System.IO.MemoryStream  buffer)
virtual

This method is used to remove a capture buffer from the internal capture buffer list. The add and remove methods can be used to get a set of raw bytes from the input stream for further processing.

Parameters
bufferBuffer in which captured bytes stored

◆ Reset()

virtual void Reset ( )
virtual

This method is used to reset the current position in the decode buffer back to the location of the last 'mark' call.

Reimplemented in Asn1PerInputStream, Asn1BerInputStream, and Asn1DerInputStream.

Referenced by Asn1BerDecodeContext.Expired(), and Asn1BerDecodeContext.MatchElemTag().

◆ ResetPos()

virtual void ResetPos ( ref BufferPos  bufferPos)
virtual

This method resets the current position using the information in the passed BufferPos structure.

Parameters
bufferPosBufferPos structure containing information for the reset.

◆ SetInputStream()

virtual void SetInputStream ( byte []  msgdata,
int  offset,
int  length 
)
virtual

This method will set the input stream from which data is read. This version of the method allows a byte array containing encoded data to be specified.

Parameters
msgdataByte array containing encoded message data
offsetStarting offset of data in the byte array
lengthLength (in bytes) of the encoded data

Reimplemented in Asn1DecodeBitBuffer.

◆ Skip()

virtual long Skip ( long  nbytes)
virtual

This method will skip over the requested number of bytes in the input stream.

Parameters
nbytesNumber of bytes to skip
Returns
Skipped number of bytes

Reimplemented in Asn1PerInputStream, Asn1BerInputStream, and Asn1DerInputStream.

Referenced by Asn1BerDecodeBuffer.CalcIndefLen().

Property Documentation

◆ ByteCount

virtual int ByteCount
get

Gets the count of bytes currently read from the message being decoded or input stream.

Referenced by Asn1BerDecodeContext.Asn1BerDecodeContext(), Asn1BerDecodeBuffer.CalcIndefLen(), Asn1BerDecodeContext.Expired(), and Asn1BerDecodeContext.MatchElemTag().

◆ LazyOpenTypeDecode

bool LazyOpenTypeDecode
getset

Lazy open type decoding. This property is relevant only when generating table constraint code (otherwise, open types cannot be decoded). Generated decode methods check this property to determine whether to decode open types or not. When lazy open type decoding is turned on, you can use the generated decodeOpenType* methods to decode open types (again, assuming table constraint code was generated).