Top Description Fields Constructors Methods
org.bouncycastle.asn1

public abstract Class ASN1Sequence

extends ASN1Primitive
implements Iterable<ASN1Encodable>
Class Inheritance
All Implemented Interfaces
org.bouncycastle.util.Iterable, java.lang.Iterable
Known Direct Subclasses
org.bouncycastle.asn1.DERSequence, org.bouncycastle.asn1.DLSequence, org.bouncycastle.asn1.LazyEncodedSequence, org.bouncycastle.asn1.BERSequence
Imports
java.io.IOException, java.util.Enumeration, .Iterator, .Vector, org.bouncycastle.util.Arrays

ASN.1 SEQUENCE and SEQUENCE OF constructs.

DER form is always definite form length fields, while BER support uses indefinite form.


X.690

8: Basic encoding rules

8.9 Encoding of a sequence value

8.9.1 The encoding of a sequence value shall be constructed.

8.9.2 The contents octets shall consist of the complete encoding of one data value from each of the types listed in the ASN.1 definition of the sequence type, in the order of their appearance in the definition, unless the type was referenced with the keyword OPTIONAL or the keyword DEFAULT.

8.9.3 The encoding of a data value may, but need not, be present for a type which was referenced with the keyword OPTIONAL or the keyword DEFAULT. If present, it shall appear in the encoding at the point corresponding to the appearance of the type in the ASN.1 definition.

8.10 Encoding of a sequence-of value

8.10.1 The encoding of a sequence-of value shall be constructed.

8.10.2 The contents octets shall consist of zero, one or more complete encodings of data values from the type listed in the ASN.1 definition.

8.10.3 The order of the encodings of the data values shall be the same as the order of the data values in the sequence-of value to be encoded.

9: Canonical encoding rules

9.1 Length forms

If the encoding is constructed, it shall employ the indefinite-length form. If the encoding is primitive, it shall include the fewest length octets necessary. [Contrast with 8.1.3.2 b).]

11: Restrictions on BER employed by both CER and DER

11.5 Set and sequence components with default value

The encoding of a set value or sequence value shall not include an encoding for any component value which is equal to its default value.

Field Summary

Modifier and TypeField and Description
protected Vector<E>

Constructor Summary

AccessConstructor and Description
protected
ASN1Sequence()

Create an empty SEQUENCE

protected
ASN1Sequence(ASN1Encodable
the object to be put in the SEQUENCE.
obj
)

Create a SEQUENCE containing one object.

protected
ASN1Sequence(ASN1EncodableVector
the vector of objects to be put in the SEQUENCE.
v
)

Create a SEQUENCE containing a vector of objects.

protected
ASN1Sequence(ASN1Encodable[]
the array of objects to be put in the SEQUENCE.
array
)

Create a SEQUENCE containing an array of objects.

Method Summary

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

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

Equality (similarity) comparison for two ASN1Primitive objects.
pack-priv abstract void
public static ASN1Sequence

Returns:

an ASN1Sequence instance, or null.
getInstance
(Object
the object we want converted.
obj
)

Return an ASN1Sequence from the given object.

public static ASN1Sequence

Returns:

an ASN1Sequence instance.
getInstance
(ASN1TaggedObject
the tagged object.
obj
,
boolean
true if the object is meant to be explicitly tagged, false otherwise.
explicit
)

Return an ASN1 SEQUENCE from a tagged object.

private ASN1Encodable
public ASN1Encodable

Returns:

the object at the sequence position indicated by index.
getObjectAt
(int
the sequence number (starting at zero) of the object
index
)

Return the object at the sequence position indicated by index.

public Enumeration<E>
public int
hashCode()

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

Returns a hash code value for this object.
pack-priv boolean
isConstructed()

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

Return true if this objected is a CONSTRUCTED one, false otherwise.
public Iterator<ASN1Encodable>
iterator()

Implements org.bouncycastle.util.Iterable.iterator.

Returns an iterator over a set of elements of type T.
public ASN1SequenceParser
public int

Returns:

the number of objects in this sequence.
size
()

Return the number of objects in this sequence.

public ASN1Encodable[]
pack-priv ASN1Primitive
toDERObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDERObject.

Change current SEQUENCE object to be encoded as DERSequence.
pack-priv ASN1Primitive
toDLObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDLObject.

Change current SEQUENCE object to be encoded as DLSequence.
public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

seqback to summary
protected Vector<E> seq

Constructor Detail

ASN1Sequenceback to summary
protected ASN1Sequence()

Create an empty SEQUENCE

ASN1Sequenceback to summary
protected ASN1Sequence(ASN1Encodable obj)

Create a SEQUENCE containing one object.

Parameters
obj:ASN1Encodable

the object to be put in the SEQUENCE.

ASN1Sequenceback to summary
protected ASN1Sequence(ASN1EncodableVector v)

Create a SEQUENCE containing a vector of objects.

Parameters
v:ASN1EncodableVector

the vector of objects to be put in the SEQUENCE.

ASN1Sequenceback to summary
protected ASN1Sequence(ASN1Encodable[] array)

Create a SEQUENCE containing an array of objects.

Parameters
array:ASN1Encodable[]

the array of objects to be put in the SEQUENCE.

Method Detail

asn1Equalsback to summary
pack-priv 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.

encodeback to summary
pack-priv abstract void encode(ASN1OutputStream out) throws IOException

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

getInstanceback to summary
public static ASN1Sequence getInstance(Object obj)

Return an ASN1Sequence from the given object.

Parameters
obj:Object

the object we want converted.

Returns:ASN1Sequence

an ASN1Sequence instance, or null.

Exceptions
IllegalArgumentException:
if the object cannot be converted.
getInstanceback to summary
public static ASN1Sequence getInstance(ASN1TaggedObject obj, boolean explicit)

Return an ASN1 SEQUENCE from a tagged object. There is a special case here, if an object appears to have been explicitly tagged on reading but we were expecting it to be implicitly tagged in the normal course of events it indicates that we lost the surrounding sequence - so we need to add it back (this will happen if the tagged object is a sequence that contains other sequences). If you are dealing with implicitly tagged sequences you really should be using this method.

Parameters
obj:ASN1TaggedObject

the tagged object.

explicit:boolean

true if the object is meant to be explicitly tagged, false otherwise.

Returns:ASN1Sequence

an ASN1Sequence instance.

Exceptions
IllegalArgumentException:
if the tagged object cannot be converted.
getNextback to summary
private ASN1Encodable getNext(Enumeration<E> e)
getObjectAtback to summary
public ASN1Encodable getObjectAt(int index)

Return the object at the sequence position indicated by index.

Parameters
index:int

the sequence number (starting at zero) of the object

Returns:ASN1Encodable

the object at the sequence position indicated by index.

getObjectsback to summary
public Enumeration<E> getObjects()
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

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.

iteratorback to summary
public Iterator<ASN1Encodable> iterator()

Implements org.bouncycastle.util.Iterable.iterator.

Doc from org.bouncycastle.util.Iterable.iterator.

Returns an iterator over a set of elements of type T.

Returns:Iterator<ASN1Encodable>

an Iterator.

parserback to summary
public ASN1SequenceParser parser()
sizeback to summary
public int size()

Return the number of objects in this sequence.

Returns:int

the number of objects in this sequence.

toArrayback to summary
public ASN1Encodable[] toArray()
toDERObjectback to summary
pack-priv ASN1Primitive toDERObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDERObject.

Change current SEQUENCE object to be encoded as DERSequence. This is part of Distinguished Encoding Rules form serialization.

Returns:ASN1Primitive

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

a DER version of this.

toDLObjectback to summary
pack-priv ASN1Primitive toDLObject()

Overrides org.bouncycastle.asn1.ASN1Primitive.toDLObject.

Change current SEQUENCE object to be encoded as DLSequence. This is part of Direct Length form serialization.

Returns:ASN1Primitive

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

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