public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "'Gokhan Cetin' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: gokhan.cetin@siemens.com, felix.moessbauer@siemens.com
Subject: [PATCH 2/3] module-signer-example: add example signer hook and signed variant for example-module
Date: Thu, 23 Jan 2025 15:51:30 +0100	[thread overview]
Message-ID: <20250123145131.1142290-3-gokhan.cetin@siemens.com> (raw)
In-Reply-To: <20250123145131.1142290-1-gokhan.cetin@siemens.com>

This patch introduces an example signer hook that generates raw detached signatures
for out-of-tree kernel modules.

Signed-off-by: Gokhan Cetin <gokhan.cetin@siemens.com>
---
 .../files/sign-module.sh                      | 40 +++++++++++++++++++
 .../module-signer-example.bb                  | 20 ++++++++++
 .../example-module-signedwith.bb              | 15 +++++++
 3 files changed, 75 insertions(+)
 create mode 100644 meta-isar/recipes-devtools/module-signer-example/files/sign-module.sh
 create mode 100644 meta-isar/recipes-devtools/module-signer-example/module-signer-example.bb
 create mode 100644 meta-isar/recipes-kernel/example-module/example-module-signedwith.bb

diff --git a/meta-isar/recipes-devtools/module-signer-example/files/sign-module.sh b/meta-isar/recipes-devtools/module-signer-example/files/sign-module.sh
new file mode 100644
index 00000000..4d22532b
--- /dev/null
+++ b/meta-isar/recipes-devtools/module-signer-example/files/sign-module.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Example signer script that generates detached signatures for modules
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+set -e
+
+module=$1
+signature=$2
+hashfn=$3
+certfile=$4
+
+if [ -z "$module" ] || [ -z "$signature" ] || [ -z "$hashfn" ] || [ -z "$certfile" ] ; then
+    exit 1
+fi
+
+echo "Signing module $module with hash function $hashfn and certificate $certfile"
+
+openssl smime -sign -nocerts -noattr -binary \
+    -in "$module" \
+    -md "$hashfn" \
+    -inkey /etc/sb-mok-keys/MOK/MOK.priv \
+    -signer /etc/sb-mok-keys/MOK/MOK.der \
+    -outform DER \
+    -out "$signature"
+
+echo "Verifying signature of module $module with hash function $hashfn and certificate $certfile"
+
+openssl smime -verify \
+    -in "$signature" \
+    -md "$hashfn" \
+    -content "$module" \
+    -certfile /etc/sb-mok-keys/MOK/MOK.der \
+    -noverify \
+    -inform DER \
+    -out /dev/null
diff --git a/meta-isar/recipes-devtools/module-signer-example/module-signer-example.bb b/meta-isar/recipes-devtools/module-signer-example/module-signer-example.bb
new file mode 100644
index 00000000..001e8cc8
--- /dev/null
+++ b/meta-isar/recipes-devtools/module-signer-example/module-signer-example.bb
@@ -0,0 +1,20 @@
+# Example recipe for signing a kernel module with custom signer script
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg-raw
+
+DPKG_ARCH = "all"
+
+DEPENDS = "sb-mok-keys"
+DEBIAN_DEPENDS += "openssl, sb-mok-keys"
+
+SRC_URI = "file://sign-module.sh"
+
+do_install[cleandirs] = "${D}/usr/bin/"
+do_install() {
+    install -m 0755 ${WORKDIR}/sign-module.sh ${D}/usr/bin/sign-module.sh
+}
diff --git a/meta-isar/recipes-kernel/example-module/example-module-signedwith.bb b/meta-isar/recipes-kernel/example-module/example-module-signedwith.bb
new file mode 100644
index 00000000..f611169c
--- /dev/null
+++ b/meta-isar/recipes-kernel/example-module/example-module-signedwith.bb
@@ -0,0 +1,15 @@
+# Example recipe for building a custom module
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2025
+#
+# SPDX-License-Identifier: MIT
+
+require example-module.bb
+
+DEPENDS += "module-signer-example"
+DEBIAN_BUILD_DEPENDS .= ', module-signer-example'
+
+DEB_BUILD_PROFILES += 'pkg.signwith'
+SIGNATURE_CERTFILE = '/etc/sb-mok-keys/MOK/MOK.der'
+SIGNATURE_SIGNWITH = '/usr/bin/sign-module.sh'
-- 
2.39.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250123145131.1142290-3-gokhan.cetin%40siemens.com.

  parent reply	other threads:[~2025-01-23 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 14:51 [PATCH 0/3] Allow use of external scripts to sign modules 'Gokhan Cetin' via isar-users
2025-01-23 14:51 ` [PATCH 1/3] meta/recipes-kernel/linux-module: " 'Gokhan Cetin' via isar-users
2025-01-23 14:51 ` 'Gokhan Cetin' via isar-users [this message]
2025-01-23 14:51 ` [PATCH 3/3] doc/user_manual: describe module signing and custom signer hooks 'Gokhan Cetin' via isar-users
2025-01-31 11:38 ` [PATCH 0/3] Allow use of external scripts to sign modules 'MOESSBAUER, Felix' via isar-users
2025-02-07  7:59 ` Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250123145131.1142290-3-gokhan.cetin@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=gokhan.cetin@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox