From 5b123e010954d8f6ef24dd0cb1a8cbe1d7d53851 Mon Sep 17 00:00:00 2001 From: Vesa Jääskeläinen Date: Sun, 16 Jun 2019 20:53:38 +0300 Subject: lib: rsa: add support to other openssl engine types than pkcs11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are multiple other openssl engines used by HSMs that can be used to sign FIT images instead of forcing users to use pkcs11 type of service. Relax engine selection so that other openssl engines can be specified and use generic key id definition formula. Signed-off-by: Vesa Jääskeläinen Cc: Tom Rini --- lib/rsa/rsa-sign.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/rsa/rsa-sign.c') diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index fb5e07b56d..5b5905aeb5 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -141,6 +141,15 @@ static int rsa_engine_get_pub_key(const char *keydir, const char *name, snprintf(key_id, sizeof(key_id), "pkcs11:object=%s;type=public", name); + } else if (engine_id) { + if (keydir) + snprintf(key_id, sizeof(key_id), + "%s%s", + keydir, name); + else + snprintf(key_id, sizeof(key_id), + "%s", + name); } else { fprintf(stderr, "Engine not supported\n"); return -ENOTSUP; @@ -252,6 +261,15 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name, snprintf(key_id, sizeof(key_id), "pkcs11:object=%s;type=private", name); + } else if (engine_id) { + if (keydir) + snprintf(key_id, sizeof(key_id), + "%s%s", + keydir, name); + else + snprintf(key_id, sizeof(key_id), + "%s", + name); } else { fprintf(stderr, "Engine not supported\n"); return -ENOTSUP; -- cgit