示例#1
0
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
示例#2
0
 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
示例#3
0
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)
示例#4
0
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=''):