ASN1C C# Runtime Library  7.5
Public Member Functions | Static Public Member Functions | Properties | List of all members
Asn1PerDecodeBuffer Class Reference
Inheritance diagram for Asn1PerDecodeBuffer:
Asn1DecodeBitBuffer Asn1PerMessageBuffer Asn1DecodeBuffer Asn1MessageBuffer Asn1MessageBufferBase Asn1PerInputStream

Public Member Functions

 Asn1PerDecodeBuffer (byte[] msgdata, bool aligned)
 
 Asn1PerDecodeBuffer (System.IO.Stream istream, bool aligned)
 
virtual void BinDump (System.String varName)
 
virtual void BinDump (System.IO.StreamWriter outs, System.String varName)
 
override void ByteAlign ()
 
virtual bool DecodeBit (System.String ident)
 
override bool DecodeBit ()
 
virtual int DecodeBitsToInt (int nbits, System.String ident)
 
override int DecodeBitsToInt (int nbits)
 
virtual long DecodeBitsToLong (int nbits, System.String ident)
 
override long DecodeBitsToLong (int nbits)
 
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int nbits, System.String ident)
 
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int bitOffset, int nbits, System.String ident)
 
override void DecodeBitsToOctetArray (byte[] data, int offset, int nbits)
 
virtual void DecodeCharString (int nchars, int abpc, int ubpc, Asn1CharSet charSet, System.Text.StringBuilder sbuf)
 
virtual long DecodeConsWholeNumber (long rangeValue, System.String ident)
 
virtual long DecodeConsWholeNumber (long rangeValue)
 
virtual long DecodeExtLength ()
 
virtual long DecodeInt (int nocts, bool signExtend, System.String ident)
 
virtual long DecodeInt (int nocts, bool signExtend)
 
virtual long DecodeLength ()
 
virtual long DecodeLength (long lower, long upper)
 
virtual int DecodeSmallLength ()
 
virtual int DecodeSmallNonNegWholeNumber ()
 
virtual long DecodeUnconsLength ()
 
virtual bool IsAligned ()
 
virtual void SetAligned (bool data)
 
void SetSizeConstraint (long lower, long upper)
 
void SetSizeConstraintExt (long lower, long upper, long extLower, long extUpper)
 
- Public Member Functions inherited from Asn1DecodeBitBuffer
 Asn1DecodeBitBuffer (byte[] msgdata)
 
 Asn1DecodeBitBuffer (System.IO.Stream istream)
 
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int bitOffset, int nbits)
 
void MoveBitCursor (long offset)
 
sealed override int ReadByte ()
 
sealed override void SetInputStream (byte[] msgdata, int offset, int length)
 
- Public Member Functions inherited from Asn1DecodeBuffer
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 int Read ()
 
virtual void Read (byte[] buffer, int offset, int nbytes)
 
virtual void Read (byte[] buffer)
 
int Read2Bytes ()
 
int Read4Bytes ()
 
virtual void RemoveCaptureBuffer (System.IO.MemoryStream buffer)
 
virtual void Reset ()
 
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)
 
- Public Member Functions inherited from Asn1PerMessageBuffer
System.IO.Stream GetInputStream ()
 

Static Public Member Functions

static Asn1PerDecodeBuffer SetBuffer (Asn1PerDecodeBuffer buffer, byte[] msgdata, bool aligned)
 
- 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)
 

Properties

virtual Asn1PerTraceHandler TraceHandler [get]
 
- Properties inherited from Asn1DecodeBitBuffer
virtual long BitOffset [get]
 
virtual int MsgBitCnt [get]
 
- Properties inherited from Asn1DecodeBuffer
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]
 
- Properties inherited from Asn1PerMessageBuffer
int MsgBitCnt [get]
 
Asn1PerTraceHandler TraceHandler [get]
 

Detailed Description

This class handles the decoding of ASN.1 messages as specified in the Packed Encoding Rules (PER) ITU-T X.691 standard.

Constructor & Destructor Documentation

