Exemplo n.º 1
0
def get_ssh_certificate_authority(private_key, password=None):
    """
    Returns the proper SSHCertificateAuthority instance based off the private_key type.
    :param private_key: SSH compatible Private Key (e.g., PEM or SSH Protocol 2 Private Key).
    It should be encrypted with a password, but that is not required.
    :param password: Password to decrypt the Private Key, if it is encrypted.  Which it should be.
    :return: An SSHCertificateAuthority instance.
    """
    if private_key.startswith(SSHCertificateAuthorityPrivateKeyType.RSA):
        return RSACertificateAuthority(private_key, password)
    else:
        raise TypeError("Unsupported CA Private Key Type")
def get_ssh_certificate_authority(private_key, password=None):
    """
    Returns the proper SSHCertificateAuthority instance based off the private_key type.
    :param private_key: ASCII bytes of an SSH compatible Private Key (e.g., PEM or SSH Protocol 2 Private Key).
    It should be encrypted with a password, but that is not required.
    :param password: ASCII bytes of the Password to decrypt the Private Key, if it is encrypted.  Which it should be.
    :return: An SSHCertificateAuthority instance.
    """
    xray_recorder.begin_subsegment('ssh_decrypt')
    if private_key.decode('ascii').startswith(
            SSHCertificateAuthorityPrivateKeyType.RSA):
        return RSACertificateAuthority(private_key, password)
    else:
        raise TypeError("Unsupported CA Private Key Type")
    xray_recorder.end_subsegment()
Exemplo n.º 3
0
def get_basic_rsa_ca():
    return RSACertificateAuthority(RSA_CA_PRIVATE_KEY,
                                   RSA_CA_PRIVATE_KEY_PASSWORD)