@@ -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" ])
@@ -397,7 +397,7 @@ def _process_key(self, data):
397397 return self ._process_ecdsa_sha (data )
398398 if self .key_type == b"ssh-ed25519" :
399399 return self ._process_ed25516 (data )
400- raise NotImplementedError ("Invalid key type: %s" % self .key_type )
400+ raise NotImplementedError ("Invalid key type: %s" % self .key_type . decode () )
401401
402402 def parse (self , keydata = None ):
403403 """Validates SSH public key.
@@ -431,7 +431,7 @@ def parse(self, keydata=None):
431431 # Check key type
432432 current_position , unpacked_key_type = self ._unpack_by_int (self ._decoded_key , 0 )
433433 if key_type is not None and key_type != unpacked_key_type .decode ():
434- raise InvalidTypeError ("Keytype mismatch: %s != %s" % (key_type , unpacked_key_type ))
434+ raise InvalidTypeError ("Keytype mismatch: %s != %s" % (key_type , unpacked_key_type . decode () ))
435435
436436 self .key_type = unpacked_key_type
437437
0 commit comments