コード例 #1
0
def main(args, return_isc=False):
    """Parses the command line arguments, performs any basic operations based on
    the parsed arguments and starts processing using the isc module.
    """
    # Log to file
    flids = logger.log_to_file(IoT_SECIMAGE_TOOL_NAME, args.output_dir)

    try:
        # Print the tool's launch command
        # logged_args = sys.argv
        logger.info('\n\n    IoT launched as: "' + ' '.join(sys.argv) + '"\n')

        # Initialize SecImageIotCore
        # The parsegen_config is set to None for now. It will be initialized
        # later before set_image_path.
        isc = SecImageIotCore(config_dir=IoT_CONFIG_DIR,
                              parsegen_config=None,
                              cfgparser=iot_cfgparser,
                              debug=args.debug)

        # Configure image signer
        if args.image_file:
            isc.set_chipset(args.chipset, args.overrides)

            crypto_params = {}
            if args.sign:
                crypto_params.update(root_certificate_properties=dict(
                    certificate_path=args.root_cert,
                    private_key_path=args.root_key))

            # Set the input, it must be done after isc.set_chipset(...)
            #
            # All actual IDs are passed to the back-end, along with root cert
            # and root private key as crypto_params.
            isc.set_image_path(args.image_file,
                               args.sign_id,
                               crypto_params=crypto_params)

        # Set the output
        if args.output_dir:
            isc.output_dir = args.output_dir

        # Process the images
        isc.process(sign=args.sign,
                    integrity_check=args.integrity_check,
                    val_sign=args.validate,
                    val_image=args.validate,
                    val_integrity_check=args.validate)

        # Print the summary
        print_summary(args, isc.image_info_list)

        if return_isc:
            return isc
        else:
            return isc.image_info_list

    finally:
        # Clear all log handlers
        logger.removeFileLogger(flids)
コード例 #2
0
def main(args, return_isc=False):
    """Parses the command line arguments, performs any basic operations based on
    the parsed arguments and starts processing using the isc module.
    """
    # Log to file
    flids = logger.log_to_file(SECIMAGE_TOOL_NAME, args.output_dir)

    # Print the tool's launch command
    logger.debug('\n\n    SecImage launched as: "' + ' '.join(sys.argv) +
                 '"\n')

    # Initialize SecImageCore
    isc = SecImageCore(debug=args.debug)

    # Configure image signer
    if args.image_file or (
            args.meta_build
            and not SecImageCore.meta_supports_sign_id(args.meta_build)):
        if args.chipset:
            isc.set_chipset(args.chipset, args._c_overrides)
        elif args.config_path:
            isc.set_config_path(args.config_path, args._c_overrides)

    # Set the input
    if args.image_file:
        isc.set_image_path(args.image_file, args.sign_id)
    elif args.meta_build:
        isc.set_meta_build_path(args.meta_build,
                                [] if args.sign_id is None else [args.sign_id])

    # Set the output
    if args.mini_build:
        isc.mini_build_path = args.mini_build
    elif args.output_dir:
        isc.output_dir = args.output_dir

    # Process the images
    isc.process(verify_setup=args.verify_inputs,
                integrity_check=args.integrity_check,
                sign=args.sign,
                encrypt=args.encrypt,
                decrypt=args.decrypt,
                val_image=args.validate,
                val_integrity_check=args.validate,
                val_sign=args.validate,
                val_encrypt=args.validate,
                root_cert_hash=args.rch)

    # Print the summary
    print_summary(args, isc.image_info_list)

    # Clear all log handlers
    logger.removeFileLogger(flids)

    if return_isc:
        return isc
    else:
        return isc.image_info_list
