[PATCH v4 3/8] crypto: keytoc: Move special handling of legacy pkcs11 format to parse_keyspec

Jonas Rebmann jre at pengutronix.de
Tue Mar 17 08:19:47 PDT 2026


This is a preparatory cleanup commit

Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
---
 scripts/keytoc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/scripts/keytoc.c b/scripts/keytoc.c
index 135a396d34..6d680422a6 100644
--- a/scripts/keytoc.c
+++ b/scripts/keytoc.c
@@ -787,6 +787,11 @@ static bool parse_info(char *p, struct keyinfo *out)
 
 static bool parse_keyspec(const char *keyspec, struct keyinfo *out)
 {
+	if (!strncmp(keyspec, "pkcs11:", 7)) { /* legacy format of pkcs11 URI */
+		out->path = strdup(keyspec);
+		return true;
+	}
+
 	char *sep, *spec;
 
 	spec = strdup(keyspec);
@@ -863,13 +868,9 @@ int main(int argc, char *argv[])
 		if (!keyspec)
 			exit(1);
 
-		if (!strncmp(keyspec, "pkcs11:", 7)) { // legacy format of pkcs11 URI
-			info->path = strdup(keyspec);
-		} else {
-			if (!parse_keyspec(keyspec, info)) {
-				fprintf(stderr, "invalid keyspec %i: %s\n", optind, keyspec);
-				exit(1);
-			}
+		if (!parse_keyspec(keyspec, info)) {
+			fprintf(stderr, "invalid keyspec %i: %s\n", optind, keyspec);
+			exit(1);
 		}
 	}
 

-- 
2.53.0.308.g50d063e335




More information about the barebox mailing list