Skip to content

Migrate to sig_alg and templatize ecdsa

Lukas Wunner keyrings linux-aspeed linux-crypto linux-security-module virtualization 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest19 patches 33 repliesIn review

Changes in v2 from the cover letter

* [PATCH 13/19] ASN.1: Clean up include statements in public headers
* Drop "#include <linux/bug.h>" from <linux/asn1_encoder.h> (Jonathan)

* [PATCH 14/19] crypto: ecdsa - Avoid signed integer overflow on signature decoding
* Add code comment explaining why vlen may be larger than bufsize (Stefan)

* [PATCH 15/19] crypto: ecdsa - Move X9.62 signature decoding into template
* Drop unnecessary "params", "param_len" and "algo" definitions from

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19crypto: ecdsa - Drop unused test vector elementscrypto/testmgr.h+10 -1053 replies
2/19crypto: sig - Introduce sig_alg backendDocumentation/crypto/api-sig.rst Documentation/crypto/api.rst Documentation/crypto/architecture.rst +6 more+433 -27 replies
3/19crypto: ecdsa - Migrate to sig_alg backendcrypto/Kconfig crypto/ecdsa.c crypto/testmgr.c +1 more+55 -900 replies
4/19crypto: ecrdsa - Migrate to sig_alg backendcrypto/Kconfig crypto/ecrdsa.c crypto/testmgr.c +1 more+28 -413 replies
5/19crypto: rsa-pkcs1pad - Deduplicate set_{pub,priv}_key callbackscrypto/rsa-pkcs1pad.c include/crypto/internal/rsa.h+30 -282 replies
6/19crypto: rsassa-pkcs1 - Migrate to sig_alg backendcrypto/Kconfig crypto/Makefile crypto/asymmetric_keys/public_key.c +8 more+480 -3459 replies
7/19crypto: rsassa-pkcs1 - Harden digest length verificationcrypto/rsassa-pkcs1.c+19 -11 reply
8/19crypto: rsassa-pkcs1 - Avoid copying hash prefixcrypto/rsassa-pkcs1.c+10 -81 reply
9/19crypto: virtio - Drop sign/verify operationsdrivers/crypto/virtio/virtio_crypto_akcipher_algs.c include/uapi/linux/virtio_crypto.h+22 -440 replies
10/19crypto: drivers - Drop sign/verify operationsdrivers/crypto/aspeed/aspeed-acry.c drivers/crypto/hisilicon/hpre/hpre_crypto.c drivers/crypto/starfive/jh7110-rsa.c+0 -60 replies
11/19crypto: akcipher - Drop sign/verify operationsDocumentation/crypto/api-akcipher.rst crypto/akcipher.c crypto/internal.h +5 more+66 -2850 replies
12/19crypto: sig - Move crypto_sig_*() API calls to include filecrypto/sig.c include/crypto/sig.h+36 -571 reply
13/19ASN.1: Clean up include statements in public headersinclude/linux/asn1_decoder.h include/linux/asn1_encoder.h+1 -10 replies
14/19crypto: ecdsa - Avoid signed integer overflow on signature decodingcrypto/ecdsa.c+7 -120 replies
15/19crypto: ecdsa - Move X9.62 signature decoding into templatecrypto/Makefile crypto/asymmetric_keys/public_key.c crypto/ecdsa-x962.c +4 more+955 -701 reply
16/19crypto: sig - Rename crypto_sig_maxsize() to crypto_sig_keysize()Documentation/crypto/api-sig.rst crypto/asymmetric_keys/public_key.c crypto/ecdsa-x962.c +6 more+25 -252 replies
17/19crypto: ecdsa - Move X9.62 signature size calculation into templateDocumentation/crypto/api-sig.rst crypto/asymmetric_keys/public_key.c crypto/ecdsa-x962.c +3 more+99 -350 replies
18/19crypto: ecdsa - Support P1363 signature decodingcrypto/Makefile crypto/asymmetric_keys/public_key.c crypto/ecdsa-p1363.c +4 more+217 -11 reply
19/19crypto: ecrdsa - Fix signature size calculationcrypto/ecrdsa.c+8 -00 replies

Reviews trailers per patch

6 of 19 patches have a Reviewed-by or Acked-by.

PatchStefan BergerJonathan CameronKlara Modin
1/19R-b
2/19
3/19
4/19
5/19R-b
6/19T-b T-b
7/19
8/19
9/19
10/19
11/19
12/19R-b
13/19R-b R-b
14/19R-b R-b
15/19T-b
16/19
17/19
18/19R-b R-b
19/19

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/19] Migrate to sig_alg and templatize ecdsa

The original impetus of this series is to introduce P1363 signature decoding for ecdsa (patch [18/19]), which is needed by the upcoming SPDM library (Security Protocol and Data Model) for PCI device authentication.

To facilitate that, move X9.62 signature decoding out of ecdsa.c and into a template (patch [15/19]).

New in v2: Move the maximum signature size calculations for ecdsa out of software_key_query() and into the X9.62 template so that corresponding calculations can be added for P1363 without further cluttering up software_key_query() (patch [16/19] - [17/19]).

