Asn1OctetString Class Reference

Inheritance diagram for Asn1OctetString:
Asn1Type Asn1TypeIF Asn1Base64BinaryString Asn1OpenType Asn1XerBase64OctetString Asn1ChoiceExt Asn1XerOpenType

List of all members.

Public Member Functions

 Asn1OctetString (System.String value)
 Asn1OctetString (byte[] data, int offset, int nbytes)
 Asn1OctetString (byte[] data)
 Asn1OctetString ()
virtual int CompareTo (System.Object octstr)
void Decode (Asn1MderDecodeBuffer buffer, int constrainedLength)
virtual void Decode (Asn1MderDecodeBuffer buffer)
virtual void Decode (Asn1PerDecodeBuffer buffer, long lower, long upper)
override void Decode (Asn1PerDecodeBuffer buffer)
override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
virtual void DecodeXER (System.String buffer, System.String attrs)
override void DecodeXML (System.String buffer, System.String attrs)
virtual void Encode (Asn1PerOutputStream outs, long lower, long upper)
override void Encode (Asn1PerOutputStream outs)
override void Encode (Asn1BerOutputStream outs, bool explicitTagging)
override void Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix)
override void Encode (Asn1XerEncoder buffer, System.String elemName)
void Encode (Asn1MderOutputStream outs, int constrainedLength)
virtual void Encode (Asn1MderOutputStream outs)
virtual void Encode (Asn1PerEncodeBuffer buffer, long lower, long upper)
override void Encode (Asn1PerEncodeBuffer buffer)
override int Encode (Asn1BerEncodeBuffer buffer, bool explicitTagging)
override void EncodeAttribute (Asn1XmlEncoder buffer, System.String attrName)
override bool Equals (System.Object value)
bool Equals (byte[] value)
override int GetHashCode ()
int GetMderLength ()
virtual System.IO.Stream toInputStream ()
override System.String ToString ()

Public Attributes

byte[] mValue

Static Public Attributes

static new readonly Asn1Tag _TAG

Properties

override int Length [get]

Detailed Description

This is a container class for holding the components of an ASN.1 octet string value.


Constructor & Destructor Documentation

Asn1OctetString (  ) 

This constructor creates an empty octet string that can be used in a Decode method call to receive an octet string value.

Asn1OctetString ( byte[]  data  ) 

This constructor initializes an octet string from the given byte array.

Parameters:
data Byte array containing an octet string in binary form.
Asn1OctetString ( byte[]  data,
int  offset,
int  nbytes 
)

This constructor initializes an octet string from a portion of the given byte array. A new byte array is created starting at the given offset and consisting of the given number of bytes.

Parameters:
data Byte array containing an octet string in binary form.
offset The offset in array at which to begin copy.
nbytes Number of bytes to copy from target array
Asn1OctetString ( System.String  value  ) 

This constructor parses the given ASN.1 value text (either a binary or hex data string) and assigns the values to the internal bit string.

Examples of valid value formats are as follows:

Binary string: '11010010111001'B

Hex string: '0fa56920014abc'H

Char string: 'abcdefg'

Parameters:
value The ASN.1 value specification text

Member Function Documentation

virtual int CompareTo ( System.Object  octstr  )  [virtual]

This method compares two Asn1OctetString objects for equality. The OCTET STRING's are equal if a) all octets are equal, and b) the lengths are the same.

This method is required to implement the Comparable interface used for sorting.

Parameters:
octstr Asn1OctetString to compare
Returns:
0 if equal, 1 if this string is greater than supplied string, -1 if this string is less than supplied string.
void Decode ( Asn1MderDecodeBuffer  buffer,
int  constrainedLength 
)

Decode an octet string from the MDER encoding into this object.

Parameters:
constrainedLength The constrained length of the type being encoded. Pass -1 if the type is unconstrained. For a constrained length octet string, exactly that many octets will be read.
virtual void Decode ( Asn1MderDecodeBuffer  buffer  )  [virtual]

Decode an unconstrained octet string from the MDER encoding into this object.

