From be68ad170bdc1641c813ea275bc397a189f9fce6 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sun, 20 May 2018 18:14:03 +0300 Subject: [PATCH] Add missing klass for DecodeErrors --- pyderasn.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyderasn.py b/pyderasn.py index 278db2c..50479c6 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -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, ) -- 2.44.0