Improve the crypto library documentation
Subsystems (3)
Eric Biggers
maintainercover Improve the crypto library documentation
While the crypto library already has a lot of kerneldoc, it's not being included in the HTML or PDF documentation. Update Documentation/crypto/ to include it, and also add a high-level overview of the library.
I'd like to take this series via the libcrypto tree for 7.1.
Eric Biggers (2):
docs: kdoc: Expand 'at_least' when creating parameter list lib/crypto: docs: Add rst documentation to Documentation/crypto/
Documentation/crypto/index.rst | 2 +- .../crypto/libcrypto-blockcipher.rst | 19 ++ Documentation/crypto/libcrypto-hash.rst | 86 +++++++++ Documentation/crypto/libcrypto-signature.rst | 11 ++ Documentation/crypto/libcrypto-utils.rst | 6 + Documentation/crypto/libcrypto.rst | 167 ++++++++++++++++++ Documentation/crypto/sha3.rst | 2 + tools/lib/python/kdoc/kdoc_parser.py | 5 + 8 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 Documentation/crypto/libcrypto-blockcipher.rst create mode 100644 Documentation/crypto/libcrypto-hash.rst create mode 100644 Documentation/crypto/libcrypto-signature.rst create mode 100644 Documentation/crypto/libcrypto-utils.rst create mode 100644 Documentation/crypto/libcrypto.rst
base-commit: 3cd8b194bf3428dfa53120fee47e827a7c495815
Signature · 1 line
2.53.0
Eric Biggers
maintainerPATCH 1/2 docs: kdoc: Expand 'at_least' when creating parameter list
sphinx doesn't know that the kernel headers do:
#define at_least static
Do this replacement before declarations are passed to it.
This prevents errors like the following from appearing once the lib/crypto/ kerneldoc is wired up to the sphinx build:
linux/Documentation/crypto/libcrypto:128: ./include/crypto/sha2.h:773: WARNING: Error in declarator or parameters
Error in declarator or parameters
Invalid C declaration: Expected ']' in end of array operator. [error at 59]
void sha512_final (struct sha512_ctx *ctx, u8 out[at_least SHA512_DIGEST_SIZE])
--- tools/lib/python/kdoc/kdoc_parser.py | 5 +++++ 1 file changed, 5 insertions(+)
tools/lib/python/kdoc/kdoc_parser.py +5 -0
@@ -437,10 +437,15 @@ class KernelDoc: for arg in args.split(splitter): # Ignore argument attributes arg = KernRe(r'\sPOS0?\s').sub(' ', arg) + # Replace '[at_least ' with '[static '. This allows sphinx to parse + # array parameter declarations like 'char A[at_least 4]', where + # 'at_least' is #defined to 'static' by the kernel headers. + arg = KernRe(r'\[at_least ').sub('[static ', arg) + # Strip leading/trailing spaces arg = arg.strip() arg = KernRe(r'\s+').sub(' ', arg, count=1) if arg.startswith('#'):
Signature · 1 line
2.53.0
Re: [PATCH 1/2] docs: kdoc: Expand 'at_least' when creating parameter list
Quoted 24 lines · Eric Biggers
sphinx doesn't know that the kernel headers do:
#define at_least staticDo this replacement before declarations are passed to it.
This prevents errors like the following from appearing once the
lib/crypto/kerneldoc is wired up to the sphinx build:linux/Documentation/crypto/libcrypto:128:
./include/crypto/sha2.h:773: WARNING: Error in declarator or parameters
Error in declarator or parameters
Invalid C declaration: Expected ']' in end of array operator. [error at 59]
voidsha512_final(structsha512_ctx*ctx, u8 out[at_leastSHA512_DIGEST_SIZE])Signed-off-by Eric Biggers <[email protected]>--- tools/lib/python/kdoc/kdoc_parser.py | 5 +++++ 1 file changed, 5 insertions(+)tools/lib/python/kdoc/kdoc_parser.py +0
-0
tools/lib/python/kdoc/kdoc_parser.py class KernelDoc: · line 446
Quoted 10 lines
tools/lib/python/kdoc/kdoc_parser.py +5
-0@@ -437,10 +437,15 @@ class KernelDoc: for arg in args.split(splitter): # Ignore argument attributes arg = KernRe(r'\sPOS0?\s').sub(' ', arg) + # Replace '[at_least ' with '[static '. This allows sphinx to parse + # array parameter declarations like 'char A[at_least 4]', where + # 'at_least' is #defined to 'static' by the kernel headers. + arg = KernRe(r'\[at_least ').sub('[static ', arg) +
This could be a regular string replacement rather than a regex. Not something I'm willing to dig in my heels on, though... so if you want to push this, either way:
Thanks,
jon
Eric Biggers
maintainerPATCH 2/2 lib/crypto: docs: Add rst documentation to Documentation/crypto/
In reply to Eric BiggersAdd a documentation file Documentation/crypto/libcrypto.rst which provides a high-level overview of lib/crypto/.
Also add several sub-pages which include the kerneldoc for the algorithms that have it. This makes the existing, quite extensive kerneldoc start being included in the HTML documentation.
Note that the intent is very much *not* that everyone has to read these Documentation/ files. The library is intended to be straightforward and use familiar conventions; generally it should be possible to dive right into the kerneldoc. You shouldn't need to read a lot of documentation to just call sha256(), for example, or to run the unit tests if you're already familiar with KUnit. (This differs from the traditional crypto API which has a larger barrier to entry.)
Nevertheless, this seems worth adding. Hopefully it is useful and makes LWN no longer consider the library to be "meticulously undocumented".
--- Documentation/crypto/index.rst | 2 +- .../crypto/libcrypto-blockcipher.rst | 19 ++ Documentation/crypto/libcrypto-hash.rst | 86 +++++++++ Documentation/crypto/libcrypto-signature.rst | 11 ++ Documentation/crypto/libcrypto-utils.rst | 6 + Documentation/crypto/libcrypto.rst | 167 ++++++++++++++++++ Documentation/crypto/sha3.rst | 2 + 7 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 Documentation/crypto/libcrypto-blockcipher.rst create mode 100644 Documentation/crypto/libcrypto-hash.rst create mode 100644 Documentation/crypto/libcrypto-signature.rst create mode 100644 Documentation/crypto/libcrypto-utils.rst create mode 100644 Documentation/crypto/libcrypto.rst
Documentation/crypto/index.rst +1 -1
@@ -11,10 +11,11 @@ for cryptographic use cases, as well as programming examples. .. toctree:: :caption: Table of contents :maxdepth: 2 + libcrypto intro api-intro architecture async-tx-api
@@ -25,6 +26,5 @@ for cryptographic use cases, as well as programming examples. api api-samples descore-readme device_drivers/index krb5 - sha3
Documentation/crypto/libcrypto-blockcipher.rst new file +19 -0
@@ -0,0 +1,19 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Block ciphers +============= + +AES +--- + +Support for the AES block cipher. + +.. kernel-doc:: include/crypto/aes.h + +DES +--- + +Support for the DES block cipher. This algorithm is obsolete and is supported +only for backwards compatibility. + +.. kernel-doc:: include/crypto/des.h
Documentation/crypto/libcrypto-hash.rst new file +86 -0
86 lines not on this page · raw message
Documentation/crypto/libcrypto-signature.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Digital signature algorithms +============================ + +ML-DSA +------ + +Support for the ML-DSA digital signature algorithm. + +.. kernel-doc:: include/crypto/mldsa.h
Documentation/crypto/libcrypto-utils.rst new file +6 -0
@@ -0,0 +1,6 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Utility functions +================= + +.. kernel-doc:: include/crypto/utils.h
Documentation/crypto/libcrypto.rst new file +167 -0
167 lines not on this page · raw message
Documentation/crypto/sha3.rst +2 -0
@@ -1,7 +1,9 @@ .. SPDX-License-Identifier: GPL-2.0-or-later +.. _sha3: + ========================== SHA-3 Algorithm Collection ========================== .. contents::
Signature · 1 line
2.53.0
Jonathan Corbet
maintainerQuoted 10 lines · Eric Biggers
While the crypto library already has a lot of kerneldoc, it's not being included in the HTML or PDF documentation. Update
Documentation/crypto/to include it, and also add a high-level overview of the library.I'd like to take this series via the libcrypto tree for 7.1.
Eric Biggers (2):
docs: kdoc: Expand 'at_least' when creating parameter list lib/crypto: docs: Add rst documentation toDocumentation/crypto/
Quoted 9 lines
Documentation/crypto/index.rst | 2 +- .../crypto/libcrypto-blockcipher.rst | 19 ++ Documentation/crypto/libcrypto-hash.rst | 86 +++++++++ Documentation/crypto/libcrypto-signature.rst | 11 ++ Documentation/crypto/libcrypto-utils.rst | 6 + Documentation/crypto/libcrypto.rst | 167 ++++++++++++++++++ Documentation/crypto/sha3.rst | 2 + tools/lib/python/kdoc/kdoc_parser.py | 5 + 8 files changed, 297 insertions(+), 1 deletion(-)
I think this is great - sorry about the snide comment on LWN, but this will make this documentation much more accessible.
Thanks,
jon
Quoted 10 lines · Eric Biggers
While the crypto library already has a lot of kerneldoc, it's not being included in the HTML or PDF documentation. Update
Documentation/crypto/to include it, and also add a high-level overview of the library.I'd like to take this series via the libcrypto tree for 7.1.
Eric Biggers (2):
docs: kdoc: Expand 'at_least' when creating parameter list lib/crypto: docs: Add rst documentation toDocumentation/crypto/
I think this hits the spot wrt scope and level of detail.