docs: def parse_private_key(data, password):
      """
      Identifies, decrypts and returns a cryptography private key object.
      """
      # PEM
      if is_pem(data):
          if b'ENCRYPTED' in data:
              if password is None:
                  raise TypeError('No password provided for encrypted key.')
          try:
              return serialization.load_pem_private_key(
                  data, password, backend=default_backend())
          except ValueError:
              # Cryptography raises ValueError if decryption fails.
              raise
          except Exception:
              pass
  
      # PKCS12
      if is_pkcs12(data):
          try:
              p12 = crypto.load_pkcs12(data, password)
              data = crypto.dump_privatekey(
                  crypto.FILETYPE_PEM, p12.get_privatekey())
              return serialization.load_pem_private_key(
                  data, password=None, backend=default_backend())
          except crypto.Error as e:
              raise ValueError(e)
  
      # DER
      try:
          return serialization.load_der_private_key(
              data, password, backend=default_backend())
      except Exception:
          pass
  
      # All parsing failed
      raise ValueError('Could not parse private key.')