ASN1C C# Runtime Library  7.8
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Asn1OctetString Class Reference
Inheritance diagram for Asn1OctetString:
Asn1Type Asn1TypeIF Asn1Base64BinaryString Asn1BCDString Asn1OpenType Asn1TBCDString Asn1ChoiceExt Asn1XerOpenType

Public Member Functions

 Asn1OctetString ()
 
 Asn1OctetString (byte[] data)
 
 Asn1OctetString (byte[] data, int offset, int nbytes)
 
 Asn1OctetString (System.String value)
 
virtual int CompareTo (System.Object octstr)
 
override void Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
 
override void Decode (Asn1PerDecodeBuffer buffer)
 
virtual void Decode (Asn1PerDecodeBuffer buffer, long lower, long upper)
 
override void Decode (Asn1OerDecodeBuffer buffer)
 
override void Decode (Asn1MderDecodeBuffer buffer)
 
void Decode (Asn1MderDecodeBuffer buffer, int constrainedLength)
 
void DecodeContent (Asn1OerDecodeBuffer buffer, int numOctets)
 
virtual void DecodeXER (System.String buffer, System.String attrs, bool base64)
 
override void DecodeXML (System.String buffer, System.String attrs)
 
override int Encode (Asn1BerEncodeBuffer buffer, bool explicitTagging)
 
override void Encode (Asn1PerEncodeBuffer buffer)
 
virtual void Encode (Asn1PerEncodeBuffer buffer, long lower, long upper)
 
override void Encode (Asn1OerEncodeBuffer buffer)
 
override void Encode (Asn1MderOutputStream outs)
 
void Encode (Asn1MderOutputStream outs, int constrainedLength)
 
override void Encode (Asn1XerEncoder buffer, System.String elemName)
 
override void Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix)
 
virtual void Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix, bool base64)
 
override void Encode (Asn1BerOutputStream outs, bool explicitTagging)
 
override void Encode (Asn1PerOutputStream outs)
 
virtual void Encode (Asn1PerOutputStream outs, long lower, long upper)
 
override void EncodeAttribute (Asn1XmlEncoder buffer, System.String attrName)
 
void EncodeContent (Asn1OerEncodeBuffer buffer)
 
bool Equals (byte[] value)
 
bool Equals (String s)
 
override bool Equals (System.Object value)
 
override int GetHashCode ()
 
int GetMderLength ()
 
virtual System.IO.Stream toInputStream ()
 
override System.String ToString ()
 
- Public Member Functions inherited from Asn1Type
void _SetKey (byte[] rtkey)
 
virtual void Decode (Asn1BerDecodeBuffer buffer)
 
virtual void Decode (System.Object reader, System.String xmlURI)
 
virtual void Decode (System.Object reader, System.IO.Stream byteStream)
 
virtual void DecodeXML (String buffer, String attrs)
 
virtual int Encode (Asn1BerEncodeBuffer buffer)
 
virtual void Encode (Asn1XerEncoder buffer)
 
virtual void Encode (Asn1XmlEncoder buffer)
 
virtual void Encode (Asn1XmlEncodeBuffer buffer)
 
virtual void Encode (Asn1MderOutputStream buffer, bool useCachedLength)
 
virtual void Encode (Asn1CerOutputStream outs, bool explicitTagging)
 
void EncodeAsOpenType (Asn1OerEncodeBuffer buffer)
 
virtual bool Equals (Asn1Type obj)
 
String GetNonParameterizedTypeName ()
 
virtual void Indent (System.IO.TextWriter outs, int level)
 
virtual bool IsOpenType ()
 
virtual bool MatchTypeName (System.String typeName)
 
virtual void Pdiag (System.String s)
 
virtual void Print (System.IO.TextWriter outs, System.String varName, int level)
 
virtual void Print (System.String varName)
 
void SetNonParameterizedTypeName (String value)
 
virtual void SetOpenType ()
 

Static Public Member Functions

static System.String EncodeBase64Binary (byte[] data)
 
static void Skip (Asn1PerDecodeBuffer buffer)
 
static void Skip (Asn1PerDecodeBuffer buffer, long lower, long upper)
 
- Static Public Member Functions inherited from Asn1Type
static void _SetKey2 (byte[] rtkey)
 
static void _SetLicLocation (String path)
 
static Asn1Type Decode (Asn1BerDecodeBuffer buffer, Asn1OpenTypeField openTypeField, bool explicitTag, int implicitLength)
 
