File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,8 @@ def remove_integer(string):
217217def read_number (string ):
218218 number = 0
219219 llen = 0
220+ if str_idx_as_int (string , 0 ) == 0x80 :
221+ raise UnexpectedDER ("Non minimal encoding of OID subidentifier" )
220222 # base-128 big endian, with b7 set in all but the last byte
221223 while True :
222224 if llen >= len (string ):
Original file line number Diff line number Diff line change @@ -311,6 +311,14 @@ def test_with_large_second_subid(self):
311311 self .assertEqual (rest , b'' )
312312 self .assertEqual (oid , (2 , 999 , 3 ))
313313
314+ def test_with_padded_first_subid (self ):
315+ with self .assertRaises (UnexpectedDER ):
316+ remove_object (b'\x06 \x02 \x80 \x00 ' )
317+
318+ def test_with_padded_second_subid (self ):
319+ with self .assertRaises (UnexpectedDER ):
320+ remove_object (b'\x06 \x04 \x88 \x37 \x80 \x01 ' )
321+
314322 def test_with_missing_last_byte_of_multi_byte (self ):
315323 with self .assertRaises (UnexpectedDER ):
316324 remove_object (b'\x06 \x03 \x88 \x37 \x83 ' )
You can’t perform that action at this time.
0 commit comments