virtual void Decode ( Asn1PerDecodeBuffer  buffer,
long  lower,
long  upper 
) [virtual]

This method decodes a sized ASN.1 octet string value using the packed encoding rules (PER).

Parameters:
buffer Decode message buffer object
lower Lower bound (inclusive) of size constraint
upper Upper bound (inclusive) of size constraint
override void Decode ( Asn1PerDecodeBuffer  buffer  )  [virtual]

This method decodes an ASN.1 octet string value using the packed encoding rules (PER). The string is assumed to not contain a size constraint.

Parameters:
buffer Decode message buffer object

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, and Asn1XerOpenType.

override void Decode ( Asn1BerDecodeBuffer  buffer,
bool  explicitTagging,
int  implicitLength 
) [virtual]

This method decodes an ASN.1 octet string value including the UNIVERSAL tag value and length if explicit tagging is specified.

Parameters:
buffer Decode message buffer object
explicitTagging Flag indicating element is explicitly tagged
implicitLength Length of contents if implicit

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, Asn1OpenType, and Asn1XerOpenType.

virtual void DecodeXER ( System.String  buffer,
System.String  attrs 
) [virtual]

This method decodes ASN.1 octet string type using the XML encoding rules (XER).

Parameters:
buffer String containing data to be decoded
attrs Attributes string from element tag

Reimplemented in Asn1XerBase64OctetString.

override void DecodeXML ( System.String  buffer,
System.String  attrs 
)

This method decodes an ASN.1 octet string type using the XML schema encoding rules(asn2xsd).

Parameters:
buffer String containing data to be decoded
attrs Attributes string from element tag

Reimplemented in Asn1XerBase64OctetString.

virtual void Encode ( Asn1PerOutputStream  outs,
long  lower,
long  upper 
) [virtual]

This method encodes a size-constrained ASN.1 octet string value using the packed encoding rules (PER). The value to be encoded is stored in the 'mValue' public member variable within this class.

Also throws any exception thrown by the underlying Asn1PerOutputStream.

Parameters:
outs PER Output Stream object
lower Lower bound (inclusive) of size constraint
upper Upper bound (inclusive) of size constraint
Exceptions:
Asn1Exception Thrown, if operation is failed.
override void Encode ( Asn1PerOutputStream  outs  )  [virtual]

This method encodes an unconstrained ASN.1 octet string value using the packed encoding rules (PER). The value to be encoded is stored in the 'mValue' public member variable within this class.

Also throws any exception thrown by the underlying Asn1PerOutputStream.

Parameters:
outs PER Output Stream object
Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, and Asn1OpenType.

override void Encode ( Asn1BerOutputStream  outs,
bool  explicitTagging 
) [virtual]

This method encodes and writes to the stream an ASN.1 octet string value including the UNIVERSAL tag value and length if explicit tagging is specified. This overloaded version uses the Basic Encoding Rules (BER).

Throws, Exception thrown by C# System.IO.Stream for I/O error

Parameters:
outs BER Output Stream object
explicitTagging Flag indicating explicit tagging should be done
Exceptions:
Asn1Exception Thrown, if operation is failed.

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, and Asn1OpenType.

override void Encode ( Asn1XmlEncoder  buffer,
System.String  elemName,
System.String  nsPrefix 
) [virtual]

This method encodes ASN.1 octet string type using the XML Encoding as specified in the XML schema standard(asn2xsd).

Parameters:
buffer Encode message buffer object
elemName XML element name used to wrap string
nsPrefix Element namespace value

Reimplemented from Asn1Type.

Reimplemented in Asn1Base64BinaryString, Asn1XerBase64OctetString, and Asn1XerOpenType.

override void Encode ( Asn1XerEncoder  buffer,
System.String  elemName 
) [virtual]

This method encodes ASN.1 octet string type using the XML encoding rules (XER).

Parameters:
buffer Encode message buffer object
elemName XML element name used to wrap string

Reimplemented from Asn1Type.

Reimplemented in Asn1XerBase64OctetString, and Asn1XerOpenType.

