summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/gnu/java/security/der
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/java/security/der')
-rw-r--r--libjava/classpath/gnu/java/security/der/DERValue.java29
-rw-r--r--libjava/classpath/gnu/java/security/der/DERWriter.java10
2 files changed, 32 insertions, 7 deletions
diff --git a/libjava/classpath/gnu/java/security/der/DERValue.java b/libjava/classpath/gnu/java/security/der/DERValue.java
index 9a597d724cc..d98ce78ec55 100644
--- a/libjava/classpath/gnu/java/security/der/DERValue.java
+++ b/libjava/classpath/gnu/java/security/der/DERValue.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.java.security.der;
+import gnu.java.security.x509.Util;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -108,7 +110,9 @@ public class DERValue implements DER
}
catch (IOException ioe)
{
- encoded = new byte[0];
+ IllegalArgumentException iae = new IllegalArgumentException ();
+ iae.initCause (ioe);
+ throw iae;
}
}
return length;
@@ -138,7 +142,9 @@ public class DERValue implements DER
}
catch (IOException ioe)
{
- encoded = new byte[0];
+ IllegalArgumentException iae = new IllegalArgumentException ();
+ iae.initCause (ioe);
+ throw iae;
}
}
return (byte[]) encoded.clone();
@@ -156,7 +162,9 @@ public class DERValue implements DER
}
catch (IOException ioe)
{
- encoded = new byte[0];
+ IllegalArgumentException iae = new IllegalArgumentException ();
+ iae.initCause (ioe);
+ throw iae;
}
}
return encoded.length;
@@ -164,7 +172,18 @@ public class DERValue implements DER
public String toString()
{
- return "DERValue [ tag=" + tag + ", class=" + tagClass + ", constructed="
- + constructed + ", value=" + value + " ]";
+ String start = "DERValue ( [";
+ if (tagClass == DER.UNIVERSAL)
+ start = start + "UNIVERSAL ";
+ else if (tagClass == DER.PRIVATE)
+ start = start + "PRIVATE ";
+ else if (tagClass == DER.APPLICATION)
+ start = start + "APPLICATION ";
+ start = start + tag + "] constructed=" + constructed + ", value=";
+ if (constructed)
+ start = start + "\n" + Util.hexDump(getEncoded(), "\t");
+ else
+ start = start + value;
+ return start + " )";
}
}
diff --git a/libjava/classpath/gnu/java/security/der/DERWriter.java b/libjava/classpath/gnu/java/security/der/DERWriter.java
index 78524fc949f..0c26336053c 100644
--- a/libjava/classpath/gnu/java/security/der/DERWriter.java
+++ b/libjava/classpath/gnu/java/security/der/DERWriter.java
@@ -84,6 +84,12 @@ public class DERWriter implements DER
public static int write(OutputStream out, DERValue object)
throws IOException
{
+ if (DER.CONSTRUCTED_VALUE.equals (object.getValue ()))
+ {
+ out.write (object.getEncoded ());
+ return object.getLength ();
+ }
+
out.write(object.getExternalTag());
Object value = object.getValue();
if (value == null)
@@ -216,10 +222,10 @@ public class DERWriter implements DER
throws IOException
{
byte[] buf = bs.getShiftedByteArray();
- out.write(buf.length + 1);
+ writeLength(out, buf.length + 1);
out.write(bs.getIgnoredBits());
out.write(buf);
- return buf.length;
+ return buf.length + 1;
}
private static int writeString(OutputStream out, int tag, String str)
OpenPOWER on IntegriCloud