ASN1C C# Runtime Library  7.2
Public Member Functions | List of all members
Asn1BerEncodeBuffer Class Reference
Inheritance diagram for Asn1BerEncodeBuffer:
Asn1DerEncodeBuffer

Public Member Functions

 Asn1BerEncodeBuffer ()
 
 Asn1BerEncodeBuffer (int sizeIncrement)
 
override void BinDump (System.IO.StreamWriter outs, System.String varName)
 
virtual void BinDump ()
 
virtual int EncodeIdentifier (int ident)
 
virtual int EncodeIntValue (long ivalue)
 
virtual int EncodeLength (int len)
 
virtual int EncodeTag (Asn1Tag tag)
 
virtual int EncodeTagAndLength (Asn1Tag tag, int len)
 
virtual int EncodeTagAndLength (short tagClass, short tagForm, int tagIDCode, int len)
 
virtual int EncodeUnsignedBinaryNumber (long ivalue)
 
virtual int TrimBitString (Asn1BitString bitstr)
 

Detailed Description

This class handles the encoding of ASN.1 messages as specified in the Basic Encoding Rules (BER) as specified in the ITU-T X.690 standard. A reference to an object of this type is passed to each of the ASN.1 type encode methods involved in encoding a particular message type.

Constructor & Destructor Documentation

◆ Asn1BerEncodeBuffer() [1/2]

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

◆ Asn1BerEncodeBuffer() [2/2]

Asn1BerEncodeBuffer ( int  sizeIncrement)

This constructor creates a BER 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
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() [1/2]

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

This method dumps the encoded message in a human-readable format showing tags and contents to the given output stream.

Parameters
outsStreamWriter where dump will be printed
varNameName of the Decoded ASN1 Type

Implements Asn1EncodeBuffer.

◆ BinDump() [2/2]

virtual void BinDump ( )
virtual

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

◆ EncodeIdentifier()

virtual int EncodeIdentifier ( int  ident)
virtual

This method encodes an ASN.1 identifier value such as the ones used in a tags or object identifiers.

Parameters
identThe identifier to be encoded.
Returns
Length of the encoded component in octets.

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

◆ EncodeIntValue()

virtual int EncodeIntValue ( long  ivalue)
virtual

This method encodes an ASN.1 integer value's contents according to the ASN.1 Basic Encoding Rules (BER)..

Parameters
ivalueInteger value to encode
Returns
Length of encoded component

References Diag.Prtln().

Referenced by Asn1Integer.Asn1Integer(), Asn1Enumerated.Encode(), and Asn1X694OrderElement.Encode().

◆ EncodeLength()

virtual int EncodeLength ( int  len)
virtual

This method encodes a length value.

Parameters
lenThe length to be encoded.
Returns
Length of encoded component

References Asn1Status.INDEFLEN.

◆ EncodeTag()

virtual int EncodeTag ( Asn1Tag  tag)
virtual

This method encodes a tag value.

Parameters
tagThe tag to be encoded.
Returns
Length of component or negative status value

References Asn1Tag.EXTIDCODE, Asn1Tag.mClass, Asn1Tag.mForm, and Asn1Tag.mIDCode.

◆ EncodeTagAndLength() [1/2]

virtual int EncodeTagAndLength ( Asn1Tag  tag,
int  len 
)
virtual

◆ EncodeTagAndLength() [2/2]

virtual int EncodeTagAndLength ( short  tagClass,
short  tagForm,
int  tagIDCode,
int  len 
)
virtual

This overloaded version of encodeTagAndLength allows tag value components to be specified instead of an Asn1Tag object

Parameters
tagClassThe class of the tag to be encoded.
tagFormThe form of the tag to be encoded.
tagIDCodeThe ID code of the tag to be encoded.
lenThe length to be encoded.
Returns
status value (see Asn1Status.java)

References Asn1BerDecodeBuffer.Parse().

◆ EncodeUnsignedBinaryNumber()

virtual int EncodeUnsignedBinaryNumber ( long  ivalue)
virtual

This method encodes an integer value as unsigned binary number according to the ASN.1 Basic Encoding Rules (BER)..

Parameters
ivalueInteger value to encode
Returns
Length of encoded component

References Diag.Prtln().

◆ TrimBitString()

virtual int TrimBitString ( Asn1BitString  bitstr)
virtual

This method will trim a BIT STRING for DER encoding by removing all zero trailing bits. The default implementation in Asn1BerEncodeBuffer does nothing. The overriden version in Asn1DerEncodeBuffer will trim the string.

<param name="bitstr> ASN.1 BIT STRING object <return> Adjusted bit count </return>

Reimplemented in Asn1DerEncodeBuffer.

References Asn1BitString.numbits.