ASN1C C# Runtime Library  7.8
Public Member Functions | List of all members
Asn1BerOutputStream Class Reference
Inheritance diagram for Asn1BerOutputStream:
Asn1OutputStream Asn1Writable Asn1CerOutputStream

Public Member Functions

 Asn1BerOutputStream (System.IO.Stream os)
 
 Asn1BerOutputStream (System.IO.Stream os, int bufSize)
 
virtual void Encode (Asn1Type type, bool explicitTagging)
 
virtual void EncodeBitString (byte[] data, int numbits, bool explicitTagging, Asn1Tag tag)
 
virtual void EncodeBMPString (System.String data, bool explicitTagging, Asn1Tag tag)
 
virtual void EncodeCharString (System.String data, bool explicitTagging, Asn1Tag tag)
 
virtual void EncodeEOC ()
 
virtual void EncodeIdentifier (long ident)
 
virtual void EncodeIntValue (long data, bool encodeLen)
 
virtual void EncodeLength (int len)
 
virtual void EncodeOctetString (byte[] data, bool explicitTagging, Asn1Tag tag)
 
virtual void EncodeTag (Asn1Tag tag)
 
virtual void EncodeTag (short tagClass, short tagForm, int tagIDCode)
 
virtual void EncodeTagAndIndefLen (Asn1Tag tag)
 
virtual void EncodeTagAndIndefLen (short tagClass, short tagForm, int tagIDCode)
 
virtual void EncodeTagAndLength (Asn1Tag tag, int len)
 
virtual void EncodeUnivString (int[] data, bool explicitTagging, Asn1Tag tag)
 
virtual void EncodeUnsignedBinaryNumber (long data)
 
- Public Member Functions inherited from Asn1OutputStream
 Asn1OutputStream (System.IO.Stream os)
 
override void Close ()
 
override void Flush ()
 
override int Read (byte[] buffer, int offset, int count)
 
override long Seek (long offset, System.IO.SeekOrigin origin)
 
override void SetLength (long value)
 
virtual void Write (byte[] b)
 
override void Write (System.Byte[] b, int off, int len)
 
void Write2Bytes (int value)
 
void Write4Bytes (int value)
 
virtual void WriteByte (int b)
 
override void WriteByte (byte b)
 
- Public Member Functions inherited from Asn1Writable
void Write (byte[] b, int off, int len)
 

Additional Inherited Members

- Properties inherited from Asn1OutputStream
override bool CanRead [get]
 
override bool CanSeek [get]
 
override bool CanWrite [get]
 
Asn1Context Context [get]
 
override long Length [get]
 
override long Position [get, set]
 

Detailed Description

This class implements the output stream to encode 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

◆ Asn1BerOutputStream() [1/2]

Asn1BerOutputStream ( System.IO.Stream  os)

This constructor creates a buffered BER output stream object with default size of buffer. Whenever the buffer becomes full, the buffer will be flushed to the stream.

Parameters
osThe underlying System.IO.Stream object.

◆ Asn1BerOutputStream() [2/2]

Asn1BerOutputStream ( System.IO.Stream  os,
int  bufSize 
)

This constructor creates a buffered BER output stream object. Whenever the buffer becomes full, the buffer will be flushed to the stream.

Parameters
osThe underlying System.IO.Stream object.
bufSizeThe buffer size. If it is 0 then the output stream is used as unbuffered one.

Member Function Documentation

◆ Encode()

virtual void Encode ( Asn1Type  type,
bool  explicitTagging 
)
virtual

This method encodes and writes to the stream ASN.1 types. The UNIVERSAL tag value and length is also encoded if explicit tagging is specified (the universal identifier must be provided by the caller).

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
typeThe object to be written
explicitTaggingFlag indicating explicit tagging should be done

Reimplemented in Asn1CerOutputStream.

References Asn1Type.Encode().

◆ EncodeBitString()

virtual void EncodeBitString ( byte []  data,
int  numbits,
bool  explicitTagging,
Asn1Tag  tag 
)
virtual

This method writes the given array of bytes as bit string value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataByte array containing data to encode.
numbitsNumber of bits to encode
explicitTaggingFlag indicating explicit tagging should be done
tagUniversal tag to apply
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented in Asn1CerOutputStream.

Referenced by Asn1BitString.Trim().

◆ EncodeBMPString()

virtual void EncodeBMPString ( System.String  data,
bool  explicitTagging,
Asn1Tag  tag 
)
virtual

This method writes the given string as BMP string value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataString containing data to encode.
explicitTaggingFlag indicating explicit tagging should be done
tagUniversal tag to apply
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented in Asn1CerOutputStream.

Referenced by Asn1BMPString.Encode().

◆ EncodeCharString()

virtual void EncodeCharString ( System.String  data,
bool  explicitTagging,
Asn1Tag  tag 
)
virtual