static Asn1Type Decode (Asn1OerDecodeBuffer buffer, Asn1OpenTypeField openTypeField)
 
static Asn1Type Decode (Asn1PerDecodeBuffer buffer, Asn1OpenTypeField openTypeField)
 
static System.String GetTypeName (short typeCode)
 

Public Attributes

byte [] mValue
 
- Public Attributes inherited from Asn1Type
const short BIT_STRING = 3
 
const short BMPString = 30
 
const short BOOLEAN = 1
 
const short DATE = 31
 
const short ENUMERATED = 10
 
const short EOC = 0
 
const short EXTERNAL = 8
 
const short GeneralString = 27
 
const short GeneralTime = 24
 
const short GraphicString = 25
 
const short IA5String = 22
 
const short INTEGER = 2
 
const short NULL = 5
 
const short NumericString = 18
 
const short OBJECT_IDENTIFIER = 6
 
const short ObjectDescriptor = 7
 
const short OCTET_STRING = 4
 
const short OpenType = 99
 
const short PrintableString = 19
 
const short REAL = 9
 
const short RELATIVE_OID_IRI = 36
 
const short RelativeOID = 13
 
const short SEQUENCE = 16
 
const short SET = 17
 
const short T61String = TeletexString
 
const short TeletexString = 20
 
const short TIME = 14
 
const short UniversalString = 28
 
const short UTCTime = 23
 
const short UTF8String = 12
 
const short VideotexString = 21
 
const short VisibleString = 26
 

Static Public Attributes

static new readonly Asn1Tag _TAG
 
- Static Public Attributes inherited from Asn1Type
static readonly Asn1Tag _TAG
 

Properties

override int Length [get]
 
- Properties inherited from Asn1Type
virtual String AsnTypeName [get]
 
virtual 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() [1/4]

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

◆ Asn1OctetString() [2/4]

Asn1OctetString ( byte []  data)

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

Parameters
dataByte array containing an octet string in binary form.

◆ Asn1OctetString() [3/4]

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
dataByte array containing an octet string in binary form.
offsetThe offset in array at which to begin copy.
nbytesNumber of bytes to copy from target array

◆ Asn1OctetString() [4/4]

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
valueThe ASN.1 value specification text

References Asn1Value.ParseString().

Member Function Documentation

◆ CompareTo()

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
octstrAsn1OctetString to compare
Returns
0 if equal, 1 if this string is greater than supplied string, -1 if this string is less than supplied string.

References Asn1PerDecodeBuffer.ByteAlign(), Asn1Tag.Constructed, Asn1EncodeBuffer.Copy(), Asn1PerDecodeBuffer.DecodeBitsToOctetArray(), Asn1PerDecodeBuffer.DecodeLength(), Asn1BerEncodeBuffer.EncodeTagAndLength(), Asn1Tag.EOC, Asn1BerDecodeContext.Expired(), Asn1Status.INDEFLEN, Asn1BerDecodeBuffer.LastTag, Asn1Type.OCTET_STRING, Diag.Prtln(), Asn1DecodeBuffer.Read(), and Asn1MessageBufferBase.TypeCode.

◆ Decode() [1/6]

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
bufferDecode message buffer object
explicitTaggingFlag indicating element is explicitly tagged
implicitLengthLength of contents if implicit

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

Referenced by Asn1UTF8String.Asn1UTF8String(), and Asn1OctetString.Decode().

◆ Decode() [2/6]

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
bufferDecode message buffer object

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

◆ Decode() [3/6]

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
bufferDecode message buffer object
lowerLower bound (inclusive) of size constraint
upperUpper bound (inclusive) of size constraint

References Asn1PerDecodeBuffer.ByteAlign(), Asn1OctetString.Decode(), Asn1PerDecodeBuffer.DecodeBitsToOctetArray(), Asn1PerDecodeBuffer.DecodeLength(), Asn1OctetString.mValue, Asn1Type.OCTET_STRING, and Asn1MessageBufferBase.TypeCode.

◆ Decode() [4/6]

override void Decode ( Asn1OerDecodeBuffer  buffer)
virtual

This method decodes an ASN.1 octet string using the Octet Encoding Rules (OER).

This implementation expects a length determinant in the encoding. This method may be overridden for ASN.1 types that have a fixed length to invoke DecodeContent with the predetermined length.

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

References Asn1OerDecodeBuffer.DecodeLength().

