X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fbouncycastle%2Fasn1%2FDEROctetString.java;h=9ce935086621b4610fe6daa564cdc4a5694684d8;hp=fd9f516c7384f61e49d4ab2ba79d271c4b3e7663;hb=da1f843588c8bd2b2c7cc74a5b4ffff8d57ab712;hpb=e5e9355b4f4e0e2c8de9068a71c1e3cc26fa9905 diff --git a/src/org/bouncycastle/asn1/DEROctetString.java b/src/org/bouncycastle/asn1/DEROctetString.java index fd9f516..9ce9350 100644 --- a/src/org/bouncycastle/asn1/DEROctetString.java +++ b/src/org/bouncycastle/asn1/DEROctetString.java @@ -3,47 +3,21 @@ package org.bouncycastle.asn1; import java.io.*; public class DEROctetString - extends DERObject + extends ASN1OctetString { - byte[] string; - /** * @param string the octets making up the octet string. */ public DEROctetString( byte[] string) { - this.string = string; - } - - public DEROctetString( - DERObject obj) - { - try - { - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - DEROutputStream dOut = new DEROutputStream(bOut); - - dOut.writeObject(obj); - dOut.close(); - - this.string = bOut.toByteArray(); - } - catch (IOException e) - { - throw new IllegalArgumentException("Error processing object : " + e.toString()); - } + super(string); } public DEROctetString( DEREncodable obj) { - this(obj.getDERObject()); - } - - public byte[] getOctets() - { - return string; + super(obj); } void encode( @@ -52,46 +26,4 @@ public class DEROctetString { out.writeEncoded(OCTET_STRING, string); } - - public int hashCode() - { - byte[] b = this.getOctets(); - int value = 0; - - for (int i = 0; i != b.length; i++) - { - value ^= (b[i] & 0xff) << (i % 4); - } - - return value; - } - - public boolean equals( - Object o) - { - if (o == null || !(o instanceof DEROctetString)) - { - return false; - } - - DEROctetString other = (DEROctetString)o; - - if (other.getOctets().length != this.getOctets().length) - { - return false; - } - - byte[] b1 = other.getOctets(); - byte[] b2 = this.getOctets(); - - for (int i = 0; i != b1.length; i++) - { - if (b1[i] != b2[i]) - { - return false; - } - } - - return true; - } }