X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fbouncycastle%2Fasn1%2FBERConstructedOctetString.java;h=c49642b1ec3237973610152f7ecb37baad94d12f;hp=47b42452e78d52fadfafbffb8ee7d6289b03cedd;hb=da1f843588c8bd2b2c7cc74a5b4ffff8d57ab712;hpb=e5e9355b4f4e0e2c8de9068a71c1e3cc26fa9905 diff --git a/src/org/bouncycastle/asn1/BERConstructedOctetString.java b/src/org/bouncycastle/asn1/BERConstructedOctetString.java index 47b4245..c49642b 100644 --- a/src/org/bouncycastle/asn1/BERConstructedOctetString.java +++ b/src/org/bouncycastle/asn1/BERConstructedOctetString.java @@ -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); + } } }