def valid_privkey(privkey):
 try:
  return OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, privkey).check()
 except (TypeError, OpenSSL.crypto.Error):
  return False

def valid_privkey ( privkey ) : try : return OpenSSL . crypto . load_privatekey ( OpenSSL . crypto . FILETYPE_PEM , privkey ) . check ( ) except ( TypeError , OpenSSL . crypto . Error ) : return False
is valid rsa private key? .