cfg80211: ship certificates as hex files

Not only does this remove the need for the hexdump code in most
normal kernel builds (still there for the extra directory), but
it also removes the need to ship binary files, which apparently
is somewhat problematic, as Randy reported.

While at it, also add the generated files to clean-files.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2017-12-19 09:26:17 +01:00
parent 958a1b5a5e
commit 04a7279ff1
3 changed files with 95 additions and 20 deletions

View File

@ -23,27 +23,14 @@ ifneq ($(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR),)
cfg80211-y += extra-certs.o
endif
$(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.x509)
$(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.hex)
@$(kecho) " GEN $@"
@(set -e; \
allf=""; \
for f in $^ ; do \
# similar to hexdump -v -e '1/1 "0x%.2x," "\n"' \
thisf=$$(od -An -v -tx1 < $$f | \
sed -e 's/ /\n/g' | \
sed -e 's/^[0-9a-f]\+$$/\0/;t;d' | \
sed -e 's/^/0x/;s/$$/,/'); \
# file should not be empty - maybe command substitution failed? \
test ! -z "$$thisf";\
allf=$$allf$$thisf;\
done; \
( \
echo '#include "reg.h"'; \
echo 'const u8 shipped_regdb_certs[] = {'; \
echo "$$allf"; \
echo '};'; \
echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \
) > $@)
@(echo '#include "reg.h"'; \
echo 'const u8 shipped_regdb_certs[] = {'; \
cat $^ ; \
echo '};'; \
echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \
) > $@
$(obj)/extra-certs.c: $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%) \
$(wildcard $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%)/*.x509)
@ -67,3 +54,5 @@ $(obj)/extra-certs.c: $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR:"%"=%) \
echo '};'; \
echo 'unsigned int extra_regdb_certs_len = sizeof(extra_regdb_certs);'; \
) > $@)
clean-files += shipped-certs.c extra-certs.c

View File

@ -0,0 +1,86 @@
/* Seth Forshee's regdb certificate */
0x30, 0x82, 0x02, 0xa4, 0x30, 0x82, 0x01, 0x8c,
0x02, 0x09, 0x00, 0xb2, 0x8d, 0xdf, 0x47, 0xae,
0xf9, 0xce, 0xa7, 0x30, 0x0d, 0x06, 0x09, 0x2a,
0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
0x05, 0x00, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f,
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x73,
0x66, 0x6f, 0x72, 0x73, 0x68, 0x65, 0x65, 0x30,
0x20, 0x17, 0x0d, 0x31, 0x37, 0x31, 0x30, 0x30,
0x36, 0x31, 0x39, 0x34, 0x30, 0x33, 0x35, 0x5a,
0x18, 0x0f, 0x32, 0x31, 0x31, 0x37, 0x30, 0x39,
0x31, 0x32, 0x31, 0x39, 0x34, 0x30, 0x33, 0x35,
0x5a, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06,
0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x73, 0x66,
0x6f, 0x72, 0x73, 0x68, 0x65, 0x65, 0x30, 0x82,
0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86,
0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82,
0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb5,
0x40, 0xe3, 0x9c, 0x28, 0x84, 0x39, 0x03, 0xf2,
0x39, 0xd7, 0x66, 0x2c, 0x41, 0x38, 0x15, 0xac,
0x7e, 0xa5, 0x83, 0x71, 0x25, 0x7e, 0x90, 0x7c,
0x68, 0xdd, 0x6f, 0x3f, 0xd9, 0xd7, 0x59, 0x38,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