cst-signer: init at 7fa50daf

The CST signer tool works in conjunction with the Code Signing
Tool (CST) provided by NXP. The tool allows a way to automate the
signing process in conjunction with a configuration file that can be
populated with necessary inputs. In addition, this tool parses the 'to
be signed' image and extracts the offset and length information needed
to sign the image, thus reducing the possible human error while signing.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
This commit is contained in:
Otavio Salvador 2023-10-12 17:32:03 -03:00
parent 7327e03c61
commit a2b50884a1
3 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,94 @@
From d7d6eebdb4f49e6a3d93c101f1fb23bb6e96f07c Mon Sep 17 00:00:00 2001
From: Otavio Salvador <otavio@ossystems.com.br>
Date: Thu, 12 Oct 2023 18:48:09 -0300
Subject: [PATCH] Improve Makefile so it is overridable and provides
standardized targets
This commit rework the Makefile targets so it provides a standardized
set of targets and allow overriding of variables so cross compiling is
properly supported.
Upstream-Status: Submitted [https://github.com/nxp-imx-support/nxp-cst-signer/pull/2]
Fixes: #1.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
Makefile | 14 +++++++-------
src/Makefile | 34 ++++++++++++++++++++++------------
2 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index c799b13..a722744 100644
--- a/Makefile
+++ b/Makefile
@@ -4,13 +4,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#==============================================================================
-SRC_DIR := src
-
-.PHONY: all clean
-
all:
- @$(MAKE) -C $(SRC_DIR)/
- @mv $(SRC_DIR)/cst_signer .
+ @$(MAKE) -C src
+
+install:
+ @$(MAKE) -C src install
clean:
- @rm -rf cst_signer src/fdt.o
+ @$(MAKE) -C src clean
+
+.PHONY: all install clean
diff --git a/src/Makefile b/src/Makefile
index 5e6dade..101be12 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,23 +4,33 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#==============================================================================
-CC = gcc
+CC ?= gcc
+CFLAGS ?= -g -Wall -Werror
+CPPFLAGS ?=
+LDFLAGS ?=
+INCLUDES = -I../inc/
-COPTS = -g -Wall -Werror
-CFLAGS = -I../inc/.
+PREFIX ?= /usr/local
+BINDIR ?= $(PREFIX)/bin
+DATADIR ?= $(PREFIX)/share
-DEPS = cst_signer.h cfg_parser.h mkimage_helper.h
-SRCS = cst_signer.c cfg_parser.c mkimage_helper.c fdt.o
+SRCS = cst_signer.c cfg_parser.c mkimage_helper.c fdt.c
-.PHONY: all clean
+all: cst-signer
-all: cst_signer fdt.o
+%.o : %.c
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) $< -o $@
-fdt.o: fdt.c
- $(CC) -c -w -o $@ $< $(CFLAGS)
+cst-signer: $(SRCS:.c=.o)
+ $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o $@ $(SRCS:.c=.o)
-cst_signer: cst_signer.c fdt.o
- $(CC) $(COPTS) $(CFLAGS) -o $@ $(SRCS)
+install: cst-signer
+ install -D -m 0755 cst-signer $(DESTDIR)/$(BINDIR)/cst-signer
+ install -D -m 0755 -t $(DESTDIR)$(DATADIR)/doc/cst-signer \
+ ../csf_ahab.cfg.sample \
+ ../csf_hab4.cfg.sample
clean:
- rm -rf cst_signer fdt.o
+ rm -rf cst-signer *.o
+
+.PHONY: all install clean

View File

@ -0,0 +1,63 @@
From fcdf06423d682cdafc092b67bbada3753c20bbd5 Mon Sep 17 00:00:00 2001
From: Otavio Salvador <otavio@ossystems.com.br>
Date: Thu, 12 Oct 2023 18:52:02 -0300
Subject: [PATCH] Fix include of headers so it indicates it uses the includedir
Upstream-Status: Submitted [https://github.com/nxp-imx-support/nxp-cst-signer/pull/2]
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
src/cfg_parser.c | 2 +-
src/cst_signer.c | 10 ++++++----
src/fdt.c | 3 ++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/cfg_parser.c b/src/cfg_parser.c
index 0f4ea0a..e289d13 100644
--- a/src/cfg_parser.c
+++ b/src/cfg_parser.c
@@ -4,7 +4,7 @@
*
*/
-#include "cfg_parser.h"
+#include <cfg_parser.h>
#define DELIMITER "="
diff --git a/src/cst_signer.c b/src/cst_signer.c
index 4d8825b..34d1711 100644
--- a/src/cst_signer.c
+++ b/src/cst_signer.c
@@ -4,11 +4,13 @@
*
*/
-#include "cst_signer.h"
-#include "cfg_parser.h"
-#include "mkimage_helper.h"
-#include "fdt.h"
#include <limits.h>
+
+#include <cst_signer.h>
+#include <cfg_parser.h>
+#include <mkimage_helper.h>
+#include <fdt.h>
+
#define RSIZE 256
uint32_t g_image_offset = 0;
diff --git a/src/fdt.c b/src/fdt.c
index 34cf585..9aecca9 100644
--- a/src/fdt.c
+++ b/src/fdt.c
@@ -13,7 +13,8 @@
#include <limits.h>
#include <stdio.h>
#include <string.h>
-#include "fdt.h"
+
+#include <fdt.h>
static struct fdt_errtabent fdt_errtable[] = {

View File

@ -0,0 +1,39 @@
SUMMARY = "CST signer tool allows a way to automate the signing process"
DESCRIPTION = "The CST signer tool works in conjunction with the Code Signing Tool (CST) provided by \
NXP. The tool allows a way to automate the signing process in conjunction with a configuration file \
that can be populated with necessary inputs. In addition, this tool parses the 'to be signed' image \
and extracts the offset and length information needed to sign the image, thus reducing the possible \
human error while signing."
AUTHOR = "Utkarsh Gupta <utkarsh.gupta@nxp.com>"
HOMEPAGE = "https://github.com/nxp-imx-support/nxp-cst-signer"
BUGTRACKER = "https://github.com/nxp-imx-support/nxp-cst-signer/issues"
SECTION = "devel"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
PV = "0.3+${SRCPV}"
SRC_URI = "git://github.com/nxp-imx-support/nxp-cst-signer;protocol=https;branch=master \
file://0001-Improve-Makefile-so-it-is-overridable-and-provides-s.patch \
file://0002-Fix-include-of-headers-so-it-indicates-it-uses-the-i.patch"
SRCREV = "7fa50daf3237661497cf753ff13e6f66d9d2fea8"
S = "${WORKDIR}/git"
EXTRA_OEMAKE += "DESTDIR=${D} PREFIX=${prefix}"
do_install () {
oe_runmake install
}
do_install:append:class-native () {
# The sample files are used as templates so here we copy them for later use.
mkdir -p ${D}${datadir}/cst-signer
for f in ${D}${datadir}/doc/cst-signer/*; do
mv $f ${D}${datadir}/cst-signer/$(basename $f | sed 's,.sample,.in,g')
done
rmdir ${D}${datadir}/doc/cst-signer \
${D}${datadir}/doc
}
BBCLASSEXTEND = "native nativesdk"