Methods Summary |
---|
void | encode(DEROutputStream out)
byte[] bytes = new byte[getBytes().length + 1];
bytes[0] = (byte)getPadBits();
System.arraycopy(getBytes(), 0, bytes, 1, bytes.length - 1);
out.writeEncoded(BIT_STRING, bytes);
|
public boolean | equals(java.lang.Object o)
if (o == null || !(o instanceof DERBitString))
{
return false;
}
DERBitString other = (DERBitString)o;
if (data.length != other.data.length)
{
return false;
}
for (int i = 0; i != data.length; i++)
{
if (data[i] != other.data[i])
{
return false;
}
}
return (padBits == other.padBits);
|
protected static byte[] | getBytes(int bitString)return the correct number of bytes for a bit string defined in
a 32 bit constant
int bytes = 0;
for (int i = 0; i < 4; i++)
{
if ((bitString & (0xFF << i)) != 0)
{
bytes++;
}
}
if (bytes == 0)
{
bytes = 1;
}
byte[] result = new byte[bytes];
for (int i = 0; i < bytes; i++)
{
result[bytes - i - 1] = (byte) ((bitString >> i) & 0xFF);
}
return result;
|
public byte[] | getBytes()
return data;
|
public static org.bouncycastle.asn1.DERBitString | getInstance(java.lang.Object obj)return a Bit String from the passed in object
if (obj == null || obj instanceof DERBitString)
{
return (DERBitString)obj;
}
if (obj instanceof ASN1OctetString)
{
byte[] bytes = ((ASN1OctetString)obj).getOctets();
int padBits = bytes[0];
byte[] data = new byte[bytes.length - 1];
System.arraycopy(bytes, 1, data, 0, bytes.length - 1);
return new DERBitString(data, padBits);
}
if (obj instanceof ASN1TaggedObject)
{
return getInstance(((ASN1TaggedObject)obj).getObject());
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
|
public static org.bouncycastle.asn1.DERBitString | getInstance(ASN1TaggedObject obj, boolean explicit)return a Bit String from a tagged object.
return getInstance(obj.getObject());
|
protected static int | getPadBits(int bitString)return the correct number of pad bits for a bit string defined in
a 32 bit constant
int val = 0;
for (int i = 3; i >=0; i--)
{
if ((bitString >> i) != 0)
{
val = (bitString >> i) & 0xFF;
break;
}
}
if (val == 0)
{
return 7;
}
int bits = 1;
while (((val <<= 1) & 0xFF) != 0)
{
bits++;
}
return 8 - bits;
|
public int | getPadBits()
return padBits;
|
public int | hashCode()
int value = 0;
for (int i = 0; i != data.length; i++)
{
value ^= (data[i] & 0xff) << (i % 4);
}
return value;
|