Top Description Fields Constructors Methods
org.bouncycastle.asn1

public Class BEROctetString

extends ASN1OctetString
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.util.Enumeration, .Vector

ASN.1 OctetStrings, with indefinite length rules, and constructed form support.

The Basic Encoding Rules (BER) format allows encoding using so called "constructed form", which DER and CER formats forbid allowing only "primitive form".

This class always produces the constructed form with underlying segments in an indefinite length array. If the input wasn't the same, then this output is not faithful reproduction.

See ASN1OctetString for X.690 encoding rules of OCTET-STRING objects.

Field Summary

Modifier and TypeField and Description
private final int
private static final int
private final ASN1OctetString[]
Inherited from org.bouncycastle.asn1.ASN1OctetString:
string

Constructor Summary

AccessConstructor and Description
public
BEROctetString(byte[]
the octets making up the octet string.
string
)

Create an OCTET-STRING object from a byte[]

public
BEROctetString(ASN1OctetString[]
an array of OCTET STRING to construct the BER OCTET STRING from.
octs
)

Multiple ASN1OctetString data blocks are input, the result is constructed form.

public
BEROctetString(byte[]
the octets making up the octet string.
string
,
int
the number of octets stored in each DER encoded component OCTET STRING.
chunkSize
)

Create an OCTET-STRING object from a byte[]

public
BEROctetString(ASN1OctetString[]
an array of OCTET STRING to construct the BER OCTET STRING from.
octs
,
int
the number of octets stored in each DER encoded component OCTET STRING.
chunkSize
)

Multiple ASN1OctetString data blocks are input, the result is constructed form.

private
BEROctetString(byte[] string, ASN1OctetString[] octs, int chunkSize)

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv int
encodedLength()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodedLength.

Return the length of the encoding this object will produce.
pack-priv static BEROctetString
private Vector<E>
public Enumeration<E>

Returns:

an Enumeration of the component OCTET STRINGs.
getObjects
()

Return the OCTET STRINGs that make up this string.

public byte[]

Returns:

the full OCTET STRING.
getOctets
()

Overrides org.bouncycastle.asn1.ASN1OctetString.getOctets.

Return a concatenated byte array of all the octets making up the constructed OCTET STRING
pack-priv boolean
isConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.isConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.
private static byte[]
toBytes(ASN1OctetString[] octs)

Convert a vector of octet strings into a single byte string

Inherited from org.bouncycastle.asn1.ASN1OctetString:
asn1EqualsgetInstancegetInstancegetLoadedObjectgetOctetStreamhashCodeparsertoDERObjecttoDLObjecttoString

Field Detail

chunkSizeback to summary
private final int chunkSize
DEFAULT_LENGTHback to summary
private static final int DEFAULT_LENGTH
octsback to summary
private final ASN1OctetString[] octs

Constructor Detail

BEROctetStringback to summary
public BEROctetString(byte[] string)

Create an OCTET-STRING object from a byte[]

Parameters
string:byte[]

the octets making up the octet string.

BEROctetStringback to summary
public BEROctetString(ASN1OctetString[] octs)

Multiple ASN1OctetString data blocks are input, the result is constructed form.

Parameters
octs:ASN1OctetString[]

an array of OCTET STRING to construct the BER OCTET STRING from.

BEROctetStringback to summary
public BEROctetString(byte[] string, int chunkSize)

Create an OCTET-STRING object from a byte[]

Parameters
string:byte[]

the octets making up the octet string.

chunkSize:int

the number of octets stored in each DER encoded component OCTET STRING.

BEROctetStringback to summary
public BEROctetString(ASN1OctetString[] octs, int chunkSize)

Multiple ASN1OctetString data blocks are input, the result is constructed form.

Parameters
octs:ASN1OctetString[]

an array of OCTET STRING to construct the BER OCTET STRING from.

chunkSize:int

the number of octets stored in each DER encoded component OCTET STRING.

BEROctetStringback to summary
private BEROctetString(byte[] string, ASN1OctetString[] octs, int chunkSize)

Method Detail

encodeback to summary
public void encode(ASN1OutputStream out) throws IOException

Implements abstract org.bouncycastle.asn1.ASN1OctetString.encode.

encodedLengthback to summary
pack-priv int encodedLength() throws IOException

Implements abstract org.bouncycastle.asn1.ASN1Primitive.encodedLength.

Doc from org.bouncycastle.asn1.ASN1Primitive.encodedLength.

Return the length of the encoding this object will produce.

Returns:int

the length of the object's encoding.

Exceptions
IOException:
if the encoding length cannot be calculated.
fromSequenceback to summary
pack-priv static BEROctetString fromSequence(ASN1Sequence seq)
generateOctsback to summary
private Vector<E> generateOcts()
getObjectsback to summary
public Enumeration<E> getObjects()

Return the OCTET STRINGs that make up this string.

Returns:Enumeration<E>

an Enumeration of the component OCTET STRINGs.

getOctetsback to summary
public byte[] getOctets()

Overrides org.bouncycastle.asn1.ASN1OctetString.getOctets.

Return a concatenated byte array of all the octets making up the constructed OCTET STRING

Returns:byte[]

the full OCTET STRING.

isConstructedback to summary
pack-priv boolean isConstructed()

Implements abstract org.bouncycastle.asn1.ASN1Primitive.isConstructed.

Doc from org.bouncycastle.asn1.ASN1Primitive.isConstructed.

Return true if this objected is a CONSTRUCTED one, false otherwise.

Returns:boolean

true if CONSTRUCTED bit set on object's tag, false otherwise.

toBytesback to summary
private static byte[] toBytes(ASN1OctetString[] octs)

Convert a vector of octet strings into a single byte string