public byte[] asn1Encode() throws Asn1Exception, IOException {
  Vector<DerValue> v=new Vector<>();
  DerOutputStream temp=new DerOutputStream();
  v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x00),ctime.asn1Encode()));
  temp.putInteger(BigInteger.valueOf(cusec));
  v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x01),temp.toByteArray()));
  if (subKey != null) {
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x02),subKey.asn1Encode()));
  }
  if (seqNumber != null) {
    temp=new DerOutputStream();
    temp.putInteger(BigInteger.valueOf(seqNumber.longValue()));
    v.addElement(new DerValue(DerValue.createTag(DerValue.TAG_CONTEXT,true,(byte)0x03),temp.toByteArray()));
  }
  DerValue der[]=new DerValue[v.size()];
  v.copyInto(der);
  temp=new DerOutputStream();
  temp.putSequence(der);
  DerOutputStream out=new DerOutputStream();
  out.write(DerValue.createTag(DerValue.TAG_APPLICATION,true,(byte)0x1B),temp);
  return out.toByteArray();
}

public byte [ ] asn1Encode ( ) throws Asn1Exception , IOException { Vector < DerValue > v = new Vector < > ( ) ; DerOutputStream temp = new DerOutputStream ( ) ; v . addElement ( new DerValue ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x00 ) , ctime . asn1Encode ( ) ) ) ; temp . putInteger ( BigInteger . valueOf ( cusec ) ) ; v . addElement ( new DerValue ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x01 ) , temp . toByteArray ( ) ) ) ; if ( subKey != null ) { v . addElement ( new DerValue ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x02 ) , subKey . asn1Encode ( ) ) ) ; } if ( seqNumber != null ) { temp = new DerOutputStream ( ) ; temp . putInteger ( BigInteger . valueOf ( seqNumber . longValue ( ) ) ) ; v . addElement ( new DerValue ( DerValue . createTag ( DerValue . TAG_CONTEXT , true , ( byte ) 0x03 ) , temp . toByteArray ( ) ) ) ; } DerValue der [ ] = new DerValue [ v . size ( ) ] ; v . copyInto ( der ) ; temp = new DerOutputStream ( ) ; temp . putSequence ( der ) ; DerOutputStream out = new DerOutputStream ( ) ; out . write ( DerValue . createTag ( DerValue . TAG_APPLICATION , true , ( byte ) 0x1B ) , temp ) ; return out . toByteArray ( ) ; }
encodes an encapreppart object .
