ASN1C C# Runtime Library  7.4
Public Member Functions | Properties | List of all members
Asn1PerEncodeBuffer Class Reference
Inheritance diagram for Asn1PerEncodeBuffer:
Asn1PerMessageBuffer Asn1PerEncoder

Public Member Functions

 Asn1PerEncodeBuffer (bool aligned)
 
 Asn1PerEncodeBuffer (bool aligned, int sizeIncrement)
 
override void BinDump (System.IO.StreamWriter outs, System.String varName)
 
override void ByteAlign ()
 
virtual void EncodeBit (bool value, System.String ident)
 
override void EncodeBit (bool value)
 
virtual void EncodeBits (byte[] value, int offset, int nbits, System.String ident)
 
virtual void EncodeBits (byte[] value, int offset, int bitOffset, int nbits, System.String ident)
 
override void EncodeBits (byte[] value, int offset, int bitOffset, int nbits)
 
override void EncodeBits (byte[] value, int offset, int nbits)
 
virtual void EncodeCharString (System.String value, int nchars, int offset, int abpc, int ubpc, Asn1CharSet charSet)
 
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue, System.String ident)
 
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue)
 
virtual void EncodeInt (long value, int nbits, System.String ident)
 
virtual void EncodeInt (long value, int nbits)
 
virtual void EncodeInt (long value, bool encodeLen, bool signExtend, System.String ident)
 
virtual void EncodeInt (long value, bool encodeLen, bool signExtend)
 
virtual long EncodeLength (long value)
 
virtual void EncodeLength (long value, long lower, long upper)
 
virtual void EncodeLengthEOM (long value)
 
virtual void EncodeOctetString (byte[] value, int offset, int nbytes)
 
virtual void EncodeOIDLengthAndValue (int[] value)
 
virtual void EncodeOpenType (byte[] value, int offset, int nbytes)
 
virtual void EncodeOpenType (Asn1PerEncodeBuffer buffer, System.String elemName)
 
virtual void EncodeRelOIDLengthAndValue (int[] value)
 
virtual void EncodeSmallLength (int value)
 
virtual void EncodeSmallNonNegWholeNumber (int value)
 
virtual long EncodeUnconsLength (long value)
 
override void HexDump ()
 
virtual bool IsAligned ()
 
override void Reset ()
 
virtual void SetAligned (bool value)
 
void SetSizeConstraint (long lower, long upper)
 
void SetSizeConstraintExt (long lower, long upper, long extLower, long extUpper)
 
- Public Member Functions inherited from Asn1PerMessageBuffer
System.IO.Stream GetInputStream ()
 
- Public Member Functions inherited from Asn1PerEncoder
void EncodeBits (byte val, int nbits)
 

Properties

virtual Asn1PerTraceHandler TraceHandler [get]
 
- Properties inherited from Asn1PerMessageBuffer
int MsgBitCnt [get]
 
Asn1PerTraceHandler TraceHandler [get]
 

Detailed Description

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

Constructor & Destructor Documentation

◆ Asn1PerEncodeBuffer() [1/2]

Asn1PerEncodeBuffer ( bool  aligned)

This constructor creates a PER encode buffer object with the default size increment. Whenever the buffer becomes full, the buffer will be expanded by the sizeIncrement size.

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

◆ Asn1PerEncodeBuffer() [2/2]

Asn1PerEncodeBuffer ( bool  aligned,
int  sizeIncrement 
)

This constructor creates a PER encode buffer object with the given size increment. Whenever the buffer becomes full, the buffer will be expanded by the sizeIncrement size. This size should be large enough to prevent resizing in normal operation.

Parameters
alignedtrue for PER aligned or false for PER unaligned encoding.
sizeIncrementThe initial size in bytes of an encode buffer. If the buffer becomes full, it will be expanded by the amount.

Member Function Documentation

◆ BinDump()

override 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 print output stream.

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

Implements Asn1EncodeBuffer.

◆ ByteAlign()

override void ByteAlign ( )

◆ EncodeBit() [1/2]

virtual void EncodeBit ( bool  value,
System.String  ident 
)
virtual

This method encodes a single bit value.

Parameters
valueBoolean value of bit to be encoded.
identBit field identifier name for tracing.

Implements Asn1PerEncoder.

Referenced by Asn1Boolean.Encode(), Asn1PerOutputStream.EncodeBit(), Asn1OpenExt.EncodeExtBits(), and Asn1Boolean.ToString().

◆ EncodeBit() [2/2]

override void EncodeBit ( bool  value)

This method encodes a single bit value. The ident argument which is used for tracing is defaulted to 'value'. Equivalent to EncodeBit(value, "value");

Parameters
valueBoolean value of bit to be encoded.

Implements Asn1PerEncoder.

◆ EncodeBits() [1/4]

virtual void EncodeBits ( byte []  value,
int  offset,
int  nbits,
System.String  ident 
)
virtual

This method encodes bit values from an array of octets.

Parameters
valueOctet array containing bits to be encoded
offsetStarting byte offset in value
nbitsNumber of bits to encode
identBit field identifier name for tracing.

Implements Asn1PerEncoder.

