Top Description Fields Constructors Methods
org.bouncycastle.asn1

public abstract Class ASN1BitString

extends ASN1Primitive
implements ASN1String
Class Inheritance
All Implemented Interfaces
org.bouncycastle.asn1.ASN1String
Known Direct Subclasses
org.bouncycastle.asn1.DERBitString, org.bouncycastle.asn1.DLBitString
Imports
java.io.ByteArrayOutputStream, .EOFException, .IOException, .InputStream, org.bouncycastle.util.Arrays, org.bouncycastle.util.io.Streams

Base class for BIT STRING objects

Field Summary

Modifier and TypeField and Description
protected final byte[]
protected final int
private static final char[]

Constructor Summary

AccessConstructor and Description
public
ASN1BitString(byte[]
the octets making up the bit string.
data
,
int
the number of extra bits at the end of the string.
padBits
)

Base constructor.

Method Summary

Modifier and TypeMethod and Description
protected boolean
asn1Equals(ASN1Primitive o)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.
protected static byte[]
derForm(byte[] data, int padBits)

pack-priv abstract void
pack-priv static ASN1BitString
fromInputStream(int length, InputStream stream)

protected static byte[]

Returns:

the correct number of bytes for a bit string defined in a 32 bit constant
getBytes
(int
an int containing the BIT STRING
bitString
)

public byte[]
public ASN1Primitive
public byte[]

Returns:

a copy of the octet aligned data.
getOctets
()

Return the octets contained in this BIT STRING, checking that this BIT STRING really does represent an octet aligned string.

protected static int

Returns:

the correct number of pad bits for a bit string defined in a 32 bit constant
getPadBits
(int
an int containing the BIT STRING
bitString
)

public int
public String

Returns:

a String representation.
getString
()

Implements org.bouncycastle.asn1.ASN1String.getString.

Return a String representation of this BIT STRING
public int
hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.hashCode.

Returns a hash code value for this object.
public int

Returns:

the value of the bit string as an int (truncating if necessary)
intValue
()

pack-priv ASN1Primitive
toDERObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDERObject.

Return the current object as one which encodes using Distinguished Encoding Rules.
pack-priv ASN1Primitive
toDLObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDLObject.

Return the current object as one which encodes using Definite Length encoding.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.bouncycastle.asn1.ASN1Primitive:
encodedLengthequalsfromByteArrayisConstructedtoASN1Primitive

Field Detail

databack to summary
protected final byte[] data
padBitsback to summary
protected final int padBits
tableback to summary
private static final char[] table

Constructor Detail

ASN1BitStringback to summary
public ASN1BitString(byte[] data, int padBits)

Base constructor.

Parameters
data:byte[]

the octets making up the bit string.

padBits:int

the number of extra bits at the end of the string.

Method Detail

asn1Equalsback to summary
protected boolean asn1Equals(ASN1Primitive o)

Implements abstract org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Doc from org.bouncycastle.asn1.ASN1Primitive.asn1Equals.

Equality (similarity) comparison for two ASN1Primitive objects.

derFormback to summary
protected static byte[] derForm(byte[] data, int padBits)
encodeback to summary
pack-priv abstract void encode(ASN1OutputStream out) throws IOException

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encode.

fromInputStreamback to summary
pack-priv static ASN1BitString fromInputStream(int length, InputStream stream) throws IOException
getBytesback to summary
protected static byte[] getBytes(int bitString)
Parameters
bitString:int

an int containing the BIT STRING

Returns:byte[]

the correct number of bytes for a bit string defined in a 32 bit constant

getBytesback to summary
public byte[] getBytes()
getLoadedObjectback to summary
public ASN1Primitive getLoadedObject()
getOctetsback to summary
public byte[] getOctets()

Return the octets contained in this BIT STRING, checking that this BIT STRING really does represent an octet aligned string. Only use this method when the standard you are following dictates that the BIT STRING will be octet aligned.

Returns:byte[]

a copy of the octet aligned data.

getPadBitsback to summary
protected static int getPadBits(int bitString)
Parameters
bitString:int

an int containing the BIT STRING

Returns:int

the correct number of pad bits for a bit string defined in a 32 bit constant

getPadBitsback to summary
public int getPadBits()
getStringback to summary
public String getString()

Implements org.bouncycastle.asn1.ASN1String.getString.

Return a String representation of this BIT STRING

Returns:String

a String representation.

hashCodeback to summary
public int hashCode()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

intValueback to summary
public int intValue()
Returns:int

the value of the bit string as an int (truncating if necessary)

toDERObjectback to summary
pack-priv ASN1Primitive toDERObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDERObject.

Doc from org.bouncycastle.asn1.ASN1Primitive.toDERObject.

Return the current object as one which encodes using Distinguished Encoding Rules.

Returns:ASN1Primitive

a DER version of this.

toDLObjectback to summary
pack-priv ASN1Primitive toDLObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDLObject.

Doc from org.bouncycastle.asn1.ASN1Primitive.toDLObject.

Return the current object as one which encodes using Definite Length encoding.

Returns:ASN1Primitive

a DL version of this.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object