New in v2: Avoid inefficient copying from kernel buffers to sglists in the new templates by introducing a sig_alg backend and migrating all algorithms to it, per Herbert's advice (patch [02/19] - [12/19]).

Clean up various smaller issues that caught my eye in ecdsa (patch [01/19] and [14/19]), ecrdsa (patch [19/19]) and ASN.1 headers (patch [13/19]).

I've also accumulated various cleanups for crypto virtio on my development branch but will leave them for another day as this series is already nearing the "too big to review" threshold. ;)

I've run selftests on every single commit, but further testing would be appreciated to raise the confidence.

Link to v1:

https://lore.kernel.org/all/cover.1722260176.git.lukas at wunner.de/

Changes v1 -> v2:

* [PATCH 13/19] ASN.1: Clean up include statements in public headers
* Drop "#include <linux/bug.h>" from <linux/asn1_encoder.h> (Jonathan)

* [PATCH 14/19] crypto: ecdsa - Avoid signed integer overflow on signature decoding
* Add code comment explaining why vlen may be larger than bufsize (Stefan)

* [PATCH 15/19] crypto: ecdsa - Move X9.62 signature decoding into template
* Drop unnecessary "params", "param_len" and "algo" definitions from

    ecdsa_nist_p{192,256,384,521}_tv_template[].

* Introduce and use struct ecdsa_raw_sig in <crypto/internal/ecc.h>.

* [PATCH 18/19] crypto: ecdsa - Support P1363 signature decoding
* Drop unnecessary "params", "param_len" and "algo" definitions from

    p1363_ecdsa_nist_p256_tv_template[].

Lukas Wunner (19):
crypto: ecdsa - Drop unused test vector elements
crypto: sig - Introduce sig_alg backend
crypto: ecdsa - Migrate to sig_alg backend
crypto: ecrdsa - Migrate to sig_alg backend
crypto: rsa-pkcs1pad - Deduplicate set_{pub,priv}_key callbacks
crypto: rsassa-pkcs1 - Migrate to sig_alg backend
crypto: rsassa-pkcs1 - Harden digest length verification
crypto: rsassa-pkcs1 - Avoid copying hash prefix
crypto: virtio - Drop sign/verify operations
crypto: drivers - Drop sign/verify operations
crypto: akcipher - Drop sign/verify operations
crypto: sig - Move crypto_sig_*() API calls to include file ASN.1: Clean up include statements in public headers
crypto: ecdsa - Avoid signed integer overflow on signature decoding
crypto: ecdsa - Move X9.62 signature decoding into template
crypto: sig - Rename crypto_sig_maxsize() to crypto_sig_keysize()
crypto: ecdsa - Move X9.62 signature size calculation into template
crypto: ecdsa - Support P1363 signature decoding
crypto: ecrdsa - Fix signature size calculation

 Documentation/crypto/api-akcipher.rst         |   2 +-
 Documentation/crypto/api-sig.rst              |  15 +
 Documentation/crypto/api.rst                  |   1 +
 Documentation/crypto/architecture.rst         |   2 +
 crypto/Kconfig                                |   5 +-
 crypto/Makefile                               |   5 +-
 crypto/akcipher.c                             |  64 +-
 crypto/asymmetric_keys/public_key.c           |  58 +-
 crypto/ecdsa-p1363.c                          | 159 ++++
 crypto/ecdsa-x962.c                           | 237 +++++
 crypto/ecdsa.c                                | 209 ++---
 crypto/ecrdsa.c                               |  64 +-
 crypto/internal.h                             |  19 -
 crypto/rsa-pkcs1pad.c                         | 371 +-------
 crypto/rsa.c                                  |  17 +-
 crypto/rsassa-pkcs1.c                         | 442 +++++++++
 crypto/sig.c                                  | 143 +--
 crypto/testmgr.c                              | 320 +++++--
 crypto/testmgr.h                              | 884 +++++++++++++++---
 drivers/crypto/aspeed/aspeed-acry.c           |   2 -
 drivers/crypto/hisilicon/hpre/hpre_crypto.c   |   2 -
 drivers/crypto/starfive/jh7110-rsa.c          |   2 -
 .../virtio/virtio_crypto_akcipher_algs.c      |  65 +-
 include/crypto/akcipher.h                     |  69 +-
 include/crypto/internal/akcipher.h            |   4 +-
 include/crypto/internal/ecc.h                 |  14 +
 include/crypto/internal/rsa.h                 |  29 +
 include/crypto/internal/sig.h                 |  80 ++
 include/crypto/sig.h                          | 152 ++-
 include/linux/asn1_decoder.h                  |   1 +
 include/linux/asn1_encoder.h                  |   1 -
 include/linux/slab.h                          |   1 +
 include/uapi/linux/cryptouser.h               |   5 +
 include/uapi/linux/virtio_crypto.h            |   1 +
 security/integrity/ima/ima_main.c             |   6 +-
 35 files changed, 2398 insertions(+), 1053 deletions(-)
 create mode 100644 Documentation/crypto/api-sig.rst
 create mode 100644 crypto/ecdsa-p1363.c
 create mode 100644 crypto/ecdsa-x962.c
 create mode 100644 crypto/rsassa-pkcs1.c
Signature · 1 line
2.43.0