byte[] sBytes = (byte[]) signature; DERValue derSignature = new DERValue(DER.BIT_STRING, new BitString(sBytes)); byte[] result; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { DERWriter.write(baos, derSignature); result = baos.toByteArray(); } catch (IOException x) { InvalidParameterException y = new InvalidParameterException(); y.initCause(x); throw y; }
byte[] result = (byte[]) signature;
  public byte[] encodeSignature(Object signature)  {    byte[] sBytes = (byte[]) signature;    DERValue derSignature = new DERValue(DER.BIT_STRING,                                         new BitString(sBytes));    byte[] result;    ByteArrayOutputStream baos = new ByteArrayOutputStream();    try      {        DERWriter.write(baos, derSignature);        result = baos.toByteArray();      }    catch (IOException x)      {        InvalidParameterException y = new InvalidParameterException();        y.initCause(x);        throw y;      }    return result;  }