Пример #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(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
Пример #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)

    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)