def parse_private(data, password=None):
if not isinstance(data, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(data)<EOL>))<EOL><DEDENT>if password is not None:<EOL><INDENT>if not isinstance(password, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(password)<EOL>))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>password = b'<STR_LIT>'<EOL><DEDENT>if data[<NUM_LIT:0>:<NUM_LIT:5>] == b'<STR_LIT>':<EOL><INDENT>key_type, _, data = _unarmor_pem(data, password)<EOL>if key_type == '<STR_LIT>':<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>'''<EOL>))<EOL><DEDENT>if key_type == '<STR_LIT>':<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>'''<EOL>))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>pki = keys.PrivateKeyInfo.load(data)<EOL>pki.native<EOL>return pki<EOL><DEDENT>except (ValueError):<EOL><INDENT>pass  <EOL><DEDENT>try:<EOL><INDENT>parsed_wrapper = keys.EncryptedPrivateKeyInfo.load(data)<EOL>encryption_algorithm_info = parsed_wrapper['<STR_LIT>']<EOL>encrypted_data = parsed_wrapper['<STR_LIT>'].native<EOL>decrypted_data = _decrypt_encrypted_data(encryption_algorithm_info, encrypted_data, password)<EOL>pki = keys.PrivateKeyInfo.load(decrypted_data)<EOL>pki.native<EOL>return pki<EOL><DEDENT>except (ValueError):<EOL><INDENT>pass  <EOL><DEDENT>try:<EOL><INDENT>parsed = keys.RSAPrivateKey.load(data)<EOL>parsed.native<EOL>return keys.PrivateKeyInfo.wrap(parsed, '<STR_LIT>')<EOL><DEDENT>except (ValueError):<EOL><INDENT>pass  <EOL><DEDENT>try:<EOL><INDENT>parsed = keys.DSAPrivateKey.load(data)<EOL>parsed.native<EOL>return keys.PrivateKeyInfo.wrap(parsed, '<STR_LIT>')<EOL><DEDENT>except (ValueError):<EOL><INDENT>pass  <EOL><DEDENT>try:<EOL><INDENT>parsed = keys.ECPrivateKey.load(data)<EOL>parsed.native<EOL>return keys.PrivateKeyInfo.wrap(parsed, '<STR_LIT>')<EOL><DEDENT>except (ValueError):<EOL><INDENT>pass  <EOL><DEDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>'''<EOL>))<EOL>
Loads a private key from a DER or PEM-formatted file. Supports RSA, DSA and
EC private keys. Works with the follow formats:

 - RSAPrivateKey (PKCS#1)
 - ECPrivateKey (SECG SEC1 V2)
 - DSAPrivateKey (OpenSSL)
 - PrivateKeyInfo (RSA/DSA/EC - PKCS#8)
 - EncryptedPrivateKeyInfo (RSA/DSA/EC - PKCS#8)
 - Encrypted RSAPrivateKey (PEM only, OpenSSL)
 - Encrypted DSAPrivateKey (PEM only, OpenSSL)
 - Encrypted ECPrivateKey (PEM only, OpenSSL)

:param data:
    A byte string to load the private key from

:param password:
    The password to unencrypt the private key

:raises:
    ValueError - when the data does not appear to contain a private key, or the password is invalid

:return:
    An asn1crypto.keys.PrivateKeyInfo object