Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makefiles/suit: place keys in $XDG_DATA_HOME #18157

Merged
merged 2 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dist/tools/suit/gen_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# directory for more details.
#

import os
import sys

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
Expand All @@ -37,7 +38,7 @@ def main():
encryption_algorithm=crypt,
)

with open(sys.argv[1], "wb") as f:
with open(os.open(sys.argv[1], os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600), "wb") as f:
f.write(pem)


Expand Down
2 changes: 1 addition & 1 deletion examples/suit_update/README.hardware.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ The following default values are using for generating the manifest:
SUIT_SEQNR ?= $(APP_VER)
SUIT_CLASS ?= $(BOARD)
SUIT_KEY ?= default
SUIT_KEY_DIR ?= $(RIOTBASE)/keys
SUIT_KEY_DIR ?= $(XDG_DATA_HOME)/RIOT/keys
SUIT_SEC ?= $(SUIT_KEY_DIR)/$(SUIT_KEY).pem

All files (both slot binaries, both manifests, copies of manifests with
Expand Down
3 changes: 2 additions & 1 deletion examples/suit_update/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ SUIT keys consist of a private and a public key file, stored in `$(SUIT_KEY_DIR)
Similar to how ssh names its keyfiles, the public key filename equals the
private key file, but has an extra `.pub` appended.

`SUIT_KEY_DIR` defaults to the `keys/` folder at the top of a RIOT checkout.
`SUIT_KEY_DIR` defaults to the `keys/` folder in `$XDG_DATA_HOME/RIOT`
(usually `~/.local/share/RIOT/keys`).

If the chosen key doesn't exist, it will be generated automatically.
That step can be done manually using the `suit/genkey` target.
Expand Down
3 changes: 2 additions & 1 deletion makefiles/suit.base.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ SUIT_TOOL ?= $(RIOTBASE)/dist/tools/suit/suit-manifest-generator/bin/suit-tool
# Will use $(SUIT_KEY_DIR)/$(SUIT_KEY).pem as combined private/public key
# files.
SUIT_KEY ?= default
XDG_DATA_HOME ?= $(HOME)/.local/share

ifeq (1, $(RIOT_CI_BUILD))
SUIT_KEY_DIR ?= $(BINDIR)
else
SUIT_KEY_DIR ?= $(RIOTBASE)/keys
SUIT_KEY_DIR ?= $(XDG_DATA_HOME)/RIOT/keys
endif

# Enable user to encrypt private key with a password
Expand Down