ASN1C C# Runtime Library  7.4
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
Asn1EncodeBuffer Class Referenceabstract
Inheritance diagram for Asn1EncodeBuffer:
Asn1MessageBuffer Asn1MessageBufferBase

Public Member Functions

virtual void BinDump (System.String varName)
 
abstract void BinDump (System.IO.StreamWriter outs, System.String varName)
 
abstract void Copy (byte value)
 
void Copy (byte[] value)
 
abstract void Copy (byte[] value, int offset, int len)
 
override Stream GetInputStream ()
 
Stream GetOutputStream ()
 
virtual void HexDump ()
 
virtual void HexDump (System.IO.StreamWriter outs)
 
abstract void Reset ()
 
abstract void Write (System.IO.Stream outs)
 
- 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)
 

Static Public Member Functions

static int EncodeIntSigned (long value, byte[] dest, int offset)
 
static int EncodeIntUnsigned (long value, byte[] dest, int offset)
 
static int GetMinimalOctetsSigned (long value)
 
static int GetMinimalOctetsUnsigned (long value)
 
- 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)
 

Public Attributes

const int SIZE_INCREMENT = 1024
 

Properties

abstract System.IO.MemoryStream ByteArrayInputStream [get]
 
abstract byte [] MsgCopy [get]
 
abstract int MsgLength [get]
 
- Properties inherited from Asn1MessageBuffer
virtual Asn1MessageBuffer EventHandlerList [set]
 
- Properties inherited from Asn1MessageBufferBase
Asn1Context Context [get]
 
virtual short TypeCode [set]
 

Detailed Description

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

Member Function Documentation

◆ BinDump() [1/2]

virtual void BinDump ( System.String  varName)
virtual

This method invokes an overloaded version of BinDump to dump the encoded message to standard output.

Parameters
varNameName of the Decoded ASN1 Type

◆ BinDump() [2/2]

abstract void BinDump ( System.IO.StreamWriter  outs,
System.String  varName 
)
pure virtual

This method dumps the encoded message in a human-readable format showing a bit trace of all fields to the given print output stream.

Parameters
outsOutput will be written to this stream
varNameName of the Decoded ASN1 Type

Implemented in Asn1BerEncodeBuffer, Asn1XmlEncodeBuffer, Asn1XerEncodeBuffer, and Asn1PerEncodeBuffer.

◆ Copy() [1/3]

abstract void Copy ( byte  value)
pure virtual

This abstract method is used to copy a single byte to the encode buffer.

Parameters
valueThe byte value to copy

Referenced by Asn1BigInteger.DecodeValue(), and Asn1EncodeBuffer.HexDump().

◆ Copy() [2/3]

void Copy ( byte []  value)

◆ Copy() [3/3]

abstract void Copy ( byte []  value,
int  offset,
int  len 
)
pure virtual

This method copies multiple bytes from the given array to the encode buffer.

Parameters
valueArray of bytes to copy to the encode buffer
offsetThe first byte copied is value[offset]
lenThe last byte copied is value[offset + len - 1]

◆ EncodeIntSigned()

static int EncodeIntSigned ( long  value,
byte []  dest,
int  offset 
)
static

Encode an integer value as a signed value (2's complement), in the minimum number of octets possible (>=1), into the given array. /p>

Parameters
valueThe value to encode.
destThe array to but the encoding into. It must be large enough to hold the result, taking into account the given offset.
offsetThe index where the first byte should go.
Returns
The number of bytes.

Referenced by Asn1Real.Encode().

◆ EncodeIntUnsigned()

static int EncodeIntUnsigned ( long  value,
byte []  dest,
int  offset 
)
static

Encode an integer value as an unsigned value (binary integer), in the minimum number of octets possible (>=1), into the given array.

Parameters
valueThe value to encode. It must be non-negative.
destThe array to but the encoding into. It must be large enough to hold the result, taking into account the given offset.
offsetThe index where the first byte should go.
Returns
The number of bytes.

Referenced by Asn1Real.Encode().

◆ GetInputStream()

override Stream GetInputStream ( )
virtual

This method returns an input stream representing the encoded message.

Returns
Input stream containing encoded message

Implements Asn1MessageBuffer.

◆ GetMinimalOctetsSigned()

static int GetMinimalOctetsSigned ( long  value)
static

Return the minimal number of octets required to represent the given value, when a signed representation is being used.

Returns
The number of octets, <= 8.

Referenced by Asn1Real.Encode().

◆ GetMinimalOctetsUnsigned()

static int GetMinimalOctetsUnsigned ( long  value)
static

Return the minimal number of octets required to represent the given value, when an unsigned representation is being used.

Parameters
valueMust be >=0
Returns
The number of octets, <= 8.

Referenced by Asn1Real.Encode().

◆ GetOutputStream()

Stream GetOutputStream ( )

Return an output stream associated with this object. Anything written to the Stream will be written to this buffer using copy(byte) or copy(byte[]).

◆ HexDump() [1/2]

virtual void HexDump ( )
virtual

This method dumps the encoded message in hex/ascii format to the standard output stream.

Reimplemented in Asn1PerEncodeBuffer.

◆ HexDump() [2/2]

virtual void HexDump ( System.IO.StreamWriter  outs)
virtual

This method dumps the encoded message in hex/ascii format to the given print output stream.

Parameters
outsOutput stream object reference

References Asn1EncodeBuffer.Copy(), and Asn1EncodeBuffer.MsgLength.

◆ Reset()

abstract void Reset ( )
pure virtual

This method resets the buffer to allow a new record to be encoded into it. Any previously encoded data is lost.

Implemented in Asn1PerEncodeBuffer.

◆ Write()

abstract void Write ( System.IO.Stream  outs)
pure virtual

This method writes the encoded record to the given output stream.

Parameters
outsOutput stream to which record is to be written

Member Data Documentation

◆ SIZE_INCREMENT

const int SIZE_INCREMENT = 1024

This constant specifies the default size of the encode buffer and size it will be incremented by each time the buffer expands. It is currently set to 1024 bytes.

Property Documentation

◆ ByteArrayInputStream

abstract System.IO.MemoryStream ByteArrayInputStream
get

Gets a reference to a MemoryStream representing the encoded message. This is the preferred way to access the contents of the encoded message as it is the most efficient (it does not make a copy of the message).

Value: MemoryStream containing encoded message

◆ MsgCopy

abstract byte [] MsgCopy
get

Gets the encoded message in a byte array. This is less efficient than the GetInputStream method because the message contents must be copied to a newly created byte array.

Value: byte array containing encoded message

Referenced by Asn1OpenType.Asn1OpenType().

◆ MsgLength

abstract int MsgLength
get

Gets the length (in bytes) of the encoded message component.

Value: length of encoded message component

Referenced by Asn1OpenType.Asn1OpenType(), and Asn1EncodeBuffer.HexDump().