@@ -132,7 +132,7 @@ def __init__(self, keydata=None, **kwargs):
132132 pass
133133
134134 def __str__ (self ):
135- return "Key type: %s, bits: %s, options: %s" % (self .key_type , self .bits , self .options )
135+ return "Key type: %s, bits: %s, options: %s" % (self .key_type . decode () , self .bits , self .options )
136136
137137 def reset (self ):
138138 """Reset all data fields."""
@@ -313,11 +313,11 @@ def _process_ssh_rsa(self, data):
313313 max_length = self .RSA_MAX_LENGTH_LOOSE
314314 if self .bits < min_length :
315315 raise TooShortKeyError (
316- "%s key data can not be shorter than %s bits (was %s)" % (self .key_type , min_length , self .bits )
316+ "%s key data can not be shorter than %s bits (was %s)" % (self .key_type . decode () , min_length , self .bits )
317317 )
318318 if self .bits > max_length :
319319 raise TooLongKeyError (
320- "%s key data can not be longer than %s bits (was %s)" % (self .key_type , max_length , self .bits )
320+ "%s key data can not be longer than %s bits (was %s)" % (self .key_type . decode () , max_length , self .bits )
321321 )
322322 return current_position
323323
@@ -340,10 +340,10 @@ def _process_ssh_dss(self, data):
340340 min_length = self .DSA_MIN_LENGTH_LOOSE
341341 max_length = self .DSA_MAX_LENGTH_LOOSE
342342 if p_bits < min_length :
343- raise TooShortKeyError ("%s key can not be shorter than %s bits (was %s)" % (self .key_type , min_length , p_bits ))
343+ raise TooShortKeyError ("%s key can not be shorter than %s bits (was %s)" % (self .key_type . decode () , min_length , p_bits ))
344344 if p_bits > max_length :
345345 raise TooLongKeyError (
346- "%s key data can not be longer than %s bits (was %s)" % (self .key_type , max_length , p_bits )
346+ "%s key data can not be longer than %s bits (was %s)" % (self .key_type . decode () , max_length , p_bits )
347347 )
348348
349349 dsa_parameters = DSAParameterNumbers (data_fields ["p" ], data_fields ["q" ], data_fields ["g" ])
@@ -398,7 +398,7 @@ def _process_key(self, data):
398398 elif self .key_type == b"ssh-ed25519" :
399399 return self ._process_ed25516 (data )
400400 else :
401- raise NotImplementedError ("Invalid key type: %s" % self .key_type )
401+ raise NotImplementedError ("Invalid key type: %s" % self .key_type . decode () )
402402
403403 def parse (self , keydata = None ):
404404 """Validates SSH public key.
@@ -432,7 +432,7 @@ def parse(self, keydata=None):
432432 # Check key type
433433 current_position , unpacked_key_type = self ._unpack_by_int (self ._decoded_key , 0 )
434434 if key_type is not None and key_type != unpacked_key_type .decode ():
435- raise InvalidTypeError ("Keytype mismatch: %s != %s" % (key_type , unpacked_key_type ))
435+ raise InvalidTypeError ("Keytype mismatch: %s != %s" % (key_type , unpacked_key_type . decode () ))
436436
437437 self .key_type = unpacked_key_type
438438
0 commit comments