public void encode(DEROutputStream out) throws IOException {
if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
{
out.write(CONSTRUCTED | OCTET_STRING);
out.write(0x80);
//
// write out the octet array
//
if (octs != null)
{
for (int i = 0; i != octs.size(); i++)
{
out.writeObject(octs.elementAt(i));
}
}
else
{
int start = 0;
int end = 0;
while ((end + 1) < string.length)
{
if (string[end] == 0 && string[end + 1] == 0)
{
byte[] nStr = new byte[end - start + 1];
System.arraycopy(string, start, nStr, 0, nStr.length);
out.writeObject(new DEROctetString(nStr));
start = end + 1;
}
end++;
}
byte[] nStr = new byte[string.length - start];
System.arraycopy(string, start, nStr, 0, nStr.length);
out.writeObject(new DEROctetString(nStr));
}
out.write(0x00);
out.write(0x00);
}
else
{
super.encode(out);
}
}
|