extends DERConstructedSequence
{
/*
- * A note on the implementation:
- * <p>
- * As DER requires the constructed, definite-length model to
- * be used for structured types, this varies slightly from the
- * ASN.1 descriptions given. Rather than just outputing SEQUENCE,
- * we also have to specify CONSTRUCTED, and the objects length.
*/
void encode(
DEROutputStream out)
throws IOException
{
- if (out instanceof BEROutputStream)
+ if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
{
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- BEROutputStream dOut = new BEROutputStream(bOut);
- Enumeration e = getObjects();
-
+ out.write(SEQUENCE | CONSTRUCTED);
+ out.write(0x80);
+
+ Enumeration e = getObjects();
while (e.hasMoreElements())
{
- Object obj = e.nextElement();
-
- dOut.writeObject(obj);
+ out.writeObject(e.nextElement());
}
-
- dOut.close();
-
- byte[] bytes = bOut.toByteArray();
-
- out.write(SEQUENCE | CONSTRUCTED);
- out.write(0x80);
- out.write(bytes);
+
out.write(0x00);
out.write(0x00);
}