1 package org.bouncycastle.asn1;
5 public class DERBitString
11 protected DERBitString(
15 this.data = new byte[1];
17 this.padBits = padBits;
21 * @param data the octets making up the bit string.
22 * @param padBits the number of extra bits at the end of the string.
29 this.padBits = padBits;
43 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
44 DEROutputStream dOut = new DEROutputStream(bOut);
46 dOut.writeObject(obj);
49 this.data = bOut.toByteArray();
54 throw new IllegalArgumentException("Error processing object : " + e.toString());
61 this(obj.getDERObject());
64 public byte[] getBytes()
69 public int getPadBits()
78 byte[] bytes = new byte[getBytes().length + 1];
80 bytes[0] = (byte)getPadBits();
81 System.arraycopy(getBytes(), 0, bytes, 1, bytes.length - 1);
83 out.writeEncoded(BIT_STRING, bytes);