public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] wireless-regdb: Support for new binary database format
@ 2017-12-22  6:02 Seth Forshee
  2017-12-22  6:02 ` [PATCH 1/6] regdb: write firmware file format (version code 20) Seth Forshee
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:02 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

This series starts with Johannes' patch for generating regulatory
databases using the new format and adds various fixes and pieces which
were missing such as installation to the firmware path, manual page
updates, etc. It also restores support for the older database format to
maintain compatibility with using CRDA on older kernels.

I've tested the results with 4.15 and things look to be working. I want
to apply this in the next couple of days and get a new release out, so
please let me know soon if you seen any issues.

Thanks,
Seth

Johannes Berg (1):
  regdb: write firmware file format (version code 20)

Seth Forshee (5):
  wireless-regdb: Restore generation of old format database files
  wireless-regdb: Add sforshee's x509 certificate
  wireless-regdb: Better support for generating public certificates
  wireless-regdb: Install regulatory.db and regulatory.db.p7s to
    /lib/firmware
  wireless-regdb: Document regulatory.db in the manual page

 Makefile          |  37 +++++++++++----
 README            |   4 +-
 db2fw.py          | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gen-pubcert.sh    |  18 ++++++++
 regulatory.bin.5  |  32 +++++++++----
 regulatory.db.5   |   1 +
 sforshee.x509.pem |  17 +++++++
 7 files changed, 220 insertions(+), 22 deletions(-)
 create mode 100755 db2fw.py
 create mode 100755 gen-pubcert.sh
 create mode 100644 regulatory.db.5
 create mode 100644 sforshee.x509.pem

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/6] regdb: write firmware file format (version code 20)
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
@ 2017-12-22  6:02 ` Seth Forshee
  2017-12-22  6:02 ` [PATCH 2/6] wireless-regdb: Restore generation of old format database files Seth Forshee
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:02 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

TODO: clean up the Makefile stuff ...

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile |  53 ++++++++++++-------------
 README   |   4 +-
 db2fw.py | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+), 30 deletions(-)
 create mode 100755 db2fw.py

diff --git a/Makefile b/Makefile
index 907ff282fc92..e708982a453d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,5 @@
 # Install prefix
 PREFIX ?= /usr
-CRDA_PATH ?= $(PREFIX)/lib/crda
-CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
 
 MANDIR ?= $(PREFIX)/share/man/
 
@@ -30,39 +28,47 @@ REGDB_AUTHOR ?= $(shell if [ -f $(DISTRO_PRIVKEY) ]; then \
 		fi)
 
 REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
-REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
-
-REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem
+REGDB_PUBCERT ?= $(REGDB_AUTHOR).x509.pem
 
 REGDB_CHANGED = $(shell $(SHA1SUM) -c --status sha1sum.txt >/dev/null 2>&1; \
         if [ $$? -ne 0 ]; then \
-                echo maintainer-clean $(REGDB_PUBKEY); \
+                echo maintainer-clean $(REGDB_PUBCERT); \
         fi)
 
 .PHONY: all clean mrproper install maintainer-clean install-distro-key
 
-all: $(REGDB_CHANGED) regulatory.bin sha1sum.txt
+all: $(REGDB_CHANGED) regulatory.db.p7s sha1sum.txt
 
 clean:
 	@rm -f *.pyc *.gz
 
 maintainer-clean: clean
-	@rm -f regulatory.bin
+	@rm -f regulatory.db regulatory.db.p7s
 
 mrproper: clean maintainer-clean
-	@echo Removed public key, regulatory.bin and compresed man pages
-	@rm -f $(REGDB_PUBKEY) .custom
+	@echo Removed public key, regulatory.db* and compressed man pages
+	@rm -f $(REGDB_PUBCERT) .custom
+
+regulatory.db: db.txt db2fw.py
+	@echo "Generating $@"
+	./db2fw.py regulatory.db db.txt
 
-regulatory.bin: db.txt $(REGDB_PRIVKEY) $(REGDB_PUBKEY)
-	@echo Generating $@ digitally signed by $(REGDB_AUTHOR)...
-	./db2bin.py regulatory.bin db.txt $(REGDB_PRIVKEY)
+regulatory.db.p7s: regulatory.db $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
+	@echo "Signing regulatory.db (by $(REGDB_AUTHOR))..."
+	@openssl smime -sign \
+		-signer $(REGDB_PUBCERT) \
+		-inkey $(REGDB_PRIVKEY) \
+		-in $< -nosmimecap -binary \
+		-outform DER -out $@
 
 sha1sum.txt: db.txt
 	sha1sum $< > $@
 
-$(REGDB_PUBKEY): $(REGDB_PRIVKEY)
-	@echo "Generating public key for $(REGDB_AUTHOR)..."
-	openssl rsa -in $(REGDB_PRIVKEY) -out $(REGDB_PUBKEY) -pubout -outform PEM
+$(REGDB_PUBCERT): $(REGDB_PRIVKEY)
+	@echo "Generating certificate for $(REGDB_AUTHOR)..."
+	@openssl req -config regulatory.openssl.conf \
+		-key $(REGDB_PRIVKEY) -days 36500 -utf8 -nodes -batch \
+		-x509 -outform PEM -out $(REGDB_PUBCERT)
 	@echo $(REGDB_PUBKEY) > .custom
 
 
@@ -97,16 +103,7 @@ install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
 #	make maintainer-clean
 #	make
 #	sudo make install
-install: regulatory.bin.5.gz
-	install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
-	install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
-	if [ -f .custom ]; then \
-		install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
-	fi
-	install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
-	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
+install: regulatory.db.5.gz
+	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.db
 	install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
-	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz
-
-uninstall:
-	rm -rf $(DESTDIR)/$(CRDA_PATH)/
+	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.db.5.gz
diff --git a/README b/README
index 065b67241c41..4028223725da 100644
--- a/README
+++ b/README
@@ -18,8 +18,8 @@ python module is used by the web viewer (Regulatory.py) which is
 implemented as a MoinMoin macro (and used on http://wireless.kernel.org)
 to allow viewing the database for verification.
 
-The dbparse module is also used by db2bin.py, the `compiler', which
-compiles and signs the binary database.
+The dbparse module is also used by db2bin.py and db2fw.py, the `compilers'
+that compile the database to its binary formats.
 
 For more information, please see the CRDA git repository:
 
diff --git a/db2fw.py b/db2fw.py
new file mode 100755
index 000000000000..7b2b14151e69
--- /dev/null
+++ b/db2fw.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+
+from cStringIO import StringIO
+import struct
+import hashlib
+from dbparse import DBParser
+import sys
+
+MAGIC = 0x52474442
+VERSION = 20
+
+if len(sys.argv) < 3:
+    print 'Usage: %s output-file input-file' % sys.argv[0]
+    sys.exit(2)
+
+def create_rules(countries):
+    result = {}
+    for c in countries.itervalues():
+        for rule in c.permissions:
+            result[rule] = 1
+    return result.keys()
+
+def create_collections(countries):
+    result = {}
+    for c in countries.itervalues():
+        result[(c.permissions, c.dfs_region)] = 1
+    return result.keys()
+
+
+def be32(output, val):
+    output.write(struct.pack('>I', val))
+def be16(output, val):
+    output.write(struct.pack('>H', val))
+
+class PTR(object):
+    def __init__(self, output):
+        self._output = output
+        self._pos = output.tell()
+        be16(output, 0)
+        self._written = False
+
+    def set(self, val=None):
+        if val is None:
+            val = self._output.tell()
+        assert val & 3 == 0
+        self._offset = val
+        pos = self._output.tell()
+        self._output.seek(self._pos)
+        be16(self._output, val >> 2)
+        self._output.seek(pos)
+        self._written = True
+
+    def get(self):
+        return self._offset
+
+    @property
+    def written(self):
+        return self._written
+
+p = DBParser()
+countries = p.parse(file(sys.argv[2]))
+rules = create_rules(countries)
+rules.sort(cmp=lambda x, y: cmp(x.freqband, y.freqband))
+collections = create_collections(countries)
+collections.sort(cmp=lambda x, y: cmp(x[0][0].freqband, y[0][0].freqband))
+
+output = StringIO()
+
+# struct regdb_file_header
+be32(output, MAGIC)
+be32(output, VERSION)
+
+country_ptrs = {}
+countrynames = countries.keys()
+countrynames.sort()
+for alpha2 in countrynames:
+    coll = countries[alpha2]
+    output.write(struct.pack('>cc', str(alpha2[0]), str(alpha2[1])))
+    country_ptrs[alpha2] = PTR(output)
+output.write('\x00' * 4)
+
+reg_rules = {}
+flags = 0
+for reg_rule in rules:
+    freq_range, power_rule = reg_rule.freqband, reg_rule.power
+    reg_rules[reg_rule] = output.tell()
+    assert power_rule.max_ant_gain == 0
+    flags = 0
+    # convert to new rule flags
+    assert reg_rule.flags & ~0x899 == 0
+    if reg_rule.flags & 1<<0:
+        flags |= 1<<0
+    if reg_rule.flags & 1<<3:
+        flags |= 1<<1
+    if reg_rule.flags & 1<<4:
+        flags |= 1<<2
+    if reg_rule.flags & 1<<7:
+        flags |= 1<<3
+    if reg_rule.flags & 1<<11:
+        flags |= 1<<4
+    rule_len = 16
+    cac_timeout = 0 # TODO
+    if not (flags & 1<<2):
+        cac_timeout = 0
+    if cac_timeout:
+        rule_len += 2
+    output.write(struct.pack('>BBHIII', rule_len, flags, power_rule.max_eirp * 100,
+                             freq_range.start * 1000, freq_range.end * 1000, freq_range.maxbw * 1000,
+                             ))
+    if cac_timeout:
+        output.write(struct.pack('>H', cac_timeout))
+    while rule_len % 4:
+        output.write('\0')
+        rule_len += 1
+
+for coll in collections:
+    for alpha2 in countrynames:
+        if (countries[alpha2].permissions, countries[alpha2].dfs_region) == coll:
+            assert not country_ptrs[alpha2].written
+            country_ptrs[alpha2].set()
+    slen = 3
+    output.write(struct.pack('>BBBx', slen, len(list(coll[0])), coll[1]))
+    coll = list(coll[0])
+    for regrule in coll:
+        be16(output, reg_rules[regrule] >> 2)
+    if len(coll) % 2:
+        be16(output, 0)
+
+for alpha2 in countrynames:
+    assert country_ptrs[alpha2].written
+
+outfile = open(sys.argv[1], 'w')
+outfile.write(output.getvalue())
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/6] wireless-regdb: Restore generation of old format database files
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
  2017-12-22  6:02 ` [PATCH 1/6] regdb: write firmware file format (version code 20) Seth Forshee
