def import_key(extern_key, passphrase=None):
 extern_key = tobytes(extern_key)
 if (passphrase is not None):
  passphrase = tobytes(passphrase)
 if extern_key.startswith(b('-----')):
  (der, marker, enc_flag) = PEM.decode(tostr(extern_key), passphrase)
  if enc_flag:
   passphrase = None
  return _import_keyDER(der, passphrase)
 if extern_key.startswith(b('ssh-rsa ')):
  keystring = binascii.a2b_base64(extern_key.split(b(' '))[1])
  keyparts = []
  while (len(keystring) > 4):
   l = struct.unpack('>I', keystring[:4])[0]
   keyparts.append(keystring[4:(4 + l)])
   keystring = keystring[(4 + l):]
  e = Integer.from_bytes(keyparts[1])
  n = Integer.from_bytes(keyparts[2])
  return construct([n, e])
 if (bord(extern_key[0]) == 48):
  return _import_keyDER(extern_key, passphrase)
 raise ValueError('RSA key format is not supported')

def import_key ( extern_key , passphrase = None ) : extern_key = tobytes ( extern_key ) if ( passphrase is not None ) : passphrase = tobytes ( passphrase ) if extern_key . startswith ( b ( '-----' ) ) : ( der , marker , enc_flag ) = PEM . decode ( tostr ( extern_key ) , passphrase ) if enc_flag : passphrase = None return _import_keyDER ( der , passphrase ) if extern_key . startswith ( b ( 'ssh-rsa ' ) ) : keystring = binascii . a2b_base64 ( extern_key . split ( b ( ' ' ) ) [ 1 ] ) keyparts = [ ] while ( len ( keystring ) > 4 ) : l = struct . unpack ( '>I' , keystring [ : 4 ] ) [ 0 ] keyparts . append ( keystring [ 4 : ( 4 + l ) ] ) keystring = keystring [ ( 4 + l ) : ] e = Integer . from_bytes ( keyparts [ 1 ] ) n = Integer . from_bytes ( keyparts [ 2 ] ) return construct ( [ n , e ] ) if ( bord ( extern_key [ 0 ] ) == 48 ) : return _import_keyDER ( extern_key , passphrase ) raise ValueError ( 'RSA key format is not supported' )
import an rsa key .