All Packages Class Hierarchy This Package Previous Next Index
Class netscape.security.util.DerOutputStream
netscape.security.util.DerOutputStream
- public class DerOutputStream
- implements DerEncoder
Output stream marshaling DER-encoded data. This is eventually provided
in the form of a byte array; there is no advance limit on the size of
that byte array.
At this time, this class supports only a subset of the types of
DER data encodings which are defined. That subset is sufficient for
generating most X.509 certificates.
-
DerOutputStream()
- Construct an DER output stream.
-
DerOutputStream(int)
- Construct an DER output stream.
-
derEncode(OutputStream)
- Write the current contents of this
DerOutputStream
to an OutputStream.
-
getDateBytes(Date, boolean)
-
-
putBitString(byte[])
- Marshals a DER bit string on the output stream.
-
putBMPString(String)
- Marshals a string which is consists of BMP (unicode) characters
-
putBoolean(boolean)
- Marshals a DER boolean on the output stream.
-
putDerValue(DerValue)
- Marshals pre-encoded DER value onto the output stream.
-
putEnumerated(int)
- Marshals a DER enumerated value on the output stream.
-
putGeneralizedTime(Date)
- Marshals a DER Generalized Time/date value.
-
putIA5String(String)
- Marshals a string which is consists of IA5(ASCII) characters
-
putInteger(BigInt)
- Marshals a DER unsigned integer on the output stream.
-
putLength(int)
- Put the encoding of the length in the stream.
-
putNull()
- Marshals a DER "null" value on the output stream.
-
putOctetString(byte[])
- DER-encodes an ASN.1 OCTET STRING value on the output stream.
-
putOID(ObjectIdentifier)
- Marshals an object identifier (OID) on the output stream.
-
putOrderedSet(byte, DerEncoder[])
-
Marshals the contents of a set on the output stream.
-
putOrderedSetOf(byte, DerEncoder[])
-
Marshals the contents of a set on the output stream.
-
putPrintableString(String)
- Converts string to printable and writes to der output stream.
-
putSequence(DerValue[])
- Marshals a sequence on the output stream.
-
putSet(byte, DerEncoder[])
- NSCP :
Like putOrderSetOf, except not sorted.
-
putSet(DerValue[])
- Marshals the contents of a set on the output stream without
ordering the elements.
-
putStringType(byte, String)
-
-
putTag(byte, boolean, byte)
- Put the tag of the attribute in the stream.
-
putUnalignedBitString(BitArray)
- Marshals a DER bit string on the output stream.
-
putUnalignedBitString(boolean[])
- Marshals a DER bit string on the output stream.
-
putUnalignedBitString(byte[])
- Marshals a DER bit string on the output stream.
-
putUnsignedInteger(byte[])
- Marshals a DER unsigned integer on the output stream.
-
putUTCTime(Date)
- Marshals a DER UTC time/date value.
-
write(byte, byte[])
- Writes tagged, pre-marshaled data.
-
write(byte, DerOutputStream)
- Writes tagged data using buffer-to-buffer copy.
-
writeImplicit(byte, DerOutputStream)
- Writes implicitly tagged data using buffer-to-buffer copy.
DerOutputStream
public DerOutputStream(int size)
- Construct an DER output stream.
- Parameters:
- size - how large a buffer to preallocate.
DerOutputStream
public DerOutputStream()
- Construct an DER output stream.
write
public void write(byte tag,
byte buf[]) throws IOException
- Writes tagged, pre-marshaled data. This calcuates and encodes
the length, so that the output data is the standard triple of
{ tag, length, data } used by all DER values.
- Parameters:
- tag - the DER value tag for the data, such as
DerValue.tag_Sequence
- buf - buffered data, which must be DER-encoded
write
public void write(byte tag,
DerOutputStream out) throws IOException
- Writes tagged data using buffer-to-buffer copy. As above,
this writes a standard DER record. This is often used when
efficiently encapsulating values in sequences.
- Parameters:
- tag - the DER value tag for the data, such as
DerValue.tag_Sequence
- out - buffered data
writeImplicit
public void writeImplicit(byte tag,
DerOutputStream value) throws IOException
- Writes implicitly tagged data using buffer-to-buffer copy. As above,
this writes a standard DER record. This is often used when
efficiently encapsulating implicitly tagged values.
- Parameters:
- tag - the DER value of the context-specific tag that replaces
original tag of the value in the output , such as in
[N] IMPLICIT
For example, FooLength [1] IMPLICIT INTEGER, with value=4;
would be encoded as "81 01 04" whereas in explicit
tagging it would be encoded as "A1 03 02 01 04".
Notice that the tag is A1 and not 81, this is because with
explicit tagging the form is always constructed.
- value - original value being implicitly tagged
putDerValue
public void putDerValue(DerValue val) throws IOException
- Marshals pre-encoded DER value onto the output stream.
putBoolean
public void putBoolean(boolean val) throws IOException
- Marshals a DER boolean on the output stream.
putInteger
public void putInteger(BigInt i) throws IOException
- Marshals a DER unsigned integer on the output stream.
putUnsignedInteger
public void putUnsignedInteger(byte integerBytes[]) throws IOException
- Marshals a DER unsigned integer on the output stream.
putEnumerated
public void putEnumerated(int i) throws IOException
- Marshals a DER enumerated value on the output stream.
putBitString
public void putBitString(byte bits[]) throws IOException
- Marshals a DER bit string on the output stream. The bit
string must be byte-aligned.
- Parameters:
- bits - the bit string, MSB first
putUnalignedBitString
public void putUnalignedBitString(BitArray ba) throws IOException
- Marshals a DER bit string on the output stream.
The bit strings need not be byte-aligned.
- Parameters:
- bits - the bit string, MSB first
putUnalignedBitString
public void putUnalignedBitString(byte bitString[]) throws IOException
- Marshals a DER bit string on the output stream.
All trailing 0 bits will be stripped off in accordance with DER
encoding.
- Parameters:
- bits - the bit string, MSB first
putUnalignedBitString
public void putUnalignedBitString(boolean bitString[]) throws IOException
- Marshals a DER bit string on the output stream.
All trailing 0 bits will be stripped off in accordance with DER
encoding.
- Parameters:
- bits - the bit string as an array of booleans.
putOctetString
public void putOctetString(byte octets[]) throws IOException
- DER-encodes an ASN.1 OCTET STRING value on the output stream.
- Parameters:
- octets - the octet string
putNull
public void putNull() throws IOException
- Marshals a DER "null" value on the output stream. These are
often used to indicate optional values which have been omitted.
putOID
public void putOID(ObjectIdentifier oid) throws IOException
- Marshals an object identifier (OID) on the output stream.
Corresponds to the ASN.1 "OBJECT IDENTIFIER" construct.
putSequence
public void putSequence(DerValue seq[]) throws IOException
- Marshals a sequence on the output stream. This supports both
the ASN.1 "SEQUENCE" (zero to N values) and "SEQUENCE OF"
(one to N values) constructs.
putSet
public void putSet(DerValue set[]) throws IOException
- Marshals the contents of a set on the output stream without
ordering the elements. Ok for BER encoding, but not for DER
encoding.
For DER encoding, use orderedPutSet() or orderedPutSetOf().
putSet
public void putSet(byte tag,
DerEncoder set[]) throws IOException
- NSCP :
Like putOrderSetOf, except not sorted.
This may defy DER encoding but is needed for compatibility
with communicator.
putOrderedSetOf
public void putOrderedSetOf(byte tag,
DerEncoder set[]) throws IOException
- Marshals the contents of a set on the output stream. Sets
are semantically unordered, but DER requires that encodings of
set elements be sorted into ascending lexicographical order
before being output. Hence sets with the same tags and
elements have the same DER encoding.
This method supports the ASN.1 "SET OF" construct, but not
"SET", which uses a different order.
putOrderedSet
public void putOrderedSet(byte tag,
DerEncoder set[]) throws IOException
- Marshals the contents of a set on the output stream. Sets
are semantically unordered, but DER requires that encodings of
set elements be sorted into ascending tag order
before being output. Hence sets with the same tags and
elements have the same DER encoding.
This method supports the ASN.1 "SET" construct, but not
"SET OF", which uses a different order.
putPrintableString
public void putPrintableString(String s) throws IOException
- Converts string to printable and writes to der output stream.
putBMPString
public void putBMPString(String s) throws IOException
- Marshals a string which is consists of BMP (unicode) characters
putIA5String
public void putIA5String(String s) throws IOException
- Marshals a string which is consists of IA5(ASCII) characters
putStringType
public void putStringType(byte tag,
String s) throws IOException
getDateBytes
public byte[] getDateBytes(Date d,
boolean UTC)
putUTCTime
public void putUTCTime(Date d) throws IOException
- Marshals a DER UTC time/date value.
YYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time
and with seconds (even if seconds=0) as per IETF-PKIX partI.
putGeneralizedTime
public void putGeneralizedTime(Date d) throws IOException
- Marshals a DER Generalized Time/date value.
YYYYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time
and with seconds (even if seconds=0) as per IETF-PKIX partI.
putLength
public void putLength(int len) throws IOException
- Put the encoding of the length in the stream.
- Parameters:
- s - len the length of the attribute.
- Throws: IOException
- on writing errors.
putTag
public void putTag(byte tagClass,
boolean form,
byte val)
- Put the tag of the attribute in the stream.
- 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
derEncode
public void derEncode(OutputStream out) throws IOException
- Write the current contents of this
DerOutputStream
to an OutputStream.
- Throws: IOException
- on output error.
All Packages Class Hierarchy This Package Previous Next Index