Referenced by Asn1BitString.BaseEncode(), Asn1PerOutputStream.Close(), Asn1UTF8String.Encode(), Asn1OctetString.Encode(), Asn1BigInteger.Encode(), Asn1Real.Encode(), and Asn1PerOutputStream.EncodeBits().

◆ EncodeBits() [2/4]

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

This method encodes bit values from an array of octets.

Parameters
valueOctet array containing bits to be encoded
offsetStarting byte offset in value
bitOffsetStarting bit offset in first byte. For example, passing 0 would begin encoding with the most significant bit, while passing 7 would begin encoding with the least significant bit.
nbitsNumber of bits to encode
identBit field identifier name for tracing.

◆ EncodeBits() [3/4]

override void EncodeBits ( byte []  value,
int  offset,
int  bitOffset,
int  nbits 
)

This method encodes bit values from an array of octets.

This overrides the parent class method in order to default the name for tracing to "value". Equivalent to: encodeBits(value, offset, bitOffset, nbits, "value");

◆ EncodeBits() [4/4]

override void EncodeBits ( byte []  value,
int  offset,
int  nbits 
)

This method encodes bit values from an array of octets. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
valueOctet array containing bits to be encoded
offsetStarting byte offset in value
nbitsNumber of bits to encode

Implements Asn1PerEncoder.

◆ EncodeCharString()

virtual void EncodeCharString ( System.String  value,
int  nchars,
int  offset,
int  abpc,
int  ubpc,
Asn1CharSet  charSet 
)
virtual

This method encodes the contents of a known-multiplier character string type. This version assumes a permitted alphabet constraint was specified.

Parameters
valueString containing characters to encode
ncharsNumber of characters from string to encode
offsetOffset to first char in string to encode
abpcNumber of bits per character (aligned)
ubpcNumber of bits per character (unaligned)
charSetObject representing permitted alphabet constraint character set (optional)

Implements Asn1PerEncoder.

References Asn1CharSet.GetCharIndex(), Asn1CharSet.GetNumBitsPerChar(), Asn1CharSet.MaxValue, and Diag.Prtln().

Referenced by Asn1PerOutputStream.EncodeCharString(), and Asn1CharString.validate().

◆ EncodeConsWholeNumber() [1/2]

virtual void EncodeConsWholeNumber ( long  adjustedValue,
long  rangeValue,
System.String  ident 
)
virtual

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

Parameters
adjustedValueAdjusted value to be encoded = value - lower range endpoint value
rangeValuelower - upper + 1
identTracing identifier

Implements Asn1PerEncoder.

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

Referenced by Asn1Enumerated.Encode(), Asn1X694OrderElement.Encode(), Asn1BigInteger.Encode(), and Asn1PerOutputStream.EncodeConsWholeNumber().

◆ EncodeConsWholeNumber() [2/2]

virtual void EncodeConsWholeNumber ( long  adjustedValue,
long  rangeValue 
)
virtual

This method implements the rules to encode 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
adjustedValueAdjusted value to be encoded = value - lower range endpoint value
rangeValuelower - upper + 1

Implements Asn1PerEncoder.

◆ EncodeInt() [1/4]

virtual void EncodeInt ( long  value,
int  nbits,
System.String  ident 
)
virtual

This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Parameters
valueInteger containing bits to be encoded
nbitsNumber of bits to encode
identTracing identifier

Implements Asn1PerEncoder.

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

Referenced by Asn1Integer.Encode(), Asn1UniversalString.Encode(), Asn1Real.Encode(), Asn1PerOutputStream.EncodeInt(), and Asn1Integer.ToString().

◆ EncodeInt() [2/4]

virtual void EncodeInt ( long  value,
int  nbits 
)
virtual

This method encodes bit values from an integer value. The least significant bits from the integer are encoded. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
valueInteger containing bits to be encoded
nbitsNumber of bits to encode

Implements Asn1PerEncoder.

◆ EncodeInt() [3/4]

virtual void EncodeInt ( long  value,
bool  encodeLen,
bool  signExtend,
System.String  ident 
)
virtual

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard.

Parameters
valueInteger value to be encoded
encodeLenFlag indicating length determinant should be encoded before encoding integer value.
signExtendFlag indicating if sign extension should be performed.
identTracing identifier

Implements Asn1PerEncoder.

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

◆ EncodeInt() [4/4]

virtual void EncodeInt ( long  value,
bool  encodeLen,
bool  signExtend 
)
virtual

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard. The ident argument which is used for tracing is defaulted to 'value'.

Parameters
valueInteger value to be encoded
encodeLenFlag indicating length determinant should be encoded before encoding integer value.
signExtendFlag indicating if sign extension should be performed.

Implements Asn1PerEncoder.

◆ EncodeLength() [1/2]

virtual long EncodeLength ( long  value)
virtual

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

Parameters
valueLength value to be encoded
Returns
Value that was actually encoded. This may be less than the value that was passed in if fragementation was done (i.e the value was >= 16k).

Implements Asn1PerEncoder.

References Asn1SizeConstraint.Extensible, Asn1SizeConstraint.RootLower, and Asn1SizeConstraint.RootUpper.

