diff options
author | Tariq Toukan <tariqt@nvidia.com> | 2022-09-20 16:01:47 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-09-22 17:27:41 -0700 |
commit | 2d2c5ea24243eb3ed12f232b2aef43981fa15360 (patch) | |
tree | bd7ca3a1b9ac1df33fcbb97a7a2f79142970a117 /net | |
parent | 8db3d514e96715c897fe793c4d5fc0fd86aca517 (diff) | |
download | linux-2d2c5ea24243eb3ed12f232b2aef43981fa15360.tar.bz2 |
net/tls: Describe ciphers sizes by const structs
Introduce cipher sizes descriptor. It helps reducing the amount of code
duplications and repeated switch/cases that assigns the proper sizes
according to the cipher type.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/tls/tls_main.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 08ddf9d837ae..5cc6911cc97d 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -58,6 +58,23 @@ enum { TLS_NUM_PROTS, }; +#define CIPHER_SIZE_DESC(cipher) [cipher] = { \ + .iv = cipher ## _IV_SIZE, \ + .key = cipher ## _KEY_SIZE, \ + .salt = cipher ## _SALT_SIZE, \ + .tag = cipher ## _TAG_SIZE, \ + .rec_seq = cipher ## _REC_SEQ_SIZE, \ +} + +const struct tls_cipher_size_desc tls_cipher_size_desc[] = { + CIPHER_SIZE_DESC(TLS_CIPHER_AES_GCM_128), + CIPHER_SIZE_DESC(TLS_CIPHER_AES_GCM_256), + CIPHER_SIZE_DESC(TLS_CIPHER_AES_CCM_128), + CIPHER_SIZE_DESC(TLS_CIPHER_CHACHA20_POLY1305), + CIPHER_SIZE_DESC(TLS_CIPHER_SM4_GCM), + CIPHER_SIZE_DESC(TLS_CIPHER_SM4_CCM), +}; + static const struct proto *saved_tcpv6_prot; static DEFINE_MUTEX(tcpv6_prot_mutex); static const struct proto *saved_tcpv4_prot; |