How to use the imgtool.keys.RSA2048 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 open-degu / degu / tools / 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):
    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)
    img.load(infile)
    key = load_key(key) if key else None
    enckey = load_key(encrypt) if encrypt else None
    if enckey:
        if not isinstance(enckey, (keys.RSA2048, keys.RSA2048Public)):
            raise Exception("Encryption only available with RSA")
        if key and not isinstance(key, (keys.RSA2048, keys.RSA2048Public)):
            raise Exception("Encryption with sign only available with RSA")
    img.create(key, enckey)
    img.save(outfile)