◆ Asn1PerDecodeBuffer() [1/2]

Asn1PerDecodeBuffer ( byte []  msgdata,
bool  aligned 
)

This constructor creates a PER Decode buffer object that references an encoded ASN.1 message.

Parameters
msgdataByte array containing an encoded ASN.1 message.
alignedtrue for specifying PER aligned; otherwise false for unaligned encoding.

◆ Asn1PerDecodeBuffer() [2/2]

Asn1PerDecodeBuffer ( System.IO.Stream  istream,
bool  aligned 
)

This constructor creates a PER Decode buffer object that references an encoded ASN.1 message. In this case, the message is passed in using an System.IO.Stream object.

Parameters
istreamInput stream containing an encoded ASN.1 message.
alignedBoolean specifying PER aligned or unaligned encoding.

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 top-level message object variable

◆ BinDump() [2/2]

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

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

Parameters
outsStreamWriter object to which output should be written
varNameName of top-level message object variable

◆ ByteAlign()

override void ByteAlign ( )
virtual

◆ DecodeBit() [1/2]

virtual bool DecodeBit ( System.String  ident)
virtual

This method decodes a single bit value.

Parameters
identBit field identifier name for tracing.
Returns
Boolean value of bit that was decoded.

Referenced by Asn1OpenExt.Decode(), Asn1TimeUtil.DecodeDateTime(), Asn1TimeUtil.DecodeDuration(), and Asn1Boolean.Encode().

◆ DecodeBit() [2/2]

override bool DecodeBit ( )
virtual

This method decodes a single bit value. The ident argument which is used for tracing is defaulted to 'value'.

Returns
Boolean value of bit that was decoded.

Reimplemented from Asn1DecodeBitBuffer.

◆ DecodeBitsToInt() [1/2]

virtual int DecodeBitsToInt ( int  nbits,
System.String  ident 
)
virtual

This method decodes bits from the input stream into a standard integer value. Up to 32 bits can be decoded. The bits are placed in the least-significant bytes of the integer.

Parameters
nbitsNumber of bits to Decode
identBit field identifier name for tracing.
Returns
Integer value containing decoded bits

Referenced by Asn1UniversalString.Decode(), Asn1Real10.Encode(), and Asn1Real.Encode().

◆ DecodeBitsToInt() [2/2]

override int DecodeBitsToInt ( int  nbits)
virtual

This method decodes bits from the input stream into a standard integer value. Up to 32 bits can be decoded. The bits are placed in the least-significant bytes of the integer. The ident argument which is used for tracing is defaulted to 'value'.

Returns
Integer value containing decoded bits
Parameters
nbitsNumber of bits to Decode

Reimplemented from Asn1DecodeBitBuffer.

◆ DecodeBitsToLong() [1/2]

virtual long DecodeBitsToLong ( int  nbits,
System.String  ident 
)
virtual

This method decodes bits from the input stream into a long integer value. Up to 64 bits can be decoded. The bits are placed in the least-significant bytes of the long integer.

Returns
Long integer value containing decoded bits
Parameters
nbitsNumber of bits to Decode
identBit field identifier name for tracing.

Referenced by Asn1Real.Encode().

◆ DecodeBitsToLong() [2/2]

override long DecodeBitsToLong ( int  nbits)
virtual

This method decodes bits from the input stream into a long integer value. Up to 64 bits can be decoded. The bits are placed in the least-significant bytes of the long integer. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
nbitsNumber of bits to Decode
Returns
Long integer value containing decoded bits

Reimplemented from Asn1DecodeBitBuffer.

◆ DecodeBitsToOctetArray() [1/3]

virtual void DecodeBitsToOctetArray ( byte []  data,
int  offset,
int  nbits,
System.String  ident 
)
virtual

This method decodes bits from the input stream into an array of octets. The user is expected to have provided an array large enough to hold the number of bits requested to be decoded.

Parameters
dataOctet array for decoded data
offsetStarting byte offset into array
nbitsNumber of bits to Decode
identBit field identifier name for tracing.

