mbox series

[net-next,00/17] tls: expand tls_cipher_size_desc to simplify getsockopt/setsockopt

Message ID cover.1692977948.git.sd@queasysnail.net (mailing list archive)
Headers show
Series tls: expand tls_cipher_size_desc to simplify getsockopt/setsockopt | expand

Message

Sabrina Dubroca Aug. 25, 2023, 9:35 p.m. UTC
Commit 2d2c5ea24243 ("net/tls: Describe ciphers sizes by const
structs") introduced tls_cipher_size_desc to describe the size of the
fields of the per-cipher crypto_info structs, and commit ea7a9d88ba21
("net/tls: Use cipher sizes structs") used it, but only in
tls_device.c and tls_device_fallback.c, and skipped converting similar
code in tls_main.c and tls_sw.c.

This series expands tls_cipher_size_desc (renamed to tls_cipher_desc
to better fit this expansion) to fully describe a cipher:
 - offset of the fields within the per-cipher crypto_info
 - size of the full struct (for copies to/from userspace)
 - offload flag
 - algorithm name used by SW crypto

With these additions, we can remove ~350L of
     switch (crypto_info->cipher_type) { ... }
from tls_set_device_offload, tls_sw_fallback_init,
do_tls_getsockopt_conf, do_tls_setsockopt_conf, tls_set_sw_offload
(mainly do_tls_getsockopt_conf and tls_set_sw_offload).

This series also adds the ARIA ciphers to the tls selftests, and some
more getsockopt/setsockopt tests to cover more of the code changed by
this series.

Sabrina Dubroca (17):
  selftests: tls: add test variants for aria-gcm
  selftests: tls: add getsockopt test
  selftests: tls: test some invalid inputs for setsockopt
  tls: move tls_cipher_size_desc to net/tls/tls.h
  tls: add TLS_CIPHER_ARIA_GCM_* to tls_cipher_size_desc
  tls: reduce size of tls_cipher_size_desc
  tls: rename tls_cipher_size_desc to tls_cipher_desc
  tls: extend tls_cipher_desc to fully describe the ciphers
  tls: validate cipher descriptions at compile time
  tls: expand use of tls_cipher_desc in tls_set_device_offload
  tls: allocate the fallback aead after checking that the cipher is
    valid
  tls: expand use of tls_cipher_desc in tls_sw_fallback_init
  tls: get crypto_info size from tls_cipher_desc in
    do_tls_setsockopt_conf
  tls: use tls_cipher_desc to simplify do_tls_getsockopt_conf
  tls: use tls_cipher_desc to get per-cipher sizes in tls_set_sw_offload
  tls: use tls_cipher_desc to access per-cipher crypto_info in
    tls_set_sw_offload
  tls: get cipher_name from cipher_desc in tls_set_sw_offload

 include/net/tls.h                  |  10 --
 net/tls/tls.h                      |  53 ++++++
 net/tls/tls_device.c               |  52 ++----
 net/tls/tls_device_fallback.c      |  62 +++----
 net/tls/tls_main.c                 | 272 ++++++++---------------------
 net/tls/tls_sw.c                   | 179 +++----------------
 tools/testing/selftests/net/config |   1 +
 tools/testing/selftests/net/tls.c  |  84 +++++++++
 8 files changed, 278 insertions(+), 435 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Aug. 28, 2023, 1:10 a.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 25 Aug 2023 23:35:05 +0200 you wrote:
> Commit 2d2c5ea24243 ("net/tls: Describe ciphers sizes by const
> structs") introduced tls_cipher_size_desc to describe the size of the
> fields of the per-cipher crypto_info structs, and commit ea7a9d88ba21
> ("net/tls: Use cipher sizes structs") used it, but only in
> tls_device.c and tls_device_fallback.c, and skipped converting similar
> code in tls_main.c and tls_sw.c.
> 
> [...]

Here is the summary with links:
  - [net-next,01/17] selftests: tls: add test variants for aria-gcm
    https://git.kernel.org/netdev/net-next/c/84e306b08340
  - [net-next,02/17] selftests: tls: add getsockopt test
    https://git.kernel.org/netdev/net-next/c/f27ad62fe38c
  - [net-next,03/17] selftests: tls: test some invalid inputs for setsockopt
    https://git.kernel.org/netdev/net-next/c/4bfb6224ed80
  - [net-next,04/17] tls: move tls_cipher_size_desc to net/tls/tls.h
    https://git.kernel.org/netdev/net-next/c/fd0fc6fdd889
  - [net-next,05/17] tls: add TLS_CIPHER_ARIA_GCM_* to tls_cipher_size_desc
    https://git.kernel.org/netdev/net-next/c/200e23165109
  - [net-next,06/17] tls: reduce size of tls_cipher_size_desc
    https://git.kernel.org/netdev/net-next/c/037303d67607
  - [net-next,07/17] tls: rename tls_cipher_size_desc to tls_cipher_desc
    https://git.kernel.org/netdev/net-next/c/8db44ab26beb
  - [net-next,08/17] tls: extend tls_cipher_desc to fully describe the ciphers
    https://git.kernel.org/netdev/net-next/c/176a3f50bc6a
  - [net-next,09/17] tls: validate cipher descriptions at compile time
    https://git.kernel.org/netdev/net-next/c/0d98cc02022d
  - [net-next,10/17] tls: expand use of tls_cipher_desc in tls_set_device_offload
    https://git.kernel.org/netdev/net-next/c/3524dd4d5f1f
  - [net-next,11/17] tls: allocate the fallback aead after checking that the cipher is valid
    https://git.kernel.org/netdev/net-next/c/d2322cf5ed59
  - [net-next,12/17] tls: expand use of tls_cipher_desc in tls_sw_fallback_init
    https://git.kernel.org/netdev/net-next/c/e907277aeb6c
  - [net-next,13/17] tls: get crypto_info size from tls_cipher_desc in do_tls_setsockopt_conf
    https://git.kernel.org/netdev/net-next/c/5f309ade49c7
  - [net-next,14/17] tls: use tls_cipher_desc to simplify do_tls_getsockopt_conf
    https://git.kernel.org/netdev/net-next/c/077e05d13548
  - [net-next,15/17] tls: use tls_cipher_desc to get per-cipher sizes in tls_set_sw_offload
    https://git.kernel.org/netdev/net-next/c/d9a6ca1a9758
  - [net-next,16/17] tls: use tls_cipher_desc to access per-cipher crypto_info in tls_set_sw_offload
    https://git.kernel.org/netdev/net-next/c/48dfad27fd40
  - [net-next,17/17] tls: get cipher_name from cipher_desc in tls_set_sw_offload
    https://git.kernel.org/netdev/net-next/c/f3e444e31f9f

You are awesome, thank you!