From: chalianis1@gmail.com
To: linux-kernel@vger.kernel.org
Cc: Anis Chali <chalianis1@gmail.com>
Subject: [PATCH] scripts: regdb2hex: add a script to convert regulatory.db.p7s to hex for net wireless certs.
Date: Sun, 18 May 2025 21:42:04 -0400 [thread overview]
Message-ID: <20250519014204.304611-1-chalianis1@gmail.com> (raw)
From: Anis Chali <chalianis1@gmail.com>
extracts the certificate from regulatory.db.p7s and generate a hex file usable
by the kernel source code, after that take the result and put it with a patch to the kernel
source tree under net/wireless/certs
Signed-off-by: Anis Chali <chalianis1@gmail.com>
---
scripts/regdb2hex.sh | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 scripts/regdb2hex.sh
diff --git a/scripts/regdb2hex.sh b/scripts/regdb2hex.sh
new file mode 100644
index 000000000000..b28912a79094
--- /dev/null
+++ b/scripts/regdb2hex.sh
@@ -0,0 +1,37 @@
+#! /usr/bin/env bash
+
+# This script extracts the certificate from regulatory.db.p7s and generate a hex file usable
+# by the kernel source code, after that take the result and put it with a patch to the kernel
+# source tree under net/wireless/certs
+# this will be added to shiped_certs
+# to verify that your certificate has been added successfully
+# 1. check inside
+# /proc/keys and you will see a line with asymetric issuer and a sha
+# 2. dmesg | grep -i x.509
+# cfg80211: Loaded X.509 cert '{issuer}: {sha}'
+
+if [ $# -lt 2 ]; then
+ echo "${0} <regulatory.db.p7s> <output-filename>"
+ exit 0
+fi
+
+trap '[ -e ${2}.x509 ] && rm ${2}.x509' SIGINT SIGTERM SIGQUIT 0
+
+openssl pkcs7 -in ${1} -inform DER -print_certs | openssl x509 -inform PEM -outform DER -out ${2}.x509
+
+hex_crt=$(od -An -v -tx1 < ${2}.x509 | sed -e 's/ /\n/g' | sed -e 's/^[0-9a-f]\+$/\0/;t;d' | sed -e 's/^/0x/;s/$/,/')
+
+echo "/* ${2}'s regdb certificate */" >> ${2}.hex
+
+cnt=0
+for h in ${hex_crt}; do
+
+ cnt=$(( cnt + 1 ))
+ nl=$(( cnt % 8 ))
+ if [ "$nl" = "0" ]; then
+ echo " $h" >> ${2}.hex
+ else
+ echo -n " $h" >> ${2}.hex
+ fi
+
+done
\ No newline at end of file
--
2.49.0
reply other threads:[~2025-05-19 1:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250519014204.304611-1-chalianis1@gmail.com \
--to=chalianis1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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