def detect_tpm(): # FIXME: Improve try: if len(next(walk('/sys/class/tpm'))[1]) == 0: return False except StopIteration: # Directory does not exist: not supported by kernel return False try: detect_executable('stpm-keygen') except ExecutableNotFoundError: return False return True
def detected(cls): if not 'DISPLAY' in environ or environ['DISPLAY'] == '': return False try: cls.executable = detect_executable('xdg-open') return True except ExecutableNotFoundError as e: return False
def generate_tpm_key(private_key_path, size): # FIXME: Error out if size != 2048 ? detect_executable('stpm-keygen').run_silent('-r', '-o', private_key_path)
distinguished_name = req_distinguished_name req_extensions = v3_req [req_distinguished_name] [v3_req] keyUsage = digitalSignature, nonRepudiation extendedKeyUsage = clientAuth [dir_sect] """ OPENSSL_RSA_ENCRYPT_FLAG = '-aes256' try: openssl = detect_executable('openssl') except ExecutableNotFoundError as e: raise ImportError( 'Unable to import %s: unable to locate openssl executable' % __name__) class SSLEngineError(Exception): pass class AsnDecodingError(SSLEngineError): pass class TemporaryInputFile(object): def __init__(self, data='', suffix=''):