imx-cst: upgrade 3.4.1 -> 4.0.1
Fabio Estevam
reviewerPATCH v2 1/1 imx-cst: upgrade 3.4.1 -> 4.0.1
CST 4.0.1 replaces the custom Makefile build with CMake. Inherit the cmake class, point OECMAKE_SOURCEPATH at src, switch the parser dependency from byacc to bison, and add json-c.
Disable installation of internal CST static libraries. Suppress line directives from flex and bison generated sources to avoid embedding build paths in the output.
Import Debian's complete 4.0.1+dfsg-2 patch series:
https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/tree/debian/unstable/debian/patches
The series fixes script regressions and shell portability, big-endian and 32-bit builds, unchecked fgets() return values, HABv4 digest initialization, OpenSSL 4 compatibility, PKCS#11 engine loading, and dynamic linking of OpenSSL, json-c, hidapi-libusb, and libusb. Pin each Origin tag to Debian's packaging commit.
With bundled third-party libraries no longer linked, the redistributed CST sources and binaries are BSD-3-Clause; OpenSSL and json-c remain recipe dependencies under their own licenses.
Refresh the source and license checksums and drop the obsolete Makefile race fix.
---
Changes since v1:
- Applied all imx-cst Debian patches.
- Fixed clang/qemuarm64 failure.
.../0001-check-return-value-of-fgets.patch | 101 +++ ...fix-missing-makefile-rule-dependency.patch | 45 -- ...e-ntohl-for-big-endian-compatibility.patch | 30 + .../0003-link-libjson-c-dynamically.patch | 23 + ...-fix-format-errors-on-32-bit-targets.patch | 79 ++ .../0005-fix-add-key-message-digest.patch | 43 ++ .../imx-cst/0006-unbreak-pki-scripts.patch | 700 ++++++++++++++++++ .../imx-cst/0007-fix-shell-syntax.patch | 25 + .../imx-cst/0008-fix-scripts-shebang.patch | 43 ++ .../0009-load-pkcs11-engine-dynamically.patch | 69 ++ ...10-link-libhidapi-libusb-dynamically.patch | 27 + .../0011-link-libusb-dynamically.patch | 26 + .../0012-fix-openssl-4-asn1-opaque.patch | 43 ++ ...vlb-remove-redundant-NULL-definition.patch | 31 + ...4-fix-pointer-sign-errors-with-clang.patch | 57 ++ .../recipes-support/imx-cst/imx-cst_3.4.1.bb | 42 -- .../recipes-support/imx-cst/imx-cst_4.0.1.bb | 47 ++ 17 files changed, 1344 insertions(+), 87 deletions(-) create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0001-check-return-value-of-fgets.patch delete mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0001-fix-missing-makefile-rule-dependency.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0002-use-ntohl-for-big-endian-compatibility.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0003-link-libjson-c-dynamically.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0004-fix-format-errors-on-32-bit-targets.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0005-fix-add-key-message-digest.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0006-unbreak-pki-scripts.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0007-fix-shell-syntax.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0008-fix-scripts-shebang.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0009-load-pkcs11-engine-dynamically.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0010-link-libhidapi-libusb-dynamically.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0011-link-libusb-dynamically.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0012-fix-openssl-4-asn1-opaque.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0013-convlb-remove-redundant-NULL-definition.patch create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst/0014-fix-pointer-sign-errors-with-clang.patch delete mode 100644 meta-oe/recipes-support/imx-cst/imx-cst_3.4.1.bb create mode 100644 meta-oe/recipes-support/imx-cst/imx-cst_4.0.1.bb
meta-oe/recipes-support/imx-cst/imx-cst/0001-check-return-value-of-fgets.patch new file +101 -0
@@ -0,0 +1,101 @@ +From 8a0717cc07e78d1133cc10e62220770734181bee Mon Sep 17 00:00:00 2001 +From: Tobias Deiminger <[email protected]> +Date: Fri, 30 Jan 2026 01:55:36 +0100 +Subject: [PATCH] Check return value of fgets + +The cmake project has a reasonable default setting +CMAKE_COMPILE_WARNING_AS_ERROR=ON in cmake/compiler_options.cmake. With this +setting our build will fail on unchecked return values from fgets(). This +patch fixes the issue by adding return value checks. + +This is not just to silence the errors. C99 defines for fgets: "If a read +error occurs during the operation, the array contents are indeterminate and a +null pointer is returned". We should actually check the return value to avoid +undefined behavior from processing indeterminate data. + +Let get_passcode_to_key_file return -1 on error, since it is used as callback +to OpenSSLs PEM_read_bio_PrivateKey_ex where documentation states "The +callback must return the number of characters in the passphrase or -1 if an +error occurred". + +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/check_return_values.patch] +--- + src/lib/back_end/pkey.c | 6 +++++- + src/tools/pki_tree/hab4_pki_tree.c | 25 +++++++++++++++++++++---- + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/src/lib/back_end/pkey.c b/src/lib/back_end/pkey.c +index 31b5c3d..d6e9784 100644 +--- a/src/lib/back_end/pkey.c ++++ b/src/lib/back_end/pkey.c +@@ -102,8 +102,12 @@ int get_passcode_to_key_file(char *buf, int size, int rwflag, void *userdata) + return 0; + } + +- fgets(buf, size, password_fp); ++ buf = fgets(buf, size, password_fp); + fclose(password_fp); ++ if (buf == NULL) ++ { ++ return -1; ++ } + chomp(buf); + + return strlen(buf); +diff --git a/src/tools/pki_tree/hab4_pki_tree.c b/src/tools/pki_tree/hab4_pki_tree.c +index 3c878e4..4ff15b2 100644 +--- a/src/tools/pki_tree/hab4_pki_tree.c ++++ b/src/tools/pki_tree/hab4_pki_tree.c +@@ -118,6 +118,7 @@ int main(int argc, char **argv) + int num_srk = 0; + int val_period = 0; + char *pass = NULL; ++ char *user_input = NULL; + unsigned long serial = 0; + char duration_str[10] = {0}; + char num_srk_str[10] = {0}; +@@ -304,10 +305,18 @@ int main(int argc, char **argv) + if (strcmp(existing_ca, "y") == 0) + { + printf("Enter CA key name: "); +- fgets(ca_key, sizeof(ca_key), stdin); ++ user_input = fgets(ca_key, sizeof(ca_key), stdin); ++ if (user_input == NULL) { ++ fprintf(stderr, "Error while reading user input\n"); ++ return 1; ++ } + ca_key[strcspn(ca_key, "\n")] = '\0'; + printf("Enter CA certificate name: "); +- fgets(ca_cert, sizeof(ca_cert), stdin); ++ user_input = fgets(ca_cert, sizeof(ca_cert), stdin); ++ if (user_input == NULL) { ++ fprintf(stderr, "Error while reading user input\n"); ++ return 1; ++ } + ca_cert[strcspn(ca_cert, "\n")] = '\0'; + } + printf("\nKey type options (confirm targeted device supports desired " +@@ -330,10 +339,18 @@ int main(int argc, char **argv) + ARRAY_SIZE(rsa_kl_values)); + } + printf("Enter PKI tree duration (years): "); +- fgets(duration_str, sizeof(duration_str), stdin); ++ user_input = fgets(duration_str, sizeof(duration_str), stdin); ++ if (user_input == NULL) { ++ fprintf(stderr, "Error while reading user input\n"); ++ return 1; ++ } + duration = atoi(duration_str); + printf("How many Super Root Keys should be generated ? : "); +- fgets(num_srk_str, sizeof(num_srk_str), stdin); ++ user_input = fgets(num_srk_str, sizeof(num_srk_str), stdin); ++ if (user_input == NULL) { ++ fprintf(stderr, "Error while reading user input\n"); ++ return 1; ++ } + num_srk = atoi(num_srk_str); + ask_until_valid( + "Do you want the SRK certificates to have the CA flag set? (y/n) :", +-- +2.47.3
meta-oe/recipes-support/imx-cst/imx-cst/0001-fix-missing-makefile-rule-dependency.patch deleted +0 -45
45 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0002-use-ntohl-for-big-endian-compatibility.patch new file +30 -0
@@ -0,0 +1,30 @@ +From: Andrej Shadura <[email protected]> +Date: Tue, 3 Jun 2025 17:20:10 +0200 +Subject: [PATCH] Use ntohl instead of a custom macro for big-endian compat + +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/be-compat.patch] +--- + src/tools/hab_csf_parser/csf_parser.h | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/tools/hab_csf_parser/csf_parser.h b/src/tools/hab_csf_parser/csf_parser.h +index b387cdc..e6755bd 100644 +--- a/src/tools/hab_csf_parser/csf_parser.h ++++ b/src/tools/hab_csf_parser/csf_parser.h +@@ -17,12 +17,10 @@ + #define PASS 1 + #define FAIL 0 + ++#include <arpa/inet.h> ++ + /* For little endian systems */ +-#define from_be32(x) \ +- ((((x) & 0x000000ff) << 24) | \ +- (((x) & 0x0000ff00) << 8 ) | \ +- (((x) & 0x00ff0000) >> 8 ) | \ +- (((x) & 0xff000000) >> 24)) ++#define from_be32(x) ntohl(x) + + #define assert(x) if ((x) == 0) { \ + printf("ASSERT failed at %s:%d\n", __FUNCTION__, __LINE__); \
meta-oe/recipes-support/imx-cst/imx-cst/0003-link-libjson-c-dynamically.patch new file +23 -0
@@ -0,0 +1,23 @@ +From: Tobias Deiminger <[email protected]> +Date: Fri, 30 Jan 2026 01:55:37 +0100 +Subject: [PATCH] Link libjson-c as shared system library + +The ahab_signed_message tool requires libjson-c. Upstream hardcodes static +linking. Use the system shared library instead. + +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/libjson_c_dynlink.patch] +--- + src/tools/ahab_signed_message/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/tools/ahab_signed_message/CMakeLists.txt b/src/tools/ahab_signed_message/CMakeLists.txt +index 1555ff7..6616986 100644 +--- a/src/tools/ahab_signed_message/CMakeLists.txt ++++ b/src/tools/ahab_signed_message/CMakeLists.txt +@@ -1,4 +1,4 @@ +-find_cst_dependency_library("libjson-c.a" json_c_DIR JSONC_LIB JSONC_INCLUDE_DIR) ++find_cst_dependency_library("libjson-c.so" json_c_DIR JSONC_LIB JSONC_INCLUDE_DIR) + + add_executable(ahab_signed_message + ahab_signed_message.c
meta-oe/recipes-support/imx-cst/imx-cst/0004-fix-format-errors-on-32-bit-targets.patch new file +79 -0
79 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0005-fix-add-key-message-digest.patch new file +43 -0
43 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0006-unbreak-pki-scripts.patch new file +700 -0
700 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0007-fix-shell-syntax.patch new file +25 -0
@@ -0,0 +1,25 @@ +From: Andrej Shadura <[email protected]> +Date: Tue, 3 Jun 2025 14:50:29 +0200 +Subject: Remove commented out lines resulting in incorrect shell syntax + +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/fix-shell-syntax.patch] +--- + src/tools/hab_srktool_scripts/createSRKTable | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/src/tools/hab_srktool_scripts/createSRKTable b/src/tools/hab_srktool_scripts/createSRKTable +index 171f430..85237df 100755 +--- a/src/tools/hab_srktool_scripts/createSRKTable ++++ b/src/tools/hab_srktool_scripts/createSRKTable +@@ -164,10 +164,3 @@ printf "%04s" $SRKTableSize | \ + dd of=SRK_table.bin bs=1 seek=1 conv=notrunc + + +-if [ $DEBUG = 0 ]; then +- +-#If hexdiff utility is installed you can compare SRK table generated +-#with SRK table from SRKTOOL as follows +- +-#hexdiff SRK_table.bin SRK_1_2_3_4_table.bin +-fi
meta-oe/recipes-support/imx-cst/imx-cst/0008-fix-scripts-shebang.patch new file +43 -0
43 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0009-load-pkcs11-engine-dynamically.patch new file +69 -0
69 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0010-link-libhidapi-libusb-dynamically.patch new file +27 -0
@@ -0,0 +1,27 @@ +From: Tobias Deiminger <[email protected]> +Date: Fri, 30 Jan 2026 01:55:37 +0100 +Subject: Link libhidapi-libusb as shared system library + +The hab_log_parser tool requires libhidapi-libusb. Upstream hardcodes static +linking. + We want to link the system shared library instead and must thus change the + related cmake find function. +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/hidapi_libusb_dynlink.patch] +--- + src/tools/hab_log_parser/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/tools/hab_log_parser/CMakeLists.txt b/src/tools/hab_log_parser/CMakeLists.txt +index 1dd6303..086496e 100644 +--- a/src/tools/hab_log_parser/CMakeLists.txt ++++ b/src/tools/hab_log_parser/CMakeLists.txt +@@ -8,7 +8,7 @@ find_cst_dependency_library("libusb-1.0.a" libusb_DIR LIBUSB_LIB LIBUSB_INCLUDE_ + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_cst_dependency_library("libhidapi.a" hidapi_DIR LIBHIDAPI_LIB LIBHIDAPI_INCLUDE_DIR) + else() +- find_cst_dependency_library("libhidapi-libusb.a" hidapi_DIR LIBHIDAPI_LIB LIBHIDAPI_INCLUDE_DIR) ++ find_cst_dependency_library("libhidapi-libusb.so.0" hidapi_DIR LIBHIDAPI_LIB LIBHIDAPI_INCLUDE_DIR) + endif() + + target_include_directories(hab_log_parser PUBLIC ${LIBHIDAPI_INCLUDE_DIR})
meta-oe/recipes-support/imx-cst/imx-cst/0011-link-libusb-dynamically.patch new file +26 -0
@@ -0,0 +1,26 @@ +From: Tobias Deiminger <[email protected]> +Date: Fri, 30 Jan 2026 01:55:37 +0100 +Subject: Link libusb as shared system library + +The hab_log_parser tool requires libusb. Upstream hardcodes static linking. + We want to link the system shared library instead and must thus change the + related cmake find function. +Upstream-Status: Pending +Origin: Debian [https://salsa.debian.org/collabora-team/imx-code-signing-tool/-/blob/fb2961efc88b9b6f37e98a5feed26873713299ee/debian/patches/libusb_dynlink.patch] +--- + src/tools/hab_log_parser/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/tools/hab_log_parser/CMakeLists.txt b/src/tools/hab_log_parser/CMakeLists.txt +index 086496e..067d728 100644 +--- a/src/tools/hab_log_parser/CMakeLists.txt ++++ b/src/tools/hab_log_parser/CMakeLists.txt +@@ -3,7 +3,7 @@ add_executable(hab_log_parser + usbhid.c + ) + +-find_cst_dependency_library("libusb-1.0.a" libusb_DIR LIBUSB_LIB LIBUSB_INCLUDE_DIR) ++find_cst_dependency_library("libusb-1.0.so" libusb_DIR LIBUSB_LIB LIBUSB_INCLUDE_DIR) + + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + find_cst_dependency_library("libhidapi.a" hidapi_DIR LIBHIDAPI_LIB LIBHIDAPI_INCLUDE_DIR)
meta-oe/recipes-support/imx-cst/imx-cst/0012-fix-openssl-4-asn1-opaque.patch new file +43 -0
43 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst/0013-convlb-remove-redundant-NULL-definition.patch new file +31 -0
@@ -0,0 +1,31 @@ +From: Fabio Estevam <[email protected]> +Date: Sun, 26 Jul 2026 09:15:12 -0300 +Subject: [PATCH] convlb: Remove redundant NULL definition + +convlb.c includes standard headers that already define NULL. Defining it +again is unnecessary and Clang rejects the redefinition because the project +enables warnings as errors: + +convlb.c:24:9: error: 'NULL' macro redefined [-Werror,-Wmacro-redefined] + +Remove the local definition and use the one supplied by the standard headers. + +Upstream-Status: Pending +Signed-off-by: Fabio Estevam <[email protected]> +--- + src/tools/convlb/convlb.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/tools/convlb/convlb.c b/src/tools/convlb/convlb.c +index 0a0197e..2459359 100644 +--- a/src/tools/convlb/convlb.c ++++ b/src/tools/convlb/convlb.c +@@ -21,8 +21,6 @@ + GLOBALS + =============================================================================*/ + +-#define NULL ((void *)0) +- + #define TEMPFILENAME ".convlb.tmp" + + char *toolname = NULL;
meta-oe/recipes-support/imx-cst/imx-cst/0014-fix-pointer-sign-errors-with-clang.patch new file +57 -0
57 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst_3.4.1.bb deleted +0 -42
42 lines not on this page · raw message
meta-oe/recipes-support/imx-cst/imx-cst_4.0.1.bb new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.43.0