Share

ASN.1 library for Python

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Boolean Types and Constraint Values

You are viewing a single message from this topic. View all messages.

  1. 2009-01-22 13:09:35 UTC
    I am working with pyasn1, and I found an issues with Boolean types. I
    am working with a protocol that considers the following a Boolean:

    "\x01\x01\xff"

    However, when I try to parse this snippet with the following code:

    from pyasn1.codec.ber import decoder
    decoder.decode("\x01\x01\xff")


    I get this exception:
    ValueConstraintError:
    ConstraintsIntersection(ConstraintsIntersection(),
    SingleValueConstraint(0, 1)) failed at: SingleValueConstraint(0, 1)
    failed at: 15

    Below is a more detailed backtrace. I am not sure how to update the
    code, and on a few passes the code and programming structure are a
    little different from what I am use to, so I was wondering if anyone
    could advise me about bow to
    1) remove the constaints on the Boolean("True") object, so that a True
    value can be 0x1 - 0xff
    2) simply add the 0xff as a value that can represent a Boolean

    I appreciate any help in advance.




    ERROR: An unexpected error occurred while tokenizing input
    The following traceback may be corrupted or invalid
    The error message is: ('EOF in multi-line statement', (241, 0))

    ERROR: An unexpected error occurred while tokenizing input
    The following traceback may be corrupted or invalid
    The error message is: ('EOF in multi-line statement', (49, 0))

    ERROR: An unexpected error occurred while tokenizing input
    The following traceback may be corrupted or invalid
    The error message is: ('EOF in multi-line statement', (34, 0))

    ---------------------------------------------------------------------------
    ValueConstraintError Traceback (most recent call last)

    /home/apridgen/Development/workspace/dpkt/src/<ipython console> in <module>()

    /var/lib/python-support/python2.5/pyasn1/v1/codec/ber/decoder.py in
    __call__(self, substrate, asn1Spec, tagSet, length, state,
    recursiveFlag)
    491 value, _substrate =
    concreteDecoder.valueDecoder(
    492 substrate[:length], asn1Spec, tagSet,
    --> 493 length, stGetValueDecoder, decodeFun
    494 )
    495 if recursiveFlag:

    /var/lib/python-support/python2.5/pyasn1/v1/codec/ber/decoder.py in
    valueDecoder(self, substrate, asn1Spec, tagSet, length, state,
    decodeFun)
    39 except OverflowError:
    40 pass
    ---> 41 return self._createComponent(tagSet,
    asn1Spec).clone(value), substrate
    42
    43 class BooleanDecoder(IntegerDecoder):

    /var/lib/python-support/python2.5/pyasn1/v1/type/univ.pyc in
    clone(self, value, tagSet, subtypeSpec, namedValues)
    89 if namedValues is None:
    90 namedValues = self.__namedValues
    ---> 91 return self.__class__(value, tagSet, subtypeSpec,
    namedValues)
    92
    93 def subtype(self, value=None, implicitTag=None,
    explicitTag=None,

    /var/lib/python-support/python2.5/pyasn1/v1/type/univ.pyc in
    __init__(self, value, tagSet, subtypeSpec, namedValues)
    20 self.__namedValues = namedValues
    21 base.AbstractSimpleAsn1Item.__init__(
    ---> 22 self, value, tagSet, subtypeSpec
    23 )
    24

    /var/lib/python-support/python2.5/pyasn1/v1/type/base.pyc in
    __init__(self, value, tagSet, subtypeSpec)
    62 else:
    63 value = self.prettyIn(value)
    ---> 64 self._verifySubtypeSpec(value)
    65 self.__hashedValue = hash(value)
    66 self._value = value

    /var/lib/python-support/python2.5/pyasn1/v1/type/base.pyc in
    _verifySubtypeSpec(self, value, idx)
    30
    31 def _verifySubtypeSpec(self, value, idx=None):
    ---> 32 self._subtypeSpec(value, idx)
    33
    34 def getSubtypeSpec(self): return self._subtypeSpec

    /var/lib/python-support/python2.5/pyasn1/v1/type/constraint.pyc in
    __call__(self, value, idx)
    31 except error.ValueConstraintError, why:
    32 raise error.ValueConstraintError('%s failed at: %s' % (
    ---> 33 self, why
    34 ))
    35 def __repr__(self):
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.