1 package org.bouncycastle.asn1;
6 * DER TaggedObject - in ASN.1 nottation this is any object proceeded by
7 * a [n] where n is some number - these are assume to follow the construction
8 * rules (as with sequences).
10 public class DERTaggedObject
11 extends ASN1TaggedObject
14 * @param tagNo the tag number for this object.
15 * @param obj the tagged object.
17 public DERTaggedObject(
25 * @param explicit true if an explicitly tagged object.
26 * @param tagNo the tag number for this object.
27 * @param obj the tagged object.
29 public DERTaggedObject(
34 super(explicit, tagNo, obj);
38 * create an implicitly tagged object that contains a zero
41 public DERTaggedObject(
44 super(false, tagNo, new DERSequence());
53 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
54 DEROutputStream dOut = new DEROutputStream(bOut);
56 dOut.writeObject(obj);
59 byte[] bytes = bOut.toByteArray();
63 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bytes);
68 // need to mark constructed types...
70 if ((bytes[0] & CONSTRUCTED) != 0)
72 bytes[0] = (byte)(CONSTRUCTED | TAGGED | tagNo);
76 bytes[0] = (byte)(TAGGED | tagNo);
84 out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, new byte[0]);