Referenced by Asn1BitString.BaseDecode(), Asn1OctetString.CompareTo(), Asn1BigInteger.Decode(), Asn1OctetString.Decode(), Asn1Real10.Encode(), and Asn1UTF8String.Encode().

◆ DecodeBitsToOctetArray() [2/3]

virtual void DecodeBitsToOctetArray ( byte []  data,
int  offset,
int  bitOffset,
int  nbits,
System.String  ident 
)
virtual

This method decodes bits from the input stream into an array of octets. The user is expected to have provided an array large enough to hold the number of bits requested to be decoded.

The first bit is decoded into the given offset byte at the MSB if bitOffset == 0, and at the LSB if bitOffset == 7.

Parameters
dataOctet array for decoded data
offsetStarting byte offset into array
bitOffsetWhere in first byte the first bit goes
nbitsNumber of bits to Decode
identBit field identifier name for tracing.

◆ DecodeBitsToOctetArray() [3/3]

override void DecodeBitsToOctetArray ( byte []  data,
int  offset,
int  nbits 
)
virtual

This method decodes bits from the input stream into an array of octets. The user is expected to have provided an array large enough to hold the number of bits requested to be decoded. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
dataOctet array for decoded data
offsetStarting byte offset into array
nbitsNumber of bits to Decode

Reimplemented from Asn1DecodeBitBuffer.

◆ DecodeCharString()

virtual void DecodeCharString ( int  nchars,
int  abpc,
int  ubpc,
Asn1CharSet  charSet,
System.Text.StringBuilder  sbuf 
)
virtual

This method decodes the contents of a known-multiplier character string. This version of the method assumes a permitted alphabet constraint is in place.

Parameters
ncharsNumber of characters
abpcNumber of bits per character (aligned)
ubpcNumber of bits per character (unaligned)
charSetObject representing the permitted alphabet constraint character set (optional)
sbufString buffer to receive decoded result

References Asn1CharSet.GetCharAtIndex(), Asn1CharSet.GetNumBitsPerChar(), and Asn1CharSet.MaxValue.

Referenced by Asn1Real.Encode(), and Asn1CharString.validate().

◆ DecodeConsWholeNumber() [1/2]

virtual long DecodeConsWholeNumber ( long  rangeValue,
System.String  ident 
)
virtual

This method implements the rules to Decode a constrained whole number as specified in section 10.5 of the X.691 standard.

Parameters
rangeValueupper - lower + 1. Treated as unsigned, with 0 representing 2^64.
identTracing identifier
Returns
Decoded adjusted value = value - lower range endpoint value

References Asn1Integer.GetBitCount(), Asn1Integer.GetUnsignedBitCount(), and Diag.Prtln().

Referenced by Asn1X694OrderElement.Decode(), Asn1BigInteger.Decode(), Asn1TimeUtil.DecodeDateTime(), Asn1TimeUtil.DecodeDuration(), and Asn1Integer.DecodeValue().

◆ DecodeConsWholeNumber() [2/2]

virtual long DecodeConsWholeNumber ( long  rangeValue)
virtual

This method implements the rules to Decode a constrained whole number as specified in section 10.5 of the X.691 standard. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
rangeValuelower - upper + 1
Returns
Decoded adjusted value = value - lower range endpoint value

◆ DecodeExtLength()

virtual long DecodeExtLength ( )
virtual

This method decodes an extension length value. Note that the decoded length is not what is returned. The bit offset to the start of the next element within the Decode buffer is returned.

Returns
Bit offset to next element in buffer

◆ DecodeInt() [1/2]

virtual long DecodeInt ( int  nocts,
bool  signExtend,
System.String  ident 
)
virtual

This method implements the rules to Decode an unconstrained integer value.

Returns
Decoded long integer value
Parameters
noctsNumber of octets to Decode
signExtendSign extend resulting value
identTracing identifier

Referenced by Asn1Integer.Decode(), Asn1Integer.DecodeValue(), and Asn1Real.Encode().

◆ DecodeInt() [2/2]

