class PyAsn1Error(Exception):
class ValueConstraintError(PyAsn1Error):
class SubstrateUnderrunError(PyAsn1Error):
class EndOfStreamError(SubstrateUnderrunError):
class UnsupportedSubstrateError(PyAsn1Error):
class PyAsn1UnicodeError(PyAsn1Error, UnicodeError):
class PyAsn1UnicodeDecodeError(PyAsn1UnicodeError, UnicodeDecodeError):
class PyAsn1UnicodeEncodeError(PyAsn1UnicodeError, UnicodeEncodeError):
    def __init__(self, *args, **kwargs):
    def context(self):
    def __init__(self, message, unicode_error=None): class EndOfOctets(base.SimpleAsn1Type):
    def __new__(cls, *args, **kwargs): def from_bytes(octets, signed=False):
def to_bytes(value, signed=False, length=0):
def bitLength(number):
def from_bytes(octets, signed=False):
def to_bytes(value, signed=False, length=0):
def bitLength(number): class Asn1Item(object):
class Asn1Type(Asn1Item):
class NoValue(object):
class SimpleAsn1Type(Asn1Type):
class ConstructedAsn1Type(Asn1Type):
    def getTypeId(cls, increment=1):
    def __init__(self, **kwargs):
    def __setattr__(self, name, value):
    def __str__(self):
    def readOnly(self):
    def effectiveTagSet(self):
    def tagMap(self):
    def isSameTypeWith(self, other, matchTags=True, matchConstraints=True):
    def isSuperTypeOf(self, other, matchTags=True, matchConstraints=True):
    def isNoValue(*values):
    def prettyPrint(self, scope=0):
    def getTagSet(self):
    def getEffectiveTagSet(self):
    def getTagMap(self):
    def getSubtypeSpec(self):
    def hasValue(self):
    def __new__(cls):
            def getPlug(name):
                def plug(self, *args, **kw):
    def __getattr__(self, attr):
    def __repr__(self):
    def __init__(self, value=noValue, **kwargs):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
        def __nonzero__(self):
        def __bool__(self):
    def __hash__(self):
    def isValue(self):
    def clone(self, value=noValue, **kwargs):
    def subtype(self, value=noValue, **kwargs):
    def prettyIn(self, value):
    def prettyOut(self, value):
    def prettyPrint(self, scope=0):
    def prettyPrintType(self, scope=0):
    def __init__(self, **kwargs):
    def _moveSizeSpec(self, **kwargs):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
        def __nonzero__(self):
        def __bool__(self):
    def components(self):
    def _cloneComponentValues(self, myClone, cloneValueFlag):
    def clone(self, **kwargs):
    def subtype(self, **kwargs):
    def getComponentByPosition(self, idx):
    def setComponentByPosition(self, idx, value, verifyConstraints=True):
    def setComponents(self, *args, **kwargs):
    def setDefaultComponents(self):
    def getComponentType(self):
    def verifySizeSpec(self): class AbstractConstraint(object):
class SingleValueConstraint(AbstractConstraint):
class ContainedSubtypeConstraint(AbstractConstraint):
class ValueRangeConstraint(AbstractConstraint):
class ValueSizeConstraint(ValueRangeConstraint):
class PermittedAlphabetConstraint(SingleValueConstraint):
class ComponentPresentConstraint(AbstractConstraint):
class ComponentAbsentConstraint(AbstractConstraint):
class WithComponentsConstraint(AbstractConstraint):
class InnerTypeConstraint(AbstractConstraint):
class ConstraintsExclusion(AbstractConstraint):
class AbstractConstraintSet(AbstractConstraint):
class ConstraintsIntersection(AbstractConstraintSet):
class ConstraintsUnion(AbstractConstraintSet):
    def __init__(self, *values):
    def __call__(self, value, idx=None):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
        def __nonzero__(self):
        def __bool__(self):
    def __hash__(self):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def getValueMap(self):
    def isSuperTypeOf(self, otherConstraint):
    def isSubTypeOf(self, otherConstraint):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def __contains__(self, item):
    def __iter__(self):
    def __sub__(self, constraint):
    def __add__(self, constraint):
    def __sub__(self, constraint):
    def _testValue(self, value, idx):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _setValues(self, values):
    def __getitem__(self, idx):
    def __iter__(self):
    def __add__(self, value):
    def __radd__(self, value):
    def __len__(self):
    def _setValues(self, values):
    def _testValue(self, value, idx):
    def _testValue(self, value, idx): class NamedType(object):
class OptionalNamedType(NamedType):
class DefaultedNamedType(NamedType):
class NamedTypes(object):
    class PostponedError(object):
    def __init__(self, name, asn1Object, openType=None):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
    def __hash__(self):
    def __getitem__(self, idx):
    def __iter__(self):
    def name(self):
    def asn1Object(self):
    def openType(self):
    def getName(self):
    def getType(self):
    def __init__(self, *namedTypes, **kwargs):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
    def __hash__(self):
    def __getitem__(self, idx):
    def __contains__(self, key):
    def __iter__(self):
        def __nonzero__(self):
        def __bool__(self):
    def __len__(self):
    def values(self):
    def keys(self):
    def items(self):
    def clone(self):
        def __init__(self, errorMsg):
        def __getitem__(self, item):
    def __computeTagToPosMap(self):
    def __computeNameToPosMap(self):
    def __computeAmbiguousTypes(self):
    def getTypeByPosition(self, idx):
    def getPositionByType(self, tagSet):
    def getNameByPosition(self, idx):
    def getPositionByName(self, name):
    def getTagMapNearPosition(self, idx):
    def getPositionNearType(self, tagSet, idx):
    def __computeMinTagSet(self):
    def minTagSet(self):
    def __computeTagMaps(self, unique):
    def tagMap(self):
    def tagMapUnique(self):
    def hasOptionalOrDefault(self):
    def hasOpenTypes(self):
    def namedTypes(self):
    def requiredComponents(self): class NamedValues(object):
    def __init__(self, *args, **kwargs):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
    def __hash__(self):
    def __getitem__(self, key):
    def __len__(self):
    def __contains__(self, key):
    def __iter__(self):
    def values(self):
    def keys(self):
    def items(self):
    def __add__(self, namedValues):
    def clone(self, *args, **kwargs):
    def getName(self, value):
    def getValue(self, name):
    def getValues(self, *names): class Tag(object):
class TagSet(object):
    def __init__(self, tagClass, tagFormat, tagId):
    def __repr__(self):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
    def __hash__(self):
    def __getitem__(self, idx):
    def __iter__(self):
    def __and__(self, otherTag):
    def __or__(self, otherTag):
    def tagClass(self):
    def tagFormat(self):
    def tagId(self):
    def __init__(self, baseTag=(), *superTags):
    def __repr__(self):
    def __add__(self, superTag):
    def __radd__(self, superTag):
    def __getitem__(self, i):
    def __eq__(self, other):
    def __ne__(self, other):
    def __lt__(self, other):
    def __le__(self, other):
    def __gt__(self, other):
    def __ge__(self, other):
    def __hash__(self):
    def __len__(self):
    def baseTag(self):
    def superTags(self):
    def tagExplicitly(self, superTag):
    def tagImplicitly(self, superTag):
    def isSuperTagSetOf(self, tagSet):
    def getBaseTag(self):
def initTagSet(tag): class TagMap(object):
    def __init__(self, presentTypes=None, skipTypes=None, defaultType=None):
    def __contains__(self, tagSet):
    def __getitem__(self, tagSet):
    def __iter__(self):
    def __repr__(self):
    def presentTypes(self):
    def skipTypes(self):
    def defaultType(self):
    def getPosMap(self):
    def getNegMap(self):
    def getDef(self):
import math
import sys
from pyasn1 import error
from pyasn1.codec.ber import eoo
from pyasn1.compat import integer
from pyasn1.compat import octets
from pyasn1.type import base
from pyasn1.type import constraint
from pyasn1.type import namedtype
from pyasn1.type import namedval
from pyasn1.type import tag
from pyasn1.type import tagmap
    #: :py:class:`~pyasn1.type.tag.TagSet` object representing ASN.1 tag(s)
    #: associated with |ASN.1| type.
    tagSet = tag.initTagSet(
        tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 0x01),
    )

    #: Set (on class, not on instance) or return a
    #: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` object
    #: imposing constraints on |ASN.1| type initialization values.
    subtypeSpec = Integer.subtypeSpec + constraint.SingleValueConstraint(0, 1)

    #: Default :py:class:`~pyasn1.type.namedval.NamedValues` object
    #: representing symbolic aliases for numbers
    namedValues = namedval.NamedValues(('False', 0), ('True', 1))

    # Optimization for faster codec lookup
    typeId = Integer.getTypeId()

if sys.version_info[0] < 3:
    SizedIntegerBase = long
else:
    SizedIntegerBase = int


class SizedInteger(SizedIntegerBase):
    bitLength = leadingZeroBits = None

    def setBitLength(self, bitLength):
        self.bitLength = bitLength
        self.leadingZeroBits = max(bitLength - integer.bitLength(self), 0)
        return self

    def __len__(self):
        if self.bitLength is None:
            self.setBitLength(integer.bitLength(self))

        return self.bitLength


class BitString(base.SimpleAsn1Type):
    """Create |ASN.1| schema or value object.

    |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its
    objects are immutable and duck-type both Python :class:`tuple` (as a tuple
    of bits) and :class:`int` objects.

    Keyword Args
    ------------
    value: :class:`int`, :class:`str` or |ASN.1| object
        Python :class:`int` or :class:`str` literal representing binary
        or hexadecimal number or sequence of integer bits or |ASN.1| object.
        If `value` is not given, schema object will be created.

    tagSet: :py:class:`~pyasn1.type.tag.TagSet`
        Object representing non-default ASN.1 tag(s)

    subtypeSpec: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection`
        Object representing non-default ASN.1 subtype constraint(s). Constraints
        verification for |ASN.1| type occurs automatically on object
        instantiation.

    namedValues: :py:class:`~pyasn1.type.namedval.NamedValues`
        Object representing non-default symbolic aliases for numbers

    binValue: :py:class:`str`
        Binary string initializer to use instead of the *value*.
        Example: '10110011'.

    hexValue: :py:class:`str`
        Hexadecimal string initializer to use instead of the *value*.
        Example: 'DEADBEEF'.

    Raises
    ------
    ~pyasn1.error.ValueConstraintError, ~pyasn1.error.PyAsn1Error
        On constraint violation or bad initializer.

    Examples
    --------
    .. code-block:: python

        class Rights(BitString):
            '''
            ASN.1 specification:

            Rights ::= BIT STRING { user-read(0), user-write(1),
                                    group-read(2), group-write(3),
                                    other-read(4), other-write(5) }

            group1 Rights ::= { group-read, group-write }
            group2 Rights ::= '0011'B
            group3 Rights ::= '3'H
            '''
            namedValues = NamedValues(
                ('user-read', 0), ('user-write', 1),
                ('group-read', 2), ('group-write', 3),
                ('other-read', 4), ('other-write', 5)
            )

        group1 = Rights(('group-read', 'group-write'))
        group2 = Rights('0011')
        group3 = Rights(0x3)
    """
    #: Set (on class, not on instance) or return a
    #: :py:class:`~pyasn1.type.tag.TagSet` object representing ASN.1 tag(s)
    #: associated with |ASN.1| type.
    tagSet = tag.initTagSet(
        tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 0x03)
    )

    #: Set (on class, not on instance) or return a
    #: :py:class:`~pyasn1.type.constraint.ConstraintsIntersection` object
    #: imposing constraints on |ASN.1| type initialization values.
    subtypeSpec = constraint.ConstraintsIntersection()

    #: Default :py:class:`~pyasn1.type.namedval.NamedValues` object
    #: representing symbolic aliases for numbers
    namedValues = namedval.NamedValues()

    # Optimization for faster codec lookup

    typeId = base.SimpleAsn1Type.getTypeId()