ASN1C C# Runtime Library  7.5
Public Member Functions | Static Public Member Functions | Properties | List of all members
Asn1BerDecodeBuffer Class Reference
Inheritance diagram for Asn1BerDecodeBuffer:
Asn1DecodeBuffer Asn1MessageBuffer Asn1MessageBufferBase Asn1BerInputStream Asn1DerDecodeBuffer Asn1CerInputStream Asn1DerInputStream

Public Member Functions

 Asn1BerDecodeBuffer (byte[] msgdata)
 
 Asn1BerDecodeBuffer (System.IO.Stream istream)
 
int DecodeEnumValue (bool explicitTagging, int implicitLength)
 
int DecodeEnumValue (Asn1Tag tag, bool explicitTagging, int implicitLength)
 
virtual int DecodeLength ()
 
virtual byte [] DecodeOpenType ()
 
virtual byte [] DecodeOpenType (bool saveData)
 
virtual void DecodeTag (Asn1Tag tag)
 
virtual int DecodeTagAndLength (Asn1Tag tag)
 
virtual bool MatchTag (short tagClass, short tagForm, int tagIDCode, Asn1Tag parsedTag, IntHolder parsedLen)
 
virtual bool MatchTag (Asn1Tag tag, Asn1Tag parsedTag, IntHolder parsedLen)
 
virtual bool MatchTag (Asn1Tag tag)
 
virtual void Parse (Asn1TaggedEventHandler handler)
 
virtual void PeekTag (Asn1Tag parsedTag)
 
virtual Asn1Tag PeekTag ()
 
override int ReadByte ()
 
- Public Member Functions inherited from Asn1DecodeBuffer
virtual void AddCaptureBuffer (System.IO.MemoryStream buffer)
 
virtual void Capture (int nbytes)
 
virtual long DecodeIntValue (int length, bool signExtend)
 
virtual int [] DecodeOIDContents (int llen)
 
virtual int [] DecodeRelOIDContents (int llen)
 
override System.IO.Stream GetInputStream ()
 
virtual void HexDump ()
 
virtual void Mark ()
 
virtual int Read ()
 
virtual void Read (byte[] buffer, int offset, int nbytes)
 
virtual void Read (byte[] buffer)
 
int Read2Bytes ()
 
int Read4Bytes ()
 
virtual void RemoveCaptureBuffer (System.IO.MemoryStream buffer)
 
virtual void Reset ()
 
virtual void SetInputStream (byte[] msgdata, int offset, int length)
 
virtual long Skip (long nbytes)
 
- Public Member Functions inherited from Asn1MessageBuffer
virtual void AddNamedEventHandler (Asn1NamedEventHandler handler)
 
virtual void InvokeCharacters (System.String svalue)
 
virtual void InvokeEndElement (System.String name, int index)
 
virtual void InvokeStartElement (System.String name, int index)
 
- Public Member Functions inherited from Asn1MessageBufferBase
void SetKey (byte[] rtkey)
 
void SetPermanentKey (byte[] rtkey)
 

Static Public Member Functions

static int CalcIndefLen (byte[] data, int offset, int len)
 
- Static Public Member Functions inherited from Asn1MessageBufferBase
static void HexDump (System.IO.Stream ins, System.IO.StreamWriter outs)
 
static void HexDump (System.IO.Stream ins)
 

Properties

virtual Asn1Tag LastTag [get]
 
- Properties inherited from Asn1DecodeBuffer
virtual int ByteCount [get]
 
bool LazyOpenTypeDecode [get, set]
 
- Properties inherited from Asn1MessageBuffer
virtual Asn1MessageBuffer EventHandlerList [set]
 
- Properties inherited from Asn1MessageBufferBase
Asn1Context Context [get]
 
virtual short TypeCode [set]
 

Detailed Description

This class handles the decoding of ASN.1 messages as specified in the Basic Encoding Rules (BER) as documented in the ITU-T X.690 standard.

Constructor & Destructor Documentation

◆ Asn1BerDecodeBuffer() [1/2]

Asn1BerDecodeBuffer ( byte []  msgdata)

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

Parameters
msgdataByte array containing an encoded ASN.1 message.

◆ Asn1BerDecodeBuffer() [2/2]

Asn1BerDecodeBuffer ( System.IO.Stream  istream)

This constructor creates a BER 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
istreamInput stream containing an encoded ASN.1 message.

Member Function Documentation

◆ CalcIndefLen()

static int CalcIndefLen ( byte []  data,
int  offset,
int  len 
)
static

This function calculates the actual length of an indefinite length message component.

Parameters
dataBuffer with the indefinite length message component.
offsetThe start offset in the array
lenLength of the buffer (begining from the offset)
Returns
calculated length

References Asn1DecodeBuffer.ByteCount, Asn1BerDecodeBuffer.DecodeTagAndLength(), Asn1Status.INDEFLEN, Asn1Tag.IsEOC(), and Asn1DecodeBuffer.Skip().

◆ DecodeEnumValue() [1/2]

int DecodeEnumValue ( bool  explicitTagging,
int  implicitLength 
)

This method decodes an enumerated value from the buffer.

Parameters
explicitTaggingA flag that indicates the element is explicitly tagged.
Parameters
implicitLengthThe length of the contents if implicitly tagged.
Returns
The decoded integer value.

References Asn1Type.ENUMERATED, IntHolder.mValue, Asn1Tag.PRIM, and Asn1Tag.UNIV.

◆ DecodeEnumValue() [2/2]

int DecodeEnumValue ( Asn1Tag  tag,
bool  explicitTagging,
int  implicitLength 
)

