Skip to contentSkip to conversation

binman: Tidy up some missing bintool docs

PATCH Superseded Simon Glass 2 participants 6 messages Apr 21 – Apr 25

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover binman: Tidy up some missing bintool docs

Some of the bintools are missing documentation. This series adds the missing pieces to bring things up to scratch.

Simon Glass (3):
binman: Flesh out the p11-kit bintool docstring
binman: Flesh out the pkcs11-tool bintool docstring
binman: Flesh out the softhsm2-util bintool docstring

 tools/binman/btool/p11_kit.py       | 10 +++++++++-
 tools/binman/btool/pkcs11_tool.py   | 10 +++++++++-
 tools/binman/btool/softhsm2_util.py | 11 ++++++++++-
 3 files changed, 28 insertions(+), 3 deletions(-)

---
base-commit: 052988aa29bfd506d7ce207fbb3f5374a5dbecbb
branch: binj-us

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 binman: Flesh out the p11-kit bintool docstring

The Sphinx-generated bintools.rst currently produces an empty section for this bintool, since its class docstring is only a single line and so the body under the heading is blank.

Extend the docstring with a short description of what p11-kit does and how binman uses it, so the generated documentation has useful content.

---

 tools/binman/btool/p11_kit.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/binman/btool/p11_kit.py +9 -1
index 9d8d5d848b4..bb9e7304c54 100644
@@ -7,7 +7,15 @@ from binman import bintool
 
 
 class Bintoolp11_kit(bintool.Bintool):
-    """p11-kit -- support tool for pkcs#11 libraries"""
+    """p11-kit -- support tool for pkcs#11 libraries
+
+    This bintool supports running `p11-kit` to discover and configure the
+    PKCS#11 modules installed on the system. Binman uses it to look up the
+    module path for a given token provider (for example SoftHSMv2) when signing
+    FIT images or capsules with a PKCS#11 key.
+
+    See https://p11-glue.github.io/p11-glue/p11-kit.html for more details.
+    """
     def __init__(self, name):
         super().__init__('p11-kit',
                          'Pkcs11 library modules tool',
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/3 binman: Flesh out the pkcs11-tool bintool docstring

In reply to Simon Glass

The Sphinx-generated bintools.rst currently produces an empty section for this bintool, since its class docstring is only a single line and so the body under the heading is blank.

Extend the docstring with a short description of what pkcs11-tool does and how binman uses it, so the generated documentation has useful content.

---

 tools/binman/btool/pkcs11_tool.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tools/binman/btool/pkcs11_tool.py +9 -1
index 673c0ea0ac3..c4c49bf7de1 100644
@@ -7,7 +7,15 @@ from binman import bintool
 
 
 class Bintoolpkcs11_tool(bintool.Bintool):
-    """pkcs11-tool -- support tool for managing pkcs#11 tokens"""
+    """pkcs11-tool -- support tool for managing pkcs#11 tokens
+
+    This bintool supports running `pkcs11-tool`, a utility from the OpenSC
+    project for managing objects stored in PKCS#11 tokens. Binman uses it to
+    import signing keys and certificates into a token so that FIT images or
+    capsules can be signed via the PKCS#11 interface.
+
+    See https://github.com/OpenSC/OpenSC/wiki for more details.
+    """
     def __init__(self, name):
         super().__init__('pkcs11-tool',
                          'PKCS #11 tokens managing tool',
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/3 binman: Flesh out the softhsm2-util bintool docstring

In reply to Simon Glass

The Sphinx-generated bintools.rst currently produces an empty section for this bintool, since its class docstring is only a single line and so the body under the heading is blank.

Extend the docstring with a short description of what softhsm2-util does and how binman uses it, so the generated documentation has useful content.

---

 tools/binman/btool/softhsm2_util.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tools/binman/btool/softhsm2_util.py +10 -1
index 869221d841d..e79584da11d 100644
@@ -7,7 +7,16 @@ from binman import bintool
 
 
 class Bintoolsofthsm2_util(bintool.Bintool):
-    """SoftHSMv2 -- support tool for libsofthsm2"""
+    """SoftHSMv2 -- support tool for libsofthsm2
+
+    This bintool supports running `softhsm2-util`, the command-line utility
+    shipped with SoftHSMv2 (a software implementation of a PKCS#11 token).
+    Binman uses it to initialise a token so that keys can be imported and used
+    to sign FIT images or capsules via the PKCS#11 interface, without requiring
+    real hardware.
+
+    See https://www.opendnssec.org/softhsm/ for more details.
+    """
     def __init__(self, name):
         super().__init__('softhsm2-util',
                          'SoftHSMv2 support tool for libsofthsm2',
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH 3/3] binman: Flesh out the softhsm2-util bintool docstring

Hi Simon,

Quoted 8 lines · Simon Glass

The Sphinx-generated bintools.rst currently produces an empty section for this bintool, since its class docstring is only a single line and so the body under the heading is blank.

Extend the docstring with a short description of what softhsm2-util does and how binman uses it, so the generated documentation has useful content.

Welllllllll... Binman currently doesn't use it for anything but checking if the tool is installed on the system and if not downloads it. I've basically abused this to check that softhsm2-util is available on the system, but I'm not using the bintool to run commands.

I'm now wondering why, because I guess we could replace tools.run('softhsm2-util', args) with softhsm2_util.run(args)...

And the same for pkcs11-tool I guess?

Quoted 14 lines

---

  tools/binman/btool/softhsm2_util.py | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
tools/binman/btool/softhsm2_util.py +0 -0
index 869221d841d..e79584da11d 100644
@@ -7,7 +7,16 @@ from binman import bintool
 
 

tools/binman/btool/softhsm2_util.py from binman import bintool · line 17

Quoted 10 lines
tools/binman/btool/softhsm2_util.py +8 -1
  class Bintoolsofthsm2_util(bintool.Bintool):
-    """SoftHSMv2 -- support tool for libsofthsm2"""
+    """SoftHSMv2 -- support tool for libsofthsm2
+
+    This bintool supports running `softhsm2-util`, the command-line utility
+    shipped with SoftHSMv2 (a software implementation of a PKCS#11 token).
+    Binman uses it to initialise a token so that keys can be imported and used
+    to sign FIT images or capsules via the PKCS#11 interface, without requiring
+    real hardware.
+

Yeah I don't know, this is all transparent to binman really. You configure the FIT via DT to use pkcs11 and binman will simply call mkimage with that which in turn will call openssl which in turn will call softhsm2 engine (see tools/binman/test/fit/openssl.conf). So it can be used for anything, and binman really doesn't care about this bintool except for its own unit tests signing FIT images with a pkcs11 engine.

I would remove the last sentence. Maybe we should tell the user to use this bintool only to check whether the package is installed but that the actual signature/token setup is expected to be done outside of binman?

Cheers,
Quentin

#5 lore raw

Re: [PATCH 3/3] binman: Flesh out the softhsm2-util bintool docstring

Quoted 47 lines · Quentin Schulz

Hi Simon,

Quoted 8 lines · Simon Glass

The Sphinx-generated bintools.rst currently produces an empty section for this bintool, since its class docstring is only a single line and so the body under the heading is blank.

Extend the docstring with a short description of what softhsm2-util does and how binman uses it, so the generated documentation has useful content.

Welllllllll... Binman currently doesn't use it for anything but checking if the tool is installed on the system and if not downloads it. I've basically abused this to check that softhsm2-util is available on the system, but I'm not using the bintool to run commands.

I'm now wondering why, because I guess we could replace tools.run('softhsm2-util', args) with softhsm2_util.run(args)...

And the same for pkcs11-tool I guess?

Quoted 18 lines

---

  tools/binman/btool/softhsm2_util.py | 11 ++++++++++-

  1 file changed, 10 insertions(+), 1 deletion(-)
tools/binman/btool/softhsm2_util.py +0 -0
index 869221d841d..e79584da11d 100644
@@ -7,7 +7,16 @@ from binman import bintool

  class Bintoolsofthsm2_util(bintool.Bintool):
-    """SoftHSMv2 -- support tool for libsofthsm2"""
+    """SoftHSMv2 -- support tool for libsofthsm2
+
+    This bintool supports running softhsm2-util, the command-line utility

Quoted 8 lines

+    shipped with SoftHSMv2 (a software implementation of a PKCS#11 token).
+    Binman uses it to initialise a token so that keys can be imported and used
+    to sign FIT images or capsules via the PKCS#11 interface, without requiring
+    real hardware.
+

Yeah I don't know, this is all transparent to binman really. You configure the FIT via DT to use pkcs11 and binman will simply call mkimage with that which in turn will call openssl which in turn will call softhsm2 engine (see tools/binman/test/fit/openssl.conf). So it can be used for anything, and binman really doesn't care about this bintool except for its own unit tests signing FIT images with a pkcs11 engine.

Quoted 2 lines

I would remove the last sentence. Maybe we should tell the user to use this bintool only to check whether the package is installed but that the actual signature/token setup is expected to be done outside of binman?

and I didn't read the other two patches before sending the previous mail, but it applies to those two other bintools as well.

Quoted 2 lines

Cheers,
Quentin