Skip to content

Commit 765dd68

Browse files
benpiccofabian18
andcommitted
makefiles/suit: use OpenSSL to generate key
Co-authored-by: Fabian Hüßler <[email protected]>
1 parent 99285d3 commit 765dd68

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

makefiles/suit.base.inc.mk

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,30 @@ SUIT_PUB_HDR_DIR = $(dir $(SUIT_PUB_HDR))
3535
CFLAGS += -I$(SUIT_PUB_HDR_DIR)
3636
BUILDDEPS += $(SUIT_PUB_HDR)
3737

38+
# OpenSSL leaves an empty file if key generation fails - remove it manually
39+
# see https://github.com/openssl/openssl/issues/25440
3840
$(SUIT_SEC): | $(CLEAN)
3941
$(Q)echo suit: generating key in $(SUIT_KEY_DIR)
4042
$(Q)mkdir -p $(SUIT_KEY_DIR)
41-
$(Q)$(RIOTBASE)/dist/tools/suit/gen_key.py $@ $(SUIT_SEC_PASSWORD)
43+
$(Q)( \
44+
printf "0) none\n"; \
45+
printf "1) aes-256-cbc\n"; \
46+
printf "Choose encryption for key file $@: "; \
47+
if [ -z "$(RIOT_CI_BUILD)" ]; then read encryption; else encryption=0; fi; \
48+
case $$encryption in \
49+
0) \
50+
openssl genpkey -algorithm ed25519 -out $@; \
51+
;; \
52+
1) \
53+
openssl genpkey -algorithm ed25519 -aes-256-cbc -out $@ || :; \
54+
;; \
55+
*) \
56+
echo "Invalid choice"; \
57+
exit 1; \
58+
;; \
59+
esac; \
60+
)
61+
$(Q)if [ ! -s $@ ]; then rm $@; fi
4262

4363
%.pem.pub: %.pem
4464
$(Q)openssl ec -inform pem -in $< -outform pem -pubout -out $@

0 commit comments

Comments
 (0)