This method decodes an enumerated value from the buffer.

Parameters
tagAn Asn1Tag value for enumerated values that are tagged other than UNIVERSAL 10.
Parameters
explicitTaggingA flag that indicates the element is explicitly tagged.
Parameters
implicitLengthThe length of the contents if implicitly tagged.
Returns
The decoded integer value.

References Asn1Tag.CONS, Asn1Type.ENUMERATED, Asn1Tag.mForm, and IntHolder.mValue.

◆ DecodeLength()

virtual int DecodeLength ( )
virtual

This method decodes a length value.

Returns
Decoded length value

References Asn1Status.INDEFLEN, Asn1Tag.L7BitsMask, and Diag.Prtln().

◆ DecodeOpenType() [1/2]

virtual byte [] DecodeOpenType ( )
virtual

This method decodes an ASN.1 BER open type value. This is a fully encoded message component of any type. The component is captured in the Decode capture buffer and a reference to a byte array is returned containing the component.

Returns
Reference to byte array containing component.

Referenced by Asn1OpenType.GetDataEncoding().

◆ DecodeOpenType() [2/2]

virtual byte [] DecodeOpenType ( bool  saveData)
virtual

This method decodes an ASN.1 BER open type value. This is a fully encoded message component of any type. This version of the method allows the option of saving or discarding the open type data.

Parameters
saveDataTrue if data should be captured and returned
Returns
Reference to byte array containing component.

References Asn1Status.INDEFLEN, Asn1Tag.IsEOC(), and IntHolder.mValue.

◆ DecodeTag()

virtual void DecodeTag ( Asn1Tag  tag)
virtual

This method decodes a tag value.

Parameters
tagTag object to receive decoded tag fields.
Returns
status value (see Asn1Status.java)

References Asn1Tag.Bit8Mask, Asn1Tag.ClassMask, Asn1Tag.EXTIDCODE, Asn1Tag.FormMask, Asn1Tag.IDMask, Asn1Tag.L7BitsMask, Asn1Tag.mClass, Asn1Tag.mForm, Asn1Tag.mIDCode, Diag.Prtln(), and Asn1Tag.ToString().

◆ DecodeTagAndLength()

virtual int DecodeTagAndLength ( Asn1Tag  tag)
virtual

This method decodes a tag and length value.

Parameters
tagTag object to receive decoded tag fields.
Returns
Decoded length value.

Referenced by Asn1BerDecodeBuffer.CalcIndefLen().

◆ MatchTag() [1/3]

virtual bool MatchTag ( short  tagClass,
short  tagForm,
int  tagIDCode,
Asn1Tag  parsedTag,
IntHolder  parsedLen 
)
virtual

This method decodes the next tag value and checks for a match with the given tag value. If the match is successful, the Decode cursor will be psoitioned at the contents field; otherwise, it will be reset to point to the start of the tag field.

Parameters
tagClassClass value of tag to match
tagFormForm value of tag to match
tagIDCodeID code of tag to match
parsedTagHolder object to receive parsed tag value
parsedLenHolder object to receive parsed length value
Returns
True if given tag matches tag at Decode cursor

References Asn1Tag.Equals(), and IntHolder.mValue.

Referenced by Asn1Type._SetLicLocation(), Asn1BerDecodeContext.Expired(), and Asn1BerDecodeContext.MatchElemTag().

◆ MatchTag() [2/3]

virtual bool MatchTag ( Asn1Tag  tag,
Asn1Tag  parsedTag,
IntHolder  parsedLen 
)
virtual

This overloaded version of MatchTag allows the tag value to be matched to be passed using an Asn1Tag object.

Parameters
tagTag value to be matched.
parsedTagHolder object to receive parsed tag value
parsedLenHolder object to receive parsed length value
Returns
True if given tag matches tag at Decode cursor

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

◆ MatchTag() [3/3]

virtual bool MatchTag ( Asn1Tag  tag)
virtual

This overloaded version of MatchTag will just test for a match and not return parsed tag and length values

Parameters
tagTag value to be matched.
Returns
True if given tag matches tag at Decode cursor

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

◆ Parse()

virtual void Parse ( Asn1TaggedEventHandler  handler)
virtual

This method parses the complete message and invokes the event handler callback methods as various items are encountered.

Parameters
handlerObject implementing the Asn1EventHandler interface.
Returns
Status value

References Asn1Tag.Constructed, Asn1TaggedEventHandler.Contents(), Asn1TaggedEventHandler.EndElement(), Asn1Status.INDEFLEN, Asn1Tag.IsEOC(), IntHolder.mValue, and Asn1TaggedEventHandler.StartElement().

Referenced by Asn1BerEncodeBuffer.EncodeTagAndLength().

◆ PeekTag() [1/2]

virtual void PeekTag ( Asn1Tag  parsedTag)
virtual

This method will Parse and return the next tag in the Decode stream without advancing the Decode cursor.

Parameters
parsedTagHolder object to receive parsed tag value

◆ PeekTag() [2/2]

virtual Asn1Tag PeekTag ( )
virtual

This overloaded version of the PeekTag method will return a reference to a newly created tag object.

Returns
Parsed tag object value reference

◆ ReadByte()

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.

Property Documentation

◆ LastTag

virtual Asn1Tag LastTag
get

Gets the last tag parsed within this decode buffer object.

Value: Last parsed tag object reference

Referenced by Asn1BitString.Clear(), Asn1OctetString.CompareTo(), Asn1BMPString.Decode(), Asn1UniversalString.Decode(), and Asn1CharString.validate().