This method encodes and writes to the stream an ASN.1 8-bit character string types including IA5String, PrintableString, NumericString, etc. The UNIVERSAL tag value and length is also encoded if explicit tagging is specified (the universal identifier must be provided by the caller).

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataThe string object to be written
explicitTaggingFlag indicating explicit tagging should be done
tagUniversal tag to apply
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented in Asn1CerOutputStream.

References Asn1Util.ToByteArray().

Referenced by Asn1IA5String.Asn1IA5String(), Asn1Time.Asn1Time(), Asn1ObjectDescriptor.Encode(), Asn1GraphicString.Encode(), Asn1VideotexString.Encode(), Asn1VisibleString.Encode(), Asn1GeneralString.Encode(), Asn1T61String.Encode(), Asn1PrintableString.Encode(), Asn1Duration.Encode(), Asn1TimeOfDay.Encode(), Asn1Date.Encode(), Asn1DateTime.Encode(), Asn1NumericString.Encode(), and Asn1AbstractTime.Encode().

◆ EncodeEOC()

virtual void EncodeEOC ( )
virtual

This method encodes and writes an End-Of-Contents marker to the stream.

Throws, exception thrown by the underlying System.IO.Stream object.

◆ EncodeIdentifier()

virtual void EncodeIdentifier ( long  ident)
virtual

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

Throws, exception thrown by the underlying System.IO.Stream.

Parameters
identThe identifier to be encoded.

References Asn1Util.URShift().

Referenced by Asn1RelativeOID.DecodeXML(), and Asn1ObjectIdentifier.ToString().

◆ EncodeIntValue()

virtual void EncodeIntValue ( long  data,
bool  encodeLen 
)
virtual

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

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataInteger value to encode.
encodeLenFlag indicating length determinant should be encoded before encoding integer value.

References Diag.Prtln().

Referenced by Asn1X694OrderElement.Encode(), Asn1Real.NormalizedRealValueToString(), Asn1Enumerated.ToString(), and Asn1Integer.ToString().

◆ EncodeLength()

virtual void EncodeLength ( int  len)
virtual

This method encodes and writes a length value to the stream.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
lenThe length to be encoded.

References Asn1Util.GetBytesCount(), and Asn1Status.INDEFLEN.

Referenced by Asn1StringRelativeOID.DecodeXML(), Asn1RelativeOID.DecodeXML(), Asn1BigInteger.DecodeXML(), Asn1UTF8String.Encode(), Asn1StringOID.EncodeIdentifier(), Asn1Real.NormalizedRealValueToString(), Asn1Null.ToString(), Asn1Boolean.ToString(), and Asn1ObjectIdentifier.ToString().

◆ EncodeOctetString()

virtual void EncodeOctetString ( byte []  data,
bool  explicitTagging,
Asn1Tag  tag 
)
virtual

This method writes the given array of bytes as octet string value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataByte array containing data to encode.
explicitTaggingFlag indicating explicit tagging should be done
tagUniversal tag to apply
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented in Asn1CerOutputStream.

Referenced by Asn1OctetString.ToString().

◆ EncodeTag() [1/2]

virtual void EncodeTag ( Asn1Tag  tag)
virtual

◆ EncodeTag() [2/2]

virtual void EncodeTag ( short  tagClass,
short  tagForm,
int  tagIDCode 
)
virtual

This method encodes and writes a tag value to the stream.

Throws, exception thrown by the underlying System.IO.Stream 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.

◆ EncodeTagAndIndefLen() [1/2]

virtual void EncodeTagAndIndefLen ( Asn1Tag  tag)
virtual

This method encodes and writes both a tag and an indefinite length indicator to the stream.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
tagThe tag to be encoded.

◆ EncodeTagAndIndefLen() [2/2]

virtual void EncodeTagAndIndefLen ( short  tagClass,
short  tagForm,
int  tagIDCode 
)
virtual

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

Throws, exception thrown by the underlying System.IO.Stream 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.

◆ EncodeTagAndLength()

virtual void EncodeTagAndLength ( Asn1Tag  tag,
int  len 
)
virtual

This method encodes and writes both a tag and length value to the stream.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
tagThe tag to be encoded.
lenThe length to be encoded.

Referenced by Asn1Real10.ConvertToDecimal(), and Asn1Real10.Encode().

◆ EncodeUnivString()

virtual void EncodeUnivString ( int []  data,
bool  explicitTagging,
Asn1Tag  tag 
)
virtual

This method writes the given array of integers as UniversalString value.

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataArray containing data to encode.
explicitTaggingFlag indicating explicit tagging should be done
tagUniversal tag to apply
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented in Asn1CerOutputStream.

References Asn1Util.URShift().

Referenced by Asn1UniversalString.ToString().

◆ EncodeUnsignedBinaryNumber()

virtual void EncodeUnsignedBinaryNumber ( long  data)
virtual

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

Throws, exception thrown by the underlying System.IO.Stream object.

Parameters
dataInteger value to encode.

References Diag.Prtln().

Referenced by Asn1Real.NormalizedRealValueToString().