コード例 #1
0
def do_getpub(args):
    key = keys.load(args.key)
    if args.lang == 'c':
        key.emit_c()
    else:
        msg = "Unsupported language, valid are: c"
        raise argparse.ArgumentTypeError(msg)
コード例 #2
0
ファイル: imgtool.py プロジェクト: mame2015/TFM-M
def do_sign(args):
    if args.rsa_pkcs1_15:
        keys.sign_rsa_pss = False

    version_num = next_version_number(args, version.decode_version("0"),
                                      "lastVerNum.txt")

    if args.security_counter is None:
        # Security counter has not been explicitly provided,
        # generate it from the version number
        args.security_counter = ((version_num.major << 24) +
                                 (version_num.minor << 16) +
                                 version_num.revision)

    img = image.Image.load(args.infile,
                           version=version_num,
                           header_size=args.header_size,
                           security_cnt=args.security_counter,
                           included_header=args.included_header,
                           pad=args.pad)
    key = keys.load(args.key) if args.key else None
    img.sign(key, find_load_address(args))

    if args.pad:
        img.pad_to(args.pad, args.align)

    img.save(args.outfile)
コード例 #3
0
def do_sign(args):
    if args.rsa_pkcs1_15:
        keys.sign_rsa_pss = False

    version_num = next_version_number(args, version.decode_version("0"),
                                      "lastVerNum.txt")

    if args.security_counter is None:
        # Security counter has not been explicitly provided,
        # generate it from the version number
        args.security_counter = ((version_num.major << 24) +
                                 (version_num.minor << 16) +
                                 version_num.revision)

    pad_size = macro_parser.evaluate_macro(args.layout, sign_bin_size_re, 0, 1)
    img = image.Image.load(args.infile,
                           version=version_num,
                           header_size=args.header_size,
                           security_cnt=args.security_counter,
                           included_header=args.included_header,
                           pad=pad_size)
    key = keys.load(args.key, args.public_key_format) if args.key else None
    ram_load_address = macro_parser.evaluate_macro(args.layout,
                                                   image_load_address_re, 0, 1)
    img.sign(key, ram_load_address, args.dependencies)

    if pad_size:
        img.pad_to(pad_size, args.align)

    img.save(args.outfile)
コード例 #4
0
ファイル: imgtool.py プロジェクト: bodza/cortex
def do_sign(args):
    if args.rsa_pkcs1_15:
        keys.sign_rsa_pss = False
    img = image.Image.load(args.infile,
                           version=next_version_number(
                               args, version.decode_version("0"),
                               "lastVerNum.txt"),
                           header_size=args.header_size,
                           included_header=args.included_header,
                           pad=args.pad)
    key = keys.load(args.key) if args.key else None
    img.sign(key, find_load_address(args))

    if args.pad:
        img.pad_to(args.pad, args.align)

    img.save(args.outfile)