Top Description Fields Constructors Methods
org.bouncycastle.asn1

public abstract Class ASN1BitString

extends ASN1Primitive
implements ASN1String, ASN1BitStringParser
Class Inheritance
All Implemented Interfaces
org.bouncycastle.asn1.ASN1BitStringParser, org.bouncycastle.asn1.InMemoryRepresentable, org.bouncycastle.asn1.ASN1Encodable, org.bouncycastle.asn1.ASN1String
Known Direct Subclasses
org.bouncycastle.asn1.BERBitString, org.bouncycastle.asn1.DERBitString, org.bouncycastle.asn1.DLBitString
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, org.bouncycastle.util.Arrays

Base class for BIT STRING objects

Field Summary

Modifier and TypeField and Description
pack-priv final byte[]
private static final char[]
pack-priv static final ASN1UniversalType

Constructor Summary

AccessConstructor and Description
pack-priv
ASN1BitString(byte data, int padBits)

pack-priv
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.

pack-priv
ASN1BitString(byte[] contents, boolean check)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
asn1Equals(ASN1Primitive other)

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

Equality (similarity) comparison for two ASN1Primitive objects.
pack-priv static ASN1BitString
createPrimitive(byte[] contents)

public InputStream
getBitStream()

Implements org.bouncycastle.asn1.ASN1BitStringParser.getBitStream.

Return an InputStream representing the contents of the BIT STRING.
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 static ASN1BitString
public static ASN1BitString
getInstance(ASN1TaggedObject taggedObject, boolean explicit)

public ASN1Primitive
getLoadedObject()

Implements org.bouncycastle.asn1.InMemoryRepresentable.getLoadedObject.

Get the in-memory representation of the ASN.1 object.
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.

public InputStream
getOctetStream()

Implements org.bouncycastle.asn1.ASN1BitStringParser.getOctetStream.

Return an InputStream representing the contents of the BIT STRING, where the content is expected to be octet-aligned (this will be automatically checked during parsing).
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
getPadBits()

Implements org.bouncycastle.asn1.ASN1BitStringParser.getPadBits.

Return the number of pad bits, if any, in the final byte, if any, read from getBitStream().
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 the object.
public int

Returns:

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

public ASN1BitStringParser
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:
encodeencodeConstructedencodedLengthencodeToencodeToequalsequalsequalsfromByteArraytoASN1Primitive

Field Detail

contentsback to summary
pack-priv final byte[] contents
tableback to summary
private static final char[] table
TYPEback to summary
pack-priv static final ASN1UniversalType TYPE

Constructor Detail

ASN1BitStringback to summary
pack-priv ASN1BitString(byte data, int padBits)
ASN1BitStringback to summary
pack-priv 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.

ASN1BitStringback to summary
pack-priv ASN1BitString(byte[] contents, boolean check)

Method Detail

asn1Equalsback to summary
pack-priv boolean asn1Equals(ASN1Primitive other)

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

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

Equality (similarity) comparison for two ASN1Primitive objects.

createPrimitiveback to summary
pack-priv static ASN1BitString createPrimitive(byte[] contents)
getBitStreamback to summary
public InputStream getBitStream() throws IOException

Implements org.bouncycastle.asn1.ASN1BitStringParser.getBitStream.

Doc from org.bouncycastle.asn1.ASN1BitStringParser.getBitStream.

Return an InputStream representing the contents of the BIT STRING. The final byte, if any, may include pad bits. See getPadBits().

Returns:InputStream

an InputStream with its source as the BIT STRING content.

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()
getInstanceback to summary
public static ASN1BitString getInstance(Object obj)
getInstanceback to summary
public static ASN1BitString getInstance(ASN1TaggedObject taggedObject, boolean explicit)
getLoadedObjectback to summary
public ASN1Primitive getLoadedObject()

Implements org.bouncycastle.asn1.InMemoryRepresentable.getLoadedObject.

Doc from org.bouncycastle.asn1.InMemoryRepresentable.getLoadedObject.

Get the in-memory representation of the ASN.1 object.

Returns:ASN1Primitive

an ASN1Primitive representing the loaded object.

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.

getOctetStreamback to summary
public InputStream getOctetStream() throws IOException

Implements org.bouncycastle.asn1.ASN1BitStringParser.getOctetStream.

Doc from org.bouncycastle.asn1.ASN1BitStringParser.getOctetStream.

Return an InputStream representing the contents of the BIT STRING, where the content is expected to be octet-aligned (this will be automatically checked during parsing).

Returns:InputStream

an InputStream with its source as the BIT STRING content.

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()

Implements org.bouncycastle.asn1.ASN1BitStringParser.getPadBits.

Doc from org.bouncycastle.asn1.ASN1BitStringParser.getPadBits.

Return the number of pad bits, if any, in the final byte, if any, read from getBitStream(). This number is in the range zero to seven. That number of the least significant bits of the final byte, if any, are not part of the contents and should be ignored.

Note

Must be called AFTER the stream has been fully processed. (Does not need to be called if getOctetStream() was used instead of getBitStream()).

Returns:int

the number of pad bits. In the range zero to seven.

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 the 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)

parserback to summary
public ASN1BitStringParser parser()
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.