コード例 #3
0
ファイル: secimage.py プロジェクト: mxpro2003/qcs605_root
def main(args, return_isc=False):
    """Parses the command line arguments, performs any basic operations based on
    the parsed arguments and starts processing using the isc module.
    """
    # Log to file
    flids = logger.log_to_file(SECIMAGE_TOOL_NAME, args.output_dir)

    try:
        # Print the tool's launch command
        logged_args = CoreOptionParser.mask_private_args(
            sys.argv, args._c_spec_override_prefix)
        logger.info('\n\n    SecImage launched as: "' + ' '.join(logged_args) +
                    '"\n')

        # Initialize SecImageCore
        isc = SecImageCore(debug=args.debug)

        # Configure image signer
        if args.image_file or (
                args.meta_build
                and not SecImageCore.meta_supports_sign_id(args.meta_build)):
            if args.chipset:
                isc.set_chipset(args.chipset, args._c_overrides,
                                args._c_spec_overrides)
            elif args.config_path:
                isc.set_config_path(args.config_path, args._c_overrides,
                                    args._c_spec_overrides)

        if args.qti_signing:
            isc.authority = AUTHORITY_QTI

        # Set the input
        if args.image_file:
            isc.set_image_path(args.image_file, args.sign_id, args.m_gen,
                               args.m_image_file)
        elif args.meta_build:
            isc.set_meta_build_path(
                args.meta_build,
                [] if args.sign_id is None else [args.sign_id], args.m_gen)

        # Set the output
        if args.mini_build:
            isc.mini_build_path = args.mini_build
        elif args.output_dir:
            isc.output_dir = args.output_dir

        # Process the images
        isc.process(verify_setup=args.verify_inputs,
                    sign_attr=args.sign_attr,
                    integrity_check=args.integrity_check,
                    sign=args.sign,
                    encrypt=args.encrypt,
                    decrypt=args.decrypt,
                    no_op=args.no_op,
                    val_image=args.validate,
                    val_integrity_check=args.validate,
                    val_sign=args.validate,
                    val_encrypt=args.validate,
                    m_sign_attr=args.m_sign_attr,
                    m_integrity_check=args.m_integrity_check,
                    m_sign=args.m_sign,
                    m_encrypt=args.m_encrypt,
                    m_decrypt=args.m_decrypt,
                    m_val_image=args.m_validate,
                    m_val_integrity_check=args.m_validate,
                    m_val_sign=args.m_validate,
                    m_val_encrypt=args.m_validate,
                    gen_multi_image=args.m_gen,
                    root_cert_hash=args.rch)

        # Print the summary
        print_summary(args, isc.image_info_list,
                      isc.multi_image_imageinfo_dict.values())

        if return_isc:
            return isc
        else:
            return isc.image_info_list

    finally:
        # Clear all log handlers
        logger.removeFileLogger(flids)
コード例 #4
0
def main(args, return_isc=False):
    """Parses the command line arguments, performs any basic operations based on
    the parsed arguments and starts processing using the isc module.
    """
    # Log to file
    flids = logger.log_to_file(SECIMAGE_TOOL_NAME, args.output_dir)

    try:
        # Print the tool's launch command
        logged_args = CoreOptionParser.mask_private_args(
            sys.argv, args._c_spec_override_prefix)
        logger.info('\n\n     SecImage v' + SECIMAGE_TOOL_VERSION +
                    ' launched as: "' + ' '.join(logged_args) + '"\n')

        # Initialize SecImageCore
        # When args.serial_numbers is ALL, disable all serial-binding.
        isc = SecImageCore(debug=args.debug,
                           verbatim_config=args.verbatim_config,
                           disable_serial_binding=args.serial_numbers ==
                           DISABLE_SERIAL_BINDING,
                           platform_binding=args.platform_binding)

        # Configure image signer
        if args.image_file or (
                args.meta_build
                and not SecImageCore.meta_supports_sign_id(args.meta_build)):
            if args.chipset:
                isc.set_chipset(args.chipset, args._c_overrides,
                                args._c_spec_overrides)
            elif args.config_path:
                isc.set_config_path(args.config_path, args._c_overrides,
                                    args._c_spec_overrides)

        if args.qti_signing:
            isc.authority = AUTHORITY_QTI

        # Set the input
        if args.image_file:
            isc.set_image_path(args.image_file, args.sign_id, args.m_gen,
                               args.m_image_file)
        elif args.meta_build:
            isc.set_meta_build_path(
                args.meta_build,
                [] if args.sign_id is None else [args.sign_id], args.m_gen)

        # Set the output
        if args.mini_build:
            isc.mini_build_path = args.mini_build
        elif args.output_dir:
            isc.output_dir = args.output_dir

        # Process the images
        isc.process(verify_setup=args.verify_inputs,
                    sign_attr=args.sign_attr,
                    integrity_check=args.integrity_check,
                    sign=args.sign,
                    encrypt=args.encrypt,
                    decrypt=args.decrypt,
                    no_op=args.no_op,
                    val_image=args.validate,
                    val_integrity_check=args.validate,
                    val_sign=args.validate,
                    val_encrypt=args.validate,
                    m_sign_attr=args.m_sign_attr,
                    m_integrity_check=args.m_integrity_check,
                    m_sign=args.m_sign,
                    m_encrypt=args.m_encrypt,
                    m_decrypt=args.m_decrypt,
                    m_val_image=args.m_validate,
                    m_val_integrity_check=args.m_validate,
                    m_val_sign=args.m_validate,
                    m_val_encrypt=args.m_validate,
                    gen_multi_image=args.m_gen,
                    root_cert_hash=args.rch,
                    enforce_signed=args.enforce_signed,
                    enforce_encrypted=args.enforce_encrypted)

        # Print the summary
        print_summary(args, isc.image_info_list,
                      isc.multi_image_imageinfo_dict.values())

        overall_status = [
            image.status.overall.state == StatusInfo.SUCCESS
            for image in isc.image_info_list
        ]
        multi_image_status = [
            m.status.overall.state == StatusInfo.SUCCESS
            for m in isc.multi_image_imageinfo_dict.values()
        ]
        return_code = RETURN_CODE_SUCCESS if all(overall_status + multi_image_status) else\
            RETURN_CODE_FAILURE

        if return_isc:
            return return_code, isc
        return return_code, isc.image_info_list

    finally:
        # Clear all log handlers
        logger.removeFileLogger(flids)