Asn1PerDecodeBuffer Class Reference

Inheritance diagram for Asn1PerDecodeBuffer:
Asn1DecodeBuffer Asn1PerMessageBuffer Asn1MessageBuffer Asn1MessageBufferBase Asn1PerInputStream

List of all members.

Public Member Functions

 Asn1PerDecodeBuffer (System.IO.Stream istream, bool aligned)
 Asn1PerDecodeBuffer (byte[] msgdata, bool aligned)
virtual void BinDump (System.IO.StreamWriter outs, System.String varName)
virtual void BinDump (System.String varName)
virtual void ByteAlign ()
virtual bool DecodeBit ()
virtual bool DecodeBit (System.String ident)
virtual int DecodeBitsToInt (int nbits)
virtual int DecodeBitsToInt (int nbits, System.String ident)
virtual long DecodeBitsToLong (int nbits)
virtual long DecodeBitsToLong (int nbits, System.String ident)
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int nbits)
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int bitOffset, int nbits, System.String ident)
virtual void DecodeBitsToOctetArray (byte[] data, int offset, int nbits, System.String ident)
virtual void DecodeCharString (int nchars, int abpc, int ubpc, Asn1CharSet charSet, System.Text.StringBuilder sbuf)
virtual long DecodeConsWholeNumber (long rangeValue)
virtual long DecodeConsWholeNumber (long rangeValue, System.String ident)
virtual long DecodeExtLength ()
virtual long DecodeInt (int nocts, bool signExtend)
virtual long DecodeInt (int nocts, bool signExtend, System.String ident)
virtual long DecodeLength (long lower, long upper)
virtual long DecodeLength ()
virtual int DecodeSmallLength ()
virtual int DecodeSmallNonNegWholeNumber ()
virtual long DecodeUnconsLength ()
virtual bool IsAligned ()
virtual void MoveBitCursor (long offset)
override int ReadByte ()
virtual void SetAligned (bool data)
override void SetInputStream (byte[] msgdata, int offset, int length)
void SetSizeConstraint (long lower, long upper)
void SetSizeConstraintExt (long lower, long upper, long extLower, long extUpper)

Static Public Member Functions

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

Protected Attributes

internal Asn1PerTraceHandler mTraceHandler

Properties

virtual long BitOffset [get]
virtual int MsgBitCnt [get]
virtual 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 ( byte[]  msgdata,
bool  aligned 
)

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

Parameters:
msgdata Byte array containing an encoded ASN.1 message.
aligned true for specifying PER aligned; otherwise false for unaligned encoding.
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:
istream Input stream containing an encoded ASN.1 message.
aligned Boolean specifying PER aligned or unaligned encoding.

Member Function Documentation

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:
outs StreamWriter object to which output should be written
varName Name of top-level message object variable
virtual void BinDump ( System.String  varName  )  [virtual]

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

Parameters:
varName Name of top-level message object variable
virtual void ByteAlign (  )  [virtual]

This methods byte-aligns the buffer.

Implements Asn1PerMessageBuffer.

virtual 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.
virtual bool DecodeBit ( System.String  ident  )  [virtual]

This method decodes a single bit value.

Parameters:
ident Bit field identifier name for tracing.
Returns:
Boolean value of bit that was decoded.
virtual 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:
nbits Number of bits to Decode
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:
nbits Number of bits to Decode
ident Bit field identifier name for tracing.
Returns:
Integer value containing decoded bits
virtual 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:
nbits Number of bits to Decode
Returns:
Long integer value containing decoded bits
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:
nbits Number of bits to Decode
ident Bit field identifier name for tracing.
virtual 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:
data Octet array for decoded data
offset Starting byte offset into array
nbits Number of bits to Decode
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:
data Octet array for decoded data
offset Starting byte offset into array
bitOffset Where in first byte the first bit goes
nbits Number of bits to Decode
ident Bit field identifier name for tracing.
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:
data Octet array for decoded data
offset Starting byte offset into array
nbits Number of bits to Decode
ident Bit field identifier name for tracing.
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:
nchars Number of characters
abpc Number of bits per character (aligned)
ubpc Number of bits per character (unaligned)
charSet Object representing the permitted alphabet constraint character set (optional)
sbuf String buffer to receive decoded result
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:
rangeValue lower - upper + 1
Returns:
Decoded adjusted value = value - lower range endpoint value
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:
rangeValue upper - lower + 1. Treated as unsigned, with 0 representing 2^64.
ident Tracing identifier
Returns:
Decoded adjusted value = value - lower range endpoint value
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
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:
nocts Number of octets to Decode
signExtend Sign extend resulting value
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:
nocts Number of octets to Decode
signExtend Sign extend resulting value
ident Tracing identifier
virtual long DecodeLength ( long  lower,
long  upper 
) [virtual]

This method decodes a constrained length determinant value.

Parameters:
lower Lower bound (inclusive) of length value range
upper Upper bound (inclusive) of length value range
Returns:
Decoded length value
virtual long DecodeLength (  )  [virtual]

This method decodes either a constrained or unconstrained length depending on whether a size constraint object is set in this object.

Returns:
Decoded length value.
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
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
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.
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.

virtual void MoveBitCursor ( long  offset  )  [virtual]

This method moves the bit cursor to the given offset.

Parameters:
offset Absolute bit offset value
override int ReadByte (  )  [virtual]

This 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

Implements Asn1DecodeBuffer.

virtual void SetAligned ( bool  data  )  [virtual]

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

Parameters:
data true for PER aligned encoding or false for unaligned encoding.
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:
buffer Existing message buffer object
msgdata Byte array containing message data
aligned true specifying PER aligned or false for unaligned encoding.
Returns:
Asn1PerDecodeBuffer to read data from the given byte array
override 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:
msgdata Byte array containing encoded message data
offset Starting offset of data in the byte array
length Length (in bytes) of the encoded data

Reimplemented from Asn1DecodeBuffer.

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.

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.


Member Data Documentation

internal Asn1PerTraceHandler mTraceHandler [protected]

Variable holds the PER message trace handler


Property Documentation

virtual long BitOffset [get]

Gets the absolute offset to the current bit in the Decode buffer.

Value: offset to current bit in Decode buffer

virtual int MsgBitCnt [get]

Gets the number of bits in the encoded PER message.

Value: count of bits in encoded message

Implements Asn1PerMessageBuffer.

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

Implements Asn1PerMessageBuffer.