summaryrefslogtreecommitdiff
path: root/scripts/sign-file.c
diff options
context:
space:
mode:
authorJan Stancek <jstancek@redhat.com>2024-07-12 10:11:14 +0300
committerJarkko Sakkinen <jarkko@kernel.org>2024-09-20 19:49:52 +0300
commit300e6d4116f956b035281ec94297dc4dc8d4e1d3 (patch)
tree7bfa3b220232f522af51f76abc5ca1e46b8acf21 /scripts/sign-file.c
parent70fd1966c93bf3bfe3fe6d753eb3d83a76597eef (diff)
downloadlinux-300e6d4116f956b035281ec94297dc4dc8d4e1d3.tar.xz
sign-file,extract-cert: move common SSL helper functions to a header
Couple error handling helpers are repeated in both tools, so move them to a common header. Signed-off-by: Jan Stancek <jstancek@redhat.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Tested-by: R Nageswara Sastry <rnsastry@linux.ibm.com> Reviewed-by: Neal Gompa <neal@gompa.dev> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Diffstat (limited to 'scripts/sign-file.c')
-rw-r--r--scripts/sign-file.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index 3edb156ae52c..39ba58db5d4e 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -29,6 +29,8 @@
#include <openssl/err.h>
#include <openssl/engine.h>
+#include "ssl-common.h"
+
/*
* OpenSSL 3.0 deprecates the OpenSSL's ENGINE API.
*
@@ -83,41 +85,6 @@ void format(void)
exit(2);
}
-static void display_openssl_errors(int l)
-{
- const char *file;
- char buf[120];
- int e, line;
-
- if (ERR_peek_error() == 0)
- return;
- fprintf(stderr, "At main.c:%d:\n", l);
-
- while ((e = ERR_get_error_line(&file, &line))) {
- ERR_error_string(e, buf);
- fprintf(stderr, "- SSL %s: %s:%d\n", buf, file, line);
- }
-}
-
-static void drain_openssl_errors(void)
-{
- const char *file;
- int line;
-
- if (ERR_peek_error() == 0)
- return;
- while (ERR_get_error_line(&file, &line)) {}
-}
-
-#define ERR(cond, fmt, ...) \
- do { \
- bool __cond = (cond); \
- display_openssl_errors(__LINE__); \
- if (__cond) { \
- errx(1, fmt, ## __VA_ARGS__); \
- } \
- } while(0)
-
static const char *key_pass;
static int pem_pw_cb(char *buf, int len, int w, void *v)