コード例 #1
0
    def __init__(self, cert_dict):

        # Data transfer from initialization dictionary #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        self.cert_config_id = cert_dict['id']
        self.chipset = cert_dict['chip']
        self.dsa_type = cert_dict[
            'dsa_type'] if 'dsa_type' in cert_dict else 'rsa'

        self.cert_keysize = cert_dict['keysize']
        self.cert_exponent = cert_dict['exponent']
        if 'padding' in cert_dict and cert_dict['padding'] is not None:
            self.cert_padding = cert_dict['padding'].upper()
        else:
            self.cert_padding = 'PKCS'
        if 'hash_algorithm' in cert_dict and cert_dict[
                'hash_algorithm'] is not None:
            self.cert_hash_algorithm = cert_dict['hash_algorithm']
        else:
            self.cert_hash_algorithm = 'sha256'

        if self.dsa_type == 'rsa':
            self.cert_keysize = cert_dict['keysize']
            self.cert_exponent = cert_dict['exponent']
            self.ecdsa_curve = None
        elif self.dsa_type == 'ecdsa':
            self.ecdsa_curve = cert_dict['ecdsa_curve']
            self.cert_keysize = None
            self.cert_exponent = None

        self.dp_basepath = cert_dict['dp_path']
        self.dp_basepath = os.path.normpath(self.dp_basepath)

        # LOCAL_STR changes for test assets #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        self.LOCAL_STR = LOCAL_STR

        # Initialize data-provisioner with dp_basepath #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        if self.dp_basepath is not None:
            self.data_prov = DataProvisioner(self.dp_basepath)
        else:
            raise RuntimeError(
                "Invalid basepath provided to data provisioner.")

        # Construct the asset dirname from cert_dict #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        get_asset_func = self.get_asset
        try:
            import sectools.features.isc.signer.signerutils.test.intf as tester
            get_asset_func = lambda x: tester.get_test_asset(self, x)
        except ImportError:
            pass

        self.LOCAL_STR, self.asset_dirname = get_asset_func(
            self.cert_config_id)

        self.message_print_set = set()
コード例 #2
0
ファイル: openssl_fetch.py プロジェクト: hades2013/mybootable
    def __init__(self, config=None, base_path=None, target=None):
        '''config file value will override the rest'''
        if config is not None:
            self.base_path = config.data_provisioning.base_path
            self.target = target if target is not None else OPENSSL_TARGET
        else:
            raise RuntimeError("Config file is not provided.")

        self.data_prov = DataProvisioner(self.base_path)
        self.message_print_set = set()
コード例 #3
0
    def __init__(self, cert_dict):

        # Data transfer from initialization dictionary #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        self.cert_config_id = cert_dict['id']
        self.chipset = cert_dict['chip']
        self.cert_keysize = cert_dict['keysize']
        self.cert_exponent = cert_dict['exponent']
        self.cert_mrc_index = cert_dict['mrc_index']
        self.dp_basepath = cert_dict['dp_path']
        self.dp_basepath = os.path.normpath(self.dp_basepath)

        # LOCAL_STR changes for test assets #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        self.LOCAL_STR = LOCAL_STR

        # Initialize data-provisioner with dp_basepath #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        if self.dp_basepath is not None:
            self.data_prov = DataProvisioner(self.dp_basepath)
        else:
            raise RuntimeError(
                "Invalid basepath provided to data provisioner.")

        # Construct the asset dirname from cert_dict #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        get_asset_func = self.get_asset
        try:
            import sectools.features.isc.signer.signerutils.test.intf as tester
            get_asset_func = lambda x: tester.get_test_asset(self, x)
        except ImportError:
            pass

        self.LOCAL_STR, self.asset_dirname = get_asset_func(
            self.cert_config_id)

        # Initialize mrc_index string for injection into cert_path later #
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
        if self.is_mrc() == 'True':
            if self.cert_mrc_index is not None:
                self.cert_mrc_index = str(self.cert_mrc_index)
            else:
                raise RuntimeError(
                    "mrc_index not given in config file but is needed for multi-root certificates"
                )
        else:
            self.cert_mrc_index = ''

        self.message_print_set = set()
コード例 #4
0
    def __init__(self, config=None, base_path=None, chipset=None):
        '''config file value will override the rest'''
        if config is not None:
            base_path = config.config.data_provisioning.base_path
            chipset = config.chipset

        if base_path is not None and chipset is not None:
            self.base_path = base_path
            self.chipset = chipset
        else:
            raise RuntimeError(
                "Required parameters are not provided. Base path and chipset.")

        self.data_prov = DataProvisioner(self.base_path)
        self.message_print_set = set()
コード例 #5
0
 def __init__(self, base_path=None):
     self.data_prov = DataProvisioner(base_path)
     self.message_print_set = set()