]> Cypherpunks.ru repositories - pyderasn.git/commitdiff
Add missing klass for DecodeErrors
authorSergey Matveev <stargrave@stargrave.org>
Sun, 20 May 2018 15:14:03 +0000 (18:14 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 20 May 2018 15:14:03 +0000 (18:14 +0300)
pyderasn.py

index 278db2c496008082006cb4ed3e15ded0cb8482c0..50479c60a9d47b3266975178bbfb25ecdff9e841 100755 (executable)
@@ -1057,6 +1057,7 @@ class Obj(object):
                 if eoc_expected.tobytes() != EOC:
                     raise DecodeError(
                         "no EOC",
+                        klass=self.__class__,
                         decode_path=decode_path,
                         offset=offset,
                     )
@@ -2203,6 +2204,7 @@ class BitString(Obj):
             if not ctx.get("bered", False):
                 raise DecodeError(
                     "unallowed BER constructed encoding",
+                    klass=self.__class__,
                     decode_path=decode_path,
                     offset=offset,
                 )
@@ -2248,6 +2250,7 @@ class BitString(Obj):
                     if vlen > l:
                         raise DecodeError(
                             "chunk out of bounds",
+                            klass=self.__class__,
                             decode_path=len(chunks) - 1,
                             offset=chunks[-1].offset,
                         )
@@ -2263,6 +2266,7 @@ class BitString(Obj):
                 except TagMismatch:
                     raise DecodeError(
                         "expected BitString encoded chunk",
+                        klass=self.__class__,
                         decode_path=sub_decode_path,
                         offset=sub_offset,
                     )
@@ -2273,6 +2277,7 @@ class BitString(Obj):
             if len(chunks) == 0:
                 raise DecodeError(
                     "no chunks",
+                    klass=self.__class__,
                     decode_path=decode_path,
                     offset=offset,
                 )
@@ -2282,6 +2287,7 @@ class BitString(Obj):
                 if chunk.bit_len % 8 != 0:
                     raise DecodeError(
                         "BitString chunk is not multiple of 8 bit",
+                        klass=self.__class__,
                         decode_path=decode_path + (str(chunk_i),),
                         offset=chunk.offset,
                     )
@@ -2566,6 +2572,7 @@ class OctetString(Obj):
             if not ctx.get("bered", False):
                 raise DecodeError(
                     "unallowed BER constructed encoding",
+                    klass=self.__class__,
                     decode_path=decode_path,
                     offset=offset,
                 )
@@ -2611,6 +2618,7 @@ class OctetString(Obj):
                     if vlen > l:
                         raise DecodeError(
                             "chunk out of bounds",
+                            klass=self.__class__,
                             decode_path=len(chunks) - 1,
                             offset=chunks[-1].offset,
                         )
@@ -2626,6 +2634,7 @@ class OctetString(Obj):
                 except TagMismatch:
                     raise DecodeError(
                         "expected OctetString encoded chunk",
+                        klass=self.__class__,
                         decode_path=sub_decode_path,
                         offset=sub_offset,
                     )
@@ -2636,6 +2645,7 @@ class OctetString(Obj):
             if len(chunks) == 0:
                 raise DecodeError(
                     "no chunks",
+                    klass=self.__class__,
                     decode_path=decode_path,
                     offset=offset,
                 )