[PATCH v2 2/2] keytoc: fix env provided keyspec handling
Marco Felsch
m.felsch at pengutronix.de
Thu Jul 24 06:50:56 PDT 2025
Currently the env provided keyspec is resolved during the gen_key() step
by making use of the try_resolve_env(). This is wrong because it will
set the complete <hint>:<key> keyspec string for the 'keyname' and 'path'.
To fix this the resolve step must happen during the main-loop as first step
because the main-loop is doing the 'keyname' and 'path' split already.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
scripts/keytoc.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/scripts/keytoc.c b/scripts/keytoc.c
index 617317d6607e..105fa4b5413d 100644
--- a/scripts/keytoc.c
+++ b/scripts/keytoc.c
@@ -615,10 +615,6 @@ static int gen_key(const char *keyname, const char *path)
char *tmp, *key_name_c;
/* key name handling */
- keyname = try_resolve_env(keyname);
- if (!keyname)
- exit(1);
-
tmp = key_name_c = strdup(keyname);
while (*tmp) {
@@ -628,10 +624,6 @@ static int gen_key(const char *keyname, const char *path)
}
/* path/URI handling */
- path = try_resolve_env(path);
- if (!path)
- exit(1);
-
if (!strncmp(path, "pkcs11:", 7)) {
ret = engine_get_pub_key(path, &key);
if (ret)
@@ -737,6 +729,11 @@ int main(int argc, char *argv[])
char *keyname = NULL;
char *path = NULL;
+ /* Check if the keyspec is provided by the ENV first */
+ keyspec = try_resolve_env(keyspec);
+ if (!keyspec)
+ exit(1);
+
if (!strncmp(keyspec, "pkcs11:", 7))
path = strdup(keyspec);
else
--
2.39.5
More information about the barebox
mailing list