resolve darcs stupidity
[org.ibex.core.git] / src / org / bouncycastle / asn1 / BERConstructedOctetString.java
index 47b4245..c49642b 100644 (file)
@@ -39,13 +39,13 @@ public class BERConstructedOctetString
     public BERConstructedOctetString(
         byte[]  string)
     {
-               super(string);
+                super(string);
     }
 
     public BERConstructedOctetString(
         Vector  octs)
     {
-               super(toBytes(octs));
+                super(toBytes(octs));
 
         this.octs = octs;
     }
@@ -53,7 +53,7 @@ public class BERConstructedOctetString
     public BERConstructedOctetString(
         DERObject  obj)
     {
-               super(obj);
+                super(obj);
     }
 
     public BERConstructedOctetString(
@@ -67,14 +67,17 @@ public class BERConstructedOctetString
         return string;
     }
 
-    public Vector getDEROctets()
+    /**
+     * return the DER octets that make up this string.
+     */
+    public Enumeration getObjects()
     {
         if (octs == null)
         {
             octs = generateOcts();
         }
 
-        return octs;
+        return octs.elements();
     }
 
     private Vector generateOcts()
@@ -83,27 +86,24 @@ public class BERConstructedOctetString
         int     end = 0;
         Vector  vec = new Vector();
 
-        while (end < string.length)
+        while ((end + 1) < string.length)
         {
-            if ((end + 1) < string.length)
+            if (string[end] == 0 && string[end + 1] == 0)
             {
-                if (string[end] == 0 && string[end + 1] == 0)
-                {
-                    byte[]  nStr = new byte[end - start + 1];
+                byte[]  nStr = new byte[end - start + 1];
 
-                    for (int i = 0; i != nStr.length; i++)
-                    {
-                        nStr[i] = string[start + i];
-                    }
-
-                    vec.addElement(new DEROctetString(nStr));
-                    start = end + 1;
+                for (int i = 0; i != nStr.length; i++)
+                {
+                    nStr[i] = string[start + i];
                 }
+
+                vec.addElement(new DEROctetString(nStr));
+                start = end + 1;
             }
             end++;
         }
 
-        byte[]  nStr = new byte[end - start];
+        byte[]  nStr = new byte[string.length - start];
         for (int i = 0; i != nStr.length; i++)
         {
             nStr[i] = string[start + i];
@@ -118,8 +118,8 @@ public class BERConstructedOctetString
         DEROutputStream out)
         throws IOException
     {
-               if (out instanceof BEROutputStream)
-               {
+        if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
+        {
             out.write(CONSTRUCTED | OCTET_STRING);
 
             out.write(0x80);
@@ -136,10 +136,10 @@ public class BERConstructedOctetString
 
             out.write(0x00);
             out.write(0x00);
-               }
-               else
-               {
-                       super.encode(out);
-               }
+        }
+        else
+        {
+            super.encode(out);
+        }
     }
 }