Asn1BerEncodeBuffer Class Reference

Inheritance diagram for Asn1BerEncodeBuffer:
Asn1EncodeBuffer Asn1MessageBuffer Asn1DerEncodeBuffer

List of all members.

Public Member Functions

 Asn1BerEncodeBuffer (int sizeIncrement)
 Asn1BerEncodeBuffer ()
virtual void BinDump ()
override void BinDump (System.IO.StreamWriter outs, System.String varName)
virtual void Copy (System.String data)
virtual void Copy (byte[] data, int startOffset, int length)
override void Copy (byte[] data)
override void Copy (byte data)
virtual int EncodeIdentifier (int ident)
virtual int EncodeIntValue (long ivalue)
virtual int EncodeLength (int len)
virtual int EncodeTag (Asn1Tag tag)
virtual int EncodeTagAndLength (short tagClass, short tagForm, int tagIDCode, int len)
virtual int EncodeTagAndLength (Asn1Tag tag, int len)
virtual int EncodeUnsignedBinaryNumber (long ivalue)
override System.IO.Stream GetInputStream ()
override void Reset ()
override System.String ToString ()
virtual int TrimBitString (Asn1BitString bitstr)
override void Write (System.IO.Stream outs)

Protected Member Functions

internal override void CheckSize (int bytesRequired)

Properties

virtual System.IO.MemoryStream ByteArrayInputStream [get]
override byte[] MsgCopy [get]
override int MsgLength [get]

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

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 ( 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:
sizeIncrement The initial size in bytes of an encode buffer. If the buffer becomes full, it will be expanded by the amount.

Member Function Documentation

virtual void BinDump (  )  [virtual]

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

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:
outs StreamWriter where dump will be printed
varName Name of the Decoded ASN1 Type

Implements Asn1EncodeBuffer.

internal override void CheckSize ( int  bytesRequired  )  [protected, virtual]

This method determines if the encode buffer can hold the requested number of bytes. If not, the buffer is expanded.

Parameters:
bytesRequired Number of required bytes.

Reimplemented from Asn1EncodeBuffer.

virtual void Copy ( System.String  data  )  [virtual]

This method copies a character string into the encode buffer

Parameters:
data String to copy to the encode buffer
virtual void Copy ( byte[]  data,
int  startOffset,
int  length 
) [virtual]

This method copies multiple bytes to the encode buffer

Parameters:
data Array of bytes to copy to the encode buffer
startOffset The byte offset in array at which to begin copy.
length Number of bytes to copy
override void Copy ( byte[]  data  )  [virtual]

This method copies multiple bytes to the encode buffer

Parameters:
data Array of bytes to copy to the encode buffer

Implements Asn1EncodeBuffer.

override void Copy ( byte  data  )  [virtual]

This method copies a single byte to the encode buffer.

Parameters:
data The byte value to copy

Implements Asn1EncodeBuffer.

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:
ident The identifier to be encoded.
Returns:
Length of the encoded component in octets.
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:
ivalue Integer value to encode
Returns:
Length of encoded component
virtual int EncodeLength ( int  len  )  [virtual]

This method encodes a length value.

Parameters:
len The length to be encoded.
Returns:
Length of encoded component
virtual int EncodeTag ( Asn1Tag  tag  )  [virtual]

This method encodes a tag value.

Parameters:
tag The tag to be encoded.
Returns:
Length of component or negative status value
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:
tagClass The class of the tag to be encoded.
tagForm The form of the tag to be encoded.
tagIDCode The ID code of the tag to be encoded.
len The length to be encoded.
Returns:
status value (see Asn1Status.java)
virtual int EncodeTagAndLength ( Asn1Tag  tag,
int  len 
) [virtual]

This method encodes both a tag and length value.

Parameters:
tag The tag to be encoded.
len The length to be encoded.
Returns:
Length of encoded component
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:
ivalue Integer value to encode
Returns:
Length of encoded component
override System.IO.Stream GetInputStream (  )  [virtual]

This method returns an input stream representing the encoded message. This is a method defined as abstract in the base class that must be implemented by all derived classes. In this case, a byte array input stream is returned.

Returns:
Input stream containing encoded message

Implements Asn1MessageBuffer.

override void Reset (  )  [virtual]

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

Implements Asn1EncodeBuffer.

override System.String ToString (  ) 

This method will return a string representation of the data in the encode buffer. The format is hex characters.

Returns:
Stringified representation of the value
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.

override void Write ( System.IO.Stream  outs  )  [virtual]

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

Parameters:
outs Output stream to which record is to be written

Implements Asn1EncodeBuffer.


Property Documentation

virtual System.IO.MemoryStream ByteArrayInputStream [get]

This method returns a reference to a byte array input stream representing the encoded message. This is the preferred way to access the contents of the encoded message as it is the most efficient.

Returns:
byte array input stream containing encoded message
override byte [] MsgCopy [get]

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

Returns:
byte array containing encoded message

Reimplemented from Asn1EncodeBuffer.

override int MsgLength [get]

This method returns the length of the encoded message component.

Returns:
length of encoded message component

Reimplemented from Asn1EncodeBuffer.