@@ -135,7 +135,7 @@ def remove_constructed(string):
135135def remove_sequence (string ):
136136 if not string :
137137 raise UnexpectedDER ("Empty string does not encode a sequence" )
138- if not string . startswith ( b ( "\x30 " )) :
138+ if string [: 1 ] != b "\x30 " :
139139 n = string [0 ] if isinstance (string [0 ], integer_types ) else \
140140 ord (string [0 ])
141141 raise UnexpectedDER ("wanted type 'sequence' (0x30), got 0x%02x" % n )
@@ -157,7 +157,7 @@ def remove_octet_string(string):
157157
158158
159159def remove_object (string ):
160- if not string . startswith ( b ( "\x06 " )) :
160+ if string [: 1 ] != b "\x06 " :
161161 n = string [0 ] if isinstance (string [0 ], integer_types ) else ord (string [0 ])
162162 raise UnexpectedDER ("wanted type 'object' (0x06), got 0x%02x" % n )
163163 length , lengthlength = read_length (string [1 :])
@@ -302,7 +302,7 @@ def remove_bitstring(string, expect_unused=_sentry):
302302 " specified" ,
303303 DeprecationWarning )
304304 num = string [0 ] if isinstance (string [0 ], integer_types ) else ord (string [0 ])
305- if not string . startswith ( b ( "\x03 " )) :
305+ if string [: 1 ] != b "\x03 " :
306306 raise UnexpectedDER ("wanted bitstring (0x03), got 0x%02x" % num )
307307 length , llen = read_length (string [1 :])
308308 if not length :
0 commit comments