virtual long DecodeInt ( int  nocts,
bool  signExtend 
)
virtual

This method implements the rules to Decode an unconstrained integer value. The ident argument which is used for tracing is defaulted to 'value'.

Returns
Decoded long integer value
Parameters
noctsNumber of octets to Decode
signExtendSign extend resulting value

◆ DecodeLength() [1/2]

virtual long DecodeLength ( )
virtual

◆ DecodeLength() [2/2]

virtual long DecodeLength ( long  lower,
long  upper 
)
virtual

This method decodes a constrained length determinant value.

Parameters
lowerLower bound (inclusive) of length value range
upperUpper bound (inclusive) of length value range
Returns
Decoded length value

◆ DecodeSmallLength()

virtual int DecodeSmallLength ( )
virtual

This method implements the rules to Decode a normally small length as specified in section 11.9 of the X.691 standard.

Returns
Decoded int value

References Diag.Prtln().

Referenced by Asn1OpenExt.Decode().

◆ DecodeSmallNonNegWholeNumber()

virtual int DecodeSmallNonNegWholeNumber ( )
virtual

This method implements the rules to Decode a small non-negative whole number as specified in section 10.6 of the X.691 standard.

Returns
Decoded int value

References Diag.Prtln().

Referenced by Asn1ChoiceExt.Decode().

◆ DecodeUnconsLength()

virtual long DecodeUnconsLength ( )
virtual

This method decodes a general (unconstrained) length determinant value as described in section 11.9 of the 2008 X.691 standard. The maximum value that will be returned is 64K which is the largest length fragment size defined for PER. If a value of 16K or larger is returned, the user must repeat this call to fully Decode the fragmented contents.

Returns
Decoded length value. If the returned value is >= 16k, this indicates a fragmented length was decoded. The user must call this method again after the data fragment is decoded to get the next fragment length.

References Diag.Prtln().

◆ IsAligned()

virtual bool IsAligned ( )
virtual

This method tests if PER alignment is turned on or off.

Returns
true for PER aligned encoding or false for unaligned encoding.

Implements Asn1PerMessageBuffer.

Referenced by Asn1BigInteger.Decode(), Asn1UniversalString.Decode(), and Asn1CharString.validate().

◆ SetAligned()

virtual void SetAligned ( bool  data)
virtual

This method is used to turn PER aligned encoding on or off.

Parameters
datatrue for PER aligned encoding or false for unaligned encoding.

◆ SetBuffer()

static Asn1PerDecodeBuffer SetBuffer ( Asn1PerDecodeBuffer  buffer,
byte []  msgdata,
bool  aligned 
)
static

This method will create or reinitialize a PER Decode message buffer object to read data from the given byte array. If the existing buffer reference is null, a new buffer will be created; otherwise, the existing buffer will be reused.

Parameters
bufferExisting message buffer object
msgdataByte array containing message data
alignedtrue specifying PER aligned or false for unaligned encoding.
Returns
Asn1PerDecodeBuffer to read data from the given byte array

References Asn1DecodeBitBuffer.SetInputStream().

◆ SetSizeConstraint()

void SetSizeConstraint ( long  lower,
long  upper 
)

This method is used to set a size constraint within the buffer object. The constraint will only be set if an existing constraint is not already in place (i.e. if the existing reference is not null). This is used for length decoding of SEQUENCE OF objects to pass constraints applied to referenced objects to the base object.

◆ SetSizeConstraintExt()

void SetSizeConstraintExt ( long  lower,
long  upper,
long  extLower,
long  extUpper 
)

This method is used to set an extensible size constraint in the buffer object. The constraint will only be set if an existing constraint is not already in place (i.e. if the existing reference is not null). This is used for length encoding of SEQUENCE OF objects to pass constraints applied to referenced objects to the base object.

Property Documentation

◆ TraceHandler

virtual Asn1PerTraceHandler TraceHandler
get

Gets a reference to the internal trace handler object used to trace the bit fields within a PER message.

Value: Asn1PerTraceHandler object

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