Referenced by Asn1BitString.BaseEncode(), Asn1Real10.Encode(), Asn1UTF8String.Encode(), Asn1Integer.Encode(), Asn1OctetString.Encode(), Asn1BigInteger.Encode(), Asn1UniversalString.Encode(), Asn1Real.Encode(), Asn1PerOutputStream.EncodeLength(), and Asn1CharString.validate().

◆ EncodeLength() [2/2]

virtual void EncodeLength ( long  value,
long  lower,
long  upper 
)
virtual

This method encodes a constrained length determinant value.

Parameters
valueLength value to be encoded
lowerLower bound (inclusive) of length value range
upperUpper bound (inclusive) of length value range

Implements Asn1PerEncoder.

◆ EncodeLengthEOM()

virtual void EncodeLengthEOM ( long  value)
virtual

This method checks to see if a zero byte needs to be added after a fragmented length has been encoded. It will add it to the byte stream if necessary.

Parameters
valueOriginal length value that was encoded.

Implements Asn1PerEncoder.

Referenced by Asn1BitString.BaseEncode(), Asn1UTF8String.Encode(), Asn1UniversalString.Encode(), Asn1PerOutputStream.EncodeLengthEOM(), and Asn1CharString.validate().

◆ EncodeOctetString()

virtual void EncodeOctetString ( byte []  value,
int  offset,
int  nbytes 
)
virtual

This method encodes the given array of bytes as an unconstrained octet string value.

Parameters
valueByte array containing data to encode. This is assumed to contain a previously encoded PER component.
offsetStarting offset in byte array value
nbytesNumber of bytes to encode

Implements Asn1PerEncoder.

Referenced by Asn1OctetString.Encode(), Asn1PerOutputStream.EncodeOctetString(), and Asn1OctetString.ToString().

◆ EncodeOIDLengthAndValue()

virtual void EncodeOIDLengthAndValue ( int []  value)
virtual

This method encodes the length and contents of an object identifier value.

Parameters
valueInteger array containing arcs to encode

Implements Asn1PerEncoder.

References Diag.Prtln().

Referenced by Asn1ObjectIdentifier.Encode(), and Asn1PerOutputStream.EncodeOIDLengthAndValue().

◆ EncodeOpenType() [1/2]

virtual void EncodeOpenType ( byte []  value,
int  offset,
int  nbytes 
)
virtual

This method encodes the given array of bytes as an open type.

Parameters
valueByte array containing data to encode. This is assumed to contain a previously encoded PER component.
offsetStarting offset in byte array value
nbytesNumber of bytes to encode

Implements Asn1PerEncoder.

Referenced by Asn1OpenType.Encode(), and Asn1PerOutputStream.EncodeOpenType().

◆ EncodeOpenType() [2/2]

virtual void EncodeOpenType ( Asn1PerEncodeBuffer  buffer,
System.String  elemName 
)
virtual

This overloaded version of encodeOpenType will encode the componet in the given PER encode buffer into this PER encode buffer.

Parameters
bufferPER encode buffer containing encoded message component.
elemNameName of element being encoded.

◆ EncodeRelOIDLengthAndValue()

virtual void EncodeRelOIDLengthAndValue ( int []  value)
virtual

This method encodes the length and contents of a relative object identifier value.

Parameters
valueInteger array containing arcs to encode

Implements Asn1PerEncoder.

References Diag.Prtln().

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

◆ EncodeSmallLength()

virtual void EncodeSmallLength ( int  value)
virtual

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

Parameters
valueValue to be encoded

Implements Asn1PerEncoder.

References Diag.Prtln().

Referenced by Asn1PerOutputStream.EncodeSmallLength().

◆ EncodeSmallNonNegWholeNumber()

virtual void EncodeSmallNonNegWholeNumber ( int  value)
virtual

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

Parameters
valueValue to be encoded

Implements Asn1PerEncoder.

References Diag.Prtln().

Referenced by Asn1ChoiceExt.Encode(), and Asn1PerOutputStream.EncodeSmallNonNegWholeNumber().

◆ EncodeUnconsLength()

virtual long EncodeUnconsLength ( long  value)
virtual

This method encodes a general (unconstrained) length determinant value as described in section 10.9 or the X.691 standard.

Parameters
valueLength value to be encoded
Returns
Value that was actually encoded. This may be less than the value that was passed in if fragementation was done (i.e the value was >= 16k).

◆ HexDump()

override void HexDump ( )
virtual

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

Reimplemented from Asn1EncodeBuffer.

◆ IsAligned()

virtual bool IsAligned ( )
virtual

This method is used to test if PER aligned encoding has been specified.

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

Implements Asn1PerMessageBuffer.

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

◆ Reset()

override void Reset ( )
virtual

This method resets the buffer object so that it can be reused to encode another PER message. Any previously encoded data is lost.

Implements Asn1EncodeBuffer.

Referenced by Asn1PerOutputStream.Close().

◆ SetAligned()

virtual void SetAligned ( bool  value)
virtual

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

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

◆ 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.

References Asn1Util.URShift().

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 Asn1Integer.Encode(), Asn1BigInteger.Encode(), and Asn1Real.Encode().