◆ Decode() [5/6]

override void Decode ( Asn1MderDecodeBuffer  buffer)
virtual

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

Reimplemented from Asn1Type.

◆ Decode() [6/6]

void Decode ( Asn1MderDecodeBuffer  buffer,
int  constrainedLength 
)

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

Parameters
constrainedLengthThe 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.

References Asn1DecodeBuffer.Read(), and Asn1DecodeBuffer.Read2Bytes().

◆ DecodeContent()

void DecodeContent ( Asn1OerDecodeBuffer  buffer,
int  numOctets 
)

This method decodes an ASN.1 OCTET STRING's content that was encoded according to OER, given the total number of octets. This does not decode a length determinant.

Parameters
bufferDecode message buffer object
numOctetsTotal number of octets encoding the content.

◆ DecodeXER()

virtual void DecodeXER ( System.String  buffer,
System.String  attrs,
bool  base64 
)
virtual

This method decodes ASN.1 octet string type using the XML encoding rules (XER). Extended-XER is supported by the base64

Parameters
bufferString containing data to be decoded
attrsAttributes string from element tag
base64pass true if encoding is base64 (extended-XER only)

References Asn1Util.DecodeBase64Array().

◆ DecodeXML()

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
bufferString containing data to be decoded
attrsAttributes string from element tag

References Asn1Util.DecodeBase64Array().

◆ Encode() [1/12]

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
bufferEncode message buffer object
explicitTaggingFlag indicating explicit tagging should be done
Returns
Length of encoded component

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

◆ Encode() [2/12]

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
bufferEncode message buffer object

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

References Asn1PerEncodeBuffer.EncodeOctetString().

◆ Encode() [3/12]

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
bufferEncode message buffer object
lowerLower bound (inclusive) of size constraint
upperUpper bound (inclusive) of size constraint

References Asn1PerEncodeBuffer.ByteAlign(), Asn1PerEncodeBuffer.EncodeBits(), Asn1PerEncodeBuffer.EncodeLength(), Asn1PerEncodeBuffer.EncodeOctetString(), Asn1DecodeBuffer.Read(), and Asn1MessageBufferBase.TypeCode.

◆ Encode() [4/12]

override void Encode ( Asn1OerEncodeBuffer  buffer)
virtual

This method encodes this ASN.1 OCTET STRING value, according to OER. This encodes the length determinant, assuming that the OCTET STRING is not fixed-size constrained. Subclasses may override this to simply call EncodeContent for fixed-size constrained strings.

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

References Asn1OerEncodeBuffer.EncodeLength().

◆ Encode() [5/12]

override 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
Asn1MderUnsupportedif the actual length > 65535 (maximum allowed by MDER).

Reimplemented from Asn1Type.

◆ Encode() [6/12]

void Encode ( Asn1MderOutputStream  outs,
int  constrainedLength 
)

Encode this octet string into the MDER encoding.

Parameters
constrainedLengthThe constrained length of the type being encoded. Pass -1 if the type is unconstrained.
Exceptions
Asn1ConsVioExceptionif a constrained length is given and the value is not exactly that length.
Asn1MderUnsupportedif the length is unconstrained and the actual length > 65535 (maximum allowed by MDER).

References Asn1XerEncoder.EncodeEmptyElement(), Asn1XerEncoder.EncodeEndElement(), Asn1XmlXerEncoder.EncodeHexStrValue(), Asn1XerEncoder.EncodeStartElement(), Asn1XmlXerEncoder.Indent(), Asn1OutputStream.Write(), and Asn1OutputStream.Write2Bytes().

◆ Encode() [7/12]

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

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

Parameters
bufferEncode message buffer object
elemNameXML element name used to wrap string

Reimplemented from Asn1Type.

◆ Encode() [8/12]

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

This method encodes ASN.1 octet string type as an xmlhstring.

Parameters
bufferEncode message buffer object
elemNameXML element name used to wrap string
nsPrefixElement namespace value

Reimplemented from Asn1Type.

◆ Encode() [9/12]

virtual void Encode ( Asn1XmlEncoder  buffer,
System.String  elemName,
System.String  nsPrefix,
bool  base64 
)
virtual

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

Parameters
bufferEncode message buffer object
elemNameXML element name used to wrap string
nsPrefixElement namespace value
base64Pass true to encode as base64 (extended-XER only, including XSD compilation)

References Asn1XmlXerEncoder.Copy(), Asn1XmlEncoder.EncodeEmptyElement(), Asn1XmlEncoder.EncodeEndElement(), Asn1XmlXerEncoder.EncodeHexStrValue(), Asn1XmlEncoder.EncodeStartElement(), and Asn1XmlXerEncoder.Indent().

◆ Encode() [10/12]

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
outsBER Output Stream object
explicitTaggingFlag indicating explicit tagging should be done
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

◆ Encode() [11/12]

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
outsPER Output Stream object
Exceptions
Asn1ExceptionThrown, if operation is failed.

Reimplemented from Asn1Type.

Reimplemented in Asn1OpenType.

◆ Encode() [12/12]

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
outsPER Output Stream object
lowerLower bound (inclusive) of size constraint
upperUpper bound (inclusive) of size constraint
Exceptions
Asn1ExceptionThrown, if operation is failed.

◆ EncodeAttribute()

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
bufferEncode message buffer object
elemNameXML element name used to wrap string
attributeElement attribute value

Reimplemented from Asn1Type.

References Asn1XmlXerEncoder.Copy().

◆ EncodeBase64Binary()

static System.String EncodeBase64Binary ( byte []  data)
static

Encodes xsd:Base64Binary data into ASCII character using the algorithm defined in RFC2045, as defined in w3c stadard http://www.w3.org/tr/2001/rec-xmlschema-2-20010502#base64Binary

Parameters
base64binaryArray containing base64binary
Returns
Encoded ASCII string

References Asn1Tag.PRIM, and Asn1Tag.UNIV.

Referenced by Asn1XmlEncodeBuffer.EncodeXSIAttrs().

◆ EncodeContent()

void EncodeContent ( Asn1OerEncodeBuffer  buffer)

This method encodes the content of an ASN.1 OCTET STRING, according to OER. (The length determinant is not encoded.)

Parameters
bufferEncode message buffer object

References Asn1EncodeBuffer.Copy().

◆ Equals() [1/3]

bool Equals ( byte []  value)

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

Parameters
valueThe byte array to compare with the current Object.
Returns
true if the specified byte array is equal to the current Object; otherwise, false.

◆ Equals() [2/3]

bool Equals ( String  s)

This method compares the given ASN.1 OCTET STRING value to this OCTET STRING value for equality.

Parameters
valueThe ASN.1 OCTET STRING value to compare with the current Object. Examples of valid value formats are as follows: Binary string: '11010010111001'B Hex string: '0fa56920014abc'H
Returns
true if the specified value is equal to this value; otherwise, false.

References Asn1Value.StringEqualsBytes().

◆ Equals() [3/3]

override bool Equals ( System.Object  value)

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

Parameters
valueThe 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.

References Asn1OctetString.mValue.

◆ GetHashCode()

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.

◆ GetMderLength()

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!).

◆ Skip() [1/2]

static void Skip ( Asn1PerDecodeBuffer  buffer)
static

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
bufferDecode message buffer object

References Asn1PerDecodeBuffer.ByteAlign(), Asn1PerDecodeBuffer.DecodeLength(), Asn1Type.OCTET_STRING, Diag.Prtln(), Asn1DecodeBitBuffer.SkipBits(), and Asn1MessageBufferBase.TypeCode.

◆ Skip() [2/2]

static void Skip ( Asn1PerDecodeBuffer  buffer,
long  lower,
long  upper 
)
static

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

Parameters
bufferDecode message buffer object
lowerLower bound (inclusive) of size constraint
upperUpper bound (inclusive) of size constraint

References Asn1PerDecodeBuffer.ByteAlign(), Asn1PerDecodeBuffer.DecodeLength(), Asn1Type.OCTET_STRING, Asn1DecodeBitBuffer.SkipBits(), and Asn1MessageBufferBase.TypeCode.

◆ toInputStream()

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

◆ ToString()

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

References Asn1BerOutputStream.EncodeOctetString(), Asn1PerEncodeBuffer.EncodeOctetString(), and Asn1Util.ToHexString().

Member Data Documentation

◆ _TAG

new readonly Asn1Tag _TAG
static

◆ mValue

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.

Referenced by Asn1UTF8String.Asn1UTF8String(), Asn1OctetString.Decode(), Asn1OpenType.SaxHandler.EndElement(), and Asn1OctetString.Equals().

Property Documentation

◆ Length

override int Length
get

Gets the length of the OCTET STRING in octets.

Value: length of the octet string