void Encode ( Asn1MderOutputStream  outs,
int  constrainedLength 
)

Encode this octet string into the MDER encoding.

Parameters:
constrainedLength The constrained length of the type being encoded. Pass -1 if the type is unconstrained.
Exceptions:
Asn1ConsVioException if a constrained length is given and the value is not exactly that length.
Asn1MderUnsupported if the length is unconstrained and the actual length > 65535 (maximum allowed by MDER).
virtual void Encode ( Asn1MderOutputStream  outs  )  [virtual]

Encode this octet string into the MDER encoding. This should be used for octet string types that are not of fixed length.

Exceptions:
Asn1MderUnsupported if the actual length > 65535 (maximum allowed by MDER).
virtual void Encode ( Asn1PerEncodeBuffer  buffer,
long  lower,
long  upper 
) [virtual]

This method encodes a size-constrained ASN.1 octet string value using the packed encoding rules (PER). The value to be encoded is stored in the 'mValue' public member variable within this class.

Parameters:
buffer Encode message buffer object
lower Lower bound (inclusive) of size constraint
upper Upper bound (inclusive) of size constraint
override void Encode ( Asn1PerEncodeBuffer  buffer  )  [virtual]

This method encodes an unconstrained ASN.1 octet string value using the packed encoding rules (PER). The value to be encoded is stored in the 'mValue' public member variable within this class.

Parameters:
buffer Encode message buffer object

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, and Asn1OpenType.

override int Encode ( Asn1BerEncodeBuffer  buffer,
bool  explicitTagging 
) [virtual]

This method encodes an ASN.1 octet string value including the UNIVERSAL tag value and length if explicit tagging is specified.

Parameters:
buffer Encode message buffer object
explicitTagging Flag indicating explicit tagging should be done
Returns:
Length of encoded component

Reimplemented from Asn1Type.

Reimplemented in Asn1ChoiceExt, Asn1OpenType, and Asn1XerOpenType.

override void EncodeAttribute ( Asn1XmlEncoder  buffer,
System.String  attrName 
) [virtual]

This method encodes ASN.1 octet string type using the XML Encoding as specified in the XML schema standard(asn2xsd).

Parameters:
buffer Encode message buffer object
elemName XML element name used to wrap string
attribute Element attribute value

Reimplemented from Asn1Type.

Reimplemented in Asn1Base64BinaryString.

override bool Equals ( System.Object  value  ) 

This method compares this octet string value to the given value for equality.

Parameters:
value The Object to compare with the current Object. Object should be instance of Asn1OctetString.
Returns:
true if the specified Object is equal to the current Object; otherwise, false.
bool Equals ( byte[]  value  ) 

This method compares this octet string value to the given value for equality.

Parameters:
value The byte array to compare with the current Object.
Returns:
true if the specified byte array is equal to the current Object; otherwise, false.
override int GetHashCode (  ) 

Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.

Returns:
A hash code for the current Object.
int GetMderLength (  ) 

Return the length of the MDER encoding for this type, assuming that the type is NOT a fixed length OCTET STRING (if it is fixed length, you need not call this method!).

virtual System.IO.Stream toInputStream (  )  [virtual]

This method will return a byte array input stream representation of the octet string value.

Returns:
Reference to System.IO.MemoryStream object
override System.String ToString (  ) 

This method will return a string representation of the octet string value. The format is the ASN.1 value format for this type..

Returns:
Stringified representation of the value

Reimplemented in Asn1Base64BinaryString, Asn1OpenType, and Asn1XerOpenType.


Member Data Documentation

new readonly Asn1Tag _TAG [static]

The _TAG constant describes the universal tag for this data type (UNIVERSAL 4).

Reimplemented from Asn1Type.

byte [] mValue

This variable holds the octet string value. These are the octets that are encoded when encode is invoked. It is also where the decoded octet string is stored after a Decode operation.


Property Documentation

override int Length [get]

Gets the length of the OCTET STRING in octets.

Value: length of the octet string

Reimplemented from Asn1Type.