How to use the imgtool.keys.RSA function in imgtool

To help you get started, we’ve selected a few imgtool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JuulLabs-OSS / mcuboot / scripts / imgtool / main.py View on Github external
def sign(key, align, version, header_size, pad_header, slot_size, pad,
         max_sectors, overwrite_only, endian, encrypt, infile, outfile,
         dependencies, load_addr, hex_addr, erased_val):
    img = image.Image(version=decode_version(version), header_size=header_size,
                      pad_header=pad_header, pad=pad, align=int(align),
                      slot_size=slot_size, max_sectors=max_sectors,
                      overwrite_only=overwrite_only, endian=endian,
                      load_addr=load_addr, erased_val=erased_val)
    img.load(infile)
    key = load_key(key) if key else None
    enckey = load_key(encrypt) if encrypt else None
    if enckey and key:
        if ((isinstance(key, keys.ECDSA256P1) and
             not isinstance(enckey, keys.ECDSA256P1Public))
                or (isinstance(key, keys.RSA) and
                    not isinstance(enckey, keys.RSAPublic))):
            # FIXME
            raise Exception("Signing and encryption must use the same type of key")
    img.create(key, enckey, dependencies)
    img.save(outfile, hex_addr)
github JuulLabs-OSS / mcuboot / scripts / imgtool / main.py View on Github external
def gen_rsa2048(keyfile, passwd):
    keys.RSA.generate().export_private(path=keyfile, passwd=passwd)