imgtool: add option to export public PEM
Update `getpub` with new `lang` option, "pem", which allows exporting a
public key as a PEM file. This can later be distributed to be used for
encrypting an image, and gets away with having to use openssl for this
step.
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/scripts/imgtool/main.py b/scripts/imgtool/main.py
index 12e5812..f50f01c 100755
--- a/scripts/imgtool/main.py
+++ b/scripts/imgtool/main.py
@@ -59,7 +59,7 @@
keys.X25519.generate().export_private(path=keyfile, passwd=passwd)
-valid_langs = ['c', 'rust']
+valid_langs = ['c', 'rust', 'pem']
keygens = {
'rsa-2048': gen_rsa2048,
'rsa-3072': gen_rsa3072,
@@ -125,6 +125,8 @@
key.emit_c_public()
elif lang == 'rust':
key.emit_rust_public()
+ elif lang == 'pem':
+ key.emit_public_pem()
else:
raise ValueError("BUG: should never get here!")