@ 2017-12-22  6:02 ` Seth Forshee
  2017-12-22  6:03 ` [PATCH 3/6] wireless-regdb: Add sforshee's x509 certificate Seth Forshee
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:02 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

Johannes removed generation and installation of these files when
adding support for the new database format. We need to keep
generating these files to support distros still using CRDA, so
restore support for building and installing these files in the
makefile.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index e708982a453d..9532c29a1dc2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
 # Install prefix
 PREFIX ?= /usr
+CRDA_PATH ?= $(PREFIX)/lib/crda
+CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
 
 MANDIR ?= $(PREFIX)/share/man/
 
@@ -28,26 +30,33 @@ REGDB_AUTHOR ?= $(shell if [ -f $(DISTRO_PRIVKEY) ]; then \
 		fi)
 
 REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
+REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
 REGDB_PUBCERT ?= $(REGDB_AUTHOR).x509.pem
 
+REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem
+
 REGDB_CHANGED = $(shell $(SHA1SUM) -c --status sha1sum.txt >/dev/null 2>&1; \
         if [ $$? -ne 0 ]; then \
-                echo maintainer-clean $(REGDB_PUBCERT); \
+                echo maintainer-clean $(REGDB_PUBKEY) $(REGDB_PUBCERT); \
         fi)
 
 .PHONY: all clean mrproper install maintainer-clean install-distro-key
 
-all: $(REGDB_CHANGED) regulatory.db.p7s sha1sum.txt
+all: $(REGDB_CHANGED) regulatory.bin sha1sum.txt regulatory.db.p7s
 
 clean:
 	@rm -f *.pyc *.gz
 
 maintainer-clean: clean
-	@rm -f regulatory.db regulatory.db.p7s
+	@rm -f regulatory.bin regulatory.db regulatory.db.p7s
 
 mrproper: clean maintainer-clean
-	@echo Removed public key, regulatory.db* and compressed man pages
-	@rm -f $(REGDB_PUBCERT) .custom
+	@echo Removed public key, regulatory.bin, regulatory.db* and compressed man pages
+	@rm -f $(REGDB_PUBKEY) $(REGDB_PUBCERT) .custom
+
+regulatory.bin: db.txt $(REGDB_PRIVKEY) $(REGDB_PUBKEY)
+	@echo Generating $@ digitally signed by $(REGDB_AUTHOR)...
+	./db2bin.py regulatory.bin db.txt $(REGDB_PRIVKEY)
 
 regulatory.db: db.txt db2fw.py
 	@echo "Generating $@"
@@ -64,6 +73,10 @@ regulatory.db.p7s: regulatory.db $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
 sha1sum.txt: db.txt
 	sha1sum $< > $@
 
+$(REGDB_PUBKEY): $(REGDB_PRIVKEY)
+	@echo "Generating public key for $(REGDB_AUTHOR)..."
+	openssl rsa -in $(REGDB_PRIVKEY) -out $(REGDB_PUBKEY) -pubout -outform PEM
+
 $(REGDB_PUBCERT): $(REGDB_PRIVKEY)
 	@echo "Generating certificate for $(REGDB_AUTHOR)..."
 	@openssl req -config regulatory.openssl.conf \
@@ -103,7 +116,13 @@ install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
 #	make maintainer-clean
 #	make
 #	sudo make install
-install: regulatory.db.5.gz
-	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.db
+install: regulatory.bin.5.gz regulatory.db.5.gz
+	install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
+	install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
+	if [ -f .custom ]; then \
+		install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
+	fi
+	install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
+	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin regulatory.db
 	install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
-	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.db.5.gz
+	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/6] wireless-regdb: Add sforshee's x509 certificate
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
  2017-12-22  6:02 ` [PATCH 1/6] regdb: write firmware file format (version code 20) Seth Forshee
  2017-12-22  6:02 ` [PATCH 2/6] wireless-regdb: Restore generation of old format database files Seth Forshee
@ 2017-12-22  6:03 ` Seth Forshee
  2017-12-22  6:03 ` [PATCH 4/6] wireless-regdb: Better support for generating public certificates Seth Forshee
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:03 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

Add a x509 certificate for sforshee.key.pub.pem. This is the same
certificate which is shipped in the kernel for validating
regulatory database files.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 sforshee.x509.pem | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 sforshee.x509.pem

diff --git a/sforshee.x509.pem b/sforshee.x509.pem
new file mode 100644
index 000000000000..ebd01606d057
--- /dev/null
+++ b/sforshee.x509.pem
@@ -0,0 +1,17 @@
+-----BEGIN CERTIFICATE-----
+MIICpDCCAYwCCQCyjd9HrvnOpzANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhz
+Zm9yc2hlZTAgFw0xNzEwMDYxOTQwMzVaGA8yMTE3MDkxMjE5NDAzNVowEzERMA8G
+A1UEAwwIc2ZvcnNoZWUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1
+QOOcKIQ5A/I512YsQTgVrH6lg3ElfpB8aN1vP9nXWTiffGpSwgMqLX5m9B6zEnAg
+W9SXMj1xizsbCBcUa2HEV4uWFhz9JNULCfloEYT7ylEM0UUZ2hBEitn+dqn9YC0Y
+CyiVsi3qiJi40VYh8FMf8QJv6Uabk18okA+sNvpoI3FXVvbM0999Ktkbc0XruieF
+73p/pcuAxzA20lPu7Kwe5zHxNqKcY8ZlW38ldWih6tN+AFyaXtggGDJ3BykSZh42
+c+eXBEE3sbFyK/ShKSB8lnkLK9DY3shsP5P7xe54UhEVG3r24miZ5/tGFoTjx6Hm
+4NJG1eHEX6Bm9NrE/5UdAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAIcD2vKCwt2v
+fEQvhtNfTJNIuf4HF7sh9yUjTqoiDBa5c66dRnx12cNJV0e/M7eX7PVAdcBGIvCg
+XZx5E6H/uKMve44GP8i25Goo8jRcIz8ywOatD6zPVXRHc9MBhbcLIlYkfZ8JqQ6G
+njdbnG0C2YzIUGriWfMWBuqyQrVY/rrRgVca77I4iFj2qsQui1on5KXopMpnXKxy
+Z8NvE8MtNXnXiuf11CEwStX2o9l5VvIPEPd90FGTL0f4fUsKhFUSCn1OOx8rL/wo
+s2k04YCAu+KvudYw8R1UhyOZn1EDTEV9AmVzq/3PlMwNOmD9PBQvFjOpIR/LULGP
+A+6gZqkWeRQ=
+-----END CERTIFICATE-----
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/6] wireless-regdb: Better support for generating public certificates
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
                   ` (2 preceding siblings ...)
  2017-12-22  6:03 ` [PATCH 3/6] wireless-regdb: Add sforshee's x509 certificate Seth Forshee
@ 2017-12-22  6:03 ` Seth Forshee
  2017-12-22  6:03 ` [PATCH 5/6] wireless-regdb: Install regulatory.db and regulatory.db.p7s to /lib/firmware Seth Forshee
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:03 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

The current makefile rule for the public certificate calls for an
openssl config file which is not provided. Let's put the pubcert
generation into a script named gen-pubcert.sh and embed the
openssl configuration file there.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile       |  4 +---
 gen-pubcert.sh | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100755 gen-pubcert.sh

diff --git a/Makefile b/Makefile
index 9532c29a1dc2..044251f64785 100644
--- a/Makefile
+++ b/Makefile
@@ -79,9 +79,7 @@ $(REGDB_PUBKEY): $(REGDB_PRIVKEY)
 
 $(REGDB_PUBCERT): $(REGDB_PRIVKEY)
 	@echo "Generating certificate for $(REGDB_AUTHOR)..."
-	@openssl req -config regulatory.openssl.conf \
-		-key $(REGDB_PRIVKEY) -days 36500 -utf8 -nodes -batch \
-		-x509 -outform PEM -out $(REGDB_PUBCERT)
+	./gen-pubcert.sh $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
 	@echo $(REGDB_PUBKEY) > .custom
 
 
diff --git a/gen-pubcert.sh b/gen-pubcert.sh
new file mode 100755
index 000000000000..1a4d57999e5d
--- /dev/null
+++ b/gen-pubcert.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [[ $# -ne 2 ]]; then
+	echo "Usage: $0 priv-key out-file"
+	exit 1
+fi
+
+openssl req -new -key "$1" -days 36500 -utf8 -nodes -batch \
+	-x509 -outform PEM -out "$2" \
+	-config <(cat <<-EOF
+		[ req ]
+		distinguished_name = req_distinguished_name
+		string_mask = utf8only
+		prompt = no
+		[ req_distinguished_name ]
+		commonName = sforshee
+		EOF
+	)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/6] wireless-regdb: Install regulatory.db and regulatory.db.p7s to /lib/firmware
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
                   ` (3 preceding siblings ...)
  2017-12-22  6:03 ` [PATCH 4/6] wireless-regdb: Better support for generating public certificates Seth Forshee
@ 2017-12-22  6:03 ` Seth Forshee
  2017-12-22  6:03 ` [PATCH 6/6] wireless-regdb: Document regulatory.db in the manual page Seth Forshee
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:03 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

regulatory.db is being installed to the CRDA path, however the
kernel expects it to be in /lib/firmware. Install it to the
proper location. Also install the detached signature, which is
needed for the kernel to check verify the database authenticity.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 044251f64785..1e8e84c64149 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
 PREFIX ?= /usr
 CRDA_PATH ?= $(PREFIX)/lib/crda
 CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
+FIRMWARE_PATH ?= /lib/firmware
 
 MANDIR ?= $(PREFIX)/share/man/
 
@@ -117,10 +118,12 @@ install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
 install: regulatory.bin.5.gz regulatory.db.5.gz
 	install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
 	install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
+	install -m 755 -d $(DESTDIR)/$(FIRMWARE_PATH)
 	if [ -f .custom ]; then \
 		install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
 	fi
 	install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
-	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin regulatory.db
+	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
+	install -m 644 -t $(DESTDIR)/$(FIRMWARE_PATH) regulatory.db regulatory.db.p7s
 	install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
 	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/6] wireless-regdb: Document regulatory.db in the manual page
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
                   ` (4 preceding siblings ...)
  2017-12-22  6:03 ` [PATCH 5/6] wireless-regdb: Install regulatory.db and regulatory.db.p7s to /lib/firmware Seth Forshee
@ 2017-12-22  6:03 ` Seth Forshee
  2017-12-22  8:45 ` [PATCH 0/6] wireless-regdb: Support for new binary database format Johannes Berg
  2017-12-24  3:24 ` Seth Forshee
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-22  6:03 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

Add information about regulatory.db to the regulatory.bin man
page, and alias the regulatory.db man page to refer to the page
for regulatory.bin.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 Makefile         |  2 +-
 regulatory.bin.5 | 32 ++++++++++++++++++++++----------
 regulatory.db.5  |  1 +
 3 files changed, 24 insertions(+), 11 deletions(-)
 create mode 100644 regulatory.db.5

diff --git a/Makefile b/Makefile
index 1e8e84c64149..2f1ed93e0e15 100644
--- a/Makefile
+++ b/Makefile
@@ -126,4 +126,4 @@ install: regulatory.bin.5.gz regulatory.db.5.gz
 	install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
 	install -m 644 -t $(DESTDIR)/$(FIRMWARE_PATH) regulatory.db regulatory.db.p7s
 	install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
-	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz
+	install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz regulatory.db.5.gz
diff --git a/regulatory.bin.5 b/regulatory.bin.5
index 430c65c9ce6d..b1862cd1756d 100644
--- a/regulatory.bin.5
+++ b/regulatory.bin.5
@@ -1,6 +1,6 @@
-.TH regulatory.bin 5 "23 January 2009" "regulatory.bin" "Linux"
+.TH regulatory.bin 5 "21 December 2017" "regulatory.bin" "Linux"
 .SH NAME
-regulatory.bin \- The Linux wireless regulatory database
+regulatory.bin, regulatory.db \- The Linux wireless regulatory database
 
 .ad l
 .in +8
@@ -9,24 +9,36 @@ regulatory.bin \- The Linux wireless regulatory database
 .SS
 .SH Description
 .B regulatory.bin
-is the file used by the Linux wireless subsystem to keep its regulatory
-database information. It is read by
+and
+.B regulatory.db
+are the files used by the Linux wireless subsystem to keep its regulatory
+database information.
+.PP
+.B regulatory.bin
+is read by
 .B crda
 upon the Linux kernel's request for regulatory information for a specific
-ISO / IEC 3166 alpha2 country code. The regulatory database is kept in
-a small binary format for size and code efficiency. The
+ISO / IEC 3166 alpha2 country code.
+.PP
+.B regulatory.db
+is a newer, extensible database format which (since Linux 4.15) is read
+by the kernel directly as a firmware file.
+
+The regulatory database is kept in a small binary format for size and code
+efficiency. The
 .B regulatory.bin
 file can be parsed and read in human format by using the
 .B regdbdump
-command. The
-.B regulatory.bin
-file should be updated upon regulatory changes or corrections.
+command. The regulatory database files should be updated upon regulatory
+changes or corrections.
 
 .SH Upkeeping
 The regulatory database is maintained by the community as such
 you are encouraged to send any corrections or updates to the
-linux-wireless mailing list:
+linux-wireless and wireless-regdb mailing lists:
 .B linux-wireless@vger.kernel.org
+and
+.B wireless-regdb@lists.infradead.org
 
 .SH SEE ALSO
 .BR regdbdump (8)
diff --git a/regulatory.db.5 b/regulatory.db.5
new file mode 100644
index 000000000000..6c8aae374621
--- /dev/null
+++ b/regulatory.db.5
@@ -0,0 +1 @@
+.so man5/regulatory.bin.5.gz
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/6] wireless-regdb: Support for new binary database format
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
                   ` (5 preceding siblings ...)
  2017-12-22  6:03 ` [PATCH 6/6] wireless-regdb: Document regulatory.db in the manual page Seth Forshee
@ 2017-12-22  8:45 ` Johannes Berg
  2017-12-24  3:24 ` Seth Forshee
  7 siblings, 0 replies; 9+ messages in thread
From: Johannes Berg @ 2017-12-22  8:45 UTC (permalink / raw)
  To: Seth Forshee, linux-wireless, wireless-regdb

On Fri, 2017-12-22 at 00:02 -0600, Seth Forshee wrote:
> This series starts with Johannes' patch for generating regulatory
> databases using the new format and adds various fixes and pieces which
> were missing such as installation to the firmware path, manual page
> updates, etc. It also restores support for the older database format to
> maintain compatibility with using CRDA on older kernels.
> 
> I've tested the results with 4.15 and things look to be working. I want
> to apply this in the next couple of days and get a new release out, so
> please let me know soon if you seen any issues.

Thanks!

johannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/6] wireless-regdb: Support for new binary database format
  2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
                   ` (6 preceding siblings ...)
  2017-12-22  8:45 ` [PATCH 0/6] wireless-regdb: Support for new binary database format Johannes Berg
@ 2017-12-24  3:24 ` Seth Forshee
  7 siblings, 0 replies; 9+ messages in thread
From: Seth Forshee @ 2017-12-24  3:24 UTC (permalink / raw)
  To: linux-wireless, wireless-regdb; +Cc: Johannes Berg

On Fri, Dec 22, 2017 at 12:02:57AM -0600, Seth Forshee wrote:
> This series starts with Johannes' patch for generating regulatory
> databases using the new format and adds various fixes and pieces which
> were missing such as installation to the firmware path, manual page
> updates, etc. It also restores support for the older database format to
> maintain compatibility with using CRDA on older kernels.
> 
> I've tested the results with 4.15 and things look to be working. I want
> to apply this in the next couple of days and get a new release out, so
> please let me know soon if you seen any issues.

Applied.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-12-24  3:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22  6:02 [PATCH 0/6] wireless-regdb: Support for new binary database format Seth Forshee
2017-12-22  6:02 ` [PATCH 1/6] regdb: write firmware file format (version code 20) Seth Forshee
2017-12-22  6:02 ` [PATCH 2/6] wireless-regdb: Restore generation of old format database files Seth Forshee
2017-12-22  6:03 ` [PATCH 3/6] wireless-regdb: Add sforshee's x509 certificate Seth Forshee
2017-12-22  6:03 ` [PATCH 4/6] wireless-regdb: Better support for generating public certificates Seth Forshee
2017-12-22  6:03 ` [PATCH 5/6] wireless-regdb: Install regulatory.db and regulatory.db.p7s to /lib/firmware Seth Forshee
2017-12-22  6:03 ` [PATCH 6/6] wireless-regdb: Document regulatory.db in the manual page Seth Forshee
2017-12-22  8:45 ` [PATCH 0/6] wireless-regdb: Support for new binary database format Johannes Berg
2017-12-24  3:24 ` Seth Forshee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox