DerValue

Represents a single DER-encoded value. DER encoding rules are a subset of the "Basic" Encoding Rules (BER), but they only support a single way ("Definite" encoding) to encode any given value.

<P>All DER-encoded data are triples <em>{type, length, data}</em>. This class represents such tagged values as they have been read (or constructed), and provides structured access to the encoded data.

<P>At this time, this class supports only a subset of the types of DER data encodings which are defined. That subset is sufficient for parsing most X.509 certificates, and working with selected additional formats (such as PKCS #10 certificate requests, and some kinds of PKCS #7 data).

A note with respect to T61/Teletex strings: From RFC 1617, section 4.1.3 and RFC 3280, section 4.1.2.4., we assume that this kind of string will contain ISO-8859-1 characters only.

More...
class DerValue {}

Constructors

this
this(string value)

Creates a PrintableString or UTF8string DER value from a string

this
this(byte stringTag, string value)

Creates a string type DER value from a string object @param stringTag the tag for the DER value to create @param value the string object to use for the DER value

this
this(byte tag, byte[] data, bool allowBER)
Undocumented in source.
this
this(byte tag, byte[] data)

Creates a DerValue from a tag and some DER-encoded data.

this
this(byte[] buf, bool allowBER)
Undocumented in source.
this
this(byte[] buf)

Get an ASN.1/DER encoded datum from a buffer. The entire buffer must hold exactly one datum, including its tag and length.

this
this(byte[] buf, int offset, int len, bool allowBER)
Undocumented in source.
this
this(byte[] buf, int offset, int len)

Get an ASN.1/DER encoded datum from part of a buffer. That part of the buffer must hold exactly one datum, including its tag and length.

this
this(InputStream inputStream, bool allowBER)
Undocumented in source.
this
this(InputStream inputStream)

Get an ASN1/DER encoded datum from an input stream. The stream may have additional data following the encoded datum. In case of indefinite length encoded datum, the input stream must hold only one datum.

Members

Functions

getAsString
string getAsString()

Returns the name component as a Java string, regardless of its encoding restrictions (ASCII, T61, Printable, IA5, BMP, UTF8).

getBMPString
string getBMPString()

Returns the ASN.1 BMP (Unicode) STRING value as a Java string.

getBigInteger
BigInt getBigInteger()

Returns an ASN.1 INTEGER value as a BigInt.

getBoolean
bool getBoolean()

Returns an ASN.1 BOOLEAN

getDataBytes
byte[] getDataBytes()

Helper routine to return all the bytes contained in the DerInputStream associated with this object.

getGeneralString
string getGeneralString()

Returns the ASN.1 GENERAL STRING value as a Java string.

getIA5String
string getIA5String()

Returns an ASN.1 IA5 (ASCII) STRING value

getInteger
int getInteger()

Returns an ASN.1 INTEGER value as an integer.

getOctetString
byte[] getOctetString()

Returns an ASN.1 OCTET STRING

getPositiveBigInteger
BigInt getPositiveBigInteger()

Returns an ASN.1 INTEGER value as a positive BigInt. This is just to deal with implementations that incorrectly encode some values as negative.

getPrintableString
string getPrintableString()

Returns an ASN.1 STRING value

getT61String
string getT61String()

Returns an ASN.1 T61 (Teletype) STRING value

getTag
byte getTag()
Undocumented in source. Be warned that the author may not have intended to support it.
getUTF8String
string getUTF8String()

Returns the ASN.1 UTF-8 STRING value as a Java string.

getUnalignedBitString
BitArray getUnalignedBitString()

Returns an ASN.1 BIT STRING value that need not be byte-aligned.

getUnalignedBitString
BitArray getUnalignedBitString(bool tagImplicit)

Returns an ASN.1 BIT STRING value, with the tag assumed implicit based on the parameter. The bit string need not be byte-aligned.

isApplication
bool isApplication()

Returns true if the tag class is APPLICATION.

isConstructed
bool isConstructed()

Returns true iff the CONSTRUCTED bit is set in the type tag.

isConstructed
bool isConstructed(byte constructedTag)

Returns true iff the CONSTRUCTED TAG matches the passed tag.

isContextSpecific
bool isContextSpecific()

Returns true iff the CONTEXT SPECIFIC bit is set in the type tag. This is associated with the ASN.1 "DEFINED BY" syntax.

isContextSpecific
bool isContextSpecific(byte cntxtTag)

Returns true iff the CONTEXT SPECIFIC TAG matches the passed tag.

isPrivate
bool isPrivate()
Undocumented in source. Be warned that the author may not have intended to support it.
isUniversal
bool isUniversal()

Returns true if the tag class is UNIVERSAL.

length
int length()

Get the length of the encoded value.

opEquals
bool opEquals(Object other)

Returns true iff the other object is a DER value which is bitwise equal to this one.

opEquals
bool opEquals(DerValue other)

Bitwise equality comparison. DER encoded values have a single encoding, so that bitwise equality of the encoded values is an efficient way to establish equivalence of the unencoded values.

resetTag
void resetTag(byte tag)

Set the tag of the attribute. Commonly used to reset the tag value used for IMPLICIT encodings.

toByteArray
byte[] toByteArray()

Returns a DER-encoded value, such that if it's passed to the DerValue constructor, a value equivalent to "this" is returned.

toHash
size_t toHash()

Returns a hashcode for this DerValue.

toString
string toString()

Returns a printable representation of the value.

Static functions

createTag
byte createTag(byte tagClass, bool form, byte val)

Create the tag of the attribute.

isPrintableStringChar
bool isPrintableStringChar(char ch)

Determine if a character is one of the permissible characters for PrintableString: A-Z, a-z, 0-9, space, apostrophe (39), left and right parentheses, plus sign, comma, hyphen, period, slash, colon, equals sign, and question mark.

Variables

TAG_APPLICATION
enum byte TAG_APPLICATION;
Undocumented in source.
TAG_CONTEXT
enum byte TAG_CONTEXT;
Undocumented in source.
TAG_PRIVATE
enum byte TAG_PRIVATE;
Undocumented in source.
TAG_UNIVERSAL
enum byte TAG_UNIVERSAL;

The tag class types

buffer
DerInputBuffer buffer;
Undocumented in source.
tag
byte tag;

The DER tag of the value; one of the tag_ constants.

tag_BMPString
enum byte tag_BMPString;

Tag value indicating an ASN.1 "BMPString" value.

tag_BitString
enum byte tag_BitString;

Tag value indicating an ASN.1 "BIT STRING" value.

tag_Boolean
enum byte tag_Boolean;

Tag value indicating an ASN.1 "BOOLEAN" value.

tag_Enumerated
enum byte tag_Enumerated;

Tag value including an ASN.1 "ENUMERATED" value

tag_GeneralString
enum byte tag_GeneralString;

Tag value indicating an ASN.1 "GenerallString" value.

tag_GeneralizedTime
enum byte tag_GeneralizedTime;

Tag value indicating an ASN.1 "GeneralizedTime" value.

tag_IA5String
enum byte tag_IA5String;

Tag value including an ASCII string

tag_Integer
enum byte tag_Integer;

Tag value indicating an ASN.1 "INTEGER" value.

tag_Null
enum byte tag_Null;

Tag value indicating an ASN.1 "NULL" value.

tag_ObjectId
enum byte tag_ObjectId;

Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value.

tag_OctetString
enum byte tag_OctetString;

Tag value indicating an ASN.1 "OCTET STRING" value.

tag_PrintableString
enum byte tag_PrintableString;

Tag value including a "printable" string

tag_Sequence
enum byte tag_Sequence;

Tag value indicating an ASN.1 "SEQUENCE" (zero to N elements, order is significant).

tag_SequenceOf
enum byte tag_SequenceOf;

Tag value indicating an ASN.1 "SEQUENCE OF" (one to N elements, order is significant).

tag_Set
enum byte tag_Set;

Tag value indicating an ASN.1 "SET" (zero to N members, order does not matter).

tag_SetOf
enum byte tag_SetOf;

Tag value indicating an ASN.1 "SET OF" (one to N members, order does not matter).

tag_T61String
enum byte tag_T61String;

Tag value including a "teletype" string

tag_UTF8String
enum byte tag_UTF8String;

Tag value indicating an ASN.1 "UTF8String" value.

tag_UniversalString
enum byte tag_UniversalString;

Tag value indicating an ASN.1 "UniversalString" value.

tag_UtcTime
enum byte tag_UtcTime;

Tag value indicating an ASN.1 "UTCTime" value.

Detailed Description

@author David Brownell @author Amit Kapoor @author Hemma Prafullchandra

Meta