Package Crypto :: Package Util :: Module asn1 :: Class DerSequence
[frames] | no frames]

Class DerSequence

DerObject --+
            |
           DerSequence

Class to model a SEQUENCE DER element.

This object behave like a dynamic Python sequence. Sub-elements that are INTEGERs, look like Python integers. Any other sub-element is a binary string encoded as the complete DER sub-element (TLV).

Instance Methods
 
__init__(self, startSeq=None)
Initialize the SEQUENCE DER object. Always empty initially.
 
__delitem__(self, n)
 
__getitem__(self, n)
 
__setitem__(self, key, value)
 
__setslice__(self, i, j, sequence)
 
__delslice__(self, i, j)
 
__getslice__(self, i, j)
 
__len__(self)
 
append(self, item)
 
hasInts(self)
Return the number of items in this sequence that are numbers.
 
hasOnlyInts(self)
Return True if all items in this sequence are numbers.
 
encode(self)
Return the DER encoding for the ASN.1 SEQUENCE, containing the non-negative integers and longs added to this object.
 
decode(self, derEle, noLeftOvers=0)
Decode a complete SEQUENCE DER element, and re-initializes this object with it.
    Inherited from DerObject
 
isType(self, ASN1Type)
Class Variables
    Inherited from DerObject
  typeTags = {'BIT STRING': 3, 'INTEGER': 2, 'NULL': 5, 'OBJECT ...
Method Details

__init__(self, startSeq=None)
(Constructor)

 
Initialize the SEQUENCE DER object. Always empty initially.
Overrides: DerObject.__init__

encode(self)

 

Return the DER encoding for the ASN.1 SEQUENCE, containing the non-negative integers and longs added to this object.

Limitation: Raises a ValueError exception if it some elements in the sequence are neither Python integers nor complete DER INTEGERs.

Overrides: DerObject.encode

decode(self, derEle, noLeftOvers=0)

 

Decode a complete SEQUENCE DER element, and re-initializes this object with it.

@param derEle A complete SEQUENCE DER element. It must start with a DER
SEQUENCE tag.
@param noLeftOvers Indicate whether it is acceptable to complete the
parsing of the DER element and find that not all bytes in derEle have been used.

@return Index of the first unused byte in the given DER element.

DER INTEGERs are decoded into Python integers. Any other DER element is not decoded. Its validity is not checked.

Raises a ValueError exception if the DER element is not a valid DER SEQUENCE. Raises an IndexError exception if the DER element is too short.

Overrides: DerObject.decode