From: Ben Hutchings <benh@debian.org>
To: linux-wireless@vger.kernel.org
Cc: wireless-regdb@lists.infradead.org
Subject: [PATCH] wireless-regdb: Replace M2Crypto with cryptography package
Date: Mon, 16 Feb 2026 21:03:34 +0100 [thread overview]
Message-ID: <aZN4FltUUWKUh6rp@decadent.org.uk> (raw)
In-Reply-To: <aZN3thlmaiBxYVQQ@decadent.org.uk>
[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]
M2Crypto is deprecated by its maintainers in favour of the
cryptography package. Update db2bin.py to use that for signing
regulatory.bin.
Signed-off-by: Ben Hutchings <benh@debian.org>
---
This applies on top of the preceding fix for M2Crypto usage, but I can
squash them together if it's preferable to switch directly to
cryptography.
Ben.
--- a/db2bin.py
+++ b/db2bin.py
@@ -2,7 +2,6 @@
from io import BytesIO, open
import struct
-import hashlib
from dbparse import DBParser
import sys
@@ -125,19 +124,18 @@ if len(sys.argv) > 3:
# Load RSA only now so people can use this script
# without having those libraries installed to verify
# their SQL changes
- from M2Crypto import RSA
+ from cryptography.hazmat.primitives import hashes, serialization
+ from cryptography.hazmat.primitives.asymmetric import padding
# determine signature length
- key = RSA.load_key(sys.argv[3])
- hash = hashlib.sha1()
- hash.update(output.getvalue())
- sig = key.sign(hash.digest(), algo='sha1')
+ with open(sys.argv[3], 'rb') as key_file:
+ key = serialization.load_pem_private_key(key_file.read(),
+ password=None)
+ sig = key.sign(output.getvalue(), padding.PKCS1v15(), hashes.SHA1())
# write it to file
siglen.set(len(sig))
# sign again
- hash = hashlib.sha1()
- hash.update(output.getvalue())
- sig = key.sign(hash.digest(), algo='sha1')
+ sig = key.sign(output.getvalue(), padding.PKCS1v15(), hashes.SHA1())
output.write(sig)
else:
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-02-16 20:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 20:01 [PATCH] wireless-regdb: Fix regulatory.bin signing with new M2Crypto Ben Hutchings
2026-02-16 20:03 ` Ben Hutchings [this message]
2026-02-25 7:38 ` [PATCH] wireless-regdb: Replace M2Crypto with cryptography package Chen-Yu Tsai
2026-02-25 7:40 ` [PATCH] wireless-regdb: Fix regulatory.bin signing with new M2Crypto Chen-Yu Tsai
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=aZN4FltUUWKUh6rp@decadent.org.uk \
--to=benh@debian.org \
--cc=linux-wireless@vger.kernel.org \
--cc=wireless-regdb@lists.infradead.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