X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=pyderasn.py;h=5597563c07964e7c90a6252138f990c23bef1591;hb=333d098f0af80eae5481c99b86419d25ea927d22;hp=2e1180d1be74014a8638620a2c1973d57883545c;hpb=e7e62716431bd975d986be4528392502be156c9c;p=pyderasn.git diff --git a/pyderasn.py b/pyderasn.py index 2e1180d..5597563 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -687,7 +687,7 @@ except ImportError: # pragma: no cover def colored(what, *args, **kwargs): return what -__version__ = "6.0" +__version__ = "6.1" __all__ = ( "Any", @@ -1669,9 +1669,8 @@ def pprint( """Pretty print object :param Obj obj: object you want to pretty print - :param oid_maps: list of ``OID <-> humand readable string`` dictionary. - When OID from it is met, then its humand readable form - is printed + :param oid_maps: list of ``str(OID) <-> human readable string`` dictionary. + Its human readable form is printed when OID is met :param big_blobs: if large binary objects are met (like OctetString values), do we need to print them too, on separate lines @@ -3421,6 +3420,13 @@ ObjectIdentifierState = namedtuple("ObjectIdentifierState", ( )) +def pureint(value): + i = int(value) + if (value[0] in "+- ") or (value[-1] == " "): + raise ValueError("non-pure integer") + return i + + class ObjectIdentifier(Obj): """``OBJECT IDENTIFIER`` OID type @@ -3498,7 +3504,7 @@ class ObjectIdentifier(Obj): return value._value if isinstance(value, string_types): try: - value = tuple(int(arc) for arc in value.split(".")) + value = tuple(pureint(arc) for arc in value.split(".")) except ValueError: raise InvalidOID("unacceptable arcs values") if isinstance(value, tuple): @@ -3512,6 +3518,8 @@ class ObjectIdentifier(Obj): pass else: raise InvalidOID("unacceptable first arc value") + if not all(arc >= 0 for arc in value): + raise InvalidOID("negative arc value") return value raise InvalidValueType((self.__class__, str, tuple))