ASN1C C# Runtime Library
7.6
|
Public Types | |
enum | StringFormat |
Public Member Functions | |
Asn1BitString () | |
Asn1BitString (int numbits_, byte[] data) | |
Asn1BitString (byte[] data) | |
Asn1BitString (bool[] bitValues) | |
Asn1BitString (System.String value_) | |
Asn1BitString (System.Collections.BitArray bitArray) | |
void | BaseDecode (Asn1PerDecodeBuffer buffer, long lower, long upper) |
virtual void | Clear (int bitno) |
override void | Decode (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength) |
override void | Decode (Asn1PerDecodeBuffer buffer) |
virtual void | Decode (Asn1PerDecodeBuffer buffer, long lower, long upper) |
void | Decode (Asn1MderDecodeBuffer buffer, int length) |
override void | Decode (Asn1OerDecodeBuffer buffer) |
void | DecodeContent (Asn1OerDecodeBuffer buffer, int numOctets, int unusedBits) |
virtual void | DecodeXER (System.String buffer, System.String attrs) |
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) |
void | Encode (Asn1MderOutputStream outs, int length) |
override void | Encode (Asn1OerEncodeBuffer buffer) |
override void | Encode (Asn1XerEncoder buffer, System.String elemName) |
virtual void | Encode (Asn1XerEncoder buffer, System.String elemName, System.String[] namedbits, int[] namedbitindex) |
virtual void | Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix, System.String[] namedbits, int[] namedbitindex) |
override void | Encode (Asn1XmlEncoder buffer, System.String elemName, System.String nsPrefix) |
override void | Encode (Asn1BerOutputStream outs, bool explicitTagging) |
override void | Encode (Asn1PerOutputStream outs) |
virtual void | Encode (Asn1PerOutputStream outs, long lower, long upper) |
void | EncodeContent (Asn1OerEncodeBuffer buffer) |
virtual bool | Equals (int nbits, byte[] value) |
override bool | Equals (System.Object value) |
virtual bool | Get (int bitno) |
override int | GetHashCode () |
virtual bool | IsNamedBitStr (System.String buffer) |
virtual void | Set (int bitno, bool value) |
virtual void | Set (int bitno) |
virtual bool [] | ToBoolArray () |
virtual System.String | ToHexString () |
virtual System.IO.Stream | toInputStream () |
override 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 | Decode (Asn1MderDecodeBuffer buffer) |
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) |
virtual void | Encode (Asn1MderOutputStream buffer, bool useCachedLength) |
virtual void | Encode (Asn1CerOutputStream outs, bool explicitTagging) |
void | EncodeAsOpenType (Asn1OerEncodeBuffer buffer) |
virtual void | EncodeAttribute (Asn1XmlEncoder buffer, System.String attrName) |
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 () |
Public Attributes | |
StringFormat | mStringFormat = StringFormat.HEXBIN |
byte [] | mValue |
int | numbits |
bool | trimZeroBits |
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 |
Protected Member Functions | |
void | BaseDecode (Asn1PerDecodeBuffer buffer) |
void | BaseEncode (Asn1PerEncodeBuffer buffer, long minEncLen) |
void | BaseEncode (Asn1PerEncodeBuffer buffer, long lower, long upper) |
virtual int | GetOerEffectiveMin () |
Properties | |
override int | Length [get] |
virtual bool | this[int bitno] [get, set] |
Properties inherited from Asn1Type | |
virtual String | AsnTypeName [get] |
virtual int | Length [get] |
Additional Inherited Members | |
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) |
This is a container class for holding the components of an ASN.1 bit string value.
|
strong |
Defines possible string formats.
The HEX
constant describes the string format as hex digit value (e.g. 0123456789ABCDEF).
The BITS
constant describes the string format as binary digit value (e.g. only 0 and 1 digits).
The ASN1VALUE
constant describes the string format as hex or binary digit value. The binary string value will end with letter 'B' and hex string value will end with letter 'H' (e.g. '0101'B or '11'H ). If the number of bits is less than or equal to 16, than it will be printed as Binary digits, else as Hex digits.
The NAMEDBITS
constant describes the string format as a list of bit position names (where applicable) followed by 1 or 0 in parentheses.
Asn1BitString | ( | ) |
This constructor creates an empty bit string that can be used in a Decode method call to receive a bit string value.
Asn1BitString | ( | int | numbits_, |
byte [] | data | ||
) |
This constructor initializes a bit string with the given number of bits and data.
numbits_ | Number of bits |
data | Binary bit string contents |
Asn1BitString | ( | byte [] | data | ) |
This constructor initializes a bit string with the given bytes, using all 8 bits of each byte.
data | Binary bit string contents |
Asn1BitString | ( | bool [] | bitValues | ) |
This constructor initializes a bit string from the given boolean array. Each array position corresponds to a bit in the bit string.
bitValues | The boolean array |
Asn1BitString | ( | 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
value_ | The ASN.1 value specification text |
References IntHolder.mValue, and Asn1Value.ParseString().
Asn1BitString | ( | System.Collections.BitArray | bitArray | ) |
This constructor initializes a bit string from the given BitSet object.
bitArray | C# BitArray object |
|
protected |
This method decodes an ASN.1 bit string value using the packed encoding rules (PER). The string is assumed to not contain a size constraint.
This method is guaranteed non-reentrant.
buffer | Decode message buffer object |
References Asn1Type.BIT_STRING, Asn1PerDecodeBuffer.ByteAlign(), Asn1PerDecodeBuffer.DecodeBitsToOctetArray(), Asn1PerDecodeBuffer.DecodeLength(), Diag.Prtln(), and Asn1MessageBufferBase.TypeCode.
void BaseDecode | ( | Asn1PerDecodeBuffer | buffer, |
long | lower, | ||
long | upper | ||
) |
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
This method is guaranteed non-reentrant.
buffer | Decode message buffer object |
lower | Lower bound (inclusive) of size constraint |
upper | Upper bound (inclusive) of size constraint |
References Asn1Type.BIT_STRING, Asn1PerDecodeBuffer.ByteAlign(), Asn1PerDecodeBuffer.DecodeBitsToOctetArray(), Asn1PerDecodeBuffer.DecodeLength(), and Asn1MessageBufferBase.TypeCode.
|
protected |
This method encodes the bit string as an unconstrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class. It does not trim trailing zeros. It will add trailing zeros if necessary, in accordance with minEncLen.
This method is guaranteed non-reentrant.
buffer | Encode message buffer object |
minEncLen | Minimum number of bits to encode. Trailing zero bits are added, if necessary. Pass 0 if no trailing zero bits should ever be added. |
References Asn1PerEncodeBuffer.ByteAlign(), Asn1PerEncodeBuffer.EncodeBits(), Asn1PerEncodeBuffer.EncodeLength(), and Asn1PerEncodeBuffer.EncodeLengthEOM().
|
protected |
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class.
This method is guaranteed non-reentrant.
buffer | Encode message buffer object |
lower | Lower bound (inclusive) of size constraint |
upper | Upper bound (inclusive) of size constraint |
References Asn1PerEncodeBuffer.ByteAlign(), Asn1PerEncodeBuffer.EncodeBits(), and Asn1PerEncodeBuffer.EncodeLength().
|
virtual |
This method clears the given bit in the bit string.
bitno | The zero-based index of the bit to clear. The bit numbers start at zero and with the MSB of the first byte and progress from left to right. |
References Asn1Type.BIT_STRING, Asn1Tag.Constructed, Asn1EncodeBuffer.Copy(), Asn1BerEncodeBuffer.EncodeTagAndLength(), Asn1Tag.EOC, Asn1BerDecodeContext.Expired(), Asn1Status.INDEFLEN, Asn1BerDecodeBuffer.LastTag, Asn1DecodeBuffer.Read(), and Asn1MessageBufferBase.TypeCode.
|
virtual |
This method decodes an ASN.1 bit string value using the BER or DER encoding rules. The UNIVERSAL tag value and length are decoded if explicit tagging is specified.
buffer | Decode message buffer object |
explicitTagging | Flag indicating element is explicitly tagged |
implicitLength | Length of contents if implicit |
Reimplemented from Asn1Type.
|
virtual |
This method decodes an ASN.1 bit string value using the packed encoding rules (PER). The string is assumed to not contain a size constraint.
buffer | Decode message buffer object |
Reimplemented from Asn1Type.
|
virtual |
This method decodes a sized ASN.1 bit string value using the packed encoding rules (PER).
buffer | Decode message buffer object |
lower | Lower bound (inclusive) of size constraint |
upper | Upper bound (inclusive) of size constraint |
void Decode | ( | Asn1MderDecodeBuffer | buffer, |
int | length | ||
) |
Decode a BIT STRING from the MDER encoding into this object. Exactly the given length of bits will be decoded.
length | This should be 8, 16, or 32, as these are the only lengths MDER supports. However, this is not checked here as it should be able to be checked at code generation time. |
References Asn1DecodeBuffer.Read().
|
virtual |
This method decodes an ASN.1 BIT STRING that was encoded according to OER.
This assumes the BIT STRING was not fixed-size constrained, so that the length and unused bits are in the encoding. Subclasses can override this method to simply call DecodeContent for fixed-size constrained BIT STRINGs.
buffer | Decode message buffer object |
Reimplemented from Asn1Type.
References Asn1OerDecodeBuffer.DecodeIntUnsigned(), Asn1OerDecodeBuffer.DecodeLength(), and Asn1OerDecodeBuffer.GetCanonicalMode().
void DecodeContent | ( | Asn1OerDecodeBuffer | buffer, |
int | numOctets, | ||
int | unusedBits | ||
) |
<summmary> This method decodes an ASN.1 BIT STRING's content that was encoded according to OER, given the total number of octets and the number of unused bits in the last octet.
</summmary>
buffer | Decode message buffer object |
numOctets | Total number of octets encoding the content, including the final, partial octet (if unusedBits > 0). |
unusedBits | # of unused bits in last octet. |
|
virtual |
This method decodes ASN.1 bit string type using the XML encoding rules (XER).
buffer | String containing data to be decoded |
attrs | Attributes string from element tag |
References Asn1XmlXerEncoder.Copy(), Asn1XmlXerEncoder.EncodeBinStrValue(), Asn1XmlEncoder.EncodeEmptyElement(), Asn1XmlEncoder.EncodeEndElement(), Asn1XmlXerEncoder.EncodeNamedValueElement(), Asn1XmlEncoder.EncodeStartElement(), and Asn1XmlXerEncoder.Indent().
override void DecodeXML | ( | System.String | buffer, |
System.String | attrs | ||
) |
This method decodes ASN.1 bit string type using the XML decoding as specified in the XML Schema standard.
buffer | String containing data to be decoded |
attrs | Attributes string from element tag |
|
virtual |
This method encodes an ASN.1 bit string value using the BER or DER encoding rules. The UNIVERSAL tag value and length are encoded if explicit tagging is specified.
buffer | Encode message buffer object |
explicitTagging | Flag indicating explicit tagging should be done |
Reimplemented from Asn1Type.
|
virtual |
This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class.
buffer | Encode message buffer object |
Reimplemented from Asn1Type.
|
virtual |
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER). The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class.
buffer | Encode message buffer object |
lower | Lower bound (inclusive) of size constraint |
upper | Upper bound (inclusive) of size constraint |
void Encode | ( | Asn1MderOutputStream | outs, |
int | length | ||
) |
Encode this BIT STRING into the MDER encoding. The length of this BIT STRING must match the given length.
length | This should be 8, 16, or 32, as these are the only lengths MDER supports. However, this is not checked here as it should be able to be checked at code generation time. We only check here that the actual and given lengths match. |
References Asn1Type.BIT_STRING, Asn1DecodeBuffer.Read(), Asn1MessageBufferBase.TypeCode, and Asn1OutputStream.Write().
|
virtual |
This method encodes this ASN.1 BIT STRING value, according to OER. This encodes the length determinant and # of unused bits, assuming that the BIT STRING is not fixed-size constrained. Subclasses may override this to simply call EncodeContent for fixed-size constrained strings.
buffer | Encode message buffer object |
Reimplemented from Asn1Type.
References Asn1OerEncodeBuffer.EncodeIntUnsigned(), and Asn1OerEncodeBuffer.EncodeLength().
|
virtual |
This method encodes ASN.1 bit string type using the XML encoding rules (XER).
buffer | Encode message buffer object |
elemName | XML element name used to wrap string |
Reimplemented from Asn1Type.
|
virtual |
This method encodes ASN.1 bit string type using the XML Encoding as specified in the itu-t XER standard.
buffer | Encode message buffer object |
elemName | XML element name used to wrap string |
namedbits | Array of named bits |
namedbitindex | Arrat of named bits index values |
References Asn1XmlXerEncoder.Copy(), Asn1XmlXerEncoder.EncodeBinStrValue(), Asn1XerEncoder.EncodeEmptyElement(), Asn1XerEncoder.EncodeEndElement(), Asn1XmlXerEncoder.EncodeNamedValueElement(), Asn1XerEncoder.EncodeStartElement(), and Asn1XmlXerEncoder.Indent().
|
virtual |
This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML Schema standard.
buffer | Encode message buffer object |
elemName | XML element name used to wrap string |
nsPrefix | XML element namespace name |
namedbits | Array of named bits |
namedbitindex | Arrat of named bits index values |
|
virtual |
This method encodes ASN.1 bit string type using the XML Encoding as specified in the XML Schema standard.
buffer | Encode message buffer object |
elemName | XML element name used to wrap string |
nsPrefix | XML element namespace name |
Reimplemented from Asn1Type.
References Asn1XmlXerEncoder.EncodeBinStrValue(), Asn1XmlEncoder.EncodeEmptyElement(), Asn1XmlEncoder.EncodeEndElement(), Asn1XmlEncoder.EncodeStartElement(), and Asn1XmlXerEncoder.Indent().
|
virtual |
This method encodes and writes to the stream an ASN.1 bit 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 the underlying System.IO.Stream object.
outs | BER Output Stream object |
explicitTagging | Flag indicating explicit tagging should be done |
Asn1Exception | Thrown, if operation is failed. |
Reimplemented from Asn1Type.
|
virtual |
This method encodes an unconstrained ASN.1 bit string value using the packed encoding rules (PER)into the stream. The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class.
Also throws any exception thrown by the underlying Asn1PerOutputStream.
outs | PER Output Stream object |
Asn1Exception | Thrown, if operation is failed. |
Reimplemented from Asn1Type.
|
virtual |
This method encodes a size-constrained ASN.1 bit string value using the packed encoding rules (PER) into the stream. The value to be encoded is stored in the 'numbits' and 'mValue' public member variables within this class.
Also throws any exception thrown by the underlying Asn1PerOutputStream.
outs | PER Output Stream object |
lower | Lower bound (inclusive) of size constraint |
upper | Upper bound (inclusive) of size constraint |
Asn1Exception | Thrown, if operation is failed. |
References Asn1Tag.PRIM, and Asn1Tag.UNIV.
void EncodeContent | ( | Asn1OerEncodeBuffer | buffer | ) |
This method encodes the content of an ASN.1 bit string value, according to OER. (The length determinant and # of unused bits is not encoded.)
buffer | Encode message buffer object |
References Asn1EncodeBuffer.Copy().
|
virtual |
This method compares this bit string value to the given value for equality.
This method assumes all unused bits in the last byte are set to zero.
nbits | The number of bits to compare from the byte array. |
value | The byte array to compare with the current Object. |
true
if the specified bit array is equal to the current Object; otherwise, false
. override bool Equals | ( | System.Object | value | ) |
This method compares this bit string value to the given value for equality. This method assumes all unused bits in the last byte are set to zero.
value | The Object to compare with the current Object. Object should be instance of Asn1BitString. |
true
if the specified Object is equal to the current Object; otherwise, false
. References Asn1BitString.mValue, Asn1BitString.numbits, and Asn1Value.StringEqualsBytes().
|
virtual |
Gets the value of the bit at a specific position in the bit array.
bitno | The zero-based index of the bit to get. The bit numbers start at zero and with the MSB of the first byte and progress from left to right. |
true
if bit is set; otherwise false
. Referenced by Asn1DerEncodeBuffer.TrimBitString().
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.
|
protectedvirtual |
Return the lower bound for the OER effective size constraint. When trimZeroBits is set, this controls the trimming done for OER encoding.
Subclasses must override this to return the correct value if the BIT STRING has named bits and the effective size constraint has a lower bound other than zero.
References Asn1XmlXerEncoder.EncodeBinStrValue(), Asn1XerEncoder.EncodeEmptyElement(), Asn1XerEncoder.EncodeEndElement(), Asn1XerEncoder.EncodeStartElement(), and Asn1XmlXerEncoder.Indent().
|
virtual |
This method determines is the input character string represented as named bit string or as bits sequence. It is used for XML decoding.
buffer | Bit string as string to be tested. |
|
virtual |
This method sets the given bit number in the bit string with given value. It will expand the existing bit array if it needs to, , setting any added bits, except bitno, to 0.
bitno | The zero-based index of the bit to set. The bit numbers start at zero and with the MSB of the first byte and progress from left to right. |
value | The Boolean value to assign to the bit. |
|
virtual |
This method will set the given bit number to one (1). It will expand the existing bit array if it needs to.
bitno | The zero-based index of the bit to set. The bit numbers start at zero and with the MSB of the first byte and progress from left to right. |
|
virtual |
This method converts the bit string stored in this object to a boolean array.
|
virtual |
This method will return a hex string representation of the bit string value. The output format is a string of hex bytes with no extra delimiting characters (ex. 0D56EF).
References Asn1Util.ToHexString().
|
virtual |
This method will return a byte array input stream representation of the bit string value.
override string ToString | ( | ) |
This method will return a string representation of the bit string value. The output format is a string of hex digits/binary digits according to the value set for mStringFormat variable.
References Asn1BerOutputStream.EncodeBitString(), and Diag.Prtln().
|
static |
The _TAG
constant describes the universal tag for this data type (UNIVERSAL 3).
Referenced by Asn1CerOutputStream.EncodeBitString().
StringFormat mStringFormat = StringFormat.HEXBIN |
The mStringFormat variable can be used to set the string format for print() or event handler calls or toString() functions. The possible options are: HEX, HEXBIN, BITS, NAMEDBITS, and ASN1VALUE. HEXBIN is the default format.
byte [] mValue |
This variable holds the bit string value. These are the bits that are encoded when encode is invoked. It is also where the decoded bit string is stored after a Decode operation.
Referenced by Asn1BitString.Equals().
int numbits |
This variable contains the number of bits in the bit string value.
Referenced by Asn1BitString.Equals(), Asn1DerEncodeBuffer.TrimBitString(), and Asn1BerEncodeBuffer.TrimBitString().
bool trimZeroBits |
This variable describes whether trailing zero bits should be truncated. This is required when encoding a named bit string using CER, DER, PER, or C-OER. By default, no trimming is done.
|
get |
Gets the length of the BIT STRING in bits.
Value:
Number of bits.
|
getset |
Gets or Sets the given bit in the bit string. It will expand the existing bit array if it needs to set the bit value.
bitno | The position of the bit in bit array |
Value:
true if bit is set; otherwise false.