All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class netscape.security.util.DerValue

netscape.security.util.DerValue

public class 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.

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

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


Variable Index

 o buffer
 o data
The DER-encoded data of the value.
 o tag
The DER tag of the value; one of the tag_ constants.
 o TAG_APPLICATION
 o tag_BitString
Tag value indicating an ASN.1 "BIT STRING" value.
 o tag_BMPString
Tag value indicating an ASN.1 "BMPString" value.
 o tag_Boolean
Tag value indicating an ASN.1 "BOOLEAN" value.
 o TAG_CONTEXT
 o tag_Enumerated
Tag value including an ASN.1 "ENUMERATED" value
 o tag_GeneralizedTime
Tag value indicating an ASN.1 "GeneralizedTime" value.
 o tag_IA5String
Tag value including an ASCII string
 o tag_Integer
Tag value indicating an ASN.1 "INTEGER" value.
 o tag_Null
Tag value indicating an ASN.1 "NULL" value.
 o tag_ObjectId
Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value.
 o tag_OctetString
Tag value indicating an ASN.1 "OCTET STRING" value.
 o tag_PrintableString
Tag value including a "printable" string
 o TAG_PRIVATE
 o tag_Sequence
Tag value indicating an ASN.1 "SEQUENCE" (zero to N elements, order is significant).
 o tag_SequenceOf
Tag value indicating an ASN.1 "SEQUENCE OF" (one to N elements, order is significant).
 o tag_Set
Tag value indicating an ASN.1 "SET" (zero to N members, order does not matter).
 o tag_SetOf
Tag value indicating an ASN.1 "SET OF" (one to N members, order does not matter).
 o tag_T61String
Tag value including a "teletype" string
 o TAG_UNIVERSAL
The tag class types
 o tag_UniversalString
Tag value indicating an ASN.1 "UniversalString" value.
 o tag_UtcTime
Tag value indicating an ASN.1 "UTCTime" value.

Constructor Index

 o DerValue(byte, byte[])
Creates a DerValue from a tag and some DER-encoded data.
 o DerValue(byte[])
Get an ASN.1/DER encoded datum from a buffer.
 o DerValue(byte[], int, int)
Get an ASN.1/DER encoded datum from part of a buffer.
 o DerValue(InputStream)
Get an ASN1/DER encoded datum from an input stream.
 o DerValue(String)
Creates a DER value from a string using a generic way of determining the proper tag for the string.

Method Index

 o createTag(byte, boolean, byte)
Create the tag of the attribute.
 o encode(DerOutputStream)
Encode an ASN1/DER encoded datum onto a DER output stream.
 o equals(DerValue)
Bitwise equality comparison.
 o equals(Object)
Returns true iff the other object is a DER value which is bitwise equal to this one.
 o getASN1CharString()
 o getAsString()
Returns the name component as a Java string, regardless of its encoding restrictions (ASCII, T61, Printable, etc).
 o getBitString()
Returns an ASN.1 BIT STRING value.
 o getBitString(boolean)
Returns an ASN.1 BIT STRING value, with the tag assumed implicit based on the parameter.
 o getBMPString()
 o getBoolean()
Returns an ASN.1 BOOLEAN
 o getEnumerated()
Returns an ASN.1 unsigned integer value of enumerated value.
 o getIA5String()
Returns an ASN.1 IA5 (ASCII) STRING value
 o getInteger()
Returns an ASN.1 unsigned INTEGER value.
 o getInteger(boolean)
Returns an ASN.1 unsigned INTEGER value, the parameter determining if the tag is implicit.
 o getOctetString()
Returns an ASN.1 OCTET STRING
 o getOID()
Returns an ASN.1 OBJECT IDENTIFIER.
 o getPrintableString()
Returns an ASN.1 STRING value
 o getT61String()
Returns an ASN.1 T61 (Teletype) STRING value
 o getUnalignedBitString()
Returns an ASN.1 BIT STRING value that need not be byte-aligned.
 o getUnalignedBitString(boolean)
Returns an ASN.1 BIT STRING value, with the tag assumed implicit based on the parameter.
 o getUniversalString()
 o isConstructed()
Returns true iff the CONSTRUCTED bit is set in the type tag.
 o isContextSpecific()
Returns true iff the CONTEXT SPECIFIC bit is set in the type tag.
 o isContextSpecific(byte)
Returns true iff the CONTEXT SPECIFIC TAG matches the passed tag.
 o length()
Get the length of the encoded value.
 o resetTag(byte)
Set the tag of the attribute.
 o toByteArray()
Returns a DER-encoded value, such that if it's passed to the DerValue constructor, a value equivalent to "this" is returned.
 o toDerInputStream()
For "set" and "sequence" types, this function may be used to return a DER stream of the members of the set or sequence.
 o toString()
Returns a printable representation of the value.

Variables

 o TAG_UNIVERSAL
 public static final byte TAG_UNIVERSAL
The tag class types

 o TAG_APPLICATION
 public static final byte TAG_APPLICATION
 o TAG_CONTEXT
 public static final byte TAG_CONTEXT
 o TAG_PRIVATE
 public static final byte TAG_PRIVATE
 o tag
 public byte tag
The DER tag of the value; one of the tag_ constants.

 o buffer
 protected DerInputBuffer buffer
 o data
 public DerInputStream data
The DER-encoded data of the value.

 o tag_Boolean
 public static final byte tag_Boolean
Tag value indicating an ASN.1 "BOOLEAN" value.

 o tag_Integer
 public static final byte tag_Integer
Tag value indicating an ASN.1 "INTEGER" value.

 o tag_BitString
 public static final byte tag_BitString
Tag value indicating an ASN.1 "BIT STRING" value.

 o tag_OctetString
 public static final byte tag_OctetString
Tag value indicating an ASN.1 "OCTET STRING" value.

 o tag_Null
 public static final byte tag_Null
Tag value indicating an ASN.1 "NULL" value.

 o tag_ObjectId
 public static final byte tag_ObjectId
Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value.

 o tag_Enumerated
 public static final byte tag_Enumerated
Tag value including an ASN.1 "ENUMERATED" value

 o tag_PrintableString
 public static final byte tag_PrintableString
Tag value including a "printable" string

 o tag_T61String
 public static final byte tag_T61String
Tag value including a "teletype" string

 o tag_IA5String
 public static final byte tag_IA5String
Tag value including an ASCII string

 o tag_UtcTime
 public static final byte tag_UtcTime
Tag value indicating an ASN.1 "UTCTime" value.

 o tag_GeneralizedTime
 public static final byte tag_GeneralizedTime
Tag value indicating an ASN.1 "GeneralizedTime" value.

 o tag_BMPString
 public static final byte tag_BMPString
Tag value indicating an ASN.1 "BMPString" value.

 o tag_UniversalString
 public static final byte tag_UniversalString
Tag value indicating an ASN.1 "UniversalString" value.

 o tag_Sequence
 public static final byte tag_Sequence
Tag value indicating an ASN.1 "SEQUENCE" (zero to N elements, order is significant).

 o tag_SequenceOf
 public static final byte tag_SequenceOf
Tag value indicating an ASN.1 "SEQUENCE OF" (one to N elements, order is significant).

 o tag_Set
 public static final byte tag_Set
Tag value indicating an ASN.1 "SET" (zero to N members, order does not matter).

 o tag_SetOf
 public static final byte tag_SetOf
Tag value indicating an ASN.1 "SET OF" (one to N members, order does not matter).

Constructors

 o DerValue
 public DerValue(String value) throws IOException
Creates a DER value from a string using a generic way of determining the proper tag for the string. Assumes the string is a Generic attribute value and uses the converter for generic string values to convert to the Der Value.

 o DerValue
 public DerValue(byte tag,
                 byte data[])
Creates a DerValue from a tag and some DER-encoded data.

Parameters:
tag - the DER type tag
data - the DER-encoded data
 o DerValue
 public DerValue(byte buf[]) throws IOException
Get an ASN.1/DER encoded datum from a buffer. The entire buffer must hold exactly one datum, including its tag and length.

Parameters:
buf - buffer holding a single DER-encoded datum.
 o DerValue
 public DerValue(byte buf[],
                 int offset,
                 int len) throws IOException
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.

Parameters:
buf - the buffer
offset - start point of the single DER-encoded dataum
length - how many bytes are in the encoded datum
 o DerValue
 public DerValue(InputStream in) throws IOException
Get an ASN1/DER encoded datum from an input stream. The stream may have additional data following the encoded datum.

Parameters:
in - the input stream holding a single DER datum, which may be followed by additional data

Methods

 o isContextSpecific
 public boolean isContextSpecific()
Returns true iff the CONTEXT SPECIFIC bit is set in the type tag. This is associated with the ASN.1 "DEFINED BY" syntax.

 o isContextSpecific
 public boolean isContextSpecific(byte cntxtTag)
Returns true iff the CONTEXT SPECIFIC TAG matches the passed tag.

 o isConstructed
 public boolean isConstructed()
Returns true iff the CONSTRUCTED bit is set in the type tag.

 o encode
 public void encode(DerOutputStream out) throws IOException
Encode an ASN1/DER encoded datum onto a DER output stream.

 o getBoolean
 public boolean getBoolean() throws IOException
Returns an ASN.1 BOOLEAN

Returns:
the boolean held in this DER value
 o getOID
 public ObjectIdentifier getOID() throws IOException
Returns an ASN.1 OBJECT IDENTIFIER.

Returns:
the OID held in this DER value
 o getOctetString
 public byte[] getOctetString() throws IOException
Returns an ASN.1 OCTET STRING

Returns:
the octet string held in this DER value
 o getEnumerated
 public int getEnumerated() throws IOException
Returns an ASN.1 unsigned integer value of enumerated value.

Returns:
the (unsigned) integer held in this DER value
 o getInteger
 public BigInt getInteger() throws IOException
Returns an ASN.1 unsigned INTEGER value.

Returns:
the (unsigned) integer held in this DER value
 o getInteger
 public BigInt getInteger(boolean tagImplicit) throws IOException
Returns an ASN.1 unsigned INTEGER value, the parameter determining if the tag is implicit.

Parameters:
s - tagImplicit if true, ignores the tag value as it is assumed implicit.
Returns:
the (unsigned) integer held in this DER value
 o getBitString
 public byte[] getBitString() throws IOException
Returns an ASN.1 BIT STRING value. The bit string must be byte-aligned.

Returns:
the bit string held in this value
 o getUnalignedBitString
 public BitArray getUnalignedBitString() throws IOException
Returns an ASN.1 BIT STRING value that need not be byte-aligned.

Returns:
a BitArray representing the bit string held in this value
 o getAsString
 public String getAsString() throws IOException
Returns the name component as a Java string, regardless of its encoding restrictions (ASCII, T61, Printable, etc).

 o getBitString
 public byte[] getBitString(boolean tagImplicit) throws IOException
Returns an ASN.1 BIT STRING value, with the tag assumed implicit based on the parameter. The bit string must be byte-aligned.

Parameters:
s - tagImplicit if true, the tag is assumed implicit.
Returns:
the bit string held in this value
 o getUnalignedBitString
 public BitArray getUnalignedBitString(boolean tagImplicit) throws IOException
Returns an ASN.1 BIT STRING value, with the tag assumed implicit based on the parameter. The bit string need not be byte-aligned.

Parameters:
s - tagImplicit if true, the tag is assumed implicit.
Returns:
the bit string held in this value
 o getPrintableString
 public String getPrintableString() throws IOException
Returns an ASN.1 STRING value

Returns:
the printable string held in this value
 o getASN1CharString
 public String getASN1CharString() throws IOException
 o getT61String
 public String getT61String() throws IOException
Returns an ASN.1 T61 (Teletype) STRING value

Returns:
the teletype string held in this value
 o getIA5String
 public String getIA5String() throws IOException
Returns an ASN.1 IA5 (ASCII) STRING value

Returns:
the ASCII string held in this value
 o getBMPString
 public String getBMPString() throws IOException
 o getUniversalString
 public String getUniversalString() throws IOException
 o equals
 public boolean equals(Object other)
Returns true iff the other object is a DER value which is bitwise equal to this one.

Parameters:
other - the object being compared with this one
 o equals
 public boolean equals(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.

Parameters:
other - the object being compared with this one
 o toString
 public String toString()
Returns a printable representation of the value.

Returns:
printable representation of the value
 o toByteArray
 public byte[] toByteArray() throws IOException
Returns a DER-encoded value, such that if it's passed to the DerValue constructor, a value equivalent to "this" is returned.

Returns:
DER-encoded value, including tag and length.
 o toDerInputStream
 public DerInputStream toDerInputStream() throws IOException
For "set" and "sequence" types, this function may be used to return a DER stream of the members of the set or sequence. This operation is not supported for primitive types such as integers or bit strings.

 o length
 public int length()
Get the length of the encoded value.

 o createTag
 public static byte createTag(byte tagClass,
                              boolean form,
                              byte val)
Create the tag of the attribute.

Parameters:
s - class the tag class type, one of UNIVERSAL, CONTEXT, APPLICATION or PRIVATE
s - form if true, the value is constructed, otherwise it is primitive.
s - val the tag value
 o resetTag
 public void resetTag(byte tag)
Set the tag of the attribute. Commonly used to reset the tag value used for IMPLICIT encodings.

Parameters:
s - tag the tag value

All Packages  Class Hierarchy  